diff options
author | Sabrina Shanman <cosmic@lindenlab.com> | 2022-11-09 00:03:34 +0000 |
---|---|---|
committer | Sabrina Shanman <cosmic@lindenlab.com> | 2022-11-09 00:03:34 +0000 |
commit | ded67322deb36dc842deb0e4c47022691d5ffb2b (patch) | |
tree | 0fb4c230d1440675a45939853882ba8d698bd13a /indra | |
parent | dafbed80b4cfdf906913a469503db320da49cabf (diff) | |
parent | cba87c62cc3c31d48c680bf92aa7ae2b9555ba69 (diff) |
Merged in SL-18523 (pull request #1190)
SL-18523: When editing an object's material override, use the object's material override as a base, rather than its render material
Diffstat (limited to 'indra')
-rw-r--r-- | indra/llprimitive/llgltfmaterial.cpp | 26 | ||||
-rw-r--r-- | indra/llprimitive/llgltfmaterial.h | 3 | ||||
-rw-r--r-- | indra/newview/llmaterialeditor.cpp | 15 |
3 files changed, 40 insertions, 4 deletions
diff --git a/indra/llprimitive/llgltfmaterial.cpp b/indra/llprimitive/llgltfmaterial.cpp index 6d23cb8039..ee1931a27b 100644 --- a/indra/llprimitive/llgltfmaterial.cpp +++ b/indra/llprimitive/llgltfmaterial.cpp @@ -61,6 +61,29 @@ 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; @@ -588,6 +611,9 @@ 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 60116fd423..2476818b27 100644 --- a/indra/llprimitive/llgltfmaterial.h +++ b/indra/llprimitive/llgltfmaterial.h @@ -48,6 +48,8 @@ public: // default material for reference static const LLGLTFMaterial sDefault; + // default material override for reference + static const LLGLTFMaterial sOverrideDefault; struct TextureTransform { @@ -66,6 +68,7 @@ public: }; 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 a0cb4e1c8f..70b165460a 100644 --- a/indra/newview/llmaterialeditor.cpp +++ b/indra/newview/llmaterialeditor.cpp @@ -2385,19 +2385,26 @@ public: // 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().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 - material = new LLGLTFMaterial(*material); + if (material.isNull()) + { + // Start with a material override which does not make any changes + material = new LLGLTFMaterial(LLGLTFMaterial::sOverrideDefault); + } + else + { + material = new LLGLTFMaterial(*material); + } U32 changed_flags = mEditor->getUnsavedChangesFlags(); U32 reverted_flags = mEditor->getRevertedChangesFlags(); |