summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrey Kleshchev <andreykproductengine@lindenlab.com>2022-11-09 03:11:50 +0200
committerAndrey Kleshchev <andreykproductengine@lindenlab.com>2022-11-09 03:12:14 +0200
commit14d901f25fdc10df871a60294eefcf4b9fb00931 (patch)
tree9bcdbcefc124b8acbfab9c55726a0fd55caec003
parent4d961ccbaafd4e8c17359c49f1acc15967e0e29c (diff)
SL-18583 Use gltf overrides as a base for live editing to send only minimal changes
-rw-r--r--indra/newview/llmaterialeditor.cpp67
-rw-r--r--indra/newview/llselectmgr.cpp31
-rw-r--r--indra/newview/llselectmgr.h5
3 files changed, 55 insertions, 48 deletions
diff --git a/indra/newview/llmaterialeditor.cpp b/indra/newview/llmaterialeditor.cpp
index a0cb4e1c8f..675ca610ce 100644
--- a/indra/newview/llmaterialeditor.cpp
+++ b/indra/newview/llmaterialeditor.cpp
@@ -908,29 +908,35 @@ void LLMaterialEditor::onSelectCtrl(LLUICtrl* ctrl, const LLSD& data, S32 dirty_
S32 num_tes = llmin((S32)objectp->getNumTEs(), (S32)objectp->getNumFaces()); // avatars have TEs but no faces
for (S32 te = 0; te < num_tes; ++te)
{
- if (nodep->isTESelected(te) && nodep->mSavedGLTFRenderMaterials.size() > te)
+ if (nodep->isTESelected(te) && nodep->mSavedGLTFOverrideMaterials.size() > te)
{
+ if (nodep->mSavedGLTFOverrideMaterials[te].isNull())
+ {
+ // populate with default values, default values basically mean 'not in use'
+ nodep->mSavedGLTFOverrideMaterials[te] = new LLGLTFMaterial();
+ }
+
switch (mDirtyFlag)
{
//Textures
case MATERIAL_BASE_COLOR_TEX_DIRTY:
{
- nodep->mSavedGLTFRenderMaterials[te]->mBaseColorId = mCtrl->getValue().asUUID();
+ nodep->mSavedGLTFOverrideMaterials[te]->mBaseColorId = mCtrl->getValue().asUUID();
break;
}
case MATERIAL_METALLIC_ROUGHTNESS_TEX_DIRTY:
{
- nodep->mSavedGLTFRenderMaterials[te]->mMetallicRoughnessId = mCtrl->getValue().asUUID();
+ nodep->mSavedGLTFOverrideMaterials[te]->mMetallicRoughnessId = mCtrl->getValue().asUUID();
break;
}
case MATERIAL_EMISIVE_TEX_DIRTY:
{
- nodep->mSavedGLTFRenderMaterials[te]->mEmissiveId = mCtrl->getValue().asUUID();
+ nodep->mSavedGLTFOverrideMaterials[te]->mEmissiveId = mCtrl->getValue().asUUID();
break;
}
case MATERIAL_NORMAL_TEX_DIRTY:
{
- nodep->mSavedGLTFRenderMaterials[te]->mNormalId = mCtrl->getValue().asUUID();
+ nodep->mSavedGLTFOverrideMaterials[te]->mNormalId = mCtrl->getValue().asUUID();
break;
}
// Colors
@@ -938,13 +944,13 @@ void LLMaterialEditor::onSelectCtrl(LLUICtrl* ctrl, const LLSD& data, S32 dirty_
{
LLColor4 ret = linearColor4(LLColor4(mCtrl->getValue()));
// except transparency
- ret.mV[3] = nodep->mSavedGLTFRenderMaterials[te]->mBaseColor.mV[3];
- nodep->mSavedGLTFRenderMaterials[te]->mBaseColor = ret;
+ ret.mV[3] = nodep->mSavedGLTFOverrideMaterials[te]->mBaseColor.mV[3];
+ nodep->mSavedGLTFOverrideMaterials[te]->mBaseColor = ret;
break;
}
case MATERIAL_EMISIVE_COLOR_DIRTY:
{
- nodep->mSavedGLTFRenderMaterials[te]->mEmissiveColor = LLColor4(mCtrl->getValue());
+ nodep->mSavedGLTFOverrideMaterials[te]->mEmissiveColor = LLColor4(mCtrl->getValue());
break;
}
default:
@@ -2379,29 +2385,40 @@ public:
{
continue;
}
-
// Get material from object
// Selection can cover multiple objects, and live editor is
// supposed to overwrite changed values only
LLTextureEntry* tep = objectp->getTE(te);
- LLPointer<LLGLTFMaterial> material = tep->getGLTFRenderMaterial();
- if (material.isNull())
+ if (tep->getGLTFMaterial() == nullptr)
{
// overrides are not supposed to work or apply if
// there is no base material to work from
return false;
}
-
+ LLPointer<LLGLTFMaterial> material = tep->getGLTFMaterialOverride();
// make a copy to not invalidate existing
// material for multiple objects
- material = new LLGLTFMaterial(*material);
+ if (material.isNull())
+ {
+ // Start with a material override which does not make any changes
+ material = new LLGLTFMaterial();
+ }
+ else
+ {
+ material = new LLGLTFMaterial(*material);
+ }
U32 changed_flags = mEditor->getUnsavedChangesFlags();
U32 reverted_flags = mEditor->getRevertedChangesFlags();
- bool can_revert = nodep->mSavedGLTFRenderMaterials.size() > te;
+
+ LLPointer<LLGLTFMaterial> revert_mat;
+ // mSavedGLTFOverrideMaterials[te] being null
+ // means we need to use a default value
+ bool can_revert = (nodep->mSavedGLTFOverrideMaterials.size() > te)
+ && nodep->mSavedGLTFOverrideMaterials[te].notNull();
// Override object's values with values from editor where appropriate
if (changed_flags & MATERIAL_BASE_COLOR_DIRTY)
@@ -2410,7 +2427,7 @@ public:
}
else if ((reverted_flags & MATERIAL_BASE_COLOR_DIRTY) && can_revert)
{
- material->setBaseColorFactor(nodep->mSavedGLTFRenderMaterials[te]->mBaseColor, true);
+ material->setBaseColorFactor(nodep->mSavedGLTFOverrideMaterials[te]->mBaseColor, true);
}
if (changed_flags & MATERIAL_BASE_COLOR_TEX_DIRTY)
@@ -2419,7 +2436,7 @@ public:
}
else if ((reverted_flags & MATERIAL_BASE_COLOR_TEX_DIRTY) && can_revert)
{
- material->setBaseColorId(nodep->mSavedGLTFRenderMaterials[te]->mBaseColorId, true);
+ material->setBaseColorId(nodep->mSavedGLTFOverrideMaterials[te]->mBaseColorId, true);
}
if (changed_flags & MATERIAL_NORMAL_TEX_DIRTY)
@@ -2428,7 +2445,7 @@ public:
}
else if ((reverted_flags & MATERIAL_NORMAL_TEX_DIRTY) && can_revert)
{
- material->setNormalId(nodep->mSavedGLTFRenderMaterials[te]->mNormalId, true);
+ material->setNormalId(nodep->mSavedGLTFOverrideMaterials[te]->mNormalId, true);
}
if (changed_flags & MATERIAL_METALLIC_ROUGHTNESS_TEX_DIRTY)
@@ -2437,7 +2454,7 @@ public:
}
else if ((reverted_flags & MATERIAL_METALLIC_ROUGHTNESS_TEX_DIRTY) && can_revert)
{
- material->setMetallicRoughnessId(nodep->mSavedGLTFRenderMaterials[te]->mMetallicRoughnessId, true);
+ material->setMetallicRoughnessId(nodep->mSavedGLTFOverrideMaterials[te]->mMetallicRoughnessId, true);
}
if (changed_flags & MATERIAL_METALLIC_ROUGHTNESS_METALNESS_DIRTY)
@@ -2446,7 +2463,7 @@ public:
}
else if ((reverted_flags & MATERIAL_METALLIC_ROUGHTNESS_METALNESS_DIRTY) && can_revert)
{
- material->setMetallicFactor(nodep->mSavedGLTFRenderMaterials[te]->mMetallicFactor, true);
+ material->setMetallicFactor(nodep->mSavedGLTFOverrideMaterials[te]->mMetallicFactor, true);
}
if (changed_flags & MATERIAL_METALLIC_ROUGHTNESS_ROUGHNESS_DIRTY)
@@ -2455,7 +2472,7 @@ public:
}
else if ((reverted_flags & MATERIAL_METALLIC_ROUGHTNESS_ROUGHNESS_DIRTY) && can_revert)
{
- material->setRoughnessFactor(nodep->mSavedGLTFRenderMaterials[te]->mRoughnessFactor, true);
+ material->setRoughnessFactor(nodep->mSavedGLTFOverrideMaterials[te]->mRoughnessFactor, true);
}
if (changed_flags & MATERIAL_EMISIVE_COLOR_DIRTY)
@@ -2464,7 +2481,7 @@ public:
}
else if ((reverted_flags & MATERIAL_EMISIVE_COLOR_DIRTY) && can_revert)
{
- material->setEmissiveColorFactor(nodep->mSavedGLTFRenderMaterials[te]->mEmissiveColor, true);
+ material->setEmissiveColorFactor(nodep->mSavedGLTFOverrideMaterials[te]->mEmissiveColor, true);
}
if (changed_flags & MATERIAL_EMISIVE_TEX_DIRTY)
@@ -2473,7 +2490,7 @@ public:
}
else if ((reverted_flags & MATERIAL_EMISIVE_TEX_DIRTY) && can_revert)
{
- material->setEmissiveId(nodep->mSavedGLTFRenderMaterials[te]->mEmissiveId, true);
+ material->setEmissiveId(nodep->mSavedGLTFOverrideMaterials[te]->mEmissiveId, true);
}
if (changed_flags & MATERIAL_DOUBLE_SIDED_DIRTY)
@@ -2482,7 +2499,7 @@ public:
}
else if ((reverted_flags & MATERIAL_DOUBLE_SIDED_DIRTY) && can_revert)
{
- material->setDoubleSided(nodep->mSavedGLTFRenderMaterials[te]->mDoubleSided, true);
+ material->setDoubleSided(nodep->mSavedGLTFOverrideMaterials[te]->mDoubleSided, true);
}
if (changed_flags & MATERIAL_ALPHA_MODE_DIRTY)
@@ -2491,7 +2508,7 @@ public:
}
else if ((reverted_flags & MATERIAL_ALPHA_MODE_DIRTY) && can_revert)
{
- material->setAlphaMode(nodep->mSavedGLTFRenderMaterials[te]->mAlphaMode, true);
+ material->setAlphaMode(nodep->mSavedGLTFOverrideMaterials[te]->mAlphaMode, true);
}
if (changed_flags & MATERIAL_ALPHA_CUTOFF_DIRTY)
@@ -2500,7 +2517,7 @@ public:
}
else if ((reverted_flags & MATERIAL_ALPHA_CUTOFF_DIRTY) && can_revert)
{
- material->setAlphaCutoff(nodep->mSavedGLTFRenderMaterials[te]->mAlphaCutoff, true);
+ material->setAlphaCutoff(nodep->mSavedGLTFOverrideMaterials[te]->mAlphaCutoff, true);
}
#if 1
diff --git a/indra/newview/llselectmgr.cpp b/indra/newview/llselectmgr.cpp
index ee10872a16..6dbdc380dc 100644
--- a/indra/newview/llselectmgr.cpp
+++ b/indra/newview/llselectmgr.cpp
@@ -2232,11 +2232,11 @@ void LLSelectMgr::selectionRevertGLTFMaterials()
// todo: make sure this does not cause race condition with setRenderMaterialID
// when we are reverting from null id to non null plus override
- if (te < (S32)nodep->mSavedGLTFRenderMaterials.size()
- && nodep->mSavedGLTFRenderMaterials[te].notNull()
+ if (te < (S32)nodep->mSavedGLTFOverrideMaterials.size()
+ && nodep->mSavedGLTFOverrideMaterials[te].notNull()
&& asset_id.notNull())
{
- overrides["gltf_json"] = nodep->mSavedGLTFRenderMaterials[te]->asJSON();
+ overrides["gltf_json"] = nodep->mSavedGLTFOverrideMaterials[te]->asJSON();
} // else nothing to blank override out
LLCoros::instance().launch("modifyMaterialCoro",
@@ -5888,10 +5888,10 @@ void LLSelectMgr::processObjectProperties(LLMessageSystem* msg, void** user_data
// reflected in a saved copy.
// Like changes from local material (reuses pointer) or
// from live editor (revert mechanics might modify this)
- LLGLTFMaterial* old_mat = node->getObject()->getTE(i)->getGLTFRenderMaterial();
- if (old_mat)
+ LLGLTFMaterial* old_override = node->getObject()->getTE(i)->getGLTFMaterialOverride();
+ if (old_override)
{
- LLPointer<LLGLTFMaterial> mat = new LLGLTFMaterial(*old_mat);
+ LLPointer<LLGLTFMaterial> mat = new LLGLTFMaterial(*old_override);
materials.push_back(mat);
}
else
@@ -5903,7 +5903,7 @@ void LLSelectMgr::processObjectProperties(LLMessageSystem* msg, void** user_data
// processObjectProperties does not include overrides so this
// might need to be moved to LLGLTFMaterialOverrideDispatchHandler
- node->saveGLTFRenderMaterials(materials);
+ node->saveGLTFOverrideMaterials(materials);
}
}
@@ -6657,7 +6657,7 @@ LLSelectNode::LLSelectNode(const LLSelectNode& nodep)
saveTextures(nodep.mSavedTextures);
saveGLTFMaterialIds(nodep.mSavedGLTFMaterialIds);
- saveGLTFRenderMaterials(nodep.mSavedGLTFRenderMaterials);
+ saveGLTFOverrideMaterials(nodep.mSavedGLTFOverrideMaterials);
}
LLSelectNode::~LLSelectNode()
@@ -6805,29 +6805,20 @@ void LLSelectNode::saveGLTFMaterialIds(const uuid_vec_t& materials)
}
}
-void LLSelectNode::saveGLTFRenderMaterials(const gltf_materials_vec_t& materials)
+void LLSelectNode::saveGLTFOverrideMaterials(const gltf_materials_vec_t& materials)
{
if (mObject.notNull())
{
- mSavedGLTFRenderMaterials.clear();
+ mSavedGLTFOverrideMaterials.clear();
for (gltf_materials_vec_t::const_iterator mat_it = materials.begin();
mat_it != materials.end(); ++mat_it)
{
- mSavedGLTFRenderMaterials.push_back(*mat_it);
+ mSavedGLTFOverrideMaterials.push_back(*mat_it);
}
}
}
-LLGLTFMaterial* LLSelectNode::getSavedGLTFRenderMaterial(S32 te)
-{
- if (mSavedGLTFRenderMaterials.size() > te)
- {
- return mSavedGLTFRenderMaterials[te].get();
- }
- return nullptr;
-}
-
void LLSelectNode::saveTextureScaleRatios(LLRender::eTexIndex index_to_query)
{
mTextureScaleRatios.clear();
diff --git a/indra/newview/llselectmgr.h b/indra/newview/llselectmgr.h
index 7e7c450767..64b87b7c86 100644
--- a/indra/newview/llselectmgr.h
+++ b/indra/newview/llselectmgr.h
@@ -198,8 +198,7 @@ public:
// Ids get applied and restored by tools floater,
// overrides get applied in live material editor
void saveGLTFMaterialIds(const uuid_vec_t& materials);
- void saveGLTFRenderMaterials(const gltf_materials_vec_t& materials);
- LLGLTFMaterial* getSavedGLTFRenderMaterial(S32 te);
+ void saveGLTFOverrideMaterials(const gltf_materials_vec_t& materials);
BOOL allowOperationOnNode(PermissionBit op, U64 group_proxy_power) const;
@@ -237,7 +236,7 @@ public:
std::vector<LLColor4> mSavedShinyColors;
uuid_vec_t mSavedTextures;
uuid_vec_t mSavedGLTFMaterialIds;
- gltf_materials_vec_t mSavedGLTFRenderMaterials;
+ gltf_materials_vec_t mSavedGLTFOverrideMaterials;
std::vector<LLVector3> mTextureScaleRatios;
std::vector<LLVector3> mSilhouetteVertices; // array of vertices to render silhouette of object
std::vector<LLVector3> mSilhouetteNormals; // array of normals to render silhouette of object