summaryrefslogtreecommitdiff
path: root/indra
diff options
context:
space:
mode:
authorDave Parks <davep@lindenlab.com>2022-10-21 18:05:19 -0500
committerDave Parks <davep@lindenlab.com>2022-10-21 18:05:19 -0500
commit0cd7c3842119f1801872b4db05e17544b4eb7158 (patch)
treea79c8ec7c24be3263c05bf0758da758a4518924b /indra
parent61967623baaa8988f4f8b48043f79be29452ca80 (diff)
SL-18105 Hook up live material editor to current selection set and implicitly open build floater when editing a PBR material.
Diffstat (limited to 'indra')
-rw-r--r--indra/newview/llmaterialeditor.cpp29
-rw-r--r--indra/newview/llmaterialeditor.h6
-rw-r--r--indra/newview/llpanelface.cpp2
-rw-r--r--indra/newview/llselectmgr.cpp1
-rw-r--r--indra/newview/llviewermenu.cpp5
5 files changed, 32 insertions, 11 deletions
diff --git a/indra/newview/llmaterialeditor.cpp b/indra/newview/llmaterialeditor.cpp
index 58894dbd69..86efdfcd06 100644
--- a/indra/newview/llmaterialeditor.cpp
+++ b/indra/newview/llmaterialeditor.cpp
@@ -1401,15 +1401,14 @@ void LLMaterialEditor::loadMaterialFromFile(const std::string& filename, S32 ind
}
}
-void LLMaterialEditor::loadLiveMaterial(LLUUID &asset_id)
+void LLMaterialEditor::loadLiveMaterialEditor()
{
LLMaterialEditor* me = (LLMaterialEditor*)LLFloaterReg::getInstance("material_editor", LLSD(LIVE_MATERIAL_EDITOR_KEY));
+ me->mIsOverride = true;
me->setTitle(me->getString("material_override_title"));
- me->setAssetId(asset_id);
- if (asset_id.notNull())
- {
- me->setFromGLTFMaterial(gGLTFMaterialList.getMaterial(asset_id));
- }
+ me->childSetVisible("save", false);
+ me->childSetVisible("save_as", false);
+ me->setFromSelection();
me->openFloater();
me->setFocus(TRUE);
}
@@ -1904,7 +1903,7 @@ private:
void LLMaterialEditor::applyToSelection()
{
- if (!mKey.isUUID() || mKey.asUUID() != LIVE_MATERIAL_EDITOR_KEY)
+ if (!mIsOverride)
{
// Only apply if working with 'live' materials
// Might need a better way to distinguish 'live' mode.
@@ -1974,6 +1973,22 @@ void LLMaterialEditor::setFromGLTFMaterial(LLGLTFMaterial* mat)
setAlphaCutoff(mat->mAlphaCutoff);
}
+void LLMaterialEditor::setFromSelection()
+{
+ struct LLSelectedTEGetGLTFRenderMaterial : public LLSelectedTEGetFunctor<LLPointer<LLGLTFMaterial> >
+ {
+ LLPointer<LLGLTFMaterial> get(LLViewerObject* object, S32 te_index)
+ {
+ return object->getTE(te_index)->getGLTFRenderMaterial(); // present user with combined override + asset
+ }
+ } func;
+
+ LLPointer<LLGLTFMaterial> mat;
+ LLSelectMgr::getInstance()->getSelection()->getSelectedTEValue(&func, mat);
+ setFromGLTFMaterial(mat);
+}
+
+
void LLMaterialEditor::loadAsset()
{
// derived from LLPreviewNotecard::loadAsset
diff --git a/indra/newview/llmaterialeditor.h b/indra/newview/llmaterialeditor.h
index 3b2648cba5..0aaf391431 100644
--- a/indra/newview/llmaterialeditor.h
+++ b/indra/newview/llmaterialeditor.h
@@ -103,7 +103,7 @@ public:
// will promt to select specific one
static void loadMaterialFromFile(const std::string& filename, S32 index = -1);
- static void loadLiveMaterial(LLUUID &asset_id);
+ static void loadLiveMaterialEditor();
static void loadFromGLTFMaterial(LLUUID &asset_id);
@@ -222,6 +222,7 @@ public:
private:
void setFromGLTFMaterial(LLGLTFMaterial* mat);
+ void setFromSelection();
void loadMaterial(const tinygltf::Model &model, const std::string &filename_lc, S32 index);
@@ -271,5 +272,8 @@ private:
S32 mExpectedUploadCost;
std::string mMaterialNameShort;
std::string mMaterialName;
+
+ // if true, this instance is live instance editing overrides
+ bool mIsOverride = false;
};
diff --git a/indra/newview/llpanelface.cpp b/indra/newview/llpanelface.cpp
index f4b75c9154..f8e786fc97 100644
--- a/indra/newview/llpanelface.cpp
+++ b/indra/newview/llpanelface.cpp
@@ -4588,7 +4588,7 @@ void LLPanelFace::onPbrStartEditing()
LL_DEBUGS() << "loading material live editor with asset " << material_id << LL_ENDL;
- LLMaterialEditor::loadLiveMaterial(material_id);
+ LLMaterialEditor::loadLiveMaterialEditor();
}
bool LLPanelFace::isIdenticalPlanarTexgen()
diff --git a/indra/newview/llselectmgr.cpp b/indra/newview/llselectmgr.cpp
index d103141669..2475900d0e 100644
--- a/indra/newview/llselectmgr.cpp
+++ b/indra/newview/llselectmgr.cpp
@@ -8576,6 +8576,7 @@ DEF_DUMMY_CHECK_FUNCTOR(int)
DEF_DUMMY_CHECK_FUNCTOR(LLColor4)
DEF_DUMMY_CHECK_FUNCTOR(LLMediaEntry)
DEF_DUMMY_CHECK_FUNCTOR(LLPointer<LLMaterial>)
+DEF_DUMMY_CHECK_FUNCTOR(LLPointer<LLGLTFMaterial>)
DEF_DUMMY_CHECK_FUNCTOR(std::string)
DEF_DUMMY_CHECK_FUNCTOR(std::vector<std::string>)
diff --git a/indra/newview/llviewermenu.cpp b/indra/newview/llviewermenu.cpp
index 5cb63426a8..47b355e554 100644
--- a/indra/newview/llviewermenu.cpp
+++ b/indra/newview/llviewermenu.cpp
@@ -2970,7 +2970,7 @@ void load_life_gltf_material(bool copy)
}
else
{
- LLMaterialEditor::loadLiveMaterial(mat_id);
+ LLMaterialEditor::loadLiveMaterialEditor();
}
LLViewerJoystick::getInstance()->moveObjects(true);
@@ -2979,7 +2979,8 @@ void load_life_gltf_material(bool copy)
void handle_object_edit_gltf_material()
{
- load_life_gltf_material(false);
+ handle_object_edit();
+ LLMaterialEditor::loadLiveMaterialEditor();
}
void handle_object_save_gltf_material()