From 360ffff2885bff2f816c099dc414dc126cb7e258 Mon Sep 17 00:00:00 2001 From: RunitaiLinden Date: Thu, 21 Sep 2023 14:54:22 -0500 Subject: SL-20321 Interpret missing TEs in override messages as indication overrides should be nulled out if present. --- indra/newview/llgltfmateriallist.cpp | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) (limited to 'indra') diff --git a/indra/newview/llgltfmateriallist.cpp b/indra/newview/llgltfmateriallist.cpp index 0bdfcf05e7..a92e699c42 100644 --- a/indra/newview/llgltfmateriallist.cpp +++ b/indra/newview/llgltfmateriallist.cpp @@ -357,6 +357,9 @@ void LLGLTFMaterialList::applyOverrideMessage(LLMessageSystem* msg, const std::s const LLSD& tes = data["te"]; const LLSD& od = data["od"]; + constexpr U32 MAX_TES = 45; + bool has_te[MAX_TES] = { false }; + if (tes.isArray()) { LLGLTFOverrideCacheEntry cache; @@ -364,13 +367,15 @@ void LLGLTFMaterialList::applyOverrideMessage(LLMessageSystem* msg, const std::s cache.mObjectId = id; cache.mRegionHandle = region->getHandle(); - for (int i = 0; i < tes.size(); ++i) + U32 count = llmin(tes.size(), MAX_TES); + for (U32 i = 0; i < count; ++i) { LLGLTFMaterial* mat = new LLGLTFMaterial(); // setTEGLTFMaterialOverride and cache will take ownership mat->applyOverrideLLSD(od[i]); S32 te = tes[i].asInteger(); + has_te[te] = true; cache.mSides[te] = od[i]; cache.mGLTFMaterial[te] = mat; @@ -384,6 +389,20 @@ void LLGLTFMaterialList::applyOverrideMessage(LLMessageSystem* msg, const std::s } } + if (obj) + { // null out overrides on TEs that shouldn't have them + U32 count = llmin(obj->getNumTEs(), MAX_TES); + for (U32 i = 0; i < count; ++i) + { + LLTextureEntry* te = obj->getTE(i); + if (te && te->getGLTFMaterialOverride()) + { + obj->setTEGLTFMaterialOverride(i, nullptr); + handle_gltf_override_message.doSelectionCallbacks(id, i); + } + } + } + region->cacheFullUpdateGLTFOverride(cache); } -- cgit v1.2.3