diff options
author | cosmic-linden <111533034+cosmic-linden@users.noreply.github.com> | 2023-01-25 13:31:25 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-01-25 13:31:25 -0800 |
commit | 98d2a46b30650465e9c0909b1c1d186752fa1d38 (patch) | |
tree | 4c4a0a12c6a838e9e452417c4e7ce1eaf06c0a21 /indra/newview/llviewerobject.cpp | |
parent | 623bb4d58c197fccc8a795426c5864104301cebe (diff) | |
parent | 2aaa15fef15243e6b38f46426d8ebb355ccfb807 (diff) |
Merge pull request #59 from secondlife/SL-19012
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) { |