diff options
| author | Cosmic Linden <cosmic@lindenlab.com> | 2023-01-24 17:48:18 -0800 |
|---|---|---|
| committer | Cosmic Linden <cosmic@lindenlab.com> | 2023-01-25 12:34:35 -0800 |
| commit | 2aaa15fef15243e6b38f46426d8ebb355ccfb807 (patch) | |
| tree | 718f00f4f3c5eb412199ab1b4c530e3308a647c2 /indra/newview/llviewerobject.cpp | |
| parent | a851aa83e705fa4a1c78919cfcac6709cfb1a875 (diff) | |
SL-19012: Fix new material IDs sometimes not applying when set via LSL
Diffstat (limited to 'indra/newview/llviewerobject.cpp')
| -rw-r--r-- | indra/newview/llviewerobject.cpp | 36 |
1 files changed, 27 insertions, 9 deletions
diff --git a/indra/newview/llviewerobject.cpp b/indra/newview/llviewerobject.cpp index f416080f9e..5a365c79ea 100644 --- a/indra/newview/llviewerobject.cpp +++ b/indra/newview/llviewerobject.cpp @@ -7160,6 +7160,14 @@ const LLUUID& LLViewerObject::getRenderMaterialID(U8 te) const return LLUUID::null; } +void LLViewerObject::rebuildMaterial() +{ + llassert(!isDead()); + + faceMappingChanged(); + gPipeline.markTextured(mDrawable); +} + void LLViewerObject::setRenderMaterialID(S32 te_in, const LLUUID& id, bool update_server) { // implementation is delicate @@ -7188,17 +7196,16 @@ void LLViewerObject::setRenderMaterialID(S32 te_in, const LLUUID& id, bool updat } + LLFetchedGLTFMaterial* new_material = nullptr; + if (id.notNull()) + { + new_material = gGLTFMaterialList.getMaterial(id); + } + // update local state for (S32 te = start_idx; te < end_idx; ++te) { - - LLGLTFMaterial* new_material = nullptr; LLTextureEntry* tep = getTE(te); - - if (id.notNull()) - { - new_material = gGLTFMaterialList.getMaterial(id); - } bool material_changed = !param_block || id != param_block->getMaterial(te); @@ -7225,8 +7232,19 @@ void LLViewerObject::setRenderMaterialID(S32 te_in, const LLUUID& id, bool updat } // signal to render pipe that render batches must be rebuilt for this object - faceMappingChanged(); - gPipeline.markTextured(mDrawable); + if (!new_material) + { + rebuildMaterial(); + } + else + { + LLPointer<LLViewerObject> this_ptr = this; + new_material->onMaterialComplete([this_ptr]() mutable { + if (this_ptr->isDead()) { return; } + + this_ptr->rebuildMaterial(); + }); + } if (update_server) { |
