From 4aaa48419594c993c6c1b0bd2f5585c6492b6a31 Mon Sep 17 00:00:00 2001
From: Sabrina Shanman <cosmic@lindenlab.com>
Date: Wed, 9 Nov 2022 00:16:41 +0000
Subject: [PATCH] Revert "SL-18523: When editing an object's material override,
 use the object's material override as a base, rather than its render material
 (pull request #1190)"

---
 indra/llprimitive/llgltfmaterial.cpp | 26 --------------------------
 indra/llprimitive/llgltfmaterial.h   |  3 ---
 indra/newview/llmaterialeditor.cpp   | 15 ++++-----------
 3 files changed, 4 insertions(+), 40 deletions(-)

diff --git a/indra/llprimitive/llgltfmaterial.cpp b/indra/llprimitive/llgltfmaterial.cpp
index ee1931a27ba..6d23cb80399 100644
--- a/indra/llprimitive/llgltfmaterial.cpp
+++ b/indra/llprimitive/llgltfmaterial.cpp
@@ -61,29 +61,6 @@ LLMatrix3 LLGLTFMaterial::TextureTransform::asMatrix()
     return offset * rotation * scale;
 }
 
-LLGLTFMaterial::LLGLTFMaterial(bool for_override)
-: LLGLTFMaterial()
-{
-    if (for_override)
-    {
-        setBaseColorId(mBaseColorId, for_override);
-        setNormalId(mNormalId, for_override);
-        setMetallicRoughnessId(mMetallicRoughnessId, for_override);
-        setEmissiveId(mEmissiveId, for_override);
-
-        setBaseColorFactor(mBaseColor, for_override);
-        setAlphaCutoff(mAlphaCutoff, for_override);
-        setEmissiveColorFactor(mEmissiveColor, for_override);
-        setMetallicFactor(mMetallicFactor, for_override);
-        setRoughnessFactor(mRoughnessFactor, for_override);
-        setAlphaMode(mAlphaMode, for_override);
-        setDoubleSided(mDoubleSided, for_override);
-
-        // *NOTE: Texture offsets only exist in overrides, so there is no need
-        // to hack in the override value here.
-    }
-}
-
 LLGLTFMaterial::LLGLTFMaterial(const LLGLTFMaterial& rhs)
 {
     *this = rhs;
@@ -611,9 +588,6 @@ void LLGLTFMaterial::applyOverrideUUID(LLUUID& dst_id, const LLUUID& override_id
     }
 }
 
-// Make a static default material override for editing materials
-const LLGLTFMaterial LLGLTFMaterial::sOverrideDefault{true};
-
 void LLGLTFMaterial::applyOverride(const LLGLTFMaterial& override_mat)
 {
     LL_PROFILE_ZONE_SCOPED;
diff --git a/indra/llprimitive/llgltfmaterial.h b/indra/llprimitive/llgltfmaterial.h
index 2476818b271..60116fd423a 100644
--- a/indra/llprimitive/llgltfmaterial.h
+++ b/indra/llprimitive/llgltfmaterial.h
@@ -48,8 +48,6 @@ class LLGLTFMaterial : public LLRefCount
 
     // default material for reference
     static const LLGLTFMaterial sDefault;
-    // default material override for reference
-    static const LLGLTFMaterial sOverrideDefault;
 
     struct TextureTransform
     {
@@ -68,7 +66,6 @@ class LLGLTFMaterial : public LLRefCount
     };
 
     LLGLTFMaterial() {}
-    LLGLTFMaterial(bool for_override);
     LLGLTFMaterial(const LLGLTFMaterial& rhs);
 
     LLGLTFMaterial& operator=(const LLGLTFMaterial& rhs);
diff --git a/indra/newview/llmaterialeditor.cpp b/indra/newview/llmaterialeditor.cpp
index 70b165460a1..a0cb4e1c8f2 100644
--- a/indra/newview/llmaterialeditor.cpp
+++ b/indra/newview/llmaterialeditor.cpp
@@ -2385,26 +2385,19 @@ class LLRenderMaterialOverrideFunctor : public LLSelectedNodeFunctor
             // 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 (tep->getGLTFMaterial().isNull())
+            if (material.isNull())
             {
                 // 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
-            if (material.isNull())
-            {
-                // Start with a material override which does not make any changes
-                material = new LLGLTFMaterial(LLGLTFMaterial::sOverrideDefault);
-            }
-            else
-            {
-                material = new LLGLTFMaterial(*material);
-            }
+            material = new LLGLTFMaterial(*material);
 
             U32 changed_flags = mEditor->getUnsavedChangesFlags();
             U32 reverted_flags = mEditor->getRevertedChangesFlags();
-- 
GitLab