summaryrefslogtreecommitdiff
path: root/indra
diff options
context:
space:
mode:
authorAndrey Kleshchev <andreykproductengine@lindenlab.com>2022-08-09 00:21:45 +0300
committerAndrey Kleshchev <andreykproductengine@lindenlab.com>2022-08-09 00:22:09 +0300
commite73fd2a2f28a01c1ab1e0dee63ba4d2ca73c9634 (patch)
tree74c69448be4d97958cb5970a0c4e776bd0c00eae /indra
parentc0d20995c32cb9cabc3e8e74aef96726bcc19ddf (diff)
SL-17653 Perially done restoration functionality
Diffstat (limited to 'indra')
-rw-r--r--indra/newview/llmaterialeditor.cpp15
-rw-r--r--indra/newview/llmaterialeditor.h2
-rw-r--r--indra/newview/llselectmgr.cpp52
-rw-r--r--indra/newview/llselectmgr.h3
4 files changed, 69 insertions, 3 deletions
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<LLGLTFMaterial> mMat;
LLUUID mMatId;
};
void LLMaterialEditor::applyToSelection()
{
- LLGLTFMaterial* mat = new LLGLTFMaterial();
+ LLPointer<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);
+ LLRemderMaterialFunctor mat_func(mat, asset_id);
LLObjectSelectionHandle selected_objects = LLSelectMgr::getInstance()->getSelection();
selected_objects->applyToTEs(&mat_func);
}
diff --git a/indra/newview/llmaterialeditor.h b/indra/newview/llmaterialeditor.h
index 3da59c7f93..1b81a7144a 100644
--- a/indra/newview/llmaterialeditor.h
+++ b/indra/newview/llmaterialeditor.h
@@ -103,6 +103,8 @@ public:
BOOL postBuild() override;
void onClickCloseBtn(bool app_quitting = false) override;
+ void onClose(bool app_quitting) override;
+
LLUUID getAlbedoId();
void setAlbedoId(const LLUUID& id);
void setAlbedoUploadId(const LLUUID& id);
diff --git a/indra/newview/llselectmgr.cpp b/indra/newview/llselectmgr.cpp
index 853703b4d5..fc5b1c60e2 100644
--- a/indra/newview/llselectmgr.cpp
+++ b/indra/newview/llselectmgr.cpp
@@ -1936,6 +1936,32 @@ BOOL LLSelectMgr::selectionRevertTextures()
return revert_successful;
}
+void LLSelectMgr::selectionRevertGLTFMaterials()
+{
+ struct f : public LLSelectedTEFunctor
+ {
+ LLObjectSelectionHandle mSelectedObjects;
+ f(LLObjectSelectionHandle sel) : mSelectedObjects(sel) {}
+ bool apply(LLViewerObject* object, S32 te)
+ {
+ if (object->permModify())
+ {
+ LLSelectNode* nodep = mSelectedObjects->findNode(object);
+ if (nodep && te < (S32)nodep->mSavedGLTFMaterials.size())
+ {
+ LLUUID id = nodep->mSavedGLTFMaterials[te];
+ object->setRenderMaterialID(te, id);
+ }
+ }
+ return true;
+ }
+ } setfunc(mSelectedObjects);
+ getSelection()->applyToTEs(&setfunc);
+
+ LLSelectMgrSendFunctor sendfunc;
+ getSelection()->applyToObjects(&sendfunc);
+}
+
void LLSelectMgr::selectionSetBumpmap(U8 bumpmap, const LLUUID &image_id)
{
struct f : public LLSelectedTEFunctor
@@ -5526,6 +5552,17 @@ void LLSelectMgr::processObjectProperties(LLMessageSystem* msg, void** user_data
// this should be the only place that saved textures is called
node->saveTextures(texture_ids);
}
+
+ if (can_copy && can_transfer && node->getObject()->getVolume())
+ {
+ uuid_vec_t material_ids;
+ LLVOVolume* vobjp = (LLVOVolume*)node->getObject();
+ for (int i = 0; i < vobjp->getNumTEs(); ++i)
+ {
+ material_ids.push_back(vobjp->getRenderMaterialID(i));
+ }
+ node->savedGLTFMaterials(material_ids);
+ }
}
node->mValid = TRUE;
@@ -6277,6 +6314,7 @@ LLSelectNode::LLSelectNode(const LLSelectNode& nodep)
}
saveTextures(nodep.mSavedTextures);
+ savedGLTFMaterials(nodep.mSavedGLTFMaterials);
}
LLSelectNode::~LLSelectNode()
@@ -6392,6 +6430,20 @@ void LLSelectNode::saveTextures(const uuid_vec_t& textures)
}
}
+void LLSelectNode::savedGLTFMaterials(const uuid_vec_t& materials)
+{
+ if (mObject.notNull())
+ {
+ mSavedGLTFMaterials.clear();
+
+ for (uuid_vec_t::const_iterator materials_it = materials.begin();
+ materials_it != materials.end(); ++materials_it)
+ {
+ mSavedGLTFMaterials.push_back(*materials_it);
+ }
+ }
+}
+
void LLSelectNode::saveTextureScaleRatios(LLRender::eTexIndex index_to_query)
{
mTextureScaleRatios.clear();
diff --git a/indra/newview/llselectmgr.h b/indra/newview/llselectmgr.h
index ce0316e610..aec2baa6a7 100644
--- a/indra/newview/llselectmgr.h
+++ b/indra/newview/llselectmgr.h
@@ -187,6 +187,7 @@ public:
void saveColors();
void saveShinyColors();
void saveTextures(const uuid_vec_t& textures);
+ void savedGLTFMaterials(const uuid_vec_t& materials);
void saveTextureScaleRatios(LLRender::eTexIndex index_to_query);
BOOL allowOperationOnNode(PermissionBit op, U64 group_proxy_power) const;
@@ -224,6 +225,7 @@ public:
std::vector<LLColor4> mSavedColors;
std::vector<LLColor4> mSavedShinyColors;
uuid_vec_t mSavedTextures;
+ uuid_vec_t mSavedGLTFMaterials;
std::vector<LLVector3> mTextureScaleRatios;
std::vector<LLVector3> mSilhouetteVertices; // array of vertices to render silhouette of object
std::vector<LLVector3> mSilhouetteNormals; // array of normals to render silhouette of object
@@ -609,6 +611,7 @@ public:
void selectionRevertColors();
void selectionRevertShinyColors();
BOOL selectionRevertTextures();
+ void selectionRevertGLTFMaterials();
void selectionSetBumpmap( U8 bumpmap, const LLUUID &image_id );
void selectionSetTexGen( U8 texgen );
void selectionSetShiny( U8 shiny, const LLUUID &image_id );