From c9ef206e39063c46c1fbab355c1a015e3e8b022e Mon Sep 17 00:00:00 2001
From: Brad Kittenbrink <brad@lindenlab.com>
Date: Thu, 28 Apr 2022 13:08:37 -0700
Subject: [PATCH] Beginning viewer side work for SL-17198 new asset and
 inventory types for Materials

---
 indra/llcommon/llassettype.cpp        |  1 +
 indra/llcommon/llassettype.h          |  3 ++-
 indra/llinventory/llinventorytype.cpp |  3 ++-
 indra/llinventory/llinventorytype.h   |  5 ++++-
 indra/llprimitive/llmaterial.cpp      | 11 +++++++++++
 indra/llprimitive/llmaterial.h        |  2 ++
 indra/llui/llui.h                     |  3 ++-
 indra/newview/llpanelface.cpp         |  4 +++-
 indra/newview/llpanelface.h           |  2 ++
 indra/newview/llviewerassettype.cpp   |  1 +
 10 files changed, 30 insertions(+), 5 deletions(-)

diff --git a/indra/llcommon/llassettype.cpp b/indra/llcommon/llassettype.cpp
index e6cc06e8d01..0bb1f1a0fdd 100644
--- a/indra/llcommon/llassettype.cpp
+++ b/indra/llcommon/llassettype.cpp
@@ -96,6 +96,7 @@ LLAssetDictionary::LLAssetDictionary()
 	addEntry(LLAssetType::AT_WIDGET,            new AssetEntry("WIDGET",            "widget",   "widget",           false,      false,      false));
 	addEntry(LLAssetType::AT_PERSON,            new AssetEntry("PERSON",            "person",   "person",           false,      false,      false));
 	addEntry(LLAssetType::AT_SETTINGS,          new AssetEntry("SETTINGS",          "settings", "settings blob",    true,       true,       true));
+	addEntry(LLAssetType::AT_MATERIAL,     new AssetEntry("MATERIAL",          "material", "render material",  true,       true,       true));
 	addEntry(LLAssetType::AT_UNKNOWN,           new AssetEntry("UNKNOWN",           "invalid",  NULL,               false,      false,      false));
     addEntry(LLAssetType::AT_NONE,              new AssetEntry("NONE",              "-1",		NULL,		  		FALSE,		FALSE,		FALSE));
 
diff --git a/indra/llcommon/llassettype.h b/indra/llcommon/llassettype.h
index 652c548d59a..9598f0f707f 100644
--- a/indra/llcommon/llassettype.h
+++ b/indra/llcommon/llassettype.h
@@ -127,8 +127,9 @@ class LL_COMMON_API LLAssetType
         AT_RESERVED_6 = 55,
 
         AT_SETTINGS = 56,   // Collection of settings
+        AT_MATERIAL = 57,   // Render Material
             
-		AT_COUNT = 57,
+		AT_COUNT = 58,
 
 			// +*********************************************************+
 			// |  TO ADD AN ELEMENT TO THIS ENUM:                        |
diff --git a/indra/llinventory/llinventorytype.cpp b/indra/llinventory/llinventorytype.cpp
index 853ed655f52..57d521429c1 100644
--- a/indra/llinventory/llinventorytype.cpp
+++ b/indra/llinventory/llinventorytype.cpp
@@ -153,7 +153,8 @@ DEFAULT_ASSET_FOR_INV_TYPE[LLAssetType::AT_COUNT] =
     LLInventoryType::IT_NONE,			// 53   AT_RESERVED_4
     LLInventoryType::IT_NONE,			// 54   AT_RESERVED_5
 
-    LLInventoryType::IT_SETTINGS,       // 55   AT_SETTINGS
+    LLInventoryType::IT_SETTINGS,       // 55   AT_SETTINGS <- why doesnt this match the value in llassettype.h? -brad
+    LLInventoryType::IT_MATERIAL,       // 57   AT_MATERIAL
 };
 
 // static
diff --git a/indra/llinventory/llinventorytype.h b/indra/llinventory/llinventorytype.h
index b6e7fb047f8..a5543814d87 100644
--- a/indra/llinventory/llinventorytype.h
+++ b/indra/llinventory/llinventorytype.h
@@ -65,7 +65,8 @@ class LLInventoryType
 		IT_WIDGET = 23,
 		IT_PERSON = 24,
         IT_SETTINGS = 25,
-		IT_COUNT = 26,
+        IT_MATERIAL = 26,
+		IT_COUNT = 27,
 
 		IT_UNKNOWN = 255,
 		IT_NONE = -1
@@ -118,6 +119,8 @@ class LLInventoryType
         ICONNAME_SETTINGS_WATER,
         ICONNAME_SETTINGS_DAY,
 
+        ICONNAME_MATERIAL,
+
 		ICONNAME_INVALID,
 		ICONNAME_UNKNOWN,
 		ICONNAME_COUNT,
diff --git a/indra/llprimitive/llmaterial.cpp b/indra/llprimitive/llmaterial.cpp
index a219ac14501..f546ac16453 100644
--- a/indra/llprimitive/llmaterial.cpp
+++ b/indra/llprimitive/llmaterial.cpp
@@ -331,6 +331,17 @@ 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 1e068c2be3c..2f8aafc2cfb 100644
--- a/indra/llprimitive/llmaterial.h
+++ b/indra/llprimitive/llmaterial.h
@@ -115,6 +115,8 @@ class LLMaterial : public LLRefCount
     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/llui/llui.h b/indra/llui/llui.h
index 30dbd7248f4..86b23c8c934 100644
--- a/indra/llui/llui.h
+++ b/indra/llui/llui.h
@@ -76,7 +76,8 @@ enum EDragAndDropType
 	DAD_WIDGET          = 16,
 	DAD_PERSON          = 17,
     DAD_SETTINGS        = 18,
-	DAD_COUNT           = 19,   // number of types in this enum
+    DAD_MATERIAL        = 19,
+    DAD_COUNT           = 20,   // number of types in this enum
 };
 
 // Reasons for drags to be denied.
diff --git a/indra/newview/llpanelface.cpp b/indra/newview/llpanelface.cpp
index 094add423fe..0b986e9a07b 100644
--- a/indra/newview/llpanelface.cpp
+++ b/indra/newview/llpanelface.cpp
@@ -123,6 +123,7 @@ F32		LLPanelFace::getCurrentShinyScaleU()		{ return getChild<LLUICtrl>("shinySca
 F32		LLPanelFace::getCurrentShinyScaleV()		{ return getChild<LLUICtrl>("shinyScaleV")->getValue().asReal();					}
 F32		LLPanelFace::getCurrentShinyOffsetU()		{ return getChild<LLUICtrl>("shinyOffsetU")->getValue().asReal();					}
 F32		LLPanelFace::getCurrentShinyOffsetV()		{ return getChild<LLUICtrl>("shinyOffsetV")->getValue().asReal();					}
+LLUUID	LLPanelFace::getCurrentMaterialID()			{ return getChild<LLUICtrl>("materialID")->getValue().asUUID(); 					}
 
 //
 // Methods
@@ -2308,7 +2309,8 @@ void LLPanelFace::onCommitMaterialMaskCutoff(LLUICtrl* ctrl, void* userdata)
 //static
 void LLPanelFace::onCommitMaterialID(LLUICtrl* ctrl, void* userdata)
 {
-    LLPanelFace* self [[maybe_unused]] = (LLPanelFace*) userdata;
+	LLPanelFace* self = static_cast<LLPanelFace*>(userdata);
+	LLSelectedTEMaterial::setMaterialID(self, self->getCurrentMaterialID());
 }
 
 // static
diff --git a/indra/newview/llpanelface.h b/indra/newview/llpanelface.h
index f7fa70a144a..6ce41a2aa7b 100644
--- a/indra/newview/llpanelface.h
+++ b/indra/newview/llpanelface.h
@@ -234,6 +234,7 @@ class LLPanelFace : public LLPanel
 	F32		getCurrentShinyScaleV();
 	F32		getCurrentShinyOffsetU();
 	F32		getCurrentShinyOffsetV();
+	LLUUID	getCurrentMaterialID();
 
 	// Update visibility of controls to match current UI mode
 	// (e.g. materials vs media editing)
@@ -498,6 +499,7 @@ class LLPanelFace : public LLPanel
 		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/llviewerassettype.cpp b/indra/newview/llviewerassettype.cpp
index 4804ef6ddcb..481086f7602 100644
--- a/indra/newview/llviewerassettype.cpp
+++ b/indra/newview/llviewerassettype.cpp
@@ -88,6 +88,7 @@ LLViewerAssetDictionary::LLViewerAssetDictionary()
 
 	addEntry(LLViewerAssetType::AT_NONE, 				new ViewerAssetEntry(DAD_NONE));
     addEntry(LLViewerAssetType::AT_SETTINGS,            new ViewerAssetEntry(DAD_SETTINGS));
+    addEntry(LLViewerAssetType::AT_MATERIAL,            new ViewerAssetEntry(DAD_MATERIAL));
 };
 
 EDragAndDropType LLViewerAssetType::lookupDragAndDropType(EType asset_type)
-- 
GitLab