Fix gltf static mesh loading issues (#14)

* Support u8 / u32 indices

* Skip primitives without vertices

* Add support for non-indexed geometry & skipping primitives

* Fix possible memory leak on error

* Use SSkinnedMesh

* Check indices

* Properly mirror node hierarchy

* Update .gitignore

* Reorder includes

* Add some throws for logic errors

* Fix non-indexed geometry winding order, add unit test

* Address code review comments

* Add matrix transform unit test
This commit is contained in:
Lars Müller
2024-04-15 15:11:37 +02:00
committed by Josiah VanderZee
parent 0faf1320c5
commit 036b40a9d8
7 changed files with 466 additions and 113 deletions

View File

@ -301,7 +301,31 @@ struct SSkinMeshBuffer : public IMeshBuffer
}
//! append the vertices and indices to the current buffer
void append(const void *const vertices, u32 numVertices, const u16 *const indices, u32 numIndices) override {}
void append(const void* const vertices, u32 numVertices, const u16* const indices, u32 numIndices) override {
if (vertices == getVertices())
throw std::logic_error("can't append own vertices");
if (VertexType != video::EVT_STANDARD)
throw std::logic_error("invalid vertex type");
const u32 prevVertexCount = getVertexCount();
Vertices_Standard.reallocate(prevVertexCount + numVertices);
for (u32 i=0; i < numVertices; ++i) {
Vertices_Standard.push_back(static_cast<const video::S3DVertex* const>(vertices)[i]);
BoundingBox.addInternalPoint(static_cast<const video::S3DVertex* const>(vertices)[i].Pos);
}
Indices.reallocate(getIndexCount() + numIndices);
for (u32 i=0; i < numIndices; ++i) {
Indices.push_back(indices[i] + prevVertexCount);
}
}
//! NOT IMPLEMENTED YET: append the meshbuffer to the current buffer
void append(const IMeshBuffer* const other) override {
throw std::logic_error("not implemented yet");
}
//! get the current hardware mapping hint for vertex buffers
E_HARDWARE_MAPPING getHardwareMappingHint_Vertex() const override