summaryrefslogtreecommitdiff
path: root/indra
diff options
context:
space:
mode:
authorBrad Kittenbrink <brad@lindenlab.com>2022-10-17 16:49:51 -0700
committerBrad Kittenbrink <brad@lindenlab.com>2022-10-17 16:51:45 -0700
commitf20c47a5968c82b1627139537e07a2ae67f64b24 (patch)
treeed471f59ed1ff5b160f46ced74687c5fd373b962 /indra
parent547fc1e6f548dbde3ba8e4d9b61d7504447afa27 (diff)
More work on SL-17697 LLMaterialEditor now uses new override diffing code when applyToSelection() gets called
Diffstat (limited to 'indra')
-rw-r--r--indra/newview/llmaterialeditor.cpp55
-rw-r--r--indra/newview/llpanelface.cpp4
2 files changed, 35 insertions, 24 deletions
diff --git a/indra/newview/llmaterialeditor.cpp b/indra/newview/llmaterialeditor.cpp
index 735b4af689..0256ab32da 100644
--- a/indra/newview/llmaterialeditor.cpp
+++ b/indra/newview/llmaterialeditor.cpp
@@ -1538,24 +1538,6 @@ void LLMaterialEditor::loadMaterial(LLGLTFMaterial * material, bool make_copy)
else
{
setTitle(getString("material_override_title"));
- // TODO: Save whole selection
-
- LLObjectSelectionHandle selection = LLSelectMgr::getInstance()->getSelection();
- LLViewerObject* object = selection->getFirstNode()->getObject();
- if (object)
- {
- const S32 num_tes = llmin((S32)object->getNumTEs(), (S32)object->getNumFaces()); // avatars have TEs but no faces
- for (S32 face = 0; face < num_tes; ++face)
- {
- LLTextureEntry *te = object->getTE(face);
- if (te->isSelected())
- {
- // TEMP
- setOverrideTarget(object->getLocalID(), face);
- break;
- }
- }
- }
}
// Todo: At the moment it always makes a 'copy'
@@ -1898,8 +1880,8 @@ private:
class LLRenderMaterialOverrideFunctor : public LLSelectedTEFunctor
{
public:
- LLRenderMaterialOverrideFunctor(LLMaterialEditor * me, std::string const & url)
- : mEditor(me), mCapUrl(url)
+ LLRenderMaterialOverrideFunctor(LLMaterialEditor * me, std::string const & url, LLUUID const & asset_id)
+ : mEditor(me), mCapUrl(url), mAssetID(asset_id)
{
}
@@ -1911,10 +1893,37 @@ public:
//LLVOVolume* vobjp = (LLVOVolume*)objectp;
S32 local_id = objectp->getLocalID();
+ LLPointer<LLGLTFMaterial> material = new LLGLTFMaterial();
+ LLPointer<LLGLTFMaterial> base;
+ mEditor->getGLTFMaterial(material);
+
+ tinygltf::Model model_out;
+
+ if(mAssetID != LLUUID::null)
+ {
+ base = gGLTFMaterialList.getMaterial(mAssetID);
+ material->writeOverridesToModel(model_out, 0, base);
+ }
+ else
+ {
+ material->writeToModel(model_out, 0);
+ }
+
+ std::string overrides_json;
+ {
+ tinygltf::TinyGLTF gltf;
+ std::ostringstream str;
+
+ gltf.WriteGltfSceneToStream(&model_out, str, false, false);
+
+ overrides_json = str.str();
+ LL_DEBUGS() << "overrides_json " << overrides_json << LL_ENDL;
+ }
+
LLSD overrides = llsd::map(
"local_id", local_id,
"side", te,
- "overrides", LLSD::emptyMap()
+ "overrides", overrides_json
);
LLCoros::instance().launch("modifyMaterialCoro", std::bind(&LLMaterialEditor::modifyMaterialCoro, mEditor, mCapUrl, overrides));
}
@@ -1924,6 +1933,7 @@ public:
private:
LLMaterialEditor * mEditor;
std::string mCapUrl;
+ LLUUID mAssetID;
};
void LLMaterialEditor::applyToSelection()
@@ -1932,7 +1942,8 @@ void LLMaterialEditor::applyToSelection()
if (!url.empty())
{
LLObjectSelectionHandle selected_objects = LLSelectMgr::getInstance()->getSelection();
- LLRenderMaterialOverrideFunctor override_func(this, url);
+ // 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, mAssetID);
selected_objects->applyToTEs(&override_func);
}
else
diff --git a/indra/newview/llpanelface.cpp b/indra/newview/llpanelface.cpp
index fd8bf044f8..457ff525c5 100644
--- a/indra/newview/llpanelface.cpp
+++ b/indra/newview/llpanelface.cpp
@@ -4593,8 +4593,8 @@ void LLPanelFace::onPbrStartEditing() {
LL_DEBUGS() << "loading material live editor with asset " << material_id << LL_ENDL;
- LLGLTFMaterial* material = gGLTFMaterialList.getMaterial(material_id);
- editor->setTitle("Editing material on selection"s);
+ LLPointer<LLGLTFMaterial> material = gGLTFMaterialList.getMaterial(material_id);
+ editor->setTitle(editor->getString("material_override_title"));
editor->setAssetId(material_id);
editor->setFromGLTFMaterial(material);
}