From 74002b47385d8c80e086f2a7dbf68bea16380253 Mon Sep 17 00:00:00 2001
From: HifiExperiments <thingsandstuffblog@gmail.com>
Date: Fri, 19 Apr 2024 16:05:59 -0700
Subject: [PATCH] simplify constructors

---
 .../procedural/ProceduralMaterialCache.cpp    | 36 +++----------------
 .../src/procedural/ProceduralMaterialCache.h  |  3 +-
 2 files changed, 5 insertions(+), 34 deletions(-)

diff --git a/libraries/procedural/src/procedural/ProceduralMaterialCache.cpp b/libraries/procedural/src/procedural/ProceduralMaterialCache.cpp
index 40044bed43..f76200ea57 100644
--- a/libraries/procedural/src/procedural/ProceduralMaterialCache.cpp
+++ b/libraries/procedural/src/procedural/ProceduralMaterialCache.cpp
@@ -826,9 +826,9 @@ NetworkMaterial::NetworkMaterial(const NetworkMaterial& m) :
     Material(m),
     _textures(m._textures),
     _albedoTransform(m._albedoTransform),
+    _isOriginal(m._isOriginal),
     _lightmapTransform(m._lightmapTransform),
-    _lightmapParams(m._lightmapParams),
-    _isOriginal(m._isOriginal)
+    _lightmapParams(m._lightmapParams)
 {}
 
 const QString NetworkMaterial::NO_TEXTURE = QString();
@@ -1135,37 +1135,9 @@ bool NetworkMaterial::checkResetOpacityMap() {
 }
 
 NetworkMToonMaterial::NetworkMToonMaterial(const HFMMaterial& material, const QUrl& textureBaseUrl) :
-    NetworkMaterial(*material._material)
+    NetworkMaterial(material, textureBaseUrl) // handles _name, albedoMap, normalMap, and emissiveMap
 {
-    _name = material.name.toStdString();
-    if (!material.albedoTexture.filename.isEmpty()) {
-        auto map = fetchTextureMap(textureBaseUrl, material.albedoTexture, image::TextureUsage::ALBEDO_TEXTURE, MapChannel::ALBEDO_MAP);
-        if (map) {
-            _albedoTransform = material.albedoTexture.transform;
-            map->setTextureTransform(_albedoTransform);
-
-            if (!material.opacityTexture.filename.isEmpty()) {
-                if (material.albedoTexture.filename == material.opacityTexture.filename) {
-                    // Best case scenario, just indicating that the albedo map contains transparency
-                    // TODO: Different albedo/opacity maps are not currently supported
-                    map->setUseAlphaChannel(true);
-                }
-            }
-        }
-
-        setTextureMap(MapChannel::ALBEDO_MAP, map);
-    }
-
-    if (!material.normalTexture.filename.isEmpty()) {
-        auto type = (material.normalTexture.isBumpmap ? image::TextureUsage::BUMP_TEXTURE : image::TextureUsage::NORMAL_TEXTURE);
-        auto map = fetchTextureMap(textureBaseUrl, material.normalTexture, type, MapChannel::NORMAL_MAP);
-        setTextureMap(MapChannel::NORMAL_MAP, map);
-    }
-
-    if (!material.emissiveTexture.filename.isEmpty()) {
-        auto map = fetchTextureMap(textureBaseUrl, material.emissiveTexture, image::TextureUsage::EMISSIVE_TEXTURE, MapChannel::EMISSIVE_MAP);
-        setTextureMap(MapChannel::EMISSIVE_MAP, map);
-    }
+    _model = VRM_MTOON;
 
     if (!material.shadeTexture.filename.isEmpty()) {
         auto map = fetchTextureMap(textureBaseUrl, material.shadeTexture, image::TextureUsage::ALBEDO_TEXTURE, (MapChannel)MToonMapChannel::SHADE_MAP);
diff --git a/libraries/procedural/src/procedural/ProceduralMaterialCache.h b/libraries/procedural/src/procedural/ProceduralMaterialCache.h
index ec64d8d77f..a7c5baa011 100644
--- a/libraries/procedural/src/procedural/ProceduralMaterialCache.h
+++ b/libraries/procedural/src/procedural/ProceduralMaterialCache.h
@@ -26,7 +26,6 @@ public:
     NetworkMaterial() : _textures(MapChannel::NUM_MAP_CHANNELS) {}
     NetworkMaterial(const HFMMaterial& material, const QUrl& textureBaseUrl);
     NetworkMaterial(const NetworkMaterial& material);
-    NetworkMaterial(const graphics::Material material) : graphics::Material(material) {}
 
     void setAlbedoMap(const QUrl& url, bool useAlphaChannel);
     void setNormalMap(const QUrl& url, bool isBumpmap);
@@ -71,7 +70,7 @@ protected:
 
     Transform _albedoTransform;
 
-    bool _isOriginal{ true };
+    bool _isOriginal { true };
 
 private:
     // Helpers for the ctors