diff options
author | cosmic-linden <111533034+cosmic-linden@users.noreply.github.com> | 2023-01-11 10:36:35 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-01-11 10:36:35 -0800 |
commit | 7e1f4e4cc7588131e12b3fc7542e10d066aad93f (patch) | |
tree | d1abc294fe0a7508d6d3b9d0b6661694b11719d9 /indra/llprimitive/llgltfmaterial.cpp | |
parent | b4f53334141b179bdb1762636ce313f14d9e2b10 (diff) | |
parent | 693925ef23ef41e3927a9654a7f423d0e24ce19a (diff) |
Merge pull request #48 from secondlife/SL-18820
Sl 18820: Build floater should preserve GLTF transforms when changing the PBR material
Diffstat (limited to 'indra/llprimitive/llgltfmaterial.cpp')
-rw-r--r-- | indra/llprimitive/llgltfmaterial.cpp | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/indra/llprimitive/llgltfmaterial.cpp b/indra/llprimitive/llgltfmaterial.cpp index c98fd7d1ee..a8dad89292 100644 --- a/indra/llprimitive/llgltfmaterial.cpp +++ b/indra/llprimitive/llgltfmaterial.cpp @@ -98,6 +98,29 @@ LLGLTFMaterial& LLGLTFMaterial::operator=(const LLGLTFMaterial& rhs) return *this; } +bool LLGLTFMaterial::operator==(const LLGLTFMaterial& rhs) const +{ + return mBaseColorId == rhs.mBaseColorId && + mNormalId == rhs.mNormalId && + mMetallicRoughnessId == rhs.mMetallicRoughnessId && + mEmissiveId == rhs.mEmissiveId && + + mBaseColor == rhs.mBaseColor && + mEmissiveColor == rhs.mEmissiveColor && + + mMetallicFactor == rhs.mMetallicFactor && + mRoughnessFactor == rhs.mRoughnessFactor && + mAlphaCutoff == rhs.mAlphaCutoff && + + mDoubleSided == rhs.mDoubleSided && + mAlphaMode == rhs.mAlphaMode && + + mTextureTransform == rhs.mTextureTransform && + + mOverrideDoubleSided == rhs.mOverrideDoubleSided && + mOverrideAlphaMode == rhs.mOverrideAlphaMode; +} + bool LLGLTFMaterial::fromJSON(const std::string& json, std::string& warn_msg, std::string& error_msg) { LL_PROFILE_ZONE_SCOPED; @@ -365,6 +388,28 @@ void LLGLTFMaterial::writeToTexture(tinygltf::Model& model, T& texture_info, Tex texture_info.extensions[GLTF_FILE_EXTENSION_TRANSFORM] = tinygltf::Value(transform_map); } +bool LLGLTFMaterial::setBaseMaterial() +{ + const LLGLTFMaterial old_override = *this; + *this = sDefault; + setBaseMaterial(old_override); + return *this != old_override; +} + +bool LLGLTFMaterial::isClearedForBaseMaterial() +{ + LLGLTFMaterial cleared_override = sDefault; + cleared_override.setBaseMaterial(*this); + return *this == cleared_override; +} + +// For material overrides only. Copies transforms from the old override. +void LLGLTFMaterial::setBaseMaterial(const LLGLTFMaterial& old_override_mat) +{ + mTextureTransform = old_override_mat.mTextureTransform; +} + + // static void LLGLTFMaterial::hackOverrideUUID(LLUUID& id) { |