From a364b5ee1d4c009b2e571fde66272ae06e434c21 Mon Sep 17 00:00:00 2001 From: Andrey Lihatskiy Date: Mon, 26 May 2025 17:43:56 +0300 Subject: #4109 Add validation for non-triangulated geometry in GLTF loader --- indra/newview/gltf/llgltfloader.cpp | 10 ++++++++++ indra/newview/skins/default/xui/en/floater_model_preview.xml | 1 + 2 files changed, 11 insertions(+) diff --git a/indra/newview/gltf/llgltfloader.cpp b/indra/newview/gltf/llgltfloader.cpp index de7c341cdf..93ed904f2e 100644 --- a/indra/newview/gltf/llgltfloader.cpp +++ b/indra/newview/gltf/llgltfloader.cpp @@ -461,6 +461,16 @@ bool LLGLTFLoader::populateModelFromMesh(LLModel* pModel, const LL::GLTF::Mesh& vertices.push_back(vert); } + if (prim.getIndexCount() % 3 != 0) + { + LL_WARNS("GLTF_IMPORT") << "Invalid primitive: index count " << prim.getIndexCount() + << " is not divisible by 3. GLTF files must contain triangulated geometry." << LL_ENDL; + LLSD args; + args["Message"] = "InvalidGeometryNonTriangulated"; + mWarningsArray.append(args); + continue; // Skip this primitive + } + // When processing indices, flip winding order if needed for (U32 i = 0; i < prim.getIndexCount(); i += 3) { diff --git a/indra/newview/skins/default/xui/en/floater_model_preview.xml b/indra/newview/skins/default/xui/en/floater_model_preview.xml index 99c348c236..067a1e0c8b 100644 --- a/indra/newview/skins/default/xui/en/floater_model_preview.xml +++ b/indra/newview/skins/default/xui/en/floater_model_preview.xml @@ -61,6 +61,7 @@ Document has no root Document has no visual_scene Unable to process mesh without position data. Invalid model. + Invalid geometry: GLTF files must contain triangulated meshes only.