Skip to content

Commit a364b5e

Browse files
committed
#4109 Add validation for non-triangulated geometry in GLTF loader
1 parent d342aa7 commit a364b5e

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

indra/newview/gltf/llgltfloader.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -461,6 +461,16 @@ bool LLGLTFLoader::populateModelFromMesh(LLModel* pModel, const LL::GLTF::Mesh&
461461
vertices.push_back(vert);
462462
}
463463

464+
if (prim.getIndexCount() % 3 != 0)
465+
{
466+
LL_WARNS("GLTF_IMPORT") << "Invalid primitive: index count " << prim.getIndexCount()
467+
<< " is not divisible by 3. GLTF files must contain triangulated geometry." << LL_ENDL;
468+
LLSD args;
469+
args["Message"] = "InvalidGeometryNonTriangulated";
470+
mWarningsArray.append(args);
471+
continue; // Skip this primitive
472+
}
473+
464474
// When processing indices, flip winding order if needed
465475
for (U32 i = 0; i < prim.getIndexCount(); i += 3)
466476
{

indra/newview/skins/default/xui/en/floater_model_preview.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@
6161
<string name="ParsingErrorNoRoot">Document has no root</string>
6262
<string name="ParsingErrorNoScene">Document has no visual_scene</string>
6363
<string name="ParsingErrorPositionInvalidModel">Unable to process mesh without position data. Invalid model.</string>
64+
<string name="InvalidGeometryNonTriangulated">Invalid geometry: GLTF files must contain triangulated meshes only.</string>
6465

6566
<panel
6667
follows="top|left"

0 commit comments

Comments
 (0)