#4114 Improve GLTF mesh uploader log

master
Andrey Lihatskiy 2025-06-10 19:36:17 +03:00
parent 4bbd6319c7
commit b3fd05fa97
2 changed files with 48 additions and 11 deletions

View File

@ -302,6 +302,10 @@ bool LLGLTFLoader::parseMeshes()
else
{
LL_WARNS("GLTF_IMPORT") << "No scenes defined in GLTF file" << LL_ENDL;
LLSD args;
args["Message"] = "NoScenesFound";
mWarningsArray.append(args);
return false;
}
@ -398,8 +402,16 @@ void LLGLTFLoader::processNodeHierarchy(S32 node_idx, std::map<std::string, S32>
else if (node.mMesh >= 0)
{
// Log invalid mesh reference
LL_WARNS("GLTF_IMPORT") << "Node " << node_idx << " references invalid mesh " << node.mMesh
LL_WARNS("GLTF_IMPORT") << "Node " << node_idx << " (" << node.mName
<< ") references invalid mesh " << node.mMesh
<< " (total meshes: " << mGLTFAsset.mMeshes.size() << ")" << LL_ENDL;
LLSD args;
args["Message"] = "InvalidMeshReference";
args["NODE_NAME"] = node.mName;
args["MESH_INDEX"] = node.mMesh;
args["TOTAL_MESHES"] = static_cast<S32>(mGLTFAsset.mMeshes.size());
mWarningsArray.append(args);
}
// Process all children recursively
@ -510,8 +522,9 @@ bool LLGLTFLoader::populateModelFromMesh(LLModel* pModel, const LL::GLTF::Mesh&
}
}
for (const LL::GLTF::Primitive& prim : mesh.mPrimitives)
for (size_t prim_idx = 0; prim_idx < mesh.mPrimitives.size(); ++prim_idx)
{
const LL::GLTF::Primitive& prim = mesh.mPrimitives[prim_idx];
// Unfortunately, SLM does not support 32 bit indices. Filter out anything that goes beyond 16 bit.
if (prim.getVertexCount() < USHRT_MAX)
{
@ -566,7 +579,14 @@ bool LLGLTFLoader::populateModelFromMesh(LLModel* pModel, const LL::GLTF::Mesh&
impMat.mDiffuseMapFilename = filename;
impMat.mDiffuseMapLabel = material->mName.empty() ? filename : material->mName;
LL_INFOS("GLTF_IMPORT") << "Found texture: " << impMat.mDiffuseMapFilename << LL_ENDL;
LL_INFOS("GLTF_IMPORT") << "Found texture: " << impMat.mDiffuseMapFilename
<< " for material: " << material->mName << LL_ENDL;
LLSD args;
args["Message"] = "TextureFound";
args["TEXTURE_NAME"] = impMat.mDiffuseMapFilename;
args["MATERIAL_NAME"] = material->mName;
mWarningsArray.append(args);
// If the image has a texture loaded already, use it
if (image.mTexture.notNull())
@ -663,10 +683,15 @@ bool LLGLTFLoader::populateModelFromMesh(LLModel* pModel, const LL::GLTF::Mesh&
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;
LL_WARNS("GLTF_IMPORT") << "Mesh '" << mesh.mName << "' primitive " << prim_idx
<< ": Invalid index count " << prim.getIndexCount()
<< " (not divisible by 3). GLTF files must contain triangulated geometry." << LL_ENDL;
LLSD args;
args["Message"] = "InvalidGeometryNonTriangulated";
args["MESH_NAME"] = mesh.mName;
args["PRIMITIVE_INDEX"] = static_cast<S32>(prim_idx);
args["INDEX_COUNT"] = static_cast<S32>(prim.getIndexCount());
mWarningsArray.append(args);
continue; // Skip this primitive
}
@ -818,10 +843,17 @@ bool LLGLTFLoader::populateModelFromMesh(LLModel* pModel, const LL::GLTF::Mesh&
pModel->getMaterialList().push_back(materialName);
mats[materialName] = impMat;
}
else {
LL_INFOS("GLTF_IMPORT") << "Unable to process mesh due to 16-bit index limits" << LL_ENDL;
else
{
LL_INFOS("GLTF_IMPORT") << "Unable to process mesh '" << mesh.mName
<< "' primitive " << prim_idx
<< " due to 16-bit index limits. Vertex count: "
<< prim.getVertexCount() << " exceeds limit: " << USHRT_MAX << LL_ENDL;
LLSD args;
args["Message"] = "ErrorIndexLimit";
args["MESH_NAME"] = mesh.mName.empty() ? ("mesh_" + std::to_string(&mesh - &mGLTFAsset.mMeshes[0])) : mesh.mName;
args["VERTEX_COUNT"] = static_cast<S32>(prim.getVertexCount());
args["LIMIT"] = USHRT_MAX;
mWarningsArray.append(args);
return false;
}

View File

@ -61,10 +61,15 @@
<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>
<string name="IgnoredExtension">Model uses unsupported extension: [EXT], related material properties are ignored.</string>
<string name="UnsupportedExtension">Unable to load a model, unsupported extension: [EXT]</string>
<string name="ErrorIndexLimit">Unable to process mesh due to 16-bit index limits</string>
<!-- GLTF specific messages -->
<string name="NoScenesFound">No scenes defined in GLTF file</string>
<string name="InvalidMeshReference">Node [NODE_NAME] references invalid mesh [MESH_INDEX] (total meshes: [TOTAL_MESHES])</string>
<string name="InvalidGeometryNonTriangulated">Mesh [MESH_NAME] primitive [PRIMITIVE_INDEX]: Invalid geometry with [INDEX_COUNT] indices (must be triangulated)</string>
<string name="ErrorIndexLimit">Mesh [MESH_NAME]: Vertex count [VERTEX_COUNT] exceeds 16-bit limit of [LIMIT]</string>
<string name="TextureFound">Found texture: [TEXTURE_NAME] for material: [MATERIAL_NAME]</string>
<string name="IgnoredExtension">Model uses unsupported extension: [EXT], related material properties are ignored</string>
<string name="UnsupportedExtension">Unable to load model, unsupported extension: [EXT]</string>
<panel
follows="top|left"