diff options
Diffstat (limited to 'indra')
-rw-r--r-- | indra/newview/llmaterialeditor.cpp | 97 | ||||
-rw-r--r-- | indra/newview/llmaterialeditor.h | 3 |
2 files changed, 96 insertions, 4 deletions
diff --git a/indra/newview/llmaterialeditor.cpp b/indra/newview/llmaterialeditor.cpp index 8086bcf402..06705a277b 100644 --- a/indra/newview/llmaterialeditor.cpp +++ b/indra/newview/llmaterialeditor.cpp @@ -302,10 +302,6 @@ void LLMaterialEditor::onClickCloseBtn(bool app_quitting) void LLMaterialEditor::onClose(bool app_quitting) { - // todo: will only revert whatever was recently selected, - // Later should work based of tools floater - LLSelectMgr::getInstance()->selectionRevertGLTFMaterials(); - LLPreview::onClose(app_quitting); } @@ -1265,6 +1261,73 @@ void LLMaterialEditor::onCancelMsgCallback(const LLSD& notification, const LLSD& S32 option = LLNotificationsUtil::getSelectedOption(notification, response); if (0 == option) { + if (mIsOverride && !mObjectOverridesSavedValues.empty()) + { + // Reapply ids back onto selection. + // TODO: monitor selection changes and resave on selection changes + struct g : public LLSelectedObjectFunctor + { + g(LLMaterialEditor* me) : mEditor(me) {} + virtual bool apply(LLViewerObject* objectp) + { + if (!objectp || !objectp->permModify()) + { + return false; + } + + U32 local_id = objectp->getLocalID(); + if (mEditor->mObjectOverridesSavedValues.find(local_id) == mEditor->mObjectOverridesSavedValues.end()) + { + return false; + } + + S32 num_tes = llmin((S32)objectp->getNumTEs(), (S32)objectp->getNumFaces()); + for (U8 te = 0; te < num_tes; te++) + { + if (mEditor->mObjectOverridesSavedValues[local_id].size() > te + && objectp->getTE(te)->isSelected()) + { + objectp->setRenderMaterialID( + te, + mEditor->mObjectOverridesSavedValues[local_id][te], + false /*wait for bulk update*/); + } + } + return true; + } + LLMaterialEditor* mEditor; + } restorefunc(this); + LLSelectMgr::getInstance()->getSelection()->applyToObjects(&restorefunc); + + struct f : public LLSelectedObjectFunctor + { + virtual bool apply(LLViewerObject* object) + { + if (object && !object->permModify()) + { + return false; + } + + LLRenderMaterialParams* param_block = (LLRenderMaterialParams*)object->getParameterEntry(LLNetworkData::PARAMS_RENDER_MATERIAL); + if (param_block) + { + if (param_block->isEmpty()) + { + object->setHasRenderMaterialParams(false); + } + else + { + object->parameterChanged(LLNetworkData::PARAMS_RENDER_MATERIAL, true); + } + } + + object->sendTEUpdate(); + return true; + } + } sendfunc; + LLSelectMgr::getInstance()->getSelection()->applyToObjects(&sendfunc); + } + closeFloater(); } } @@ -1410,6 +1473,32 @@ void LLMaterialEditor::loadLive() me->setTitle(me->getString("material_override_title")); me->childSetVisible("save", false); me->childSetVisible("save_as", false); + me->mObjectOverridesSavedValues.clear(); + + // Collect ids to be able to revert overrides. + // TODO: monitor selection changes and resave on selection changes + struct g : public LLSelectedObjectFunctor + { + g(LLMaterialEditor* me) : mEditor(me) {} + virtual bool apply(LLViewerObject* objectp) + { + if (!objectp) + { + return false; + } + + U32 local_id = objectp->getLocalID(); + S32 num_tes = llmin((S32)objectp->getNumTEs(), (S32)objectp->getNumFaces()); + for (U8 te = 0; te < num_tes; te++) + { + LLUUID mat_id = objectp->getRenderMaterialID(te); + mEditor->mObjectOverridesSavedValues[local_id].push_back(mat_id); + } + return true; + } + LLMaterialEditor* mEditor; + } savefunc(me); + LLSelectMgr::getInstance()->getSelection()->applyToObjects(&savefunc); me->openFloater(); me->setFocus(TRUE); diff --git a/indra/newview/llmaterialeditor.h b/indra/newview/llmaterialeditor.h index 23cb32aacf..60907b18ba 100644 --- a/indra/newview/llmaterialeditor.h +++ b/indra/newview/llmaterialeditor.h @@ -276,5 +276,8 @@ private: // if true, this instance is live instance editing overrides bool mIsOverride = false; + // local id, texture ids per face for object overrides + // for "cancel" support + std::map<U32, uuid_vec_t> mObjectOverridesSavedValues; }; |