SL-18105 When saving an object's material to inventory, save the version that as overrides applied.
parent
7135934e50
commit
88659e9fe7
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
||||
|
|
|
|||
|
|
@ -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())
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
||||
|
|
|
|||
|
|
@ -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()
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Reference in New Issue