diff options
Diffstat (limited to 'indra/newview/llmaterialeditor.cpp')
-rw-r--r-- | indra/newview/llmaterialeditor.cpp | 98 |
1 files changed, 90 insertions, 8 deletions
diff --git a/indra/newview/llmaterialeditor.cpp b/indra/newview/llmaterialeditor.cpp index 533f882d39..20fee6686c 100644 --- a/indra/newview/llmaterialeditor.cpp +++ b/indra/newview/llmaterialeditor.cpp @@ -86,6 +86,9 @@ static const U32 MATERIAL_DOUBLE_SIDED_DIRTY = 0x1 << 9; static const U32 MATERIAL_ALPHA_MODE_DIRTY = 0x1 << 10; static const U32 MATERIAL_ALPHA_CUTOFF_DIRTY = 0x1 << 11; +LLUUID LLMaterialEditor::mOverrideObjectId; +S32 LLMaterialEditor::mOverrideObjectTE = -1; + LLFloaterComboOptions::LLFloaterComboOptions() : LLFloater(LLSD()) { @@ -1513,13 +1516,22 @@ 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 - mUnsavedChanges = 0; - clearTextures(); - setFromSelection(); + + // Drop selection updates if we are waiting for + // overrides to finish aplying to not reset values + // (might need a timeout) + if (!mOverrideInProgress) + { + clearTextures(); + setFromSelection(); + } + + // At the moment all cahges are 'live' so don't reset dirty flags // saveLiveValues(); todo } @@ -1554,6 +1566,44 @@ void LLMaterialEditor::saveLiveValues() LLSelectMgr::getInstance()->getSelection()->applyToObjects(&savefunc); } +void LLMaterialEditor::updateLive() +{ + const LLSD floater_key(LIVE_MATERIAL_EDITOR_KEY); + LLFloater* instance = LLFloaterReg::findInstance("material_editor", floater_key); + if (instance && LLFloater::isVisible(instance)) + { + LLMaterialEditor* me = (LLMaterialEditor*)instance; + if (me) + { + me->mOverrideInProgress = false; + me->clearTextures(); + me->setFromSelection(); + } + } +} + +void LLMaterialEditor::updateLive(const LLUUID &object_id, S32 te) +{ + if (mOverrideObjectId != object_id + || mOverrideObjectTE != te) + { + // Not an update we are waiting for + return; + } + const LLSD floater_key(LIVE_MATERIAL_EDITOR_KEY); + LLFloater* instance = LLFloaterReg::findInstance("material_editor", floater_key); + if (instance && LLFloater::isVisible(instance)) + { + LLMaterialEditor* me = (LLMaterialEditor*)instance; + if (me) + { + me->mOverrideInProgress = false; + me->clearTextures(); + me->setFromSelection(); + } + } +} + void LLMaterialEditor::loadLive() { // Allow only one 'live' instance @@ -1561,6 +1611,7 @@ void LLMaterialEditor::loadLive() LLMaterialEditor* me = (LLMaterialEditor*)LLFloaterReg::getInstance("material_editor", floater_key); if (me) { + me->mOverrideInProgress = false; me->setFromSelection(); me->setTitle(me->getString("material_override_title")); me->childSetVisible("save", false); @@ -2136,11 +2187,21 @@ public: "side", te, "gltf_json", overrides_json ); - LLCoros::instance().launch("modifyMaterialCoro", std::bind(&LLGLTFMaterialList::modifyMaterialCoro, mCapUrl, overrides)); + LLCoros::instance().launch("modifyMaterialCoro", std::bind(&LLGLTFMaterialList::modifyMaterialCoro, mCapUrl, overrides, modifyCallback)); } return true; } + static void modifyCallback(bool success) + { + if (!success) + { + // something went wrong update selection + LLMaterialEditor::updateLive(); + } + // else we will get updateLive(obj, id) from aplied overrides + } + private: LLMaterialEditor * mEditor; std::string mCapUrl; @@ -2160,10 +2221,22 @@ void LLMaterialEditor::applyToSelection() std::string url = gAgent.getRegionCapability("ModifyMaterialParams"); if (!url.empty()) { - LLObjectSelectionHandle selected_objects = LLSelectMgr::getInstance()->getSelection(); - // TODO figure out how to get the right asset id in cases where we don't have a good one - LLRenderMaterialOverrideFunctor override_func(this, url); - selected_objects->applyToTEs(&override_func); + // Don't send data if there is nothing to send. + // Some UI elements will cause multiple commits, + // like spin ctrls on click and on down + if (mUnsavedChanges != 0) + { + mOverrideInProgress = true; + LLObjectSelectionHandle selected_objects = LLSelectMgr::getInstance()->getSelection(); + LLRenderMaterialOverrideFunctor override_func(this, url); + if (!selected_objects->applyToTEs(&override_func)) + { + mOverrideInProgress = false; + } + + // we posted all changes + mUnsavedChanges = 0; + } } else { @@ -2228,6 +2301,7 @@ bool LLMaterialEditor::setFromSelection() , mIdenticalTexMetal(true) , mIdenticalTexEmissive(true) , mIdenticalTexNormal(true) + , mObjectTE(-1) , mFirst(true) {} @@ -2265,6 +2339,8 @@ bool LLMaterialEditor::setFromSelection() mTexMetalId = tex_metal_id; mTexEmissiveId = tex_emissive_id; mTexNormalId = tex_normal_id; + mObjectTE = te_index; + mObjectId = objectp->getID(); mFirst = false; } else @@ -2299,6 +2375,8 @@ bool LLMaterialEditor::setFromSelection() LLUUID mTexMetalId; LLUUID mTexEmissiveId; LLUUID mTexNormalId; + LLUUID mObjectId; + S32 mObjectTE; LLPointer<LLGLTFMaterial> mMaterial; } func(mIsOverride); @@ -2325,6 +2403,10 @@ bool LLMaterialEditor::setFromSelection() mMetallicTextureCtrl->setTentative(!func.mIdenticalTexMetal); mEmissiveTextureCtrl->setTentative(!func.mIdenticalTexEmissive); mNormalTextureCtrl->setTentative(!func.mIdenticalTexNormal); + + // Memorize selection data for filtering further updates + mOverrideObjectId = func.mObjectId; + mOverrideObjectTE = func.mObjectTE; } return func.mMaterial.notNull(); |