summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrey Lihatskiy <alihatskiy@productengine.com>2025-05-26 17:43:56 +0300
committerAndrey Lihatskiy <alihatskiy@productengine.com>2025-05-26 17:45:57 +0300
commita364b5ee1d4c009b2e571fde66272ae06e434c21 (patch)
treee3cdbcd83535068a419ff8601e1d978bf75393c2
parentd342aa79c24fe20d06a018eabdb03912d11d4702 (diff)
#4109 Add validation for non-triangulated geometry in GLTF loader
-rw-r--r--indra/newview/gltf/llgltfloader.cpp10
-rw-r--r--indra/newview/skins/default/xui/en/floater_model_preview.xml1
2 files changed, 11 insertions, 0 deletions
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 @@
<string name="ParsingErrorNoRoot">Document has no root</string>
<string name="ParsingErrorNoScene">Document has no visual_scene</string>
<string name="ParsingErrorPositionInvalidModel">Unable to process mesh without position data. Invalid model.</string>
+ <string name="InvalidGeometryNonTriangulated">Invalid geometry: GLTF files must contain triangulated meshes only.</string>
<panel
follows="top|left"