diff --git a/AssetLoader/interface/GLTFBuilder.hpp b/AssetLoader/interface/GLTFBuilder.hpp index 26444769..b52671e4 100644 --- a/AssetLoader/interface/GLTFBuilder.hpp +++ b/AssetLoader/interface/GLTFBuilder.hpp @@ -444,6 +444,8 @@ Mesh* ModelBuilder::LoadMesh(const GltfModelType& GltfModel, if (GltfPrimitive.GetIndicesId() >= 0) { IndexCount = ConvertIndexData(GltfModel, GltfPrimitive.GetIndicesId(), VertexStart); + // For indexed primitives, the vertex offset is baked into the indices, + VertexStart = 0; } int MaterialId = GltfPrimitive.GetMaterialId(); @@ -461,6 +463,7 @@ Mesh* ModelBuilder::LoadMesh(const GltfModelType& GltfModel, IndexStart, IndexCount, VertexCount, + VertexStart, static_cast(MaterialId), PosMin, PosMax // diff --git a/AssetLoader/interface/GLTFLoader.hpp b/AssetLoader/interface/GLTFLoader.hpp index 02699abe..ecdeff81 100644 --- a/AssetLoader/interface/GLTFLoader.hpp +++ b/AssetLoader/interface/GLTFLoader.hpp @@ -410,6 +410,7 @@ struct Primitive const Uint32 FirstIndex; const Uint32 IndexCount; const Uint32 VertexCount; + const Uint32 FirstVertex; const Uint32 MaterialId; const BoundBox BB; @@ -417,12 +418,14 @@ struct Primitive Primitive(Uint32 _FirstIndex, Uint32 _IndexCount, Uint32 _VertexCount, + Uint32 _FirstVertex, Uint32 _MaterialId, const float3& _BBMin, const float3& _BBMax) : FirstIndex{_FirstIndex}, IndexCount{_IndexCount}, VertexCount{_VertexCount}, + FirstVertex{_FirstVertex}, MaterialId{_MaterialId}, BB{_BBMin, _BBMax} {