summaryrefslogtreecommitdiff
path: root/indra
diff options
context:
space:
mode:
authorBrad Kittenbrink <brad@lindenlab.com>2022-10-17 15:44:32 -0700
committerBrad Kittenbrink <brad@lindenlab.com>2022-10-17 15:48:49 -0700
commit53e5216b2092b98d6973c2b27c5c75713ec99e73 (patch)
treee0ec5ca609b7f25648621b51715b7101bca37515 /indra
parent77eba62335158db6b0c6c7966a26b956fd796da9 (diff)
Continuing work on SL-17697 Live editing with material overrides.
* Fixed Selection usage so material editor no longer hardcoded to a single object/face * made local preview hack the fallback for when the ModifyMaterialParams cap is missing
Diffstat (limited to 'indra')
-rw-r--r--indra/newview/llgltfmateriallist.cpp17
-rw-r--r--indra/newview/llmaterialeditor.cpp77
-rw-r--r--indra/newview/llmaterialeditor.h4
-rw-r--r--indra/newview/llpanelface.cpp11
4 files changed, 64 insertions, 45 deletions
diff --git a/indra/newview/llgltfmateriallist.cpp b/indra/newview/llgltfmateriallist.cpp
index 24fd623231..a433644e0e 100644
--- a/indra/newview/llgltfmateriallist.cpp
+++ b/indra/newview/llgltfmateriallist.cpp
@@ -47,11 +47,22 @@ namespace
bool operator()(const LLDispatcher* dispatcher, const std::string& key, const LLUUID& invoice, const sparam_t& strings) override
{
- LL_DEBUGS() << "strings: ";
for (std::string const & s : strings) {
- LL_CONT << " " << s;
+ LL_DEBUGS() << "received override: " << s << LL_ENDL;
+
+#if 0
+ // for now messages are coming in llsd
+ LLSD override_data;
+ std::istringstream input(s);
+ LLSDSerialize::deserialize(override_data, input, s.length());
+ LL_DEBUGS() << "deserialized override: " << override_data << LL_ENDL;
+#else
+ std::string warn_msg, error_msg;
+ LLGLTFMaterial override_data;
+ override_data.fromJSON(s, warn_msg, error_msg);
+#endif
}
- LL_CONT << LL_ENDL;
+
return true;
}
};
diff --git a/indra/newview/llmaterialeditor.cpp b/indra/newview/llmaterialeditor.cpp
index f1b015fc84..735b4af689 100644
--- a/indra/newview/llmaterialeditor.cpp
+++ b/indra/newview/llmaterialeditor.cpp
@@ -200,8 +200,6 @@ LLMaterialEditor::LLMaterialEditor(const LLSD& key)
, mHasUnsavedChanges(false)
, mExpectedUploadCost(0)
, mUploadingTexturesCount(0)
- , mOverrideLocalId(0)
- , mOverrideFace(0)
{
const LLInventoryItem* item = getItem();
if (item)
@@ -1875,10 +1873,10 @@ void LLMaterialEditor::importMaterial()
true);
}
-class LLRemderMaterialFunctor : public LLSelectedTEFunctor
+class LLRenderMaterialFunctor : public LLSelectedTEFunctor
{
public:
- LLRemderMaterialFunctor(const LLUUID &id)
+ LLRenderMaterialFunctor(const LLUUID &id)
: mMatId(id)
{
}
@@ -1897,29 +1895,59 @@ private:
LLUUID mMatId;
};
+class LLRenderMaterialOverrideFunctor : public LLSelectedTEFunctor
+{
+public:
+ LLRenderMaterialOverrideFunctor(LLMaterialEditor * me, std::string const & url)
+ : mEditor(me), mCapUrl(url)
+ {
+
+ }
+
+ bool apply(LLViewerObject* objectp, S32 te) override
+ {
+ if (objectp && objectp->permModify() && objectp->getVolume())
+ {
+ //LLVOVolume* vobjp = (LLVOVolume*)objectp;
+ S32 local_id = objectp->getLocalID();
+
+ LLSD overrides = llsd::map(
+ "local_id", local_id,
+ "side", te,
+ "overrides", LLSD::emptyMap()
+ );
+ LLCoros::instance().launch("modifyMaterialCoro", std::bind(&LLMaterialEditor::modifyMaterialCoro, mEditor, mCapUrl, overrides));
+ }
+ return true;
+ }
+
+private:
+ LLMaterialEditor * mEditor;
+ std::string mCapUrl;
+};
+
void LLMaterialEditor::applyToSelection()
{
-#if 0 // local preview placeholder hack
- // Placehodler. Will be removed once override systems gets finished.
- LLPointer<LLGLTFMaterial> mat = new LLGLTFMaterial();
- getGLTFMaterial(mat);
- const LLUUID placeholder("984e183e-7811-4b05-a502-d79c6f978a98");
- gGLTFMaterialList.addMaterial(placeholder, mat);
- LLRemderMaterialFunctor mat_func(placeholder);
- LLObjectSelectionHandle selected_objects = LLSelectMgr::getInstance()->getSelection();
- //selected_objects->applyToTEs(&mat_func);
-#else
std::string url = gAgent.getRegionCapability("ModifyMaterialParams");
if (!url.empty())
{
- LLSDMap overrides;
- LLCoros::instance().launch("modifyMaterialCoro", std::bind(&LLMaterialEditor::modifyMaterialCoro, this, url, overrides));
+ LLObjectSelectionHandle selected_objects = LLSelectMgr::getInstance()->getSelection();
+ LLRenderMaterialOverrideFunctor override_func(this, url);
+ selected_objects->applyToTEs(&override_func);
}
else
{
LL_WARNS() << "not connected to materials capable region, missing ModifyMaterialParams cap" << LL_ENDL;
+
+ // Fallback local preview. Will be removed once override systems is finished and new cap is deployed everywhere.
+ LLPointer<LLGLTFMaterial> mat = new LLGLTFMaterial();
+ getGLTFMaterial(mat);
+ static const LLUUID placeholder("984e183e-7811-4b05-a502-d79c6f978a98");
+ gGLTFMaterialList.addMaterial(placeholder, mat);
+ LLRenderMaterialFunctor mat_func(placeholder);
+ LLObjectSelectionHandle selected_objects = LLSelectMgr::getInstance()->getSelection();
+ selected_objects->applyToTEs(&mat_func);
}
-#endif
}
void LLMaterialEditor::getGLTFMaterial(LLGLTFMaterial* mat)
@@ -2323,13 +2351,10 @@ void LLMaterialEditor::modifyMaterialCoro(std::string cap_url, LLSD overrides)
LLCore::HttpHeaders::ptr_t httpHeaders;
httpOpts->setFollowRedirects(true);
- LLSD body = llsd::map(
- "local_id", S32(mOverrideLocalId),
- "face", mOverrideFace,
- "overrides", overrides
- );
- LLSD result = httpAdapter->postAndSuspend(httpRequest, cap_url, body, httpOpts, httpHeaders);
+ LL_DEBUGS() << "Applying override via ModifyMaterialParams cap: " << overrides << LL_ENDL;
+
+ LLSD result = httpAdapter->postAndSuspend(httpRequest, cap_url, overrides, httpOpts, httpHeaders);
LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS];
LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults);
@@ -2343,9 +2368,3 @@ void LLMaterialEditor::modifyMaterialCoro(std::string cap_url, LLSD overrides)
LL_WARNS() << "Failed to modify material: " << result["message"] << LL_ENDL;
}
}
-
-void LLMaterialEditor::setOverrideTarget(U32 local_id, S32 face)
-{
- mOverrideLocalId = local_id;
- mOverrideFace = face;
-}
diff --git a/indra/newview/llmaterialeditor.h b/indra/newview/llmaterialeditor.h
index 3dabc6e26a..9bc6be4b92 100644
--- a/indra/newview/llmaterialeditor.h
+++ b/indra/newview/llmaterialeditor.h
@@ -218,7 +218,6 @@ public:
void loadDefaults();
void modifyMaterialCoro(std::string cap_url, LLSD overrides);
- void setOverrideTarget(U32 local_id, S32 face_id);
private:
void loadMaterial(const tinygltf::Model &model, const std::string &filename_lc, S32 index);
@@ -272,8 +271,5 @@ private:
S32 mExpectedUploadCost;
std::string mMaterialNameShort;
std::string mMaterialName;
-
- U32 mOverrideLocalId;
- S32 mOverrideFace;
};
diff --git a/indra/newview/llpanelface.cpp b/indra/newview/llpanelface.cpp
index f93a0e7142..fd8bf044f8 100644
--- a/indra/newview/llpanelface.cpp
+++ b/indra/newview/llpanelface.cpp
@@ -4587,23 +4587,16 @@ void LLPanelFace::onPbrStartEditing() {
dynamic_cast<LLMaterialEditor *>(LLFloaterReg::showInstance("material_editor", LLSD(LLUUID::null), TAKE_FOCUS_YES));
if (editor)
{
- LLObjectSelection *select = LLSelectMgr::getInstance()->getSelection();
- LLViewerObject * objectp = select->getFirstObject();
- LLUUID object_id = objectp->getID();
-
bool identical;
LLUUID material_id;
LLSelectedTE::getPbrMaterialId(material_id, identical);
- S32 face = 0;
-
- LL_DEBUGS() << "loading material live editor with asset " << material_id << " on object " << object_id << LL_ENDL;
+ LL_DEBUGS() << "loading material live editor with asset " << material_id << LL_ENDL;
LLGLTFMaterial* material = gGLTFMaterialList.getMaterial(material_id);
- editor->setTitle("Editing material on "s + object_id.asString());
+ editor->setTitle("Editing material on selection"s);
editor->setAssetId(material_id);
editor->setFromGLTFMaterial(material);
- editor->setOverrideTarget(objectp->getLocalID(), face);
}
}