diff options
| author | Jonathan "Geenz" Goodman <geenz@lindenlab.com> | 2025-12-03 11:50:32 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-12-03 11:50:32 -0500 |
| commit | bf347d15804c27348c84a55ab763f89b718e8aac (patch) | |
| tree | a112d8ef3e65581fb1fae03a093a75637d134756 /indra/newview/gltf/llgltfloader.cpp | |
| parent | aec7bf19ebffd9d6b60c68e31de723eabd6aa98a (diff) | |
| parent | ad6008a5880dff8691f5fce56b7fbfc5ea8b1626 (diff) | |
Merge pull request #4853 from secondlife/release/2025.08
Release/2025.08
Diffstat (limited to 'indra/newview/gltf/llgltfloader.cpp')
| -rw-r--r-- | indra/newview/gltf/llgltfloader.cpp | 37 |
1 files changed, 24 insertions, 13 deletions
diff --git a/indra/newview/gltf/llgltfloader.cpp b/indra/newview/gltf/llgltfloader.cpp index dd1d327683..4f8f80129d 100644 --- a/indra/newview/gltf/llgltfloader.cpp +++ b/indra/newview/gltf/llgltfloader.cpp @@ -412,17 +412,14 @@ void LLGLTFLoader::processNodeHierarchy(S32 node_idx, std::map<std::string, S32> // Process this node's mesh if it has one if (node.mMesh >= 0 && node.mMesh < mGLTFAsset.mMeshes.size()) { - LLMatrix4 transformation; - material_map mats; - - LLModel* pModel = new LLModel(volume_params, 0.f); - const LL::GLTF::Mesh& mesh = mGLTFAsset.mMeshes[node.mMesh]; - - // Get base mesh name and track usage - std::string base_name = getLodlessLabel(mesh); + // Get base node name and track usage + // Potentially multiple nodes can reuse the same mesh and Collada used + // node name instead of mesh name, so for consistency use node name if + // avaliable, node index otherwise. + std::string base_name = getLodlessLabel(node); if (base_name.empty()) { - base_name = "mesh_" + std::to_string(node.mMesh); + base_name = "node_" + std::to_string(node_idx); } S32 instance_count = mesh_name_counts[base_name]++; @@ -433,6 +430,12 @@ void LLGLTFLoader::processNodeHierarchy(S32 node_idx, std::map<std::string, S32> base_name = base_name + "_copy_" + std::to_string(instance_count); } + LLMatrix4 transformation; + material_map mats; + + LLModel* pModel = new LLModel(volume_params, 0.f); + const LL::GLTF::Mesh& mesh = mGLTFAsset.mMeshes[node.mMesh]; + if (populateModelFromMesh(pModel, base_name, mesh, node, mats) && (LLModel::NO_ERRORS == pModel->getStatus()) && validate_model(pModel)) @@ -652,6 +655,14 @@ std::string LLGLTFLoader::processTexture(S32 texture_index, const std::string& t filename = filename.substr(pos + 1); } + std::string dir = gDirUtilp->getDirName(mFilename); + std::string full_path = dir + gDirUtilp->getDirDelimiter() + filename; + if (!gDirUtilp->fileExists(full_path) && filename.find("data:") == std::string::npos) + { + // Uri might be escaped + filename = LLURI::unescape(filename); + } + LL_INFOS("GLTF_IMPORT") << "Found texture: " << filename << " for material: " << material_name << LL_ENDL; LLSD args; @@ -1810,13 +1821,13 @@ size_t LLGLTFLoader::getSuffixPosition(const std::string &label) return -1; } -std::string LLGLTFLoader::getLodlessLabel(const LL::GLTF::Mesh& mesh) +std::string LLGLTFLoader::getLodlessLabel(const LL::GLTF::Node& node) { - size_t ext_pos = getSuffixPosition(mesh.mName); + size_t ext_pos = getSuffixPosition(node.mName); if (ext_pos != -1) { - return mesh.mName.substr(0, ext_pos); + return node.mName.substr(0, ext_pos); } - return mesh.mName; + return node.mName; } |
