From 91b9e69cdd3376dd6a185d33f555017b98c7638f Mon Sep 17 00:00:00 2001 From: John Turner <7strbass@gmail.com> Date: Thu, 26 May 2022 12:54:26 -0400 Subject: [PATCH] --add ref to MaterialAttributesManager;Simplify --- src/esp/bindings/AttributesBindings.cpp | 1 + src/esp/metadata/CMakeLists.txt | 2 ++ .../attributes/MaterialAttributes.cpp | 21 ++++++------------- .../managers/MaterialAttributesManager.h | 10 --------- 4 files changed, 9 insertions(+), 25 deletions(-) diff --git a/src/esp/bindings/AttributesBindings.cpp b/src/esp/bindings/AttributesBindings.cpp index 4ad4b04fa6..ddda6c5c74 100644 --- a/src/esp/bindings/AttributesBindings.cpp +++ b/src/esp/bindings/AttributesBindings.cpp @@ -9,6 +9,7 @@ #include "esp/core/managedContainers/AbstractManagedObject.h" #include "esp/metadata/attributes/AttributesBase.h" #include "esp/metadata/attributes/LightLayoutAttributes.h" +#include "esp/metadata/attributes/MaterialAttributes.h" #include "esp/metadata/attributes/ObjectAttributes.h" #include "esp/metadata/attributes/PhysicsManagerAttributes.h" #include "esp/metadata/attributes/PrimitiveAssetAttributes.h" diff --git a/src/esp/metadata/CMakeLists.txt b/src/esp/metadata/CMakeLists.txt index 357bcc33a4..106e483dc0 100644 --- a/src/esp/metadata/CMakeLists.txt +++ b/src/esp/metadata/CMakeLists.txt @@ -28,6 +28,8 @@ set( managers/AssetAttributesManager.cpp managers/LightLayoutAttributesManager.h managers/LightLayoutAttributesManager.cpp + managers/MaterialAttributesManager.h + managers/MaterialAttributesManager.cpp managers/ObjectAttributesManager.h managers/ObjectAttributesManager.cpp managers/PhysicsAttributesManager.h diff --git a/src/esp/metadata/attributes/MaterialAttributes.cpp b/src/esp/metadata/attributes/MaterialAttributes.cpp index f3d403beeb..dd6ccdf4a2 100644 --- a/src/esp/metadata/attributes/MaterialAttributes.cpp +++ b/src/esp/metadata/attributes/MaterialAttributes.cpp @@ -70,16 +70,13 @@ void PBRMetallicRoughnessAttributes::writeValuesToJson( io::JsonGenericValue& jsonObj, io::JsonAllocator& allocator) const { if (hasSubconfig("baseColorTexture")) { - MaterialTextureAttributes::cptr bctSubConfig = - getSubconfigCopy("baseColorTexture"); + MaterialTextureAttributes::cptr bctSubConfig = getBaseColorTexture(); auto bctJsonObj = bctSubConfig->writeToJsonObject(allocator); jsonObj.AddMember("baseColorTexture", bctJsonObj, allocator); } writeValueToJson("baseColorFactor", jsonObj, allocator); if (hasSubconfig("metallicRoughnessTexture")) { - MaterialTextureAttributes::cptr mrSubConfig = - getSubconfigCopy( - "metallicRoughnessTexture"); + MaterialTextureAttributes::cptr mrSubConfig = getMetallicRoughnessTexture(); auto mrJsonObj = mrSubConfig->writeToJsonObject(allocator); jsonObj.AddMember("metallicRoughnessTexture", mrJsonObj, allocator); } @@ -90,17 +87,14 @@ void PBRMetallicRoughnessAttributes::writeValuesToJson( std::string PBRMetallicRoughnessAttributes::getObjectInfoInternal() const { std::string res(""); if (hasSubconfig("baseColorTexture")) { - MaterialTextureAttributes::cptr bctSubConfig = - getSubconfigCopy("baseColorTexture"); + MaterialTextureAttributes::cptr bctSubConfig = getBaseColorTexture(); Cr::Utility::formatInto(res, res.size(), "{},", bctSubConfig->getObjectInfo()); } Cr::Utility::formatInto(res, res.size(), "{},", getAsString("baseColorFactor")); if (hasSubconfig("metallicRoughnessTexture")) { - MaterialTextureAttributes::cptr mrSubConfig = - getSubconfigCopy( - "metallicRoughnessTexture"); + MaterialTextureAttributes::cptr mrSubConfig = getMetallicRoughnessTexture(); Cr::Utility::formatInto(res, res.size(), "{},", mrSubConfig->getObjectInfo()); } @@ -114,16 +108,13 @@ std::string PBRMetallicRoughnessAttributes::getObjectInfoHeaderInternal() const { std::string res(""); if (hasSubconfig("baseColorTexture")) { - MaterialTextureAttributes::cptr bctSubConfig = - getSubconfigCopy("baseColorTexture"); + MaterialTextureAttributes::cptr bctSubConfig = getBaseColorTexture(); Cr::Utility::formatInto(res, res.size(), "{},", bctSubConfig->getObjectInfoHeader()); } Cr::Utility::formatInto(res, res.size(), "Base Color Factor,"); if (hasSubconfig("metallicRoughnessTexture")) { - MaterialTextureAttributes::cptr mrSubConfig = - getSubconfigCopy( - "metallicRoughnessTexture"); + MaterialTextureAttributes::cptr mrSubConfig = getMetallicRoughnessTexture(); Cr::Utility::formatInto(res, res.size(), "{},", mrSubConfig->getObjectInfoHeader()); } diff --git a/src/esp/metadata/managers/MaterialAttributesManager.h b/src/esp/metadata/managers/MaterialAttributesManager.h index d57af84722..cfb0465ebb 100644 --- a/src/esp/metadata/managers/MaterialAttributesManager.h +++ b/src/esp/metadata/managers/MaterialAttributesManager.h @@ -113,16 +113,6 @@ class MaterialAttributesManager */ void resetFinalize() override {} - /** - * @brief Material Attributes has no reason to check this value - * @param handle String name of primitive asset attributes desired - * @return whether handle exists or not in asset attributes library - */ - bool isValidPrimitiveAttributes( - CORRADE_UNUSED const std::string& handle) override { - return false; - } - public: ESP_SMART_POINTERS(MaterialAttributesManager)