diff options
author | Andrey Kleshchev <andreykproductengine@lindenlab.com> | 2022-11-03 00:16:20 +0200 |
---|---|---|
committer | Andrey Kleshchev <andreykproductengine@lindenlab.com> | 2022-11-03 01:36:45 +0200 |
commit | 0f20cf17fd31abb051efd5bd14399ed6329112cf (patch) | |
tree | 6851337b67c9046218e92b6e62bf08ba7b4b628a /indra/newview/llmaterialeditor.cpp | |
parent | a87505333e0fcd5ba06da76d0d66e469121e8b30 (diff) |
SL-18446 Don't cause excessive udpates #2
Diffstat (limited to 'indra/newview/llmaterialeditor.cpp')
-rw-r--r-- | indra/newview/llmaterialeditor.cpp | 70 |
1 files changed, 40 insertions, 30 deletions
diff --git a/indra/newview/llmaterialeditor.cpp b/indra/newview/llmaterialeditor.cpp index cf627cf992..00105c1e8f 100644 --- a/indra/newview/llmaterialeditor.cpp +++ b/indra/newview/llmaterialeditor.cpp @@ -84,6 +84,8 @@ static const U32 MATERIAL_ALPHA_CUTOFF_DIRTY = 0x1 << 10; LLUUID LLMaterialEditor::mOverrideObjectId; S32 LLMaterialEditor::mOverrideObjectTE = -1; +bool LLMaterialEditor::mOverrideInProgress = false; +bool LLMaterialEditor::mSelectionNeedsUpdate = true; LLFloaterComboOptions::LLFloaterComboOptions() : LLFloater(LLSD()) @@ -443,6 +445,27 @@ void LLMaterialEditor::onClose(bool app_quitting) LLPreview::onClose(app_quitting); } + +void LLMaterialEditor::draw() +{ + if (mIsOverride) + { + bool selection_empty = LLSelectMgr::getInstance()->getSelection()->isEmpty(); + if (selection_empty && mHasSelection) + { + mSelectionNeedsUpdate = true; + } + + if (mSelectionNeedsUpdate) + { + mSelectionNeedsUpdate = false; + clearTextures(); + setFromSelection(); + } + } + LLPreview::draw(); +} + void LLMaterialEditor::handleReshape(const LLRect& new_rect, bool by_user) { if (by_user) @@ -1610,32 +1633,20 @@ void LLMaterialEditor::loadMaterialFromFile(const std::string& filename, S32 ind void LLMaterialEditor::onSelectionChanged() { - // This won't get deletion or deselectAll() - // Might need to handle that separately - // Drop selection updates if we are waiting for - // overrides to finish aplying to not reset values + // overrides to finish applying to not reset values // (might need a timeout) if (!mOverrideInProgress) { - clearTextures(); - setFromSelection(); + // mUpdateSignal triggers a lot per frame, breakwater + mSelectionNeedsUpdate = true; } } void LLMaterialEditor::updateLive() { - LLFloater* instance = LLFloaterReg::findInstance("live_material_editor"); - if (instance && LLFloater::isVisible(instance)) - { - LLMaterialEditor* me = (LLMaterialEditor*)instance; - if (me) - { - me->mOverrideInProgress = false; - me->clearTextures(); - me->setFromSelection(); - } - } + mSelectionNeedsUpdate = true; + mOverrideInProgress = false; } void LLMaterialEditor::updateLive(const LLUUID &object_id, S32 te) @@ -1643,20 +1654,15 @@ void LLMaterialEditor::updateLive(const LLUUID &object_id, S32 te) if (mOverrideObjectId != object_id || mOverrideObjectTE != te) { - // Not an update we are waiting for + // Ignore if waiting for override, + // if not waiting, mark selection dirty + mSelectionNeedsUpdate |= !mOverrideInProgress; return; } - LLFloater* instance = LLFloaterReg::findInstance("live_material_editor"); - if (instance && LLFloater::isVisible(instance)) - { - LLMaterialEditor* me = (LLMaterialEditor*)instance; - if (me) - { - me->mOverrideInProgress = false; - me->clearTextures(); - me->setFromSelection(); - } - } + + // update for currently displayed object and face + mSelectionNeedsUpdate = true; + mOverrideInProgress = false; } void LLMaterialEditor::loadLive() @@ -2401,9 +2407,13 @@ void LLMaterialEditor::setFromGLTFMaterial(LLGLTFMaterial* mat) bool LLMaterialEditor::setFromSelection() { + LLObjectSelectionHandle selected_objects = LLSelectMgr::getInstance()->getSelection(); LLSelectedTEGetMatData func(mIsOverride); - LLSelectMgr::getInstance()->getSelection()->applyToTEs(&func); + selected_objects->applyToTEs(&func); + mHasSelection = !selected_objects->isEmpty(); + mSelectionNeedsUpdate = false; + if (func.mMaterial.notNull()) { setFromGLTFMaterial(func.mMaterial); |