|
11 | 11 |
|
12 | 12 | #include <resources/PackFile.h>
|
13 | 13 | #include <resources/ResourceSystem.h>
|
| 14 | +#include <resources/StaticMeshData.h> |
14 | 15 | #include <utils/Logging.h>
|
15 | 16 |
|
16 | 17 | #include "Swapchain.h"
|
17 |
| -#include "resources/StaticMeshData.h" |
18 | 18 |
|
19 | 19 | namespace Siege::Vulkan
|
20 | 20 | {
|
@@ -43,22 +43,25 @@ StaticMesh::StaticMesh(const char* filePath, Material* material)
|
43 | 43 | {
|
44 | 44 | // TODO(Aryeh): How to extract material data from object files?
|
45 | 45 | PackFile* packFile = ResourceSystem::GetInstance().GetPackFile();
|
46 |
| - StaticMeshData* vertexData = packFile->FindData<StaticMeshData>(filePath); |
| 46 | + std::shared_ptr<StaticMeshData> staticMeshData = |
| 47 | + packFile->FindDataDeserialised<StaticMeshData>(filePath); |
47 | 48 |
|
48 |
| - CC_ASSERT(vertexData->verticesCount > 0, "Cannot load in a file with no vertices!") |
49 |
| - CC_ASSERT(vertexData->indicesCount > 0, "Cannot load in a file with no indices!") |
| 49 | + CC_ASSERT(!staticMeshData->vertices.empty(), "Cannot load in a file with no vertices!") |
| 50 | + CC_ASSERT(!staticMeshData->indices.empty(), "Cannot load in a file with no indices!") |
50 | 51 |
|
51 |
| - CC_ASSERT(vertexData->verticesCount < MAX_VERTICES, "The provided model has too many vertices!") |
52 |
| - CC_ASSERT(vertexData->indicesCount < MAX_INDICES, "The provided model has too many indices!") |
| 52 | + CC_ASSERT(staticMeshData->vertices.size() < MAX_VERTICES, |
| 53 | + "The provided model has too many vertices!") |
| 54 | + CC_ASSERT(staticMeshData->indices.size() < MAX_INDICES, |
| 55 | + "The provided model has too many indices!") |
53 | 56 |
|
54 |
| - vertexBuffer = VertexBuffer(sizeof(BaseVertex) * vertexData->verticesCount); |
55 |
| - vertexBuffer.Copy(vertexData->GetVertices(), sizeof(BaseVertex) * vertexData->verticesCount); |
| 57 | + vertexCount = staticMeshData->vertices.size(); |
| 58 | + indexCount = staticMeshData->indices.size(); |
56 | 59 |
|
57 |
| - indexBuffer = IndexBuffer(sizeof(unsigned int) * vertexData->indicesCount); |
58 |
| - indexBuffer.Copy(vertexData->GetIndices(), sizeof(unsigned int) * vertexData->indicesCount); |
| 60 | + vertexBuffer = VertexBuffer(sizeof(BaseVertex) * vertexCount); |
| 61 | + vertexBuffer.Copy(staticMeshData->vertices.data(), sizeof(BaseVertex) * vertexCount); |
59 | 62 |
|
60 |
| - vertexCount = vertexData->verticesCount; |
61 |
| - indexCount = vertexData->indicesCount; |
| 63 | + indexBuffer = IndexBuffer(sizeof(unsigned int) * indexCount); |
| 64 | + indexBuffer.Copy(staticMeshData->indices.data(), sizeof(unsigned int) * indexCount); |
62 | 65 |
|
63 | 66 | subMeshes = MHArray<SubMesh>(1);
|
64 | 67 | materials = MHArray<Material*>(1);
|
|
0 commit comments