From f1ad9a7e9698eee55788485e0990cc8fadceeb54 Mon Sep 17 00:00:00 2001 From: Chris Adams Date: Tue, 4 Nov 2025 14:09:51 -0500 Subject: [PATCH 1/2] added in vertex start positions to address gltf file with mixed indicies/no indicies primitives --- AssetLoader/interface/GLTFBuilder.hpp | 1 + AssetLoader/interface/GLTFLoader.hpp | 3 +++ 2 files changed, 4 insertions(+) diff --git a/AssetLoader/interface/GLTFBuilder.hpp b/AssetLoader/interface/GLTFBuilder.hpp index 26444769..8c98d3d3 100644 --- a/AssetLoader/interface/GLTFBuilder.hpp +++ b/AssetLoader/interface/GLTFBuilder.hpp @@ -461,6 +461,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..41e60b5f 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 VertexStart; const Uint32 MaterialId; const BoundBox BB; @@ -417,12 +418,14 @@ struct Primitive Primitive(Uint32 _FirstIndex, Uint32 _IndexCount, Uint32 _VertexCount, + Uint32 _VertexStart, Uint32 _MaterialId, const float3& _BBMin, const float3& _BBMax) : FirstIndex{_FirstIndex}, IndexCount{_IndexCount}, VertexCount{_VertexCount}, + VertexStart{_VertexStart}, MaterialId{_MaterialId}, BB{_BBMin, _BBMax} { From 2a156a1f38f5a70c156522d43a3997b04a8284be Mon Sep 17 00:00:00 2001 From: Chris Adams Date: Thu, 6 Nov 2025 11:26:36 -0500 Subject: [PATCH 2/2] pr updates --- AssetLoader/interface/GLTFBuilder.hpp | 2 ++ AssetLoader/interface/GLTFLoader.hpp | 6 +++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/AssetLoader/interface/GLTFBuilder.hpp b/AssetLoader/interface/GLTFBuilder.hpp index 8c98d3d3..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(); diff --git a/AssetLoader/interface/GLTFLoader.hpp b/AssetLoader/interface/GLTFLoader.hpp index 41e60b5f..ecdeff81 100644 --- a/AssetLoader/interface/GLTFLoader.hpp +++ b/AssetLoader/interface/GLTFLoader.hpp @@ -410,7 +410,7 @@ struct Primitive const Uint32 FirstIndex; const Uint32 IndexCount; const Uint32 VertexCount; - const Uint32 VertexStart; + const Uint32 FirstVertex; const Uint32 MaterialId; const BoundBox BB; @@ -418,14 +418,14 @@ struct Primitive Primitive(Uint32 _FirstIndex, Uint32 _IndexCount, Uint32 _VertexCount, - Uint32 _VertexStart, + Uint32 _FirstVertex, Uint32 _MaterialId, const float3& _BBMin, const float3& _BBMax) : FirstIndex{_FirstIndex}, IndexCount{_IndexCount}, VertexCount{_VertexCount}, - VertexStart{_VertexStart}, + FirstVertex{_FirstVertex}, MaterialId{_MaterialId}, BB{_BBMin, _BBMax} {