Added Mesh Registration Functions to SHGraphicsSystem and a SHGraphicsSystem compatible version of mesh generation functions for SHPrimitiveGenerator
This commit is contained in:
parent
41daaaba9c
commit
b9185eab18
|
@ -356,6 +356,27 @@ namespace SHADE
|
||||||
resourceManager.Free(materialInstance);
|
resourceManager.Free(materialInstance);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------------*/
|
||||||
|
/* Mesh Registration Functions */
|
||||||
|
/*---------------------------------------------------------------------------------*/
|
||||||
|
SHADE::Handle<SHADE::SHMesh> SHGraphicsSystem::AddMesh(uint32_t vertexCount, const SHMesh::VertexPosition* const positions, const SHMesh::VertexTexCoord* const texCoords, const SHMesh::VertexTangent* const tangents, const SHMesh::VertexNormal* const normals, uint32_t indexCount, const SHMesh::Index* const indices)
|
||||||
|
{
|
||||||
|
return meshLibrary.AddMesh(vertexCount, positions, texCoords, tangents, normals, indexCount, indices);
|
||||||
|
}
|
||||||
|
|
||||||
|
void SHGraphicsSystem::RemoveMesh(Handle<SHMesh> mesh)
|
||||||
|
{
|
||||||
|
meshLibrary.RemoveMesh(mesh);
|
||||||
|
}
|
||||||
|
|
||||||
|
void SHGraphicsSystem::BuildMeshBuffers()
|
||||||
|
{
|
||||||
|
transferCmdBuffer->BeginRecording();
|
||||||
|
meshLibrary.BuildBuffers(device, transferCmdBuffer);
|
||||||
|
transferCmdBuffer->EndRecording();
|
||||||
|
queue->SubmitCommandBuffer({ transferCmdBuffer });
|
||||||
|
}
|
||||||
|
|
||||||
void SHGraphicsSystem::SetWindow(SHWindow* wind) noexcept
|
void SHGraphicsSystem::SetWindow(SHWindow* wind) noexcept
|
||||||
{
|
{
|
||||||
window = wind;
|
window = wind;
|
||||||
|
|
|
@ -25,6 +25,7 @@ of DigiPen Institute of Technology is prohibited.
|
||||||
#include "ECS_Base/System/SHSystemRoutine.h"
|
#include "ECS_Base/System/SHSystemRoutine.h"
|
||||||
#include "Graphics/Descriptors/SHVkDescriptorPool.h"
|
#include "Graphics/Descriptors/SHVkDescriptorPool.h"
|
||||||
#include "Graphics/RenderGraph/SHRenderGraph.h"
|
#include "Graphics/RenderGraph/SHRenderGraph.h"
|
||||||
|
#include "SHMeshLibrary.h"
|
||||||
|
|
||||||
namespace SHADE
|
namespace SHADE
|
||||||
{
|
{
|
||||||
|
@ -120,6 +121,67 @@ namespace SHADE
|
||||||
Handle<SHMaterialInstance> AddMaterialInstance(Handle<SHMaterial> material);
|
Handle<SHMaterialInstance> AddMaterialInstance(Handle<SHMaterial> material);
|
||||||
void RemoveMaterialInstance(Handle<SHMaterialInstance> materialInstance);
|
void RemoveMaterialInstance(Handle<SHMaterialInstance> materialInstance);
|
||||||
|
|
||||||
|
/*-----------------------------------------------------------------------------*/
|
||||||
|
/* Mesh Registration Functions */
|
||||||
|
/*-----------------------------------------------------------------------------*/
|
||||||
|
/*******************************************************************************/
|
||||||
|
/*!
|
||||||
|
|
||||||
|
\brief
|
||||||
|
Adds a mesh to the Mesh Library. But this does not mean that the meshes have
|
||||||
|
been added yet. A call to "BuildBuffers()" is required to transfer all
|
||||||
|
meshes into the GPU.
|
||||||
|
|
||||||
|
\param vertexCount
|
||||||
|
Number of vertices in this Mesh.
|
||||||
|
\param positions
|
||||||
|
Pointer to the first in a contiguous array of SHMathVec3s that define vertex
|
||||||
|
positions.
|
||||||
|
\param texCoords
|
||||||
|
Pointer to the first in a contiguous array of SHMathVec2s that define vertex
|
||||||
|
texture coordinates.
|
||||||
|
\param tangents
|
||||||
|
Pointer to the first in a contiguous array of SHMathVec3s that define vertex
|
||||||
|
tangents.
|
||||||
|
\param normals
|
||||||
|
Pointer to the first in a contiguous array of SHMathVec3s that define vertex
|
||||||
|
normals.
|
||||||
|
\param indexCount
|
||||||
|
Number of indices in this mesh.
|
||||||
|
\param indices
|
||||||
|
Pointer to the first in a contiguous array of uint32_ts that define mesh
|
||||||
|
indices.
|
||||||
|
|
||||||
|
\return
|
||||||
|
Handle to the created Mesh. This is not valid to be used until a call to
|
||||||
|
BuildBuffers().
|
||||||
|
|
||||||
|
*/
|
||||||
|
/*******************************************************************************/
|
||||||
|
Handle<SHMesh> AddMesh(uint32_t vertexCount, const SHMesh::VertexPosition* const positions, const SHMesh::VertexTexCoord* const texCoords, const const SHMesh::VertexTangent* const tangents, const SHMesh::VertexNormal* const normals, uint32_t indexCount, const SHMesh::Index* const indices);
|
||||||
|
/*******************************************************************************/
|
||||||
|
/*!
|
||||||
|
|
||||||
|
\brief
|
||||||
|
Removes a mesh from the MeshLibrary. But this does not mean that the meshes
|
||||||
|
have been removed yet. A call to "BuildBuffers()" is required to finalise all
|
||||||
|
changes.
|
||||||
|
|
||||||
|
\param mesh
|
||||||
|
Handle to the mesh to remove.
|
||||||
|
|
||||||
|
*/
|
||||||
|
/*******************************************************************************/
|
||||||
|
void RemoveMesh(Handle<SHMesh> mesh);
|
||||||
|
/***************************************************************************/
|
||||||
|
/*!
|
||||||
|
|
||||||
|
\brief
|
||||||
|
Finalises all changes to the MeshLibrary into the GPU buffers.
|
||||||
|
|
||||||
|
*/
|
||||||
|
/***************************************************************************/
|
||||||
|
void BuildMeshBuffers();
|
||||||
|
|
||||||
/*-----------------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------------*/
|
||||||
/* Setters */
|
/* Setters */
|
||||||
|
@ -155,15 +217,12 @@ namespace SHADE
|
||||||
Handle<SHVkCommandBuffer> transferCmdBuffer;
|
Handle<SHVkCommandBuffer> transferCmdBuffer;
|
||||||
SHRenderContext renderContext;
|
SHRenderContext renderContext;
|
||||||
std::array<Handle<SHVkSemaphore>, 2> graphSemaphores;
|
std::array<Handle<SHVkSemaphore>, 2> graphSemaphores;
|
||||||
|
|
||||||
// Not Owned Resources
|
// Not Owned Resources
|
||||||
SHWindow* window;
|
SHWindow* window;
|
||||||
|
|
||||||
|
|
||||||
std::vector<Handle<SHVkDescriptorSetLayout>> globalDescSetLayouts;
|
std::vector<Handle<SHVkDescriptorSetLayout>> globalDescSetLayouts;
|
||||||
|
|
||||||
// Middle End Resources
|
// Middle End Resources
|
||||||
ResourceManager resourceManager;
|
ResourceManager resourceManager;
|
||||||
|
SHMeshLibrary meshLibrary;
|
||||||
// Viewports
|
// Viewports
|
||||||
Handle<SHViewport> defaultViewport; // Whole screen
|
Handle<SHViewport> defaultViewport; // Whole screen
|
||||||
std::vector<Handle<SHViewport>> viewports; // Additional viewports
|
std::vector<Handle<SHViewport>> viewports; // Additional viewports
|
||||||
|
|
|
@ -13,6 +13,8 @@ of DigiPen Institute of Technology is prohibited.
|
||||||
#include "SHpch.h"
|
#include "SHpch.h"
|
||||||
#include "SHPrimitiveGenerator.h"
|
#include "SHPrimitiveGenerator.h"
|
||||||
|
|
||||||
|
#include "Graphics/MiddleEnd/Interface/SHGraphicsSystem.h"
|
||||||
|
|
||||||
namespace SHADE
|
namespace SHADE
|
||||||
{
|
{
|
||||||
SHMeshData SHPrimitiveGenerator::Cube() noexcept
|
SHMeshData SHPrimitiveGenerator::Cube() noexcept
|
||||||
|
@ -203,4 +205,18 @@ namespace SHADE
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Handle<SHADE::SHMesh> SHPrimitiveGenerator::Cube(SHGraphicsSystem& gfxSystem) noexcept
|
||||||
|
{
|
||||||
|
SHMeshData meshData = Cube();
|
||||||
|
return gfxSystem.AddMesh
|
||||||
|
(
|
||||||
|
meshData.VertexPositions.size(),
|
||||||
|
meshData.VertexPositions.data(),
|
||||||
|
meshData.VertexTexCoords.data(),
|
||||||
|
meshData.VertexTangents.data(),
|
||||||
|
meshData.VertexNormals.data(),
|
||||||
|
meshData.Indices.size(),
|
||||||
|
meshData.Indices.data()
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -56,5 +56,18 @@ namespace SHADE
|
||||||
*/
|
*/
|
||||||
/***********************************************************************************/
|
/***********************************************************************************/
|
||||||
[[nodiscard]] static Handle<SHMesh> Cube(SHMeshLibrary& meshLibrary) noexcept;
|
[[nodiscard]] static Handle<SHMesh> Cube(SHMeshLibrary& meshLibrary) noexcept;
|
||||||
|
/***********************************************************************************/
|
||||||
|
/*!
|
||||||
|
\brief
|
||||||
|
Produces a cube and constructs a SHMesh using the SHGraphicsSystem provided.
|
||||||
|
|
||||||
|
\param gfxSystem
|
||||||
|
Reference to the SHGraphicsSystem to produce and store a cube mesh in.
|
||||||
|
|
||||||
|
\return
|
||||||
|
SHMesh object that points to the generated cube mesh in the SHGraphicsSystem.
|
||||||
|
*/
|
||||||
|
/***********************************************************************************/
|
||||||
|
[[nodiscard]] static Handle<SHMesh> Cube(SHGraphicsSystem& gfxSystem) noexcept;
|
||||||
};
|
};
|
||||||
}
|
}
|
Loading…
Reference in New Issue