|
11 | 11 |
|
12 | 12 | #include <resources/PackFile.h>
|
13 | 13 | #include <resources/ResourceSystem.h>
|
14 |
| -#include <resources/PackFileData.h> |
15 | 14 | #include <resources/StaticMeshData.h>
|
16 | 15 | #include <utils/Logging.h>
|
17 | 16 |
|
@@ -44,31 +43,25 @@ StaticMesh::StaticMesh(const char* filePath, Material* material)
|
44 | 43 | {
|
45 | 44 | // TODO(Aryeh): How to extract material data from object files?
|
46 | 45 | PackFile* packFile = ResourceSystem::GetInstance().GetPackFile();
|
47 |
| - std::shared_ptr<PackFileData> vertexDataDataBuffer = packFile->FindData<PackFileData>(filePath); |
| 46 | + std::shared_ptr<StaticMeshData> staticMeshData = |
| 47 | + packFile->FindDataDeserialised<StaticMeshData>(filePath); |
48 | 48 |
|
49 |
| - BinarySerialisation::Buffer buffer; |
50 |
| - uint8_t* data = reinterpret_cast<uint8_t*>(vertexDataDataBuffer->data); |
51 |
| - size_t dataSize = vertexDataDataBuffer->dataSize; |
52 |
| - buffer.data.assign(data, dataSize); |
| 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!") |
53 | 51 |
|
54 |
| - // TODO - Fold into resource system |
55 |
| - StaticMeshData staticMeshData; |
56 |
| - staticMeshData.serialise(buffer, BinarySerialisation::DESERIALISE); |
| 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!") |
57 | 56 |
|
58 |
| - CC_ASSERT(!staticMeshData.vertices.empty(), "Cannot load in a file with no vertices!") |
59 |
| - CC_ASSERT(!staticMeshData.indices.empty(), "Cannot load in a file with no indices!") |
60 |
| - |
61 |
| - CC_ASSERT(staticMeshData.vertices.size() < MAX_VERTICES, "The provided model has too many vertices!") |
62 |
| - CC_ASSERT(staticMeshData.indices.size() < MAX_INDICES, "The provided model has too many indices!") |
63 |
| - |
64 |
| - vertexCount = staticMeshData.vertices.size(); |
65 |
| - indexCount = staticMeshData.indices.size(); |
| 57 | + vertexCount = staticMeshData->vertices.size(); |
| 58 | + indexCount = staticMeshData->indices.size(); |
66 | 59 |
|
67 | 60 | vertexBuffer = VertexBuffer(sizeof(BaseVertex) * vertexCount);
|
68 |
| - vertexBuffer.Copy(staticMeshData.vertices.data(), sizeof(BaseVertex) * vertexCount); |
| 61 | + vertexBuffer.Copy(staticMeshData->vertices.data(), sizeof(BaseVertex) * vertexCount); |
69 | 62 |
|
70 | 63 | indexBuffer = IndexBuffer(sizeof(unsigned int) * indexCount);
|
71 |
| - indexBuffer.Copy(staticMeshData.indices.data(), sizeof(unsigned int) * indexCount); |
| 64 | + indexBuffer.Copy(staticMeshData->indices.data(), sizeof(unsigned int) * indexCount); |
72 | 65 |
|
73 | 66 | subMeshes = MHArray<SubMesh>(1);
|
74 | 67 | materials = MHArray<Material*>(1);
|
|
0 commit comments