summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrey Kleshchev <andreykproductengine@lindenlab.com>2025-06-05 21:07:19 +0300
committerAndrey Kleshchev <117672381+akleshchev@users.noreply.github.com>2025-06-05 21:44:11 +0300
commit74d990872c8d8f59083b868a7ae8df5e90df62c2 (patch)
tree9939e475ed6b7b21d67fb00942d06814ed7769a1
parent08f6f5c697fce4ccbfba357ab9ce5af915dd0574 (diff)
#4214 Fix material upload
-rw-r--r--indra/newview/gltf/llgltfloader.cpp20
-rw-r--r--indra/newview/gltf/llgltfloader.h3
2 files changed, 19 insertions, 4 deletions
diff --git a/indra/newview/gltf/llgltfloader.cpp b/indra/newview/gltf/llgltfloader.cpp
index 60c6832058..1d7b44e566 100644
--- a/indra/newview/gltf/llgltfloader.cpp
+++ b/indra/newview/gltf/llgltfloader.cpp
@@ -140,7 +140,8 @@ void LLGLTFLoader::addModelToScene(
LLModel* pModel,
U32 submodel_limit,
const LLMatrix4& transformation,
- const LLVolumeParams& volume_params)
+ const LLVolumeParams& volume_params,
+ const material_map& mats)
{
U32 volume_faces = pModel->getNumVolumeFaces();
@@ -220,7 +221,15 @@ void LLGLTFLoader::addModelToScene(
std::map<std::string, LLImportMaterial> materials;
for (U32 i = 0; i < (U32)model->mMaterialList.size(); ++i)
{
- materials[model->mMaterialList[i]] = LLImportMaterial();
+ material_map::const_iterator found = mats.find(model->mMaterialList[i]);
+ if (found != mats.end())
+ {
+ materials[model->mMaterialList[i]] = found->second;
+ }
+ else
+ {
+ materials[model->mMaterialList[i]] = LLImportMaterial();
+ }
}
mScene[transformation].push_back(LLModelInstance(model, model->mLabel, transformation, materials));
stretch_extents(model, transformation);
@@ -325,7 +334,8 @@ bool LLGLTFLoader::parseMeshes()
mWarningsArray.append(args);
}
- addModelToScene(pModel, submodel_limit, transformation, volume_params);
+ addModelToScene(pModel, submodel_limit, transformation, volume_params, mats);
+ mats.clear();
}
else
{
@@ -815,6 +825,10 @@ bool LLGLTFLoader::populateModelFromMesh(LLModel* pModel, const LL::GLTF::Mesh&
}
// Remap indices for pModel->mSkinWeights
+ // Todo: this is now partially redundant due to
+ // remapSkinWeightsAndJoints being called later.
+ // Consider storing all joints now as is and let it
+ // ramap later due to missing weights.
for (auto& weights : pModel->mSkinWeights)
{
for (auto& weight : weights.second)
diff --git a/indra/newview/gltf/llgltfloader.h b/indra/newview/gltf/llgltfloader.h
index a3ee8d91df..5b9eb78c63 100644
--- a/indra/newview/gltf/llgltfloader.h
+++ b/indra/newview/gltf/llgltfloader.h
@@ -181,7 +181,8 @@ private:
LLModel* pModel,
U32 submodel_limit,
const LLMatrix4& transformation,
- const LLVolumeParams& volume_params);
+ const LLVolumeParams& volume_params,
+ const material_map& mats);
S32 findClosestValidJoint(S32 source_joint, const LL::GLTF::Skin& gltf_skin) const;
S32 findValidRootJointNode(S32 source_joint_node, const LL::GLTF::Skin& gltf_skin) const;
S32 findGLTFRootJointNode(const LL::GLTF::Skin& gltf_skin) const; // if there are multiple roots, gltf stores them under one commor joint