summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDave Parks <davep@lindenlab.com>2022-10-22 15:25:03 -0500
committerDave Parks <davep@lindenlab.com>2022-10-22 15:25:03 -0500
commit88659e9fe793a02fb4edcbf8ef07307c25119604 (patch)
tree101a4f72c45ce3bce4bde6b3a391d32e69ccf70a
parent7135934e50bf2727c2366687af7427d44483e984 (diff)
SL-18105 When saving an object's material to inventory, save the version that as overrides applied.
-rw-r--r--indra/llprimitive/lltextureentry.cpp51
-rw-r--r--indra/newview/llgltfmateriallist.cpp1
-rw-r--r--indra/newview/llmaterialeditor.cpp14
-rw-r--r--indra/newview/llmaterialeditor.h3
-rw-r--r--indra/newview/llpanelface.cpp2
-rw-r--r--indra/newview/llviewermenu.cpp6
-rw-r--r--indra/newview/llviewerobject.cpp3
7 files changed, 58 insertions, 22 deletions
diff --git a/indra/llprimitive/lltextureentry.cpp b/indra/llprimitive/lltextureentry.cpp
index e185404ada..68de480d87 100644
--- a/indra/llprimitive/lltextureentry.cpp
+++ b/indra/llprimitive/lltextureentry.cpp
@@ -80,22 +80,7 @@ LLTextureEntry::LLTextureEntry(const LLTextureEntry &rhs)
, mSelected(false)
, mMaterialUpdatePending(false)
{
- mID = rhs.mID;
- mScaleS = rhs.mScaleS;
- mScaleT = rhs.mScaleT;
- mOffsetS = rhs.mOffsetS;
- mOffsetT = rhs.mOffsetT;
- mRotation = rhs.mRotation;
- mColor = rhs.mColor;
- mBump = rhs.mBump;
- mMediaFlags = rhs.mMediaFlags;
- mGlow = rhs.mGlow;
- mMaterialID = rhs.mMaterialID;
- mMaterial = rhs.mMaterial;
- if (rhs.mMediaEntry != NULL) {
- // Make a copy
- mMediaEntry = new LLMediaEntry(*rhs.mMediaEntry);
- }
+ *this = rhs;
}
LLTextureEntry &LLTextureEntry::operator=(const LLTextureEntry &rhs)
@@ -124,6 +109,17 @@ LLTextureEntry &LLTextureEntry::operator=(const LLTextureEntry &rhs)
else {
mMediaEntry = NULL;
}
+
+ mMaterialID = rhs.mMaterialID;
+
+ if (rhs.mGLTFMaterialOverrides.notNull())
+ {
+ mGLTFMaterialOverrides = new LLGLTFMaterial(*rhs.mGLTFMaterialOverrides);
+ }
+ else
+ {
+ mGLTFMaterialOverrides = nullptr;
+ }
}
return *this;
@@ -218,6 +214,11 @@ void LLTextureEntry::asLLSD(LLSD& sd) const
sd[TEXTURE_MEDIA_DATA_KEY] = mediaData;
}
sd["glow"] = mGlow;
+
+ if (mGLTFMaterialOverrides.notNull())
+ {
+ sd["gltf_override"] = mGLTFMaterialOverrides->asJSON();
+ }
}
bool LLTextureEntry::fromLLSD(const LLSD& sd)
@@ -282,6 +283,24 @@ bool LLTextureEntry::fromLLSD(const LLSD& sd)
setGlow((F32)sd[w].asReal() );
}
+ w = "gltf_override";
+ if (sd.has(w))
+ {
+ if (mGLTFMaterialOverrides.isNull())
+ {
+ mGLTFMaterialOverrides = new LLGLTFMaterial();
+ }
+
+ std::string warn_msg, error_msg;
+ if (!mGLTFMaterialOverrides->fromJSON(sd[w].asString(), warn_msg, error_msg))
+ {
+ LL_WARNS() << llformat("Failed to parse GLTF json: %s -- %s", warn_msg.c_str(), error_msg.c_str()) << LL_ENDL;
+ LL_WARNS() << sd[w].asString() << LL_ENDL;
+
+ mGLTFMaterialOverrides = nullptr;
+ }
+ }
+
return true;
fail:
return false;
diff --git a/indra/newview/llgltfmateriallist.cpp b/indra/newview/llgltfmateriallist.cpp
index 88923ba734..4861c2a33b 100644
--- a/indra/newview/llgltfmateriallist.cpp
+++ b/indra/newview/llgltfmateriallist.cpp
@@ -74,6 +74,7 @@ namespace
}
LLViewerObject * obj = gObjectList.findObject(message["object_id"].asUUID());
+ llassert(obj); // should never get an override for an object we don't know about
S32 side = message["side"].asInteger();
std::string gltf_json = message["gltf_json"].asString();
diff --git a/indra/newview/llmaterialeditor.cpp b/indra/newview/llmaterialeditor.cpp
index 038f4df863..8086bcf402 100644
--- a/indra/newview/llmaterialeditor.cpp
+++ b/indra/newview/llmaterialeditor.cpp
@@ -1401,7 +1401,7 @@ void LLMaterialEditor::loadMaterialFromFile(const std::string& filename, S32 ind
}
}
-void LLMaterialEditor::loadLiveMaterialEditor()
+void LLMaterialEditor::loadLive()
{
LLMaterialEditor* me = (LLMaterialEditor*)LLFloaterReg::getInstance("material_editor", LLSD(LIVE_MATERIAL_EDITOR_KEY));
if (me->setFromSelection())
@@ -1416,6 +1416,18 @@ void LLMaterialEditor::loadLiveMaterialEditor()
}
}
+void LLMaterialEditor::loadObjectSave()
+{
+ LLMaterialEditor* me = (LLMaterialEditor*)LLFloaterReg::getInstance("material_editor", LLSD(LIVE_MATERIAL_EDITOR_KEY));
+ if (me->setFromSelection())
+ {
+ me->mIsOverride = false;
+ me->childSetVisible("save", false);
+ me->openFloater();
+ me->setFocus(TRUE);
+ }
+}
+
void LLMaterialEditor::loadFromGLTFMaterial(LLUUID &asset_id)
{
if (asset_id.isNull())
diff --git a/indra/newview/llmaterialeditor.h b/indra/newview/llmaterialeditor.h
index 9cd8bcd88b..23cb32aacf 100644
--- a/indra/newview/llmaterialeditor.h
+++ b/indra/newview/llmaterialeditor.h
@@ -103,7 +103,8 @@ public:
// will promt to select specific one
static void loadMaterialFromFile(const std::string& filename, S32 index = -1);
- static void loadLiveMaterialEditor();
+ static void loadLive();
+ static void loadObjectSave();
static void loadFromGLTFMaterial(LLUUID &asset_id);
diff --git a/indra/newview/llpanelface.cpp b/indra/newview/llpanelface.cpp
index f8e786fc97..c6e0bc5153 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::loadLiveMaterialEditor();
+ LLMaterialEditor::loadLive();
}
bool LLPanelFace::isIdenticalPlanarTexgen()
diff --git a/indra/newview/llviewermenu.cpp b/indra/newview/llviewermenu.cpp
index 47b355e554..18d215f9f4 100644
--- a/indra/newview/llviewermenu.cpp
+++ b/indra/newview/llviewermenu.cpp
@@ -2970,7 +2970,7 @@ void load_life_gltf_material(bool copy)
}
else
{
- LLMaterialEditor::loadLiveMaterialEditor();
+ LLMaterialEditor::loadLive();
}
LLViewerJoystick::getInstance()->moveObjects(true);
@@ -2980,12 +2980,12 @@ void load_life_gltf_material(bool copy)
void handle_object_edit_gltf_material()
{
handle_object_edit();
- LLMaterialEditor::loadLiveMaterialEditor();
+ LLMaterialEditor::loadLive();
}
void handle_object_save_gltf_material()
{
- load_life_gltf_material(true);
+ LLMaterialEditor::loadObjectSave();
}
void handle_attachment_edit(const LLUUID& inv_item_id)
diff --git a/indra/newview/llviewerobject.cpp b/indra/newview/llviewerobject.cpp
index eaf0287dae..603dcc4fa7 100644
--- a/indra/newview/llviewerobject.cpp
+++ b/indra/newview/llviewerobject.cpp
@@ -5333,6 +5333,9 @@ S32 LLViewerObject::setTEGLTFMaterialOverride(U8 te, LLGLTFMaterial* override_ma
tep->setGLTFMaterialOverride(override_mat);
+ // if override mat exists, we must also have a source mat
+ llassert(override_mat ? src_mat : true);
+
if (override_mat && src_mat)
{
LLFetchedGLTFMaterial* render_mat = new LLFetchedGLTFMaterial(*src_mat);