summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcosmic-linden <111533034+cosmic-linden@users.noreply.github.com>2023-08-14 09:29:58 -0700
committerGitHub <noreply@github.com>2023-08-14 09:29:58 -0700
commit50e2973cd2360dedd6baf1c0772d9d009e2628d4 (patch)
tree71a86030d3d52045642ea1a21168a2effc98e4f6
parentd8e4572b901b429439f991703f2bc12f81e03901 (diff)
parent076a02e2d8ddb10856602c3f5f3115ace41327b5 (diff)
Merge pull request #323 from secondlife/SL-20024
SL-20024: Improve material permissions handling
-rw-r--r--indra/llinventory/llpermissions.h4
-rw-r--r--indra/llprimitive/llmaterial.cpp11
-rw-r--r--indra/llprimitive/llmaterial.h2
-rw-r--r--indra/newview/app_settings/settings.xml2
-rw-r--r--indra/newview/llmaterialeditor.cpp333
-rw-r--r--indra/newview/llmaterialeditor.h11
-rw-r--r--indra/newview/llpanelface.cpp101
-rw-r--r--indra/newview/llpanelface.h11
-rw-r--r--indra/newview/llpreview.cpp20
-rw-r--r--indra/newview/llpreview.h2
-rw-r--r--indra/newview/llselectmgr.cpp36
-rw-r--r--indra/newview/llselectmgr.h14
-rw-r--r--indra/newview/lltooldraganddrop.cpp43
-rw-r--r--indra/newview/llviewerinventory.cpp61
-rw-r--r--indra/newview/llviewerinventory.h4
-rw-r--r--indra/newview/llviewerobject.cpp11
-rw-r--r--indra/newview/llviewerobject.h1
-rw-r--r--indra/newview/skins/default/xui/en/notifications.xml12
-rw-r--r--indra/newview/skins/default/xui/en/panel_tools_texture.xml16
19 files changed, 551 insertions, 144 deletions
diff --git a/indra/llinventory/llpermissions.h b/indra/llinventory/llpermissions.h
index 27252f7b97..32fae844fb 100644
--- a/indra/llinventory/llpermissions.h
+++ b/indra/llinventory/llpermissions.h
@@ -251,7 +251,9 @@ public:
BOOL setNextOwnerBits(const LLUUID& agent, const LLUUID& group, BOOL set, PermissionMask bits);
// This is currently only used in the Viewer to handle calling cards
- // where the creator is actually used to store the target. Use with care.
+ // where the creator is actually used to store the target.
+ // It is also used for saving a GLTF material on a prim.
+ // Use with care.
void setCreator(const LLUUID& creator) { mCreator = creator; }
//
diff --git a/indra/llprimitive/llmaterial.cpp b/indra/llprimitive/llmaterial.cpp
index f6cb3c8b70..0d146de949 100644
--- a/indra/llprimitive/llmaterial.cpp
+++ b/indra/llprimitive/llmaterial.cpp
@@ -332,17 +332,6 @@ void LLMaterial::setAlphaMaskCutoff(U8 cutoff)
mAlphaMaskCutoff = cutoff;
}
-LLUUID LLMaterial::getMaterialID() const
-{
- // TODO - not null
- return LLUUID::null;
-}
-
-void LLMaterial::setMaterialID(const LLUUID &material_id)
-{
- // TODO - set
-}
-
LLSD LLMaterial::asLLSD() const
{
LLSD material_data;
diff --git a/indra/llprimitive/llmaterial.h b/indra/llprimitive/llmaterial.h
index b46d85c2d1..81f41ddc51 100644
--- a/indra/llprimitive/llmaterial.h
+++ b/indra/llprimitive/llmaterial.h
@@ -115,8 +115,6 @@ public:
void setDiffuseAlphaMode(U8 alpha_mode);
U8 getAlphaMaskCutoff() const;
void setAlphaMaskCutoff(U8 cutoff);
- LLUUID getMaterialID() const;
- void setMaterialID(LLUUID const & material_id);
bool isNull() const;
static const LLMaterial null;
diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml
index 0cd63d9d5f..b92a829f36 100644
--- a/indra/newview/app_settings/settings.xml
+++ b/indra/newview/app_settings/settings.xml
@@ -250,7 +250,7 @@
<key>TextureLivePreview</key>
<map>
<key>Comment</key>
- <string>Preview selections in texture picker immediately</string>
+ <string>Preview selections in texture picker or material picker immediately</string>
<key>Persist</key>
<integer>1</integer>
<key>Type</key>
diff --git a/indra/newview/llmaterialeditor.cpp b/indra/newview/llmaterialeditor.cpp
index 3a0e64985c..41df58914b 100644
--- a/indra/newview/llmaterialeditor.cpp
+++ b/indra/newview/llmaterialeditor.cpp
@@ -37,6 +37,7 @@
#include "llfilesystem.h"
#include "llgltfmateriallist.h"
#include "llinventorymodel.h"
+#include "llinventoryobserver.h"
#include "lllocalgltfmaterials.h"
#include "llnotificationsutil.h"
#include "lltexturectrl.h"
@@ -237,7 +238,9 @@ struct LLSelectedTEGetMatData : public LLSelectedTEFunctor
LLUUID mTexEmissiveId;
LLUUID mTexNormalId;
LLUUID mObjectId;
+ LLViewerObject* mObject = nullptr;
S32 mObjectTE;
+ LLUUID mMaterialId;
LLPointer<LLGLTFMaterial> mMaterial;
LLPointer<LLLocalGLTFMaterial> mLocalMaterial;
};
@@ -259,6 +262,7 @@ bool LLSelectedTEGetMatData::apply(LLViewerObject* objectp, S32 te_index)
return false;
}
LLUUID mat_id = objectp->getRenderMaterialID(te_index);
+ mMaterialId = mat_id;
bool can_use = mIsOverride ? objectp->permModify() : objectp->permCopy();
LLTextureEntry *tep = objectp->getTE(te_index);
// We might want to disable this entirely if at least
@@ -290,6 +294,7 @@ bool LLSelectedTEGetMatData::apply(LLViewerObject* objectp, S32 te_index)
mTexEmissiveId = tex_emissive_id;
mTexNormalId = tex_normal_id;
mObjectTE = te_index;
+ mObject = objectp;
mObjectId = objectp->getID();
mFirst = false;
}
@@ -318,6 +323,8 @@ bool LLSelectedTEGetMatData::apply(LLViewerObject* objectp, S32 te_index)
LLGLTFMaterial *mat = tep->getGLTFMaterial();
LLLocalGLTFMaterial *local_mat = dynamic_cast<LLLocalGLTFMaterial*>(mat);
+ mObject = objectp;
+ mObjectId = objectp->getID();
if (local_mat)
{
mLocalMaterial = local_mat;
@@ -1192,7 +1199,9 @@ bool LLMaterialEditor::saveIfNeeded()
{
//make a new inventory item
std::string res_desc = buildMaterialDescription();
- createInventoryItem(buffer, mMaterialName, res_desc);
+ LLPermissions local_permissions;
+ local_permissions.init(gAgent.getID(), gAgent.getID(), LLUUID::null, LLUUID::null);
+ createInventoryItem(buffer, mMaterialName, res_desc, local_permissions);
// We do not update floater with uploaded asset yet, so just close it.
closeFloater();
@@ -1286,36 +1295,37 @@ bool LLMaterialEditor::updateInventoryItem(const std::string &buffer, const LLUU
return true;
}
-void LLMaterialEditor::createInventoryItem(const std::string &buffer, const std::string &name, const std::string &desc)
+// Callback intended for when a material is saved from an object and needs to
+// be modified to reflect the new asset/name.
+class LLObjectsMaterialItemCallback : public LLInventoryCallback
{
- // gen a new uuid for this asset
- LLTransactionID tid;
- tid.generate(); // timestamp-based randomization + uniquification
- U32 next_owner_perm = LLFloaterPerms::getNextOwnerPerms("Materials");
- LLUUID parent = gInventory.findUserDefinedCategoryUUIDForType(LLFolderType::FT_MATERIAL);
- const U8 subtype = NO_INV_SUBTYPE; // TODO maybe use AT_SETTINGS and LLSettingsType::ST_MATERIAL ?
+public:
+ LLObjectsMaterialItemCallback(const LLPermissions& permissions, const std::string& asset_data, const std::string& new_name)
+ : mPermissions(permissions),
+ mAssetData(asset_data),
+ mNewName(new_name)
+ {
+ }
- create_inventory_item(gAgent.getID(), gAgent.getSessionID(), parent, tid, name, desc,
- LLAssetType::AT_MATERIAL, LLInventoryType::IT_MATERIAL, subtype, next_owner_perm,
- new LLBoostFuncInventoryCallback([output = buffer](LLUUID const& inv_item_id)
+ void fire(const LLUUID& inv_item_id) override
{
LLViewerInventoryItem* item = gInventory.getItem(inv_item_id);
- if (item)
+ if (!item)
{
- // create_inventory_item doesn't allow presetting some permissions, fix it now
- LLPermissions perm = item->getPermissions();
- if (perm.getMaskEveryone() != LLFloaterPerms::getEveryonePerms("Materials")
- || perm.getMaskGroup() != LLFloaterPerms::getGroupPerms("Materials"))
- {
- perm.setMaskEveryone(LLFloaterPerms::getEveryonePerms("Materials"));
- perm.setMaskGroup(LLFloaterPerms::getGroupPerms("Materials"));
+ return;
+ }
- item->setPermissions(perm);
+ // create_inventory_item/copy_inventory_item don't allow presetting some permissions, fix it now
+ item->setPermissions(mPermissions);
+ item->updateServer(FALSE);
+ gInventory.updateItem(item);
+ gInventory.notifyObservers();
- item->updateServer(FALSE);
- gInventory.updateItem(item);
- gInventory.notifyObservers();
- }
+ if (item->getName() != mNewName)
+ {
+ LLSD updates;
+ updates["name"] = mNewName;
+ update_inventory_item(inv_item_id, updates, NULL);
}
// from reference in LLSettingsVOBase::createInventoryItem()/updateInventoryItem()
@@ -1323,7 +1333,7 @@ void LLMaterialEditor::createInventoryItem(const std::string &buffer, const std:
std::make_shared<LLBufferedAssetUploadInfo>(
inv_item_id,
LLAssetType::AT_MATERIAL,
- output,
+ mAssetData,
[](LLUUID item_id, LLUUID new_asset_id, LLUUID new_item_id, LLSD response)
{
// done callback
@@ -1342,8 +1352,25 @@ void LLMaterialEditor::createInventoryItem(const std::string &buffer, const std:
}
LLViewerAssetUpload::EnqueueInventoryUpload(agent_url, uploadInfo);
}
- })
- );
+ }
+private:
+ LLPermissions mPermissions;
+ std::string mAssetData;
+ std::string mNewName;
+};
+
+void LLMaterialEditor::createInventoryItem(const std::string &buffer, const std::string &name, const std::string &desc, const LLPermissions& permissions)
+{
+ // gen a new uuid for this asset
+ LLTransactionID tid;
+ tid.generate(); // timestamp-based randomization + uniquification
+ LLUUID parent = gInventory.findUserDefinedCategoryUUIDForType(LLFolderType::FT_MATERIAL);
+ const U8 subtype = NO_INV_SUBTYPE; // TODO maybe use AT_SETTINGS and LLSettingsType::ST_MATERIAL ?
+
+ LLPointer<LLObjectsMaterialItemCallback> cb = new LLObjectsMaterialItemCallback(permissions, buffer, name);
+ create_inventory_item(gAgent.getID(), gAgent.getSessionID(), parent, tid, name, desc,
+ LLAssetType::AT_MATERIAL, LLInventoryType::IT_MATERIAL, subtype, permissions.getMaskNextOwner(),
+ cb);
}
void LLMaterialEditor::finishInventoryUpload(LLUUID itemId, LLUUID newAssetId, LLUUID newItemId)
@@ -1792,55 +1819,142 @@ void LLMaterialEditor::loadLive()
}
}
-void LLMaterialEditor::saveObjectsMaterialAs()
+// *NOTE: permissions_out includes user preferences for new item creation (LLFloaterPerms)
+bool can_use_objects_material(LLSelectedTEGetMatData& func, const std::vector<PermissionBit>& ops, LLPermissions& permissions_out, LLViewerInventoryItem*& item_out)
{
- LLSelectedTEGetMatData func(false);
+ if (!LLMaterialEditor::capabilitiesAvailable())
+ {
+ return false;
+ }
+
LLSelectMgr::getInstance()->getSelection()->applyToTEs(&func, true /*first applicable*/);
- saveMaterialAs(func.mMaterial, func.mLocalMaterial);
-}
-void LLMaterialEditor::savePickedMaterialAs()
-{
- LLPickInfo pick = LLToolPie::getInstance()->getPick();
- if (pick.mPickType != LLPickInfo::PICK_OBJECT || !pick.getObject())
+ LLViewerObject* selected_object = func.mObject;
+ if (!selected_object)
{
- return;
+ // LLSelectedTEGetMatData can fail if there are no selected faces
+ // with materials, but we expect at least some object is selected.
+ llassert(LLSelectMgr::getInstance()->getSelection()->getFirstObject());
+ return false;
+ }
+ for (PermissionBit op : ops)
+ {
+ if (op == PERM_MODIFY && selected_object->isPermanentEnforced())
+ {
+ return false;
+ }
}
- LLPointer<LLGLTFMaterial> render_material;
- LLPointer<LLLocalGLTFMaterial> local_material;
+ item_out = selected_object->getInventoryItemByAsset(func.mMaterialId);
- LLViewerObject *objectp = pick.getObject();
- LLUUID mat_id = objectp->getRenderMaterialID(pick.mObjectFace);
- if (mat_id.notNull() && objectp->permCopy())
+ LLPermissions item_permissions;
+ if (item_out)
{
- // Try a face user picked first
- // (likely the only method we need, but in such case
- // enable_object_save_gltf_material will need to check this)
- LLTextureEntry *tep = objectp->getTE(pick.mObjectFace);
- LLGLTFMaterial *mat = tep->getGLTFMaterial();
- LLLocalGLTFMaterial *local_mat = dynamic_cast<LLLocalGLTFMaterial*>(mat);
+ item_permissions.set(item_out->getPermissions());
+ for (PermissionBit op : ops)
+ {
+ if (!gAgent.allowOperation(op, item_permissions, GP_OBJECT_MANIPULATE))
+ {
+ return false;
+ }
+ }
+ // Update flags for new owner
+ if (!item_permissions.setOwnerAndGroup(LLUUID::null, gAgent.getID(), LLUUID::null, true))
+ {
+ llassert(false);
+ return false;
+ }
+ }
+ else
+ {
+ item_permissions.init(gAgent.getID(), gAgent.getID(), LLUUID::null, LLUUID::null);
+ }
- if (local_mat)
+ // Use root object for permissions checking
+ LLViewerObject* root_object = selected_object->getRootEdit();
+ LLPermissions* object_permissions_p = LLSelectMgr::getInstance()->findObjectPermissions(root_object);
+ LLPermissions object_permissions;
+ if (object_permissions_p)
+ {
+ object_permissions.set(*object_permissions_p);
+ for (PermissionBit op : ops)
{
- local_material = local_mat;
+ if (!gAgent.allowOperation(op, object_permissions, GP_OBJECT_MANIPULATE))
+ {
+ return false;
+ }
+ }
+ // Update flags for new owner
+ if (!object_permissions.setOwnerAndGroup(LLUUID::null, gAgent.getID(), LLUUID::null, true))
+ {
+ llassert(false);
+ return false;
}
- render_material = tep->getGLTFRenderMaterial();
}
else
{
- // Find an applicable material.
- // Do this before showing message, because
- // message is going to drop selection.
- LLSelectedTEGetMatData func(false);
- LLSelectMgr::getInstance()->getSelection()->applyToTEs(&func, true /*first applicable*/);
- local_material = func.mLocalMaterial;
- render_material = func.mMaterial;
+ object_permissions.init(gAgent.getID(), gAgent.getID(), LLUUID::null, LLUUID::null);
}
- saveMaterialAs(render_material, local_material);
+ LLPermissions floater_perm;
+ floater_perm.init(gAgent.getID(), gAgent.getID(), LLUUID::null, LLUUID::null);
+ floater_perm.setMaskEveryone(LLFloaterPerms::getEveryonePerms("Materials"));
+ floater_perm.setMaskGroup(LLFloaterPerms::getGroupPerms("Materials"));
+ floater_perm.setMaskNext(LLFloaterPerms::getNextOwnerPerms("Materials"));
+
+ // *NOTE: A close inspection of LLPermissions::accumulate shows that
+ // conflicting UUIDs will be unset. This is acceptable behavior for now.
+ // The server will populate creator info based on the item creation method
+ // used.
+ // *NOTE: As far as I'm aware, there is currently no good way to preserve
+ // creation history when there's no material item present. In that case,
+ // the agent who saved the material will be considered the creator.
+ // -Cosmic,2023-08-07
+ if (item_out)
+ {
+ permissions_out.set(item_permissions);
+ }
+ else
+ {
+ permissions_out.set(object_permissions);
+ }
+ permissions_out.accumulate(floater_perm);
+
+ return true;
+}
+
+bool LLMaterialEditor::canModifyObjectsMaterial()
+{
+ LLSelectedTEGetMatData func(false);
+ LLPermissions permissions;
+ LLViewerInventoryItem* item_out;
+ return can_use_objects_material(func, std::vector({PERM_MODIFY}), permissions, item_out);
+}
+
+bool LLMaterialEditor::canSaveObjectsMaterial()
+{
+ LLSelectedTEGetMatData func(false);
+ LLPermissions permissions;
+ LLViewerInventoryItem* item_out;
+ return can_use_objects_material(func, std::vector({PERM_COPY, PERM_MODIFY}), permissions, item_out);
+}
+
+void LLMaterialEditor::saveObjectsMaterialAs()
+{
+ LLSelectedTEGetMatData func(false);
+ LLPermissions permissions;
+ LLViewerInventoryItem* item = nullptr;
+ bool allowed = can_use_objects_material(func, std::vector({PERM_COPY, PERM_MODIFY}), permissions, item);
+ if (!allowed)
+ {
+ LL_WARNS("MaterialEditor") << "Failed to save GLTF material from object" << LL_ENDL;
+ return;
+ }
+ const LLUUID item_id = item ? item->getUUID() : LLUUID::null;
+ saveObjectsMaterialAs(func.mMaterial, func.mLocalMaterial, permissions, func.mObjectId, item_id);
}
-void LLMaterialEditor::saveMaterialAs(const LLGLTFMaterial* render_material, const LLLocalGLTFMaterial *local_material)
+
+void LLMaterialEditor::saveObjectsMaterialAs(const LLGLTFMaterial* render_material, const LLLocalGLTFMaterial *local_material, const LLPermissions& permissions, const LLUUID& object_id, const LLUUID& item_id)
{
if (local_material)
{
@@ -1916,26 +2030,98 @@ void LLMaterialEditor::saveMaterialAs(const LLGLTFMaterial* render_material, con
LLSD args;
args["DESC"] = LLTrans::getString("New Material");
- LLNotificationsUtil::add("SaveMaterialAs", args, payload, boost::bind(&LLMaterialEditor::onSaveObjectsMaterialAsMsgCallback, _1, _2));
+ if (local_material)
+ {
+ LLPermissions local_permissions;
+ local_permissions.init(gAgent.getID(), gAgent.getID(), LLUUID::null, LLUUID::null);
+ LLNotificationsUtil::add("SaveMaterialAs", args, payload, boost::bind(&LLMaterialEditor::onSaveObjectsMaterialAsMsgCallback, _1, _2, local_permissions));
+ }
+ else
+ {
+ if (item_id.notNull())
+ {
+ // Copy existing item from object inventory, and create new composite asset on top of it
+ LLNotificationsUtil::add("SaveMaterialAs", args, payload, boost::bind(&LLMaterialEditor::onCopyObjectsMaterialAsMsgCallback, _1, _2, permissions, object_id, item_id));
+ }
+ else
+ {
+ LLNotificationsUtil::add("SaveMaterialAs", args, payload, boost::bind(&LLMaterialEditor::onSaveObjectsMaterialAsMsgCallback, _1, _2, permissions));
+ }
+ }
}
-void LLMaterialEditor::onSaveObjectsMaterialAsMsgCallback(const LLSD& notification, const LLSD& response)
+// static
+void LLMaterialEditor::onCopyObjectsMaterialAsMsgCallback(const LLSD& notification, const LLSD& response, const LLPermissions& permissions, const LLUUID& object_id, const LLUUID& item_id)
{
S32 option = LLNotificationsUtil::getSelectedOption(notification, response);
- if (0 == option)
+ if (0 != option)
+ {
+ return;
+ }
+
+ LLSD asset;
+ asset["version"] = LLGLTFMaterial::ASSET_VERSION;
+ asset["type"] = LLGLTFMaterial::ASSET_TYPE;
+ // This is the string serialized from LLGLTFMaterial::asJSON
+ asset["data"] = notification["payload"]["data"];
+
+ std::ostringstream str;
+ LLSDSerialize::serialize(asset, str, LLSDSerialize::LLSD_BINARY);
+
+ LLViewerObject* object = gObjectList.findObject(object_id);
+ if (!object)
+ {
+ return;
+ }
+ const LLInventoryItem* item = object->getInventoryItem(item_id);
+ if (!item)
{
- LLSD asset;
- asset["version"] = LLGLTFMaterial::ASSET_VERSION;
- asset["type"] = LLGLTFMaterial::ASSET_TYPE;
- // This is the string serialized from LLGLTFMaterial::asJSON
- asset["data"] = notification["payload"]["data"];
+ return;
+ }
- std::ostringstream str;
- LLSDSerialize::serialize(asset, str, LLSDSerialize::LLSD_BINARY);
+ std::string new_name = response["message"].asString();
+ LLInventoryObject::correctInventoryName(new_name);
+ if (new_name.empty())
+ {
+ return;
+ }
- std::string new_name = response["message"].asString();
- createInventoryItem(str.str(), new_name, std::string());
+ const LLUUID destination_id = gInventory.findCategoryUUIDForType(LLFolderType::FT_MATERIAL);
+
+ LLPointer<LLInventoryCallback> cb = new LLObjectsMaterialItemCallback(permissions, str.str(), new_name);
+ // NOTE: This should be an item copy. Saving a material to an inventory should be disabled when the associated material is no-copy.
+ move_or_copy_inventory_from_object(destination_id,
+ object_id,
+ item_id,
+ cb);
+}
+
+// static
+void LLMaterialEditor::onSaveObjectsMaterialAsMsgCallback(const LLSD& notification, const LLSD& response, const LLPermissions& permissions)
+{
+ S32 option = LLNotificationsUtil::getSelectedOption(notification, response);
+ if (0 != option)
+ {
+ return;
}
+
+ LLSD asset;
+ asset["version"] = LLGLTFMaterial::ASSET_VERSION;
+ asset["type"] = LLGLTFMaterial::ASSET_TYPE;
+ // This is the string serialized from LLGLTFMaterial::asJSON
+ asset["data"] = notification["payload"]["data"];
+
+ std::ostringstream str;
+ LLSDSerialize::serialize(asset, str, LLSDSerialize::LLSD_BINARY);
+
+ std::string new_name = response["message"].asString();
+ LLInventoryObject::correctInventoryName(new_name);
+ if (new_name.empty())
+ {
+ return;
+ }
+
+ createInventoryItem(str.str(), new_name, std::string(), permissions);
}
const void upload_bulk(const std::vector<std::string>& filenames, LLFilePicker::ELoadFilter type);
@@ -2708,7 +2894,10 @@ bool LLMaterialEditor::setFromSelection()
if (func.mMaterial.notNull())
{
setFromGLTFMaterial(func.mMaterial);
- setEnableEditing(true);
+ LLViewerObject* selected_object = func.mObject;
+ const LLViewerInventoryItem* item = selected_object->getInventoryItemByAsset(func.mMaterialId);
+ const bool allow_modify = !item || canModify(selected_object, item);
+ setEnableEditing(allow_modify);
}
else
{
diff --git a/indra/newview/llmaterialeditor.h b/indra/newview/llmaterialeditor.h
index 6f674a4170..6b2f49e2fc 100644
--- a/indra/newview/llmaterialeditor.h
+++ b/indra/newview/llmaterialeditor.h
@@ -38,6 +38,7 @@ class LLGLTFMaterial;
class LLLocalGLTFMaterial;
class LLTextureCtrl;
class LLTextBox;
+class LLViewerInventoryItem;
namespace tinygltf
{
@@ -112,9 +113,11 @@ class LLMaterialEditor : public LLPreview, public LLVOInventoryListener
static void updateLive(const LLUUID &object_id, S32 te);
static void loadLive();
+ static bool canModifyObjectsMaterial();
+ static bool canSaveObjectsMaterial();
static void saveObjectsMaterialAs();
- static void savePickedMaterialAs();
- static void onSaveObjectsMaterialAsMsgCallback(const LLSD& notification, const LLSD& response);
+ static void onCopyObjectsMaterialAsMsgCallback(const LLSD& notification, const LLSD& response, const LLPermissions& permissions, const LLUUID& object_id, const LLUUID& item_id);
+ static void onSaveObjectsMaterialAsMsgCallback(const LLSD& notification, const LLSD& response, const LLPermissions& permissions);
static void onLoadComplete(const LLUUID& asset_uuid, LLAssetType::EType type, void* user_data, S32 status, LLExtStat ext_status);
@@ -229,10 +232,10 @@ class LLMaterialEditor : public LLPreview, public LLVOInventoryListener
static bool capabilitiesAvailable();
private:
- static void saveMaterialAs(const LLGLTFMaterial *render_material, const LLLocalGLTFMaterial *local_material);
+ static void saveObjectsMaterialAs(const LLGLTFMaterial *render_material, const LLLocalGLTFMaterial *local_material, const LLPermissions& permissions, const LLUUID& object_id /* = LLUUID::null */, const LLUUID& item /* = LLUUID::null */);
static bool updateInventoryItem(const std::string &buffer, const LLUUID &item_id, const LLUUID &task_id);
- static void createInventoryItem(const std::string &buffer, const std::string &name, const std::string &desc);
+ static void createInventoryItem(const std::string &buffer, const std::string &name, const std::string &desc, const LLPermissions& permissions);
void setFromGLTFMaterial(LLGLTFMaterial* mat);
bool setFromSelection();
diff --git a/indra/newview/llpanelface.cpp b/indra/newview/llpanelface.cpp
index 837217387f..21651899db 100644
--- a/indra/newview/llpanelface.cpp
+++ b/indra/newview/llpanelface.cpp
@@ -51,6 +51,7 @@
#include "llinventorymodelbackgroundfetch.h"
#include "llfloatermediasettings.h"
#include "llfloaterreg.h"
+#include "llfloatertools.h"
#include "lllineeditor.h"
#include "llmaterialmgr.h"
#include "llmaterialeditor.h"
@@ -77,6 +78,7 @@
#include "llviewerregion.h"
#include "llviewerstats.h"
#include "llvovolume.h"
+#include "llvoinventorylistener.h"
#include "lluictrlfactory.h"
#include "llpluginclassmedia.h"
#include "llviewertexturelist.h"// Update sel manager as to which channel we're editing so it can reflect the correct overlay UI
@@ -1100,7 +1102,7 @@ void LLPanelFace::updateUI(bool force_set_values /*false*/)
getChildView("checkbox_sync_settings")->setEnabled(editable);
childSetValue("checkbox_sync_settings", gSavedSettings.getBOOL("SyncMaterialSettings"));
- updateVisibility();
+ updateVisibility(objectp);
// Color swatch
{
@@ -1834,13 +1836,54 @@ void LLPanelFace::updateUI(bool force_set_values /*false*/)
}
}
+// One-off listener that updates the build floater UI when the prim inventory updates
+class PBRPickerItemListener : public LLVOInventoryListener
+{
+protected:
+ LLViewerObject* mObjectp;
+ bool mChangePending = true;
+public:
+
+ PBRPickerItemListener(LLViewerObject* object)
+ : mObjectp(object)
+ {
+ registerVOInventoryListener(mObjectp, nullptr);
+ }
+
+ const bool isListeningFor(const LLViewerObject* objectp) const
+ {
+ return mChangePending && (objectp == mObjectp);
+ }
+
+ void inventoryChanged(LLViewerObject* object,
+ LLInventoryObject::object_list_t* inventory,
+ S32 serial_num,
+ void* user_data) override
+ {
+ if (gFloaterTools)
+ {
+ gFloaterTools->dirty();
+ }
+ removeVOInventoryListener();
+ mChangePending = false;
+ }
+
+ ~PBRPickerItemListener()
+ {
+ removeVOInventoryListener();
+ mChangePending = false;
+ }
+};
+
void LLPanelFace::updateUIGLTF(LLViewerObject* objectp, bool& has_pbr_material, bool& has_faces_without_pbr, bool force_set_values)
{
has_pbr_material = false;
- const bool editable = objectp->permModify() && !objectp->isPermanentEnforced();
bool has_pbr_capabilities = LLMaterialEditor::capabilitiesAvailable();
bool identical_pbr = true;
+ const bool settable = has_pbr_capabilities && objectp->permModify() && !objectp->isPermanentEnforced();
+ const bool editable = LLMaterialEditor::canModifyObjectsMaterial();
+ const bool saveable = LLMaterialEditor::canSaveObjectsMaterial();
// pbr material
LLTextureCtrl* pbr_ctrl = findChild<LLTextureCtrl>("pbr_control");
@@ -1850,13 +1893,26 @@ void LLPanelFace::updateUIGLTF(LLViewerObject* objectp, bool& has_pbr_material,
LLSelectedTE::getPbrMaterialId(pbr_id, identical_pbr, has_pbr_material, has_faces_without_pbr);
pbr_ctrl->setTentative(identical_pbr ? FALSE : TRUE);
- pbr_ctrl->setEnabled(editable && has_pbr_capabilities);
+ pbr_ctrl->setEnabled(settable);
pbr_ctrl->setImageAssetID(pbr_id);
}
- getChildView("pbr_from_inventory")->setEnabled(editable && has_pbr_capabilities);
- getChildView("edit_selected_pbr")->setEnabled(editable && has_pbr_material && !has_faces_without_pbr && has_pbr_capabilities);
- getChildView("save_selected_pbr")->setEnabled(objectp->permCopy() && has_pbr_material && identical_pbr && has_pbr_capabilities);
+ const bool inventory_pending = objectp->isInventoryPending();
+ getChildView("pbr_from_inventory")->setEnabled(settable);
+ getChildView("edit_selected_pbr")->setEnabled(editable && !inventory_pending && !has_faces_without_pbr);
+ getChildView("save_selected_pbr")->setEnabled(saveable && !inventory_pending && identical_pbr);
+ if (inventory_pending)
+ {
+ // Reuse the same listener when possible
+ if (!mInventoryListener || !mInventoryListener->isListeningFor(objectp))
+ {
+ mInventoryListener = std::make_unique<PBRPickerItemListener>(objectp);
+ }
+ }
+ else
+ {
+ mInventoryListener = nullptr;
+ }
const bool show_pbr = mComboMatMedia->getCurrentIndex() == MATMEDIA_PBR && mComboMatMedia->getEnabled();
if (show_pbr)
@@ -1881,9 +1937,10 @@ void LLPanelFace::updateUIGLTF(LLViewerObject* objectp, bool& has_pbr_material,
}
}
-void LLPanelFace::updateVisibilityGLTF()
+void LLPanelFace::updateVisibilityGLTF(LLViewerObject* objectp /*= nullptr */)
{
const bool show_pbr = mComboMatMedia->getCurrentIndex() == MATMEDIA_PBR && mComboMatMedia->getEnabled();
+ const bool inventory_pending = objectp && objectp->isInventoryPending();
LLRadioGroup* radio_pbr_type = findChild<LLRadioGroup>("radio_pbr_type");
radio_pbr_type->setVisible(show_pbr);
@@ -1894,8 +1951,9 @@ void LLPanelFace::updateVisibilityGLTF()
getChildView("pbr_control")->setVisible(show_pbr_render_material_id);
getChildView("pbr_from_inventory")->setVisible(show_pbr_render_material_id);
- getChildView("edit_selected_pbr")->setVisible(show_pbr_render_material_id);
- getChildView("save_selected_pbr")->setVisible(show_pbr_render_material_id);
+ getChildView("edit_selected_pbr")->setVisible(show_pbr_render_material_id && !inventory_pending);
+ getChildView("save_selected_pbr")->setVisible(show_pbr_render_material_id && !inventory_pending);
+ getChildView("material_permissions_loading_label")->setVisible(show_pbr_render_material_id && inventory_pending);
getChildView("gltfTextureScaleU")->setVisible(show_pbr);
getChildView("gltfTextureScaleV")->setVisible(show_pbr);
@@ -2736,7 +2794,7 @@ void LLPanelFace::onCommitMaterialsMedia(LLUICtrl* ctrl, void* userdata)
self->refreshMedia();
}
-void LLPanelFace::updateVisibility()
+void LLPanelFace::updateVisibility(LLViewerObject* objectp /* = nullptr */)
{
LLRadioGroup* radio_mat_type = findChild<LLRadioGroup>("radio_material_type");
LLRadioGroup* radio_pbr_type = findChild<LLRadioGroup>("radio_pbr_type");
@@ -2827,7 +2885,7 @@ void LLPanelFace::updateVisibility()
getChild<LLSpinCtrl>("rptctrl")->setVisible(show_material || show_media);
// PBR controls
- updateVisibilityGLTF();
+ updateVisibilityGLTF(objectp);
}
// static
@@ -3093,11 +3151,7 @@ void LLPanelFace::onSelectPbr(const LLSD& data)
{
id = pbr_ctrl->getImageAssetID();
}
- if (LLSelectMgr::getInstance()->selectionSetGLTFMaterial(id))
- {
- LLSelectedTEMaterial::setMaterialID(this, id);
- }
- else
+ if (!LLSelectMgr::getInstance()->selectionSetGLTFMaterial(id))
{
refresh();
}
@@ -4994,23 +5048,24 @@ void LLPanelFace::onPbrSelectionChanged(LLInventoryItem* itemp)
LLSaleInfo sale_info;
LLSelectMgr::instance().selectGetSaleInfo(sale_info);
- bool can_copy = itemp->getPermissions().allowCopyBy(gAgentID); // do we have perm to copy this texture?
- bool can_transfer = itemp->getPermissions().allowOperationBy(PERM_TRANSFER, gAgentID); // do we have perm to transfer this texture?
- bool is_object_owner = gAgentID == obj_owner_id; // does object for which we are going to apply texture belong to the agent?
- bool not_for_sale = !sale_info.isForSale(); // is object for which we are going to apply texture not for sale?
+ bool can_copy = itemp->getPermissions().allowCopyBy(gAgentID); // do we have perm to copy this material?
+ bool can_transfer = itemp->getPermissions().allowOperationBy(PERM_TRANSFER, gAgentID); // do we have perm to transfer this material?
+ bool can_modify = itemp->getPermissions().allowOperationBy(PERM_MODIFY, gAgentID); // do we have perm to transfer this material?
+ bool is_object_owner = gAgentID == obj_owner_id; // does object for which we are going to apply material belong to the agent?
+ bool not_for_sale = !sale_info.isForSale(); // is object for which we are going to apply material not for sale?
- if (can_copy && can_transfer)
+ if (can_copy && can_transfer && can_modify)
{
pbr_ctrl->setCanApply(true, true);
return;
}
- // if texture has (no-transfer) attribute it can be applied only for object which we own and is not for sale
+ // if material has (no-transfer) attribute it can be applied only for object which we own and is not for sale
pbr_ctrl->setCanApply(false, can_transfer ? true : is_object_owner && not_for_sale);
if (gSavedSettings.getBOOL("TextureLivePreview"))
{
- LLNotificationsUtil::add("LivePreviewUnavailable");
+ LLNotificationsUtil::add("LivePreviewUnavailablePBR");
}
}
}
diff --git a/indra/newview/llpanelface.h b/indra/newview/llpanelface.h
index f6a813f9e5..d07be2e4b4 100644
--- a/indra/newview/llpanelface.h
+++ b/indra/newview/llpanelface.h
@@ -35,6 +35,8 @@
#include "lltextureentry.h"
#include "llselectmgr.h"
+#include <memory>
+
class LLButton;
class LLCheckBoxCtrl;
class LLColorSwatchCtrl;
@@ -51,6 +53,8 @@ class LLMaterialID;
class LLMediaCtrl;
class LLMenuButton;
+class PBRPickerItemListener;
+
// Represents an edit for use in replicating the op across one or more materials in the selection set.
//
// The apply function optionally performs the edit which it implements
@@ -292,7 +296,7 @@ private:
//
// Do NOT call updateUI from within this function.
//
- void updateVisibility();
+ void updateVisibility(LLViewerObject* objectp = nullptr);
// Hey look everyone, a type-safe alternative to copy and paste! :)
//
@@ -453,7 +457,7 @@ private:
void onPbrSelectionChanged(LLInventoryItem* itemp);
void updateUIGLTF(LLViewerObject* objectp, bool& has_pbr_material, bool& has_faces_without_pbr, bool force_set_values);
- void updateVisibilityGLTF();
+ void updateVisibilityGLTF(LLViewerObject* objectp = nullptr);
void updateSelectedGLTFMaterials(std::function<void(LLGLTFMaterial*)> func);
void updateGLTFTextureTransform(float value, U32 pbr_type, std::function<void(LLGLTFMaterial::TextureTransform*)> edit);
@@ -503,6 +507,8 @@ private:
static Selection sMaterialOverrideSelection;
+ std::unique_ptr<PBRPickerItemListener> mInventoryListener;
+
public:
#if defined(DEF_GET_MAT_STATE)
#undef DEF_GET_MAT_STATE
@@ -583,7 +589,6 @@ public:
DEF_EDIT_MAT_STATE(LLUUID,const LLUUID&,setNormalID);
DEF_EDIT_MAT_STATE(LLUUID,const LLUUID&,setSpecularID);
DEF_EDIT_MAT_STATE(LLColor4U, const LLColor4U&,setSpecularLightColor);
- DEF_EDIT_MAT_STATE(LLUUID, const LLUUID&, setMaterialID);
};
class LLSelectedTE
diff --git a/indra/newview/llpreview.cpp b/indra/newview/llpreview.cpp
index b9b2279e77..0117db86e8 100644
--- a/indra/newview/llpreview.cpp
+++ b/indra/newview/llpreview.cpp
@@ -241,14 +241,22 @@ void LLPreview::refreshFromItem()
// static
BOOL LLPreview::canModify(const LLUUID taskUUID, const LLInventoryItem* item)
{
+ const LLViewerObject* object = nullptr;
if (taskUUID.notNull())
{
- LLViewerObject* object = gObjectList.findObject(taskUUID);
- if(object && !object->permModify())
- {
- // No permission to edit in-world inventory
- return FALSE;
- }
+ object = gObjectList.findObject(taskUUID);
+ }
+
+ return canModify(object, item);
+}
+
+// static
+BOOL LLPreview::canModify(const LLViewerObject* object, const LLInventoryItem* item)
+{
+ if (object && !object->permModify())
+ {
+ // No permission to edit in-world inventory
+ return FALSE;
}
return item && gAgent.allowOperation(PERM_MODIFY, item->getPermissions(), GP_OBJECT_MANIPULATE);
diff --git a/indra/newview/llpreview.h b/indra/newview/llpreview.h
index ab60f4c008..3688ee0192 100644
--- a/indra/newview/llpreview.h
+++ b/indra/newview/llpreview.h
@@ -36,6 +36,7 @@
#include <map>
class LLInventoryItem;
+class LLViewerObject;
class LLLineEditor;
class LLRadioGroup;
class LLPreview;
@@ -109,6 +110,7 @@ public:
// We can't modify Item or description in preview if either in-world Object
// or Item itself is unmodifiable
static BOOL canModify(const LLUUID taskUUID, const LLInventoryItem* item);
+ static BOOL canModify(const LLViewerObject* object, const LLInventoryItem* item);
protected:
virtual void onCommit();
diff --git a/indra/newview/llselectmgr.cpp b/indra/newview/llselectmgr.cpp
index 5c1a339570..6692d124d8 100644
--- a/indra/newview/llselectmgr.cpp
+++ b/indra/newview/llselectmgr.cpp
@@ -1773,15 +1773,17 @@ void LLObjectSelection::applyNoCopyTextureToTEs(LLViewerInventoryItem* item)
}
}
-void LLObjectSelection::applyNoCopyPbrMaterialToTEs(LLViewerInventoryItem* item)
+bool LLObjectSelection::applyRestrictedPbrMaterialToTEs(LLViewerInventoryItem* item)
{
if (!item)
{
- return;
+ return false;
}
LLUUID asset_id = item->getAssetUUID();
+ bool material_copied_all_faces = true;
+
for (iterator iter = begin(); iter != end(); ++iter)
{
LLSelectNode* node = *iter;
@@ -1797,12 +1799,17 @@ void LLObjectSelection::applyNoCopyPbrMaterialToTEs(LLViewerInventoryItem* item)
{
if (node->isTESelected(te))
{
- //(no-copy) materials must be moved to the object's inventory only once
+ //(no-copy), (no-modify), and (no-transfer) materials must be moved to the object's inventory only once
// without making any copies
if (!material_copied && asset_id.notNull())
{
- LLToolDragAndDrop::handleDropMaterialProtections(object, item, LLToolDragAndDrop::SOURCE_AGENT, LLUUID::null);
- material_copied = true;
+ material_copied = (bool)LLToolDragAndDrop::handleDropMaterialProtections(object, item, LLToolDragAndDrop::SOURCE_AGENT, LLUUID::null);
+ }
+ if (!material_copied)
+ {
+ // Applying the material is not possible for this object given the current inventory
+ material_copied_all_faces = false;
+ break;
}
// apply texture for the selected faces
@@ -1814,6 +1821,8 @@ void LLObjectSelection::applyNoCopyPbrMaterialToTEs(LLViewerInventoryItem* item)
}
LLGLTFMaterialList::flushUpdates();
+
+ return material_copied_all_faces;
}
@@ -1924,6 +1933,8 @@ bool LLSelectMgr::selectionSetGLTFMaterial(const LLUUID& mat_id)
{
LLViewerInventoryItem* mItem;
LLUUID mMatId;
+ bool material_copied_any_face = false;
+ bool material_copied_all_faces = true;
f(LLViewerInventoryItem* item, const LLUUID& id) : mItem(item), mMatId(id) {}
bool apply(LLViewerObject* objectp, S32 te)
{
@@ -1950,14 +1961,19 @@ bool LLSelectMgr::selectionSetGLTFMaterial(const LLUUID& mat_id)
}
};
- if (item && !item->getPermissions().allowOperationBy(PERM_COPY, gAgent.getID()))
+ bool success = true;
+ if (item &&
+ (!item->getPermissions().allowOperationBy(PERM_COPY, gAgent.getID()) ||
+ !item->getPermissions().allowOperationBy(PERM_TRANSFER, gAgent.getID()) ||
+ !item->getPermissions().allowOperationBy(PERM_MODIFY, gAgent.getID())
+ ))
{
- getSelection()->applyNoCopyPbrMaterialToTEs(item);
+ success = success && getSelection()->applyRestrictedPbrMaterialToTEs(item);
}
else
{
f setfunc(item, mat_id);
- getSelection()->applyToTEs(&setfunc);
+ success = success && getSelection()->applyToTEs(&setfunc);
}
struct g : public LLSelectedObjectFunctor
@@ -1986,11 +2002,11 @@ bool LLSelectMgr::selectionSetGLTFMaterial(const LLUUID& mat_id)
return true;
}
} sendfunc(item);
- getSelection()->applyToObjects(&sendfunc);
+ success = success && getSelection()->applyToObjects(&sendfunc);
LLGLTFMaterialList::flushUpdates();
- return true;
+ return success;
}
//-----------------------------------------------------------------------------
diff --git a/indra/newview/llselectmgr.h b/indra/newview/llselectmgr.h
index 327134a487..f89209b437 100644
--- a/indra/newview/llselectmgr.h
+++ b/indra/newview/llselectmgr.h
@@ -378,7 +378,17 @@ public:
* Then this only texture is used for all selected faces.
*/
void applyNoCopyTextureToTEs(LLViewerInventoryItem* item);
- void applyNoCopyPbrMaterialToTEs(LLViewerInventoryItem* item);
+ /*
+ * Multi-purpose function for applying PBR materials to the
+ * selected object or faces, any combination of copy/mod/transfer
+ * permission restrictions. This method moves the restricted
+ * material to the object's inventory and doesn't make a copy of the
+ * material for each face. Then this only material is used for
+ * all selected faces.
+ * Returns false if applying the material failed on one or more selected
+ * faces.
+ */
+ bool applyRestrictedPbrMaterialToTEs(LLViewerInventoryItem* item);
ESelectType getSelectType() const { return mSelectType; }
@@ -635,7 +645,7 @@ public:
void selectionSetRestitution(F32 restitution);
void selectionSetMaterial(U8 material);
bool selectionSetImage(const LLUUID& imageid); // could be item or asset id
- bool selectionSetGLTFMaterial(const LLUUID& mat_id); // could be item or asset id
+ bool selectionSetGLTFMaterial(const LLUUID& mat_id); // material id only
void selectionSetColor(const LLColor4 &color);
void selectionSetColorOnly(const LLColor4 &color); // Set only the RGB channels
void selectionSetAlphaOnly(const F32 alpha); // Set only the alpha channel
diff --git a/indra/newview/lltooldraganddrop.cpp b/indra/newview/lltooldraganddrop.cpp
index 1918d11964..23a6634154 100644
--- a/indra/newview/lltooldraganddrop.cpp
+++ b/indra/newview/lltooldraganddrop.cpp
@@ -930,6 +930,8 @@ BOOL LLToolDragAndDrop::handleDropMaterialProtections(LLViewerObject* hit_obj,
LLToolDragAndDrop::ESource source,
const LLUUID& src_id)
{
+ if (!item) return FALSE;
+
// Always succeed if....
// material is from the library
// or already in the contents of the object
@@ -948,7 +950,14 @@ BOOL LLToolDragAndDrop::handleDropMaterialProtections(LLViewerObject* hit_obj,
{
hit_obj->requestInventory();
LLSD args;
- args["ERROR_MESSAGE"] = "Unable to add texture.\nPlease wait a few seconds and try again.";
+ if (LLAssetType::AT_MATERIAL == item->getType())
+ {
+ args["ERROR_MESSAGE"] = "Unable to add material.\nPlease wait a few seconds and try again.";
+ }
+ else
+ {
+ args["ERROR_MESSAGE"] = "Unable to add texture.\nPlease wait a few seconds and try again.";
+ }
LLNotificationsUtil::add("ErrorMessage", args);
return FALSE;
}
@@ -957,11 +966,9 @@ BOOL LLToolDragAndDrop::handleDropMaterialProtections(LLViewerObject* hit_obj,
// if the asset is already in the object's inventory
// then it can always be added to a side.
// This saves some work if the task's inventory is already loaded
- // and ensures that the texture item is only added once.
+ // and ensures that the asset item is only added once.
return TRUE;
}
-
- if (!item) return FALSE;
LLPointer<LLViewerInventoryItem> new_item = new LLViewerInventoryItem(item);
if (!item->getPermissions().allowOperationBy(PERM_COPY, gAgent.getID()))
@@ -995,7 +1002,7 @@ BOOL LLToolDragAndDrop::handleDropMaterialProtections(LLViewerObject* hit_obj,
return FALSE;
}
}
- // Add the texture item to the target object's inventory.
+ // Add the asset item to the target object's inventory.
if (LLAssetType::AT_TEXTURE == new_item->getType()
|| LLAssetType::AT_MATERIAL == new_item->getType())
{
@@ -1011,14 +1018,14 @@ BOOL LLToolDragAndDrop::handleDropMaterialProtections(LLViewerObject* hit_obj,
else if (!item->getPermissions().allowOperationBy(PERM_TRANSFER,
gAgent.getID()))
{
- // Check that we can add the texture as inventory to the object
+ // Check that we can add the asset as inventory to the object
if (willObjectAcceptInventory(hit_obj,item) < ACCEPT_YES_COPY_SINGLE )
{
return FALSE;
}
// *FIX: may want to make sure agent can paint hit_obj.
- // Add the texture item to the target object's inventory.
+ // Add the asset item to the target object's inventory.
if (LLAssetType::AT_TEXTURE == new_item->getType()
|| LLAssetType::AT_MATERIAL == new_item->getType())
{
@@ -1028,7 +1035,27 @@ BOOL LLToolDragAndDrop::handleDropMaterialProtections(LLViewerObject* hit_obj,
{
hit_obj->updateInventory(new_item, TASK_INVENTORY_ITEM_KEY, true);
}
- // Force the object to update and refetch its inventory so it has this texture.
+ // Force the object to update and refetch its inventory so it has this asset.
+ hit_obj->dirtyInventory();
+ hit_obj->requestInventory();
+ // TODO: Check to see if adding the item was successful; if not, then
+ // we should return false here. This will requre a separate listener
+ // since without listener, we have no way to receive update
+ }
+ else if (LLAssetType::AT_MATERIAL == new_item->getType() &&
+ !item->getPermissions().allowOperationBy(PERM_MODIFY, gAgent.getID()))
+ {
+ // Check that we can add the material as inventory to the object
+ if (willObjectAcceptInventory(hit_obj,item) < ACCEPT_YES_COPY_SINGLE )
+ {
+ return FALSE;
+ }
+ // *FIX: may want to make sure agent can paint hit_obj.
+
+ // Add the material item to the target object's inventory.
+ hit_obj->updateMaterialInventory(new_item, TASK_INVENTORY_ITEM_KEY, true);
+
+ // Force the object to update and refetch its inventory so it has this material.
hit_obj->dirtyInventory();
hit_obj->requestInventory();
// TODO: Check to see if adding the item was successful; if not, then
diff --git a/indra/newview/llviewerinventory.cpp b/indra/newview/llviewerinventory.cpp
index 518967709d..aa1827a8e2 100644
--- a/indra/newview/llviewerinventory.cpp
+++ b/indra/newview/llviewerinventory.cpp
@@ -1604,6 +1604,67 @@ void copy_inventory_from_notecard(const LLUUID& destination_id,
}
}
+void move_or_copy_inventory_from_object(const LLUUID& destination_id,
+ const LLUUID& object_id,
+ const LLUUID& item_id,
+ LLPointer<LLInventoryCallback> cb)
+{
+ LLViewerObject* object = gObjectList.findObject(object_id);
+ if (!object)
+ {
+ return;
+ }
+ const LLInventoryItem* item = object->getInventoryItem(item_id);
+ if (!item)
+ {
+ return;
+ }
+
+ class LLItemAddedObserver : public LLInventoryObserver
+ {
+ public:
+ LLItemAddedObserver(const LLUUID& copied_asset_id, LLPointer<LLInventoryCallback> cb)
+ : LLInventoryObserver(),
+ mAssetId(copied_asset_id),
+ mCallback(cb)
+ {
+ }
+
+ void changed(U32 mask) override
+ {
+ if((mask & (LLInventoryObserver::ADD)) == 0)
+ {
+ return;
+ }
+ for (const LLUUID& changed_id : gInventory.getChangedIDs())
+ {
+ LLViewerInventoryItem* changed_item = gInventory.getItem(changed_id);
+ if (changed_item->getAssetUUID() == mAssetId)
+ {
+ changeComplete(changed_item->getUUID());
+ return;
+ }
+ }
+ }
+
+ private:
+ void changeComplete(const LLUUID& item_id)
+ {
+ mCallback->fire(item_id);
+ gInventory.removeObserver(this);
+ delete this;
+ }
+
+ LLUUID mAssetId;
+ LLPointer<LLInventoryCallback> mCallback;
+ };
+
+ const LLUUID& asset_id = item->getAssetUUID();
+ LLItemAddedObserver* observer = new LLItemAddedObserver(asset_id, cb);
+ gInventory.addObserver(observer);
+ object->moveInventory(destination_id, item_id);
+}
+
void create_new_item(const std::string& name,
const LLUUID& parent_id,
LLAssetType::EType asset_type,
diff --git a/indra/newview/llviewerinventory.h b/indra/newview/llviewerinventory.h
index 24b632632b..6c0f1b8d07 100644
--- a/indra/newview/llviewerinventory.h
+++ b/indra/newview/llviewerinventory.h
@@ -439,6 +439,10 @@ void copy_inventory_from_notecard(const LLUUID& destination_id,
const LLInventoryItem *src,
U32 callback_id = 0);
+void move_or_copy_inventory_from_object(const LLUUID& destination_id,
+ const LLUUID& object_id,
+ const LLUUID& item_id,
+ LLPointer<LLInventoryCallback> cb);
void menu_create_inventory_item(LLInventoryPanel* root,
LLFolderBridge* bridge,
diff --git a/indra/newview/llviewerobject.cpp b/indra/newview/llviewerobject.cpp
index d21d6f7027..69e62ace97 100644
--- a/indra/newview/llviewerobject.cpp
+++ b/indra/newview/llviewerobject.cpp
@@ -3610,6 +3610,17 @@ LLInventoryObject* LLViewerObject::getInventoryObject(const LLUUID& item_id)
return rv;
}
+LLInventoryItem* LLViewerObject::getInventoryItem(const LLUUID& item_id)
+{
+ LLInventoryObject* iobj = getInventoryObject(item_id);
+ if (!iobj || iobj->getType() == LLAssetType::AT_CATEGORY)
+ {
+ return NULL;
+ }
+ LLInventoryItem* item = dynamic_cast<LLInventoryItem*>(iobj);
+ return item;
+}
+
void LLViewerObject::getInventoryContents(LLInventoryObject::object_list_t& objects)
{
if(mInventory)
diff --git a/indra/newview/llviewerobject.h b/indra/newview/llviewerobject.h
index 3665c64965..898b21e1ae 100644
--- a/indra/newview/llviewerobject.h
+++ b/indra/newview/llviewerobject.h
@@ -494,6 +494,7 @@ public:
void updateInventoryLocal(LLInventoryItem* item, U8 key); // Update without messaging.
void updateMaterialInventory(LLViewerInventoryItem* item, U8 key, bool is_new);
LLInventoryObject* getInventoryObject(const LLUUID& item_id);
+ LLInventoryItem* getInventoryItem(const LLUUID& item_id);
// Get content except for root category
void getInventoryContents(LLInventoryObject::object_list_t& objects);
diff --git a/indra/newview/skins/default/xui/en/notifications.xml b/indra/newview/skins/default/xui/en/notifications.xml
index ca07aacb21..bbc3798034 100644
--- a/indra/newview/skins/default/xui/en/notifications.xml
+++ b/indra/newview/skins/default/xui/en/notifications.xml
@@ -9211,6 +9211,18 @@ We cannot display a preview of this texture because it is no-copy and/or no-tran
<notification
icon="alertmodal.tga"
+ name="LivePreviewUnavailablePBR"
+ type="alert">
+
+We cannot display a preview of this material because it is no-copy, no-transfer, and/or no-modify.
+ <usetemplate
+ ignoretext="Warn me that Live Preview mode is not available for no-copy, no-transfer, and/or no-modify materials"
+ name="okignore"
+ yestext="OK"/>
+ </notification>
+
+ <notification
+ icon="alertmodal.tga"
name="FacePasteFailed"
type="alertmodal">
Paste failed. [REASON]
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 51e6099ceb..5b15752eb7 100644
--- a/indra/newview/skins/default/xui/en/panel_tools_texture.xml
+++ b/indra/newview/skins/default/xui/en/panel_tools_texture.xml
@@ -284,12 +284,26 @@
name="pbr_from_inventory"
label="Choose from inventory"
width="140"/>
+ <text
+ visible="false"
+ type="string"
+ length="1"
+ follows="left|top"
+ height="10"
+ layout="topleft"
+ top_pad="4"
+ left_delta="0"
+ name="material_permissions_loading_label"
+ text_readonly_color="LabelDisabledColor"
+ width="160">
+ Loading contents...
+ </text>
<button
follows="left|top"
height="23"
layout="topleft"
left_delta="0"
- top_pad="4"
+ top_delta="0"
name="edit_selected_pbr"
label="Edit Selected"
width="140"/>