Skip to content

Commit

Permalink
--add ref to MaterialAttributesManager;Simplify
Browse files Browse the repository at this point in the history
  • Loading branch information
jturner65 committed Nov 18, 2022
1 parent 376938c commit 0270f77
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 25 deletions.
1 change: 1 addition & 0 deletions src/esp/bindings/AttributesBindings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 2 additions & 0 deletions src/esp/metadata/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
21 changes: 6 additions & 15 deletions src/esp/metadata/attributes/MaterialAttributes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,16 +70,13 @@ void PBRMetallicRoughnessAttributes::writeValuesToJson(
io::JsonGenericValue& jsonObj,
io::JsonAllocator& allocator) const {
if (hasSubconfig("baseColorTexture")) {
MaterialTextureAttributes::cptr bctSubConfig =
getSubconfigCopy<const MaterialTextureAttributes>("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<const MaterialTextureAttributes>(
"metallicRoughnessTexture");
MaterialTextureAttributes::cptr mrSubConfig = getMetallicRoughnessTexture();
auto mrJsonObj = mrSubConfig->writeToJsonObject(allocator);
jsonObj.AddMember("metallicRoughnessTexture", mrJsonObj, allocator);
}
Expand All @@ -90,17 +87,14 @@ void PBRMetallicRoughnessAttributes::writeValuesToJson(
std::string PBRMetallicRoughnessAttributes::getObjectInfoInternal() const {
std::string res("");
if (hasSubconfig("baseColorTexture")) {
MaterialTextureAttributes::cptr bctSubConfig =
getSubconfigCopy<const MaterialTextureAttributes>("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<const MaterialTextureAttributes>(
"metallicRoughnessTexture");
MaterialTextureAttributes::cptr mrSubConfig = getMetallicRoughnessTexture();
Cr::Utility::formatInto(res, res.size(), "{},",
mrSubConfig->getObjectInfo());
}
Expand All @@ -114,16 +108,13 @@ std::string PBRMetallicRoughnessAttributes::getObjectInfoHeaderInternal()
const {
std::string res("");
if (hasSubconfig("baseColorTexture")) {
MaterialTextureAttributes::cptr bctSubConfig =
getSubconfigCopy<const MaterialTextureAttributes>("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<const MaterialTextureAttributes>(
"metallicRoughnessTexture");
MaterialTextureAttributes::cptr mrSubConfig = getMetallicRoughnessTexture();
Cr::Utility::formatInto(res, res.size(), "{},",
mrSubConfig->getObjectInfoHeader());
}
Expand Down
10 changes: 0 additions & 10 deletions src/esp/metadata/managers/MaterialAttributesManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down

0 comments on commit 0270f77

Please sign in to comment.