summaryrefslogtreecommitdiff
path: root/indra/newview
diff options
context:
space:
mode:
authorAndrey Kleshchev <andreykproductengine@lindenlab.com>2022-10-31 20:12:53 +0200
committerAndrey Kleshchev <andreykproductengine@lindenlab.com>2022-10-31 20:12:53 +0200
commit094a8876d6e030b5dc618ea28250e15022030c78 (patch)
treedef08dcfc7baa41eb445d2f9a8ed54f5daed6d14 /indra/newview
parent35d4124b5eb3d412643124993b4fa8c09f3f747c (diff)
SL-18446 Material override arrival filtering
Diffstat (limited to 'indra/newview')
-rw-r--r--indra/newview/llgltfmateriallist.cpp49
-rw-r--r--indra/newview/llgltfmateriallist.h2
-rw-r--r--indra/newview/llmaterialeditor.cpp66
-rw-r--r--indra/newview/llmaterialeditor.h4
-rw-r--r--indra/newview/llviewermenufile.cpp4
-rw-r--r--indra/newview/llviewerobject.cpp2
6 files changed, 99 insertions, 28 deletions
diff --git a/indra/newview/llgltfmateriallist.cpp b/indra/newview/llgltfmateriallist.cpp
index 80f198fc6c..d91a448bc8 100644
--- a/indra/newview/llgltfmateriallist.cpp
+++ b/indra/newview/llgltfmateriallist.cpp
@@ -117,6 +117,12 @@ namespace
if (!success)
{
LL_WARNS() << "failed to parse GLTF override data. errors: " << error_msg << " | warnings: " << warn_msg << LL_ENDL;
+
+ // unblock material editor
+ if (obj && obj->isAnySelected())
+ {
+ LLMaterialEditor::updateLive(object_id, sides[i].asInteger());
+ }
}
else
{
@@ -131,28 +137,25 @@ namespace
}
else if (obj && obj->isAnySelected())
{
- // Might want to cause a full selection
- // update here instead of just an editor
- LLMaterialEditor::updateLive();
+ LLMaterialEditor::updateLive(object_id, side);
}
}
}
if (obj && side_set.size() != obj->getNumTEs())
{ // object exists and at least one texture entry needs to have its override data nulled out
+ bool object_has_selection = obj->isAnySelected();
for (int i = 0; i < obj->getNumTEs(); ++i)
{
if (side_set.find(i) == side_set.end())
{
obj->setTEGLTFMaterialOverride(i, nullptr);
+ if (object_has_selection)
+ {
+ LLMaterialEditor::updateLive(object_id, i);
+ }
}
}
- if (obj->isAnySelected())
- {
- // Might want to cause a full selection
- // update here instead of just an editor
- LLMaterialEditor::updateLive();
- }
}
}
else
@@ -163,15 +166,14 @@ namespace
if (clear_all && obj)
{ // override list was empty or an error occurred, null out all overrides for this object
+ bool object_has_selection = obj->isAnySelected();
for (int i = 0; i < obj->getNumTEs(); ++i)
{
obj->setTEGLTFMaterialOverride(i, nullptr);
- }
- if (obj->isAnySelected())
- {
- // Might want to cause a full selection
- // update here instead of just an editor
- LLMaterialEditor::updateLive();
+ if (object_has_selection)
+ {
+ LLMaterialEditor::updateLive(obj->getID(), i);
+ }
}
}
return true;
@@ -199,6 +201,7 @@ void LLGLTFMaterialList::applyQueuedOverrides(LLViewerObject* obj)
if (iter != mQueuedOverrides.end())
{
+ bool object_has_selection = obj->isAnySelected();
override_list_t& overrides = iter->second;
for (int i = 0; i < overrides.size(); ++i)
{
@@ -209,11 +212,9 @@ void LLGLTFMaterialList::applyQueuedOverrides(LLViewerObject* obj)
return;
}
obj->setTEGLTFMaterialOverride(i, overrides[i]);
- if (obj->isAnySelected())
+ if (object_has_selection)
{
- // Might want to cause a full selection
- // update here instead of just an editor
- LLMaterialEditor::updateLive();
+ LLMaterialEditor::updateLive(id, i);
}
}
}
@@ -380,7 +381,7 @@ void LLGLTFMaterialList::registerCallbacks()
}
// static
-void LLGLTFMaterialList::modifyMaterialCoro(std::string cap_url, LLSD overrides)
+void LLGLTFMaterialList::modifyMaterialCoro(std::string cap_url, LLSD overrides, void(*done_callback)(bool) )
{
LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID);
LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t
@@ -398,12 +399,20 @@ void LLGLTFMaterialList::modifyMaterialCoro(std::string cap_url, LLSD overrides)
LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS];
LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults);
+ bool success = true;
if (!status)
{
LL_WARNS() << "Failed to modify material." << LL_ENDL;
+ success = false;
}
else if (!result["success"].asBoolean())
{
LL_WARNS() << "Failed to modify material: " << result["message"] << LL_ENDL;
+ success = false;
+ }
+
+ if (done_callback)
+ {
+ done_callback(success);
}
}
diff --git a/indra/newview/llgltfmateriallist.h b/indra/newview/llgltfmateriallist.h
index b74e0b3ec2..bfdd9e5e32 100644
--- a/indra/newview/llgltfmateriallist.h
+++ b/indra/newview/llgltfmateriallist.h
@@ -57,7 +57,7 @@ public:
// "object_id": LLUUID - object to be modified
// "side": integer - index of face to be modified
// "gltf_json" : string - GLTF compliant json of override data (optional, if omitted any existing override data will be cleared)
- static void modifyMaterialCoro(std::string cap_url, LLSD overrides);
+ static void modifyMaterialCoro(std::string cap_url, LLSD overrides, void(*done_callback)(bool));
// save an override update for later (for example, if an override arrived for an unknown object)
void queueOverrideUpdate(const LLUUID& id, S32 side, LLGLTFMaterial* override_data);
diff --git a/indra/newview/llmaterialeditor.cpp b/indra/newview/llmaterialeditor.cpp
index c10625a45a..70ba77e18b 100644
--- a/indra/newview/llmaterialeditor.cpp
+++ b/indra/newview/llmaterialeditor.cpp
@@ -86,6 +86,9 @@ static const U32 MATERIAL_DOUBLE_SIDED_DIRTY = 0x1 << 9;
static const U32 MATERIAL_ALPHA_MODE_DIRTY = 0x1 << 10;
static const U32 MATERIAL_ALPHA_CUTOFF_DIRTY = 0x1 << 11;
+LLUUID LLMaterialEditor::mOverrideObjectId;
+S32 LLMaterialEditor::mOverrideObjectTE = -1;
+
LLFloaterComboOptions::LLFloaterComboOptions()
: LLFloater(LLSD())
{
@@ -1518,8 +1521,16 @@ void LLMaterialEditor::onSelectionChanged()
{
// This won't get deletion or deselectAll()
// Might need to handle that separately
- clearTextures();
- setFromSelection();
+
+ // Drop selection updates if we are waiting for
+ // overrides to finish aplying to not reset values
+ // (might need a timeout)
+ if (!mOverrideInProgress)
+ {
+ clearTextures();
+ setFromSelection();
+ }
+
// At the moment all cahges are 'live' so don't reset dirty flags
// saveLiveValues(); todo
}
@@ -1564,6 +1575,29 @@ void LLMaterialEditor::updateLive()
LLMaterialEditor* me = (LLMaterialEditor*)instance;
if (me)
{
+ me->mOverrideInProgress = false;
+ me->clearTextures();
+ me->setFromSelection();
+ }
+ }
+}
+
+void LLMaterialEditor::updateLive(const LLUUID &object_id, S32 te)
+{
+ if (mOverrideObjectId != object_id
+ || mOverrideObjectTE != te)
+ {
+ // Not an update we are waiting for
+ return;
+ }
+ const LLSD floater_key(LIVE_MATERIAL_EDITOR_KEY);
+ LLFloater* instance = LLFloaterReg::findInstance("material_editor", floater_key);
+ if (instance && LLFloater::isVisible(instance))
+ {
+ LLMaterialEditor* me = (LLMaterialEditor*)instance;
+ if (me)
+ {
+ me->mOverrideInProgress = false;
me->clearTextures();
me->setFromSelection();
}
@@ -1577,6 +1611,7 @@ void LLMaterialEditor::loadLive()
LLMaterialEditor* me = (LLMaterialEditor*)LLFloaterReg::getInstance("material_editor", floater_key);
if (me)
{
+ me->mOverrideInProgress = false;
me->setFromSelection();
me->setTitle(me->getString("material_override_title"));
me->childSetVisible("save", false);
@@ -2152,11 +2187,21 @@ public:
"side", te,
"gltf_json", overrides_json
);
- LLCoros::instance().launch("modifyMaterialCoro", std::bind(&LLGLTFMaterialList::modifyMaterialCoro, mCapUrl, overrides));
+ LLCoros::instance().launch("modifyMaterialCoro", std::bind(&LLGLTFMaterialList::modifyMaterialCoro, mCapUrl, overrides, modifyCallback));
}
return true;
}
+ static void modifyCallback(bool success)
+ {
+ if (!success)
+ {
+ // something went wrong update selection
+ LLMaterialEditor::updateLive();
+ }
+ // else we will get updateLive(obj, id) from aplied overrides
+ }
+
private:
LLMaterialEditor * mEditor;
std::string mCapUrl;
@@ -2176,10 +2221,14 @@ void LLMaterialEditor::applyToSelection()
std::string url = gAgent.getRegionCapability("ModifyMaterialParams");
if (!url.empty())
{
+ mOverrideInProgress = true;
LLObjectSelectionHandle selected_objects = LLSelectMgr::getInstance()->getSelection();
// TODO figure out how to get the right asset id in cases where we don't have a good one
LLRenderMaterialOverrideFunctor override_func(this, url);
- selected_objects->applyToTEs(&override_func);
+ if (!selected_objects->applyToTEs(&override_func))
+ {
+ mOverrideInProgress = false;
+ }
// we posted all changes
mUnsavedChanges = 0;
@@ -2247,6 +2296,7 @@ bool LLMaterialEditor::setFromSelection()
, mIdenticalTexMetal(true)
, mIdenticalTexEmissive(true)
, mIdenticalTexNormal(true)
+ , mObjectTE(-1)
, mFirst(true)
{}
@@ -2284,6 +2334,8 @@ bool LLMaterialEditor::setFromSelection()
mTexMetalId = tex_metal_id;
mTexEmissiveId = tex_emissive_id;
mTexNormalId = tex_normal_id;
+ mObjectTE = te_index;
+ mObjectId = objectp->getID();
mFirst = false;
}
else
@@ -2318,6 +2370,8 @@ bool LLMaterialEditor::setFromSelection()
LLUUID mTexMetalId;
LLUUID mTexEmissiveId;
LLUUID mTexNormalId;
+ LLUUID mObjectId;
+ S32 mObjectTE;
LLPointer<LLGLTFMaterial> mMaterial;
} func(mIsOverride);
@@ -2344,6 +2398,10 @@ bool LLMaterialEditor::setFromSelection()
mMetallicTextureCtrl->setTentative(!func.mIdenticalTexMetal);
mEmissiveTextureCtrl->setTentative(!func.mIdenticalTexEmissive);
mNormalTextureCtrl->setTentative(!func.mIdenticalTexNormal);
+
+ // Memorize selection data for filtering further updates
+ mOverrideObjectId = func.mObjectId;
+ mOverrideObjectTE = func.mObjectTE;
}
return func.mMaterial.notNull();
diff --git a/indra/newview/llmaterialeditor.h b/indra/newview/llmaterialeditor.h
index 87c94041d3..749cd4cd54 100644
--- a/indra/newview/llmaterialeditor.h
+++ b/indra/newview/llmaterialeditor.h
@@ -107,6 +107,7 @@ public:
void saveLiveValues(); // for restoration on cancel
static void updateLive();
+ static void updateLive(const LLUUID &object_id, S32 te);
static void loadLive();
static void loadObjectSave();
@@ -283,8 +284,11 @@ private:
// if true, this instance is live instance editing overrides
bool mIsOverride = false;
+ bool mOverrideInProgress = false;
// local id, texture ids per face for object overrides
// for "cancel" support
+ static LLUUID mOverrideObjectId; // static to avoid searching for the floater
+ static S32 mOverrideObjectTE;
std::map<U32, uuid_vec_t> mObjectOverridesSavedValues;
boost::signals2::connection mSelectionUpdateSlot;
};
diff --git a/indra/newview/llviewermenufile.cpp b/indra/newview/llviewermenufile.cpp
index ffa2ce865e..25eb3eff1d 100644
--- a/indra/newview/llviewermenufile.cpp
+++ b/indra/newview/llviewermenufile.cpp
@@ -106,8 +106,7 @@ class LLFileEnableUploadMaterial : public view_listener_t
{
bool handleEvent(const LLSD& userdata)
{
- LLMaterialEditor* me = (LLMaterialEditor*)LLFloaterReg::findInstance("material_editor");
- if (me && me->isShown())
+ if (!gAgent.getRegionCapability("UpdateMaterialAgentInventory").empty())
{
return false;
}
@@ -1145,6 +1144,7 @@ void init_menu_file()
view_listener_t::addEnable(new LLFileEnableUpload(), "File.EnableUpload");
view_listener_t::addEnable(new LLFileEnableUploadModel(), "File.EnableUploadModel");
+ view_listener_t::addEnable(new LLFileEnableUploadMaterial(), "File.EnableUploadMaterial");
view_listener_t::addMenu(new LLMeshEnabled(), "File.MeshEnabled");
view_listener_t::addMenu(new LLMeshUploadVisible(), "File.VisibleUploadModel");
diff --git a/indra/newview/llviewerobject.cpp b/indra/newview/llviewerobject.cpp
index 6fcad1a8c7..43525a3173 100644
--- a/indra/newview/llviewerobject.cpp
+++ b/indra/newview/llviewerobject.cpp
@@ -7212,7 +7212,7 @@ void LLViewerObject::setRenderMaterialID(S32 te_in, const LLUUID& id, bool updat
gAgent.getRegionCapability("ModifyMaterialParams"),
llsd::map(
"object_id", getID(),
- "side", te)));
+ "side", te), nullptr));
}
// update and send LLRenderMaterialParams