From a4030031f895f8497e106f0547eb29780d6ec4e9 Mon Sep 17 00:00:00 2001
From: Cosmic Linden <cosmic@lindenlab.com>
Date: Fri, 21 Jul 2023 17:28:09 -0700
Subject: [PATCH] SL-20024: Do not show material preview for no-modify
 materials

---
 indra/newview/app_settings/settings.xml          |  2 +-
 indra/newview/llpanelface.cpp                    | 16 +++++++++-------
 .../skins/default/xui/en/notifications.xml       | 12 ++++++++++++
 3 files changed, 22 insertions(+), 8 deletions(-)

diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml
index 0cd63d9d5fb..b92a829f368 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/llpanelface.cpp b/indra/newview/llpanelface.cpp
index b633ccc5d5a..e91b14a453b 100644
--- a/indra/newview/llpanelface.cpp
+++ b/indra/newview/llpanelface.cpp
@@ -3094,6 +3094,7 @@ void LLPanelFace::onSelectPbr(const LLSD& data)
             id = pbr_ctrl->getImageAssetID();
         }
         if (!LLSelectMgr::getInstance()->selectionSetGLTFMaterial(id))
+        {
             refresh();
         }
     }
@@ -4989,23 +4990,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/skins/default/xui/en/notifications.xml b/indra/newview/skins/default/xui/en/notifications.xml
index ca07aacb210..bbc37980340 100644
--- a/indra/newview/skins/default/xui/en/notifications.xml
+++ b/indra/newview/skins/default/xui/en/notifications.xml
@@ -9209,6 +9209,18 @@ We cannot display a preview of this texture because it is no-copy and/or no-tran
     yestext="OK"/>
   </notification>
 
+  <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"
-- 
GitLab