summaryrefslogtreecommitdiff
path: root/indra/newview
diff options
context:
space:
mode:
authorAndrey Kleshchev <andreykproductengine@lindenlab.com>2023-11-03 21:07:46 +0200
committerakleshchev <117672381+akleshchev@users.noreply.github.com>2023-11-06 18:29:42 +0200
commitcc089d88ad5ab9088a5036e1d6f301d87cb3b127 (patch)
tree828f82b8e9fdd41c25a3b755b2bf34706cc27a3a /indra/newview
parent0d8893822d8975194313e940914afc8945754a21 (diff)
SL-20523 Ensure override gets updated before render material
Diffstat (limited to 'indra/newview')
-rw-r--r--indra/newview/llfetchedgltfmaterial.cpp8
-rw-r--r--indra/newview/lllocalbitmaps.cpp60
-rw-r--r--indra/newview/llmaterialeditor.cpp4
3 files changed, 46 insertions, 26 deletions
diff --git a/indra/newview/llfetchedgltfmaterial.cpp b/indra/newview/llfetchedgltfmaterial.cpp
index a47b52fddc..1a47293523 100644
--- a/indra/newview/llfetchedgltfmaterial.cpp
+++ b/indra/newview/llfetchedgltfmaterial.cpp
@@ -183,6 +183,14 @@ bool LLFetchedGLTFMaterial::replaceLocalTexture(const LLUUID& tracking_id, const
res = true;
}
+ for (int i = 0; i < GLTF_TEXTURE_INFO_COUNT; ++i)
+ {
+ if (mTextureId[i] == new_id)
+ {
+ res = true;
+ }
+ }
+
if (res)
{
mTrackingIdToLocalTexture[tracking_id] = new_id;
diff --git a/indra/newview/lllocalbitmaps.cpp b/indra/newview/lllocalbitmaps.cpp
index 4121df4bac..5a5fb7474c 100644
--- a/indra/newview/lllocalbitmaps.cpp
+++ b/indra/newview/lllocalbitmaps.cpp
@@ -641,41 +641,49 @@ void LLLocalBitmap::updateGLTFMaterials(LLUUID old_id, LLUUID new_id)
}
else if ((*it)->replaceLocalTexture(mTrackingID, old_id, new_id))
{
- LLFetchedGLTFMaterial* fetched_mat = dynamic_cast<LLFetchedGLTFMaterial*>((*it).get());
- if (fetched_mat)
+ it++;
+ }
+ else
+ {
+ // Matching id not found, no longer in use
+ // material would clean itself, remove from the list
+ it = mGLTFMaterialWithLocalTextures.erase(it);
+ end = mGLTFMaterialWithLocalTextures.end();
+ }
+ }
+
+ // Render material consists of base and override materials, make sure replaceLocalTexture
+ // gets called for base and override before applyOverride
+ end = mGLTFMaterialWithLocalTextures.end();
+ for (mat_list_t::iterator it = mGLTFMaterialWithLocalTextures.begin(); it != end;)
+ {
+ LLFetchedGLTFMaterial* fetched_mat = dynamic_cast<LLFetchedGLTFMaterial*>((*it).get());
+ if (fetched_mat)
+ {
+ for (LLTextureEntry* entry : fetched_mat->mTextureEntires)
{
- for (LLTextureEntry* entry : fetched_mat->mTextureEntires)
+ // Normally a change in applied material id is supposed to
+ // drop overrides thus reset material, but local materials
+ // currently reuse their existing asset id, and purpose is
+ // to preview how material will work in-world, overrides
+ // included, so do an override to render update instead.
+ LLGLTFMaterial* override_mat = entry->getGLTFMaterialOverride();
+ if (override_mat)
{
- // Normally a change in applied material id is supposed to
- // drop overrides thus reset material, but local materials
- // currently reuse their existing asset id, and purpose is
- // to preview how material will work in-world, overrides
- // included, so do an override to render update instead.
- LLGLTFMaterial* override_mat = entry->getGLTFMaterialOverride();
- if (override_mat)
+ // do not create a new material, reuse existing pointer
+ LLFetchedGLTFMaterial* render_mat = (LLFetchedGLTFMaterial*)entry->getGLTFRenderMaterial();
+ if (render_mat)
{
- // do not create a new material, reuse existing pointer
- LLFetchedGLTFMaterial* render_mat = (LLFetchedGLTFMaterial*)entry->getGLTFRenderMaterial();
- if (render_mat)
+ llassert(dynamic_cast<LLFetchedGLTFMaterial*>(entry->getGLTFRenderMaterial()) != nullptr);
{
- llassert(dynamic_cast<LLFetchedGLTFMaterial*>(entry->getGLTFRenderMaterial()) != nullptr);
- {
- *render_mat = *fetched_mat;
- }
- render_mat->applyOverride(*override_mat);
+ *render_mat = *fetched_mat;
}
+ render_mat->applyOverride(*override_mat);
}
}
}
- ++it;
- }
- else
- {
- // Matching id not found, no longer in use
- // material would clean itself, remove from the list
- it = mGLTFMaterialWithLocalTextures.erase(it);
- end = mGLTFMaterialWithLocalTextures.end();
}
+ ++it;
}
}
diff --git a/indra/newview/llmaterialeditor.cpp b/indra/newview/llmaterialeditor.cpp
index 7d1ac32282..11a528314e 100644
--- a/indra/newview/llmaterialeditor.cpp
+++ b/indra/newview/llmaterialeditor.cpp
@@ -3231,6 +3231,10 @@ bool LLMaterialEditor::setFromSelection()
// Ovverdired might have been updated,
// refresh state of local textures in overrides
+ //
+ // Todo: this probably shouldn't be here, but in localbitmap,
+ // subscried to all material overrides if we want copied
+ // objects to get properly updated as well
LLSelectedTEUpdateOverrides local_tex_func(this);
selected_objects->applyToNodes(&local_tex_func);
}