From 49278013ef3af18f4565f46aeb67368e6439ae46 Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Mon, 8 Aug 2022 23:24:29 +0300 Subject: SL-17653 Apply selection to faces and linkset instead of just first object --- indra/newview/llmaterialeditor.cpp | 52 +++++++++++++++++++++----------------- 1 file changed, 29 insertions(+), 23 deletions(-) (limited to 'indra/newview/llmaterialeditor.cpp') diff --git a/indra/newview/llmaterialeditor.cpp b/indra/newview/llmaterialeditor.cpp index 57cd74e0f2..0e252518cb 100644 --- a/indra/newview/llmaterialeditor.cpp +++ b/indra/newview/llmaterialeditor.cpp @@ -62,6 +62,7 @@ const std::string MATERIAL_NORMAL_DEFAULT_NAME = "Normal"; const std::string MATERIAL_METALLIC_DEFAULT_NAME = "Metallic Roughness"; const std::string MATERIAL_EMISSIVE_DEFAULT_NAME = "Emissive"; + class LLMaterialEditorCopiedCallback : public LLInventoryCallback { public: @@ -1341,34 +1342,39 @@ void LLMaterialEditor::importMaterial() (new LLMaterialFilePicker(this))->getFile(); } -void LLMaterialEditor::applyToSelection() +class LLRemderMaterialFunctor : public LLSelectedTEFunctor { - // Todo: fix this, this is a hack, not a proper live preview - LLViewerObject* objectp = LLSelectMgr::instance().getSelection()->getFirstObject(); - if (objectp && objectp->getVolume() && objectp->permModify()) +public: + LLRemderMaterialFunctor(LLGLTFMaterial *mat, const LLUUID &id) + : mMat(mat), mMatId(id) { - LLGLTFMaterial* mat = new LLGLTFMaterial(); - getGLTFMaterial(mat); - LLVOVolume* vobjp = (LLVOVolume*)objectp; - for (int i = 0; i < vobjp->getNumTEs(); ++i) - { - // this is here just to prevent material from immediately resetting - if (mAssetID.notNull()) - { - vobjp->setRenderMaterialID(i, mAssetID); - } - else - { - const LLUUID placeholder("984e183e-7811-4b05-a502-d79c6f978a98"); - vobjp->setRenderMaterialID(i, placeholder); - } + } - vobjp->getTE(i)->setGLTFMaterial(mat); - vobjp->updateTEMaterialTextures(i); + virtual bool apply(LLViewerObject* objectp, S32 te) + { + if (objectp && objectp->permModify() && objectp->getVolume()) + { + LLVOVolume* vobjp = (LLVOVolume*)objectp; + vobjp->setRenderMaterialID(te, mMatId); + vobjp->getTE(te)->setGLTFMaterial(mMat); + vobjp->updateTEMaterialTextures(te); } - - vobjp->markForUpdate(TRUE); + return true; } +private: + LLGLTFMaterial *mMat; + LLUUID mMatId; +}; + +void LLMaterialEditor::applyToSelection() +{ + LLGLTFMaterial* mat = new LLGLTFMaterial(); + getGLTFMaterial(mat); + const LLUUID placeholder("984e183e-7811-4b05-a502-d79c6f978a98"); + LLUUID asset_id = mAssetID.notNull() ? mAssetID : placeholder; + LLRemderMaterialFunctor mat_func(mat, mAssetID); + LLObjectSelectionHandle selected_objects = LLSelectMgr::getInstance()->getSelection(); + selected_objects->applyToTEs(&mat_func); } void LLMaterialEditor::getGLTFMaterial(LLGLTFMaterial* mat) -- cgit v1.2.3 From e73fd2a2f28a01c1ab1e0dee63ba4d2ca73c9634 Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Tue, 9 Aug 2022 00:21:45 +0300 Subject: SL-17653 Perially done restoration functionality --- indra/newview/llmaterialeditor.cpp | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'indra/newview/llmaterialeditor.cpp') diff --git a/indra/newview/llmaterialeditor.cpp b/indra/newview/llmaterialeditor.cpp index 0e252518cb..13e250ec3b 100644 --- a/indra/newview/llmaterialeditor.cpp +++ b/indra/newview/llmaterialeditor.cpp @@ -165,6 +165,15 @@ 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); +} + LLUUID LLMaterialEditor::getAlbedoId() { return mAlbedoTextureCtrl->getValue().asUUID(); @@ -1362,17 +1371,17 @@ public: return true; } private: - LLGLTFMaterial *mMat; + LLPointer mMat; LLUUID mMatId; }; void LLMaterialEditor::applyToSelection() { - LLGLTFMaterial* mat = new LLGLTFMaterial(); + LLPointer mat = new LLGLTFMaterial(); getGLTFMaterial(mat); const LLUUID placeholder("984e183e-7811-4b05-a502-d79c6f978a98"); LLUUID asset_id = mAssetID.notNull() ? mAssetID : placeholder; - LLRemderMaterialFunctor mat_func(mat, mAssetID); + LLRemderMaterialFunctor mat_func(mat, asset_id); LLObjectSelectionHandle selected_objects = LLSelectMgr::getInstance()->getSelection(); selected_objects->applyToTEs(&mat_func); } -- cgit v1.2.3