From 145284b7f1a3583176e4e7de890a55ce39f4eab1 Mon Sep 17 00:00:00 2001 From: Paul Melis Date: Tue, 4 Jun 2024 17:17:29 +0200 Subject: [PATCH] Only count primitives made up of triangles in glTF meshes --- src/rmodels.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/rmodels.c b/src/rmodels.c index 23aaa04a6..18a7e1ac2 100644 --- a/src/rmodels.c +++ b/src/rmodels.c @@ -4969,9 +4969,14 @@ static Model LoadGLTF(const char *fileName) cgltf_mesh *mesh = node->mesh; if (!mesh) continue; - primitivesCount += mesh->primitives_count; + + for (unsigned int p = 0; p < mesh->primitives_count; p++) + { + if (mesh->primitives[p].type == cgltf_primitive_type_triangles) + primitivesCount++; + } } - TRACELOG(LOG_DEBUG, " > Primitives count based on hierarchy: %i", primitivesCount); + TRACELOG(LOG_DEBUG, " > Primitives (triangles only) count based on hierarchy : %i", primitivesCount); // Load our model data: meshes and materials model.meshCount = primitivesCount;