summaryrefslogtreecommitdiff
path: root/indra/newview
diff options
context:
space:
mode:
authorDave Parks <davep@lindenlab.com>2022-10-31 15:20:02 -0500
committerDave Parks <davep@lindenlab.com>2022-10-31 15:20:02 -0500
commit94afae5b1552439f69126ecf7cd6716fa692fed6 (patch)
tree52abb39e749f4c2e2835e89ff3afd39034d34fba /indra/newview
parent29e344bbd0043bb1cd5f1defd6f9a193b0cc728e (diff)
parent4cb5439e425dbfd354a27cbfbfe071904d068d5d (diff)
Merge branch 'DRTVWR-559' of ssh://bitbucket.org/lindenlab/viewer into DRTVWR-559
Diffstat (limited to 'indra/newview')
-rw-r--r--indra/newview/llgltfmateriallist.cpp36
-rw-r--r--indra/newview/llgltfmateriallist.h2
-rw-r--r--indra/newview/llmaterialeditor.cpp98
-rw-r--r--indra/newview/llmaterialeditor.h8
-rw-r--r--indra/newview/llpanelface.cpp39
-rw-r--r--indra/newview/llpanelface.h3
-rw-r--r--indra/newview/llviewermenufile.cpp4
-rw-r--r--indra/newview/llviewerobject.cpp2
-rw-r--r--indra/newview/skins/default/xui/en/panel_tools_texture.xml38
9 files changed, 189 insertions, 41 deletions
diff --git a/indra/newview/llgltfmateriallist.cpp b/indra/newview/llgltfmateriallist.cpp
index ab7a6495c4..d91a448bc8 100644
--- a/indra/newview/llgltfmateriallist.cpp
+++ b/indra/newview/llgltfmateriallist.cpp
@@ -31,6 +31,7 @@
#include "lldispatcher.h"
#include "llfetchedgltfmaterial.h"
#include "llfilesystem.h"
+#include "llmaterialeditor.h"
#include "llsdserialize.h"
#include "lltinygltfhelper.h"
#include "llviewercontrol.h"
@@ -116,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
{
@@ -128,16 +135,25 @@ namespace
// object not ready to receive override data, queue for later
gGLTFMaterialList.queueOverrideUpdate(object_id, side, override_data);
}
+ else if (obj && obj->isAnySelected())
+ {
+ 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);
+ }
}
}
}
@@ -150,9 +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 (object_has_selection)
+ {
+ LLMaterialEditor::updateLive(obj->getID(), i);
+ }
}
}
return true;
@@ -180,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)
{
@@ -190,6 +212,10 @@ void LLGLTFMaterialList::applyQueuedOverrides(LLViewerObject* obj)
return;
}
obj->setTEGLTFMaterialOverride(i, overrides[i]);
+ if (object_has_selection)
+ {
+ LLMaterialEditor::updateLive(id, i);
+ }
}
}
@@ -355,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
@@ -373,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 533f882d39..20fee6686c 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())
{
@@ -1513,13 +1516,22 @@ void LLMaterialEditor::loadMaterialFromFile(const std::string& filename, S32 ind
);
}
}
+
void LLMaterialEditor::onSelectionChanged()
{
// This won't get deletion or deselectAll()
// Might need to handle that separately
- mUnsavedChanges = 0;
- 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
}
@@ -1554,6 +1566,44 @@ void LLMaterialEditor::saveLiveValues()
LLSelectMgr::getInstance()->getSelection()->applyToObjects(&savefunc);
}
+void LLMaterialEditor::updateLive()
+{
+ 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();
+ }
+ }
+}
+
+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();
+ }
+ }
+}
+
void LLMaterialEditor::loadLive()
{
// Allow only one 'live' instance
@@ -1561,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);
@@ -2136,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;
@@ -2160,10 +2221,22 @@ void LLMaterialEditor::applyToSelection()
std::string url = gAgent.getRegionCapability("ModifyMaterialParams");
if (!url.empty())
{
- 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);
+ // Don't send data if there is nothing to send.
+ // Some UI elements will cause multiple commits,
+ // like spin ctrls on click and on down
+ if (mUnsavedChanges != 0)
+ {
+ mOverrideInProgress = true;
+ LLObjectSelectionHandle selected_objects = LLSelectMgr::getInstance()->getSelection();
+ LLRenderMaterialOverrideFunctor override_func(this, url);
+ if (!selected_objects->applyToTEs(&override_func))
+ {
+ mOverrideInProgress = false;
+ }
+
+ // we posted all changes
+ mUnsavedChanges = 0;
+ }
}
else
{
@@ -2228,6 +2301,7 @@ bool LLMaterialEditor::setFromSelection()
, mIdenticalTexMetal(true)
, mIdenticalTexEmissive(true)
, mIdenticalTexNormal(true)
+ , mObjectTE(-1)
, mFirst(true)
{}
@@ -2265,6 +2339,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
@@ -2299,6 +2375,8 @@ bool LLMaterialEditor::setFromSelection()
LLUUID mTexMetalId;
LLUUID mTexEmissiveId;
LLUUID mTexNormalId;
+ LLUUID mObjectId;
+ S32 mObjectTE;
LLPointer<LLGLTFMaterial> mMaterial;
} func(mIsOverride);
@@ -2325,6 +2403,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 091f51234f..749cd4cd54 100644
--- a/indra/newview/llmaterialeditor.h
+++ b/indra/newview/llmaterialeditor.h
@@ -103,8 +103,11 @@ public:
// will promt to select specific one
static void loadMaterialFromFile(const std::string& filename, S32 index = -1);
- void onSelectionChanged(); // // live overrides selection changes
+ void onSelectionChanged(); // live overrides selection changes
void saveLiveValues(); // for restoration on cancel
+
+ static void updateLive();
+ static void updateLive(const LLUUID &object_id, S32 te);
static void loadLive();
static void loadObjectSave();
@@ -281,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/llpanelface.cpp b/indra/newview/llpanelface.cpp
index 6d8d19c57c..f884cfe842 100644
--- a/indra/newview/llpanelface.cpp
+++ b/indra/newview/llpanelface.cpp
@@ -201,6 +201,8 @@ BOOL LLPanelFace::postBuild()
childSetAction("button align",&LLPanelFace::onClickAutoFix,this);
childSetAction("button align textures", &LLPanelFace::onAlignTexture, this);
+ childSetAction("pbr_from_inventory", &LLPanelFace::onClickBtnLoadInvPBR, this);
+ childSetAction("edit_selected_pbr", &LLPanelFace::onClickBtnEditPBR, this);
LLTextureCtrl* mTextureCtrl;
LLTextureCtrl* mShinyTextureCtrl;
@@ -237,9 +239,6 @@ BOOL LLPanelFace::postBuild()
pbr_ctrl->setDnDFilterPermMask(PERM_COPY | PERM_TRANSFER);
pbr_ctrl->setBakeTextureEnabled(false);
pbr_ctrl->setInventoryPickType(LLTextureCtrl::PICK_MATERIAL);
-
- // TODO - design real UI for activating live editing
- pbr_ctrl->setRightMouseUpCallback(boost::bind(&LLPanelFace::onPbrStartEditing, this));
}
mTextureCtrl = getChild<LLTextureCtrl>("texture control");
@@ -968,6 +967,8 @@ void LLPanelFace::updateUI(bool force_set_values /*false*/)
pbr_ctrl->setImageAssetID(pbr_id);
has_pbr_material = pbr_id.notNull();
}
+ getChildView("pbr_from_inventory")->setEnabled(editable);
+ getChildView("edit_selected_pbr")->setEnabled(editable && has_pbr_material);
LLTextureCtrl* texture_ctrl = getChild<LLTextureCtrl>("texture control");
LLTextureCtrl* shinytexture_ctrl = getChild<LLTextureCtrl>("shinytexture control");
@@ -1469,8 +1470,8 @@ void LLPanelFace::updateUI(bool force_set_values /*false*/)
LLSelectedTE::getGlow(glow,identical_glow);
getChild<LLUICtrl>("glow")->setValue(glow);
getChild<LLUICtrl>("glow")->setTentative(!identical_glow);
- getChildView("glow")->setEnabled(editable && !has_pbr_material);
- getChildView("glow label")->setEnabled(editable && !has_pbr_material);
+ getChildView("glow")->setEnabled(editable);
+ getChildView("glow label")->setEnabled(editable);
}
{
@@ -1746,6 +1747,8 @@ void LLPanelFace::updateUI(bool force_set_values /*false*/)
getChildView("label shininess")->setEnabled(FALSE);
getChildView("label bumpiness")->setEnabled(FALSE);
getChildView("button align")->setEnabled(FALSE);
+ getChildView("pbr_from_inventory")->setEnabled(FALSE);
+ getChildView("edit_selected_pbr")->setEnabled(FALSE);
//getChildView("has media")->setEnabled(FALSE);
//getChildView("media info set")->setEnabled(FALSE);
@@ -2677,6 +2680,8 @@ void LLPanelFace::updateVisibility()
// PBR controls
getChildView("pbr_control")->setVisible(show_pbr);
+ getChildView("pbr_from_inventory")->setVisible(show_pbr);
+ getChildView("edit_selected_pbr")->setVisible(show_pbr);
}
// static
@@ -3651,6 +3656,19 @@ void LLPanelFace::onAlignTexture(void* userdata)
self->alignTestureLayer();
}
+void LLPanelFace::onClickBtnLoadInvPBR(void* userdata)
+{
+ // Shouldn't this be "save to inventory?"
+ LLPanelFace* self = (LLPanelFace*)userdata;
+ LLTextureCtrl* pbr_ctrl = self->findChild<LLTextureCtrl>("pbr_control");
+ pbr_ctrl->showPicker(true);
+}
+
+void LLPanelFace::onClickBtnEditPBR(void* userdata)
+{
+ LLMaterialEditor::loadLive();
+}
+
enum EPasteMode
{
PASTE_COLOR,
@@ -4580,17 +4598,6 @@ void LLPanelFace::onPbrSelectionChanged(LLInventoryItem* itemp)
}
}
-void LLPanelFace::onPbrStartEditing()
-{
- bool identical;
- LLUUID material_id;
- LLSelectedTE::getPbrMaterialId(material_id, identical);
-
- LL_DEBUGS() << "loading material live editor with asset " << material_id << LL_ENDL;
-
- LLMaterialEditor::loadLive();
-}
-
bool LLPanelFace::isIdenticalPlanarTexgen()
{
LLTextureEntry::e_texgen selected_texgen = LLTextureEntry::TEX_GEN_DEFAULT;
diff --git a/indra/newview/llpanelface.h b/indra/newview/llpanelface.h
index cc46116545..38d81e44ba 100644
--- a/indra/newview/llpanelface.h
+++ b/indra/newview/llpanelface.h
@@ -228,6 +228,8 @@ protected:
static void onCommitRepeatsPerMeter( LLUICtrl* ctrl, void* userinfo);
static void onClickAutoFix(void*);
static void onAlignTexture(void*);
+ static void onClickBtnLoadInvPBR(void* userdata);
+ static void onClickBtnEditPBR(void* userdata);
public: // needs to be accessible to selection manager
void onCopyColor(); // records all selected faces
@@ -438,7 +440,6 @@ private:
*/
void onTextureSelectionChanged(LLInventoryItem* itemp);
void onPbrSelectionChanged(LLInventoryItem* itemp);
- void onPbrStartEditing();
LLMenuButton* mMenuClipboardColor;
LLMenuButton* mMenuClipboardTexture;
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
diff --git a/indra/newview/skins/default/xui/en/panel_tools_texture.xml b/indra/newview/skins/default/xui/en/panel_tools_texture.xml
index ff2323784c..e2d571324f 100644
--- a/indra/newview/skins/default/xui/en/panel_tools_texture.xml
+++ b/indra/newview/skins/default/xui/en/panel_tools_texture.xml
@@ -239,28 +239,46 @@
width="160" />
<texture_picker
can_apply_immediately="true"
- default_image_name="Default"
- fallback_image="materials_ui_x_24.png"
+ allow_no_texture="true"
follows="left|top"
height="80"
- label="Texture "
+ label="PBR "
layout="topleft"
left="10"
- name="texture control"
- tool_tip="Click to choose a picture"
+ name="pbr_control"
+ tool_tip="Click to choose a pbr material"
top_pad="5"
width="64" />
+ <button
+ follows="left|top"
+ height="23"
+ layout="topleft"
+ left_pad="10"
+ top_delta="0"
+ name="pbr_from_inventory"
+ label="Choose from inventory"
+ width="140"/>
+ <button
+ follows="left|top"
+ height="23"
+ layout="topleft"
+ left_delta="0"
+ top_pad="4"
+ name="edit_selected_pbr"
+ label="Edit Selected"
+ width="140"/>
<texture_picker
can_apply_immediately="true"
- allow_no_texture="true"
+ default_image_name="Default"
+ fallback_image="materials_ui_x_24.png"
follows="left|top"
height="80"
- label="PBR "
+ label="Texture "
layout="topleft"
left="10"
- name="pbr_control"
- tool_tip="Click to choose a pbr material"
- top_delta="0"
+ name="texture control"
+ tool_tip="Click to choose a picture"
+ top_delta="-27"
width="64" />
<text
type="string"