From 47ecbca24d5ec11ee5cd940fe9db55022fab8dbe Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Tue, 30 Aug 2022 16:43:05 -0500
Subject: [PATCH] SL-17987 Fix for material editor not initializing to GLTF
 defaults when loading a null material asset.

---
 indra/newview/llmaterialeditor.cpp | 7 +++++++
 indra/newview/llmaterialeditor.h   | 2 ++
 2 files changed, 9 insertions(+)

diff --git a/indra/newview/llmaterialeditor.cpp b/indra/newview/llmaterialeditor.cpp
index 2052f252b38..f05f0344bd0 100644
--- a/indra/newview/llmaterialeditor.cpp
+++ b/indra/newview/llmaterialeditor.cpp
@@ -1605,6 +1605,7 @@ void LLMaterialEditor::loadAsset()
             if (mAssetID.isNull())
             {
                 mAssetStatus = PREVIEW_ASSET_LOADED;
+                loadDefaults();
                 setHasUnsavedChanges(false);
             }
             else
@@ -1905,3 +1906,9 @@ S32 LLMaterialEditor::saveTextures()
     return work_count;
 }
 
+void LLMaterialEditor::loadDefaults()
+{
+    tinygltf::Model model_in;
+    model_in.materials.resize(1);
+    setFromGltfModel(model_in, true);
+}
diff --git a/indra/newview/llmaterialeditor.h b/indra/newview/llmaterialeditor.h
index 59ae00e5658..cc72193a0ef 100644
--- a/indra/newview/llmaterialeditor.h
+++ b/indra/newview/llmaterialeditor.h
@@ -161,6 +161,8 @@ class LLMaterialEditor : public LLPreview, public LLVOInventoryListener
     void onCommitEmissiveTexture(LLUICtrl* ctrl, const LLSD& data);
     void onCommitNormalTexture(LLUICtrl* ctrl, const LLSD& data);
 
+    // initialize the UI from a default GLTF material
+    void loadDefaults();
 private:
     friend class LLMaterialFilePicker;
 
-- 
GitLab