summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSabrina Shanman <cosmic@lindenlab.com>2022-11-14 23:06:44 +0000
committerSabrina Shanman <cosmic@lindenlab.com>2022-11-14 23:06:44 +0000
commit3cc3e6a5e026e4d55aaa70663e33c432cbd23ab7 (patch)
tree3673a3d74e3d8ceae8dd76244ab4b0448ed2655c
parent5756a0284dbde6108118158bad5d61c1cd614af2 (diff)
parente4dd9c1e648e38c15a1fa792ffeb5754ae936709 (diff)
Merged in SL-18634 (pull request #1198)
SL-18634: Fix GLTF material texture transform not serializing when texture ID is null
-rw-r--r--indra/llprimitive/llgltfmaterial.cpp21
-rw-r--r--indra/llprimitive/llgltfmaterial.h8
2 files changed, 17 insertions, 12 deletions
diff --git a/indra/llprimitive/llgltfmaterial.cpp b/indra/llprimitive/llgltfmaterial.cpp
index 6fbcf50482..e8e4b62934 100644
--- a/indra/llprimitive/llgltfmaterial.cpp
+++ b/indra/llprimitive/llgltfmaterial.cpp
@@ -61,6 +61,11 @@ LLMatrix3 LLGLTFMaterial::TextureTransform::asMatrix()
return offset * rotation * scale;
}
+bool LLGLTFMaterial::TextureTransform::operator==(const TextureTransform& other) const
+{
+ return mOffset == other.mOffset && mScale == other.mScale && mRotation == other.mRotation;
+}
+
LLGLTFMaterial::LLGLTFMaterial(const LLGLTFMaterial& rhs)
{
*this = rhs;
@@ -268,16 +273,14 @@ void LLGLTFMaterial::writeToModel(tinygltf::Model& model, S32 mat_index) const
tinygltf::Material& material_out = model.materials[mat_index];
- constexpr bool is_override = false;
-
// set base color texture
- writeToTexture(model, material_out.pbrMetallicRoughness.baseColorTexture, GLTF_TEXTURE_INFO_BASE_COLOR, mBaseColorId, is_override, LLUUID());
+ writeToTexture(model, material_out.pbrMetallicRoughness.baseColorTexture, GLTF_TEXTURE_INFO_BASE_COLOR, mBaseColorId);
// set normal texture
- writeToTexture(model, material_out.normalTexture, GLTF_TEXTURE_INFO_NORMAL, mNormalId, is_override, LLUUID());
+ writeToTexture(model, material_out.normalTexture, GLTF_TEXTURE_INFO_NORMAL, mNormalId);
// set metallic-roughness texture
- writeToTexture(model, material_out.pbrMetallicRoughness.metallicRoughnessTexture, GLTF_TEXTURE_INFO_METALLIC_ROUGHNESS, mMetallicRoughnessId, is_override, LLUUID());
+ writeToTexture(model, material_out.pbrMetallicRoughness.metallicRoughnessTexture, GLTF_TEXTURE_INFO_METALLIC_ROUGHNESS, mMetallicRoughnessId);
// set emissive texture
- writeToTexture(model, material_out.emissiveTexture, GLTF_TEXTURE_INFO_EMISSIVE, mEmissiveId, is_override, LLUUID());
+ writeToTexture(model, material_out.emissiveTexture, GLTF_TEXTURE_INFO_EMISSIVE, mEmissiveId);
material_out.alphaMode = getAlphaMode();
material_out.alphaCutoff = mAlphaCutoff;
@@ -338,10 +341,11 @@ void gltf_allocate_texture_image(tinygltf::Model& model, T& texture_info, const
}
template<typename T>
-void LLGLTFMaterial::writeToTexture(tinygltf::Model& model, T& texture_info, TextureInfo texture_info_id, const LLUUID& texture_id, bool is_override, const LLUUID& base_texture_id) const
+void LLGLTFMaterial::writeToTexture(tinygltf::Model& model, T& texture_info, TextureInfo texture_info_id, const LLUUID& texture_id) const
{
LL_PROFILE_ZONE_SCOPED;
- if (texture_id.isNull() || (is_override && texture_id == base_texture_id))
+ const TextureTransform& transform = mTextureTransform[texture_info_id];
+ if (texture_id.isNull() && transform == sDefault.mTextureTransform[0])
{
return;
}
@@ -349,7 +353,6 @@ void LLGLTFMaterial::writeToTexture(tinygltf::Model& model, T& texture_info, Tex
gltf_allocate_texture_image(model, texture_info, texture_id.asString());
tinygltf::Value::Object transform_map;
- const TextureTransform& transform = mTextureTransform[texture_info_id];
transform_map[GLTF_FILE_EXTENSION_TRANSFORM_OFFSET] = tinygltf::Value(tinygltf::Value::Array({
tinygltf::Value(transform.mOffset.mV[VX]),
tinygltf::Value(transform.mOffset.mV[VY])
diff --git a/indra/llprimitive/llgltfmaterial.h b/indra/llprimitive/llgltfmaterial.h
index 60116fd423..aa49a58f0c 100644
--- a/indra/llprimitive/llgltfmaterial.h
+++ b/indra/llprimitive/llgltfmaterial.h
@@ -56,6 +56,8 @@ public:
F32 mRotation = 0.f;
LLMatrix3 asMatrix();
+
+ bool operator==(const TextureTransform& other) const;
};
enum AlphaMode
@@ -149,14 +151,14 @@ public:
static LLVector2 getDefaultTextureScale();
static F32 getDefaultTextureRotation();
-
+
static void hackOverrideUUID(LLUUID& id);
static void applyOverrideUUID(LLUUID& dst_id, const LLUUID& override_id);
// set mAlphaMode from string.
// Anything otherthan "MASK" or "BLEND" sets mAlphaMode to ALPHA_MODE_OPAQUE
void setAlphaMode(const std::string& mode, bool for_override = false);
-
+
const char* getAlphaMode() const;
// set the contents of this LLGLTFMaterial from the given json
@@ -185,6 +187,6 @@ private:
void setFromTexture(const tinygltf::Model& model, const T& texture_info, TextureInfo texture_info_id, LLUUID& texture_id_out);
template<typename T>
- void writeToTexture(tinygltf::Model& model, T& texture_info, TextureInfo texture_info_id, const LLUUID& texture_id, bool is_override, const LLUUID& base_texture_id) const;
+ void writeToTexture(tinygltf::Model& model, T& texture_info, TextureInfo texture_info_id, const LLUUID& texture_id) const;
};