From b3fd05fa97ee90b68fb6003db68afcafeb2c2b95 Mon Sep 17 00:00:00 2001 From: Andrey Lihatskiy Date: Tue, 10 Jun 2025 19:36:17 +0300 Subject: #4114 Improve GLTF mesh uploader log --- indra/newview/gltf/llgltfloader.cpp | 46 ++++++++++++++++++---- .../skins/default/xui/en/floater_model_preview.xml | 13 ++++-- 2 files changed, 48 insertions(+), 11 deletions(-) diff --git a/indra/newview/gltf/llgltfloader.cpp b/indra/newview/gltf/llgltfloader.cpp index 8fe5a8f2fb..d0a0a0b541 100644 --- a/indra/newview/gltf/llgltfloader.cpp +++ b/indra/newview/gltf/llgltfloader.cpp @@ -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 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(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(prim_idx); + args["INDEX_COUNT"] = static_cast(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(prim.getVertexCount()); + args["LIMIT"] = USHRT_MAX; mWarningsArray.append(args); return false; } 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 1c4a857dab..d9a344ba41 100644 --- a/indra/newview/skins/default/xui/en/floater_model_preview.xml +++ b/indra/newview/skins/default/xui/en/floater_model_preview.xml @@ -61,10 +61,15 @@ 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. - Model uses unsupported extension: [EXT], related material properties are ignored. - Unable to load a model, unsupported extension: [EXT] - Unable to process mesh due to 16-bit index limits + + + No scenes defined in GLTF file + Node [NODE_NAME] references invalid mesh [MESH_INDEX] (total meshes: [TOTAL_MESHES]) + Mesh [MESH_NAME] primitive [PRIMITIVE_INDEX]: Invalid geometry with [INDEX_COUNT] indices (must be triangulated) + Mesh [MESH_NAME]: Vertex count [VERTEX_COUNT] exceeds 16-bit limit of [LIMIT] + Found texture: [TEXTURE_NAME] for material: [MATERIAL_NAME] + Model uses unsupported extension: [EXT], related material properties are ignored + Unable to load model, unsupported extension: [EXT]