Skip to content

Commit 42660fe

Browse files
authored
GLTF Loader: add vertex start position to the primitive
This addresses gltf file with mixed indicies/no indicies primitives
1 parent 719dd6d commit 42660fe

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

AssetLoader/interface/GLTFBuilder.hpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -444,6 +444,8 @@ Mesh* ModelBuilder::LoadMesh(const GltfModelType& GltfModel,
444444
if (GltfPrimitive.GetIndicesId() >= 0)
445445
{
446446
IndexCount = ConvertIndexData(GltfModel, GltfPrimitive.GetIndicesId(), VertexStart);
447+
// For indexed primitives, the vertex offset is baked into the indices,
448+
VertexStart = 0;
447449
}
448450

449451
int MaterialId = GltfPrimitive.GetMaterialId();
@@ -461,6 +463,7 @@ Mesh* ModelBuilder::LoadMesh(const GltfModelType& GltfModel,
461463
IndexStart,
462464
IndexCount,
463465
VertexCount,
466+
VertexStart,
464467
static_cast<Uint32>(MaterialId),
465468
PosMin,
466469
PosMax //

AssetLoader/interface/GLTFLoader.hpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -410,19 +410,22 @@ struct Primitive
410410
const Uint32 FirstIndex;
411411
const Uint32 IndexCount;
412412
const Uint32 VertexCount;
413+
const Uint32 FirstVertex;
413414
const Uint32 MaterialId;
414415

415416
const BoundBox BB;
416417

417418
Primitive(Uint32 _FirstIndex,
418419
Uint32 _IndexCount,
419420
Uint32 _VertexCount,
421+
Uint32 _FirstVertex,
420422
Uint32 _MaterialId,
421423
const float3& _BBMin,
422424
const float3& _BBMax) :
423425
FirstIndex{_FirstIndex},
424426
IndexCount{_IndexCount},
425427
VertexCount{_VertexCount},
428+
FirstVertex{_FirstVertex},
426429
MaterialId{_MaterialId},
427430
BB{_BBMin, _BBMax}
428431
{

0 commit comments

Comments
 (0)