Updated the naming convention for material property "names" vs "IDs".

A "property name" is the name of the just the property without regard to the group that it's in. A "group name" is the name of the group. And a "property ID" is the full unique name of a property in the form "groupName.propertyName". This is important preparation for upcoming changes where property sets can contain other property sets, and property IDs can be arbitrarily long like "layer1.baseColor.factor" for example.

The naming changes include variables, some code comments, and the .materialtype file format. I was able to make these changes in a backward compatible way so a property or group "id" field has been replaced with a "name" field, but "id" is still supported for compatibility. StandardPBR, EnhancedPBR, StandardMultilayerPBR, and Skin have all been updated. Note that MinimalPBR has not been updated, proving that backward compatibility works. (We can update this one too at some point though).

Testing:
Opened up materials in the material editor.
Ran AtomSampleViewer in dx12 and vulkan with no new failures.

Signed-off-by: santorac <55155825+santorac@users.noreply.github.com>
monroegm-disable-blank-issue-2
santorac 4 years ago
parent 22e43c9122
commit c2abd2d74f

@ -40,12 +40,12 @@ namespace AZ
AZ_TYPE_INFO(AZ::RPI::MaterialTypeSourceData::PropertyConnection, "{C2F37C26-D7EF-4142-A650-EF50BB18610F}"); AZ_TYPE_INFO(AZ::RPI::MaterialTypeSourceData::PropertyConnection, "{C2F37C26-D7EF-4142-A650-EF50BB18610F}");
PropertyConnection() = default; PropertyConnection() = default;
PropertyConnection(MaterialPropertyOutputType type, AZStd::string_view nameId, int32_t shaderIndex = -1); PropertyConnection(MaterialPropertyOutputType type, AZStd::string_view fieldName, int32_t shaderIndex = -1);
MaterialPropertyOutputType m_type = MaterialPropertyOutputType::Invalid; MaterialPropertyOutputType m_type = MaterialPropertyOutputType::Invalid;
//! The name of a specific shader setting. This will either be a ShaderResourceGroup input or a ShaderOption, depending on m_type //! The name of a specific shader setting. This will either be a ShaderResourceGroup input or a ShaderOption, depending on m_type
AZStd::string m_nameId; AZStd::string m_fieldName;
//! For m_type==ShaderOption, this is either the index of a specific shader in m_shaderCollection, or -1 which means every shader in m_shaderCollection. //! For m_type==ShaderOption, this is either the index of a specific shader in m_shaderCollection, or -1 which means every shader in m_shaderCollection.
//! For m_type==ShaderInput, this field is not used. //! For m_type==ShaderInput, this field is not used.
@ -58,8 +58,8 @@ namespace AZ
{ {
AZ_TYPE_INFO(AZ::RPI::MaterialTypeSourceData::GroupDefinition, "{B2D0FC5C-72A3-435E-A194-1BFDABAC253D}"); AZ_TYPE_INFO(AZ::RPI::MaterialTypeSourceData::GroupDefinition, "{B2D0FC5C-72A3-435E-A194-1BFDABAC253D}");
//! The unique name of the property group. A property's full ID will be groupNameId.propertyNameId. //! The unique name of the property group. The full property ID will be groupName.propertyName
AZStd::string m_nameId; AZStd::string m_name;
// Editor metadata ... // Editor metadata ...
AZStd::string m_displayName; AZStd::string m_displayName;
@ -74,7 +74,7 @@ namespace AZ
static const float DefaultMax; static const float DefaultMax;
static const float DefaultStep; static const float DefaultStep;
AZStd::string m_nameId; //!< The name of the property within the property group. The full ID will be groupNameId.propertyNameId. AZStd::string m_name; //!< The name of the property within the property group. The full property ID will be groupName.propertyName.
MaterialPropertyVisibility m_visibility = MaterialPropertyVisibility::Default; MaterialPropertyVisibility m_visibility = MaterialPropertyVisibility::Default;
@ -130,7 +130,7 @@ namespace AZ
AZStd::vector<GroupDefinition> m_groups; AZStd::vector<GroupDefinition> m_groups;
//! Collection of all available user-facing properties //! Collection of all available user-facing properties
AZStd::map<AZStd::string /*group name ID*/, PropertyList> m_properties; AZStd::map<AZStd::string /*group name*/, PropertyList> m_properties;
}; };
AZStd::string m_description; AZStd::string m_description;
@ -151,9 +151,9 @@ namespace AZ
//! Copy over UV custom names to the properties enum values. //! Copy over UV custom names to the properties enum values.
void ResolveUvEnums(); void ResolveUvEnums();
const GroupDefinition* FindGroup(AZStd::string_view groupNameId) const; const GroupDefinition* FindGroup(AZStd::string_view groupName) const;
const PropertyDefinition* FindProperty(AZStd::string_view groupNameId, AZStd::string_view propertyNameId) const; const PropertyDefinition* FindProperty(AZStd::string_view groupName, AZStd::string_view propertyName) const;
//! Construct a complete list of group definitions, including implicit groups, arranged in the same order as the source data //! Construct a complete list of group definitions, including implicit groups, arranged in the same order as the source data
//! Groups with the same name will be consolidated into a single entry //! Groups with the same name will be consolidated into a single entry

@ -70,8 +70,8 @@ namespace AZ
virtual ~Material(); virtual ~Material();
//! Finds the material property index from the material property name //! Finds the material property index from the material property ID
MaterialPropertyIndex FindPropertyIndex(const Name& name) const; MaterialPropertyIndex FindPropertyIndex(const Name& propertyId) const;
//! Sets the value of a material property. The template data type must match the property's data type. //! Sets the value of a material property. The template data type must match the property's data type.
//! @return true if property value was changed //! @return true if property value was changed

@ -35,7 +35,7 @@ namespace AZ
AZ_DISABLE_COPY_MOVE(MaterialPropertiesLayout); AZ_DISABLE_COPY_MOVE(MaterialPropertiesLayout);
size_t GetPropertyCount() const; size_t GetPropertyCount() const;
MaterialPropertyIndex FindPropertyIndex(const Name& propertyName) const; MaterialPropertyIndex FindPropertyIndex(const Name& propertyId) const;
const MaterialPropertyDescriptor* GetPropertyDescriptor(MaterialPropertyIndex index) const; const MaterialPropertyDescriptor* GetPropertyDescriptor(MaterialPropertyIndex index) const;
private: private:

@ -27,7 +27,8 @@ namespace AZ
{ {
namespace Field namespace Field
{ {
static constexpr const char id[] = "id"; static constexpr const char id[] = "id"; // legacy field, replaced by "name"
static constexpr const char name[] = "name";
static constexpr const char displayName[] = "displayName"; static constexpr const char displayName[] = "displayName";
static constexpr const char description[] = "description"; static constexpr const char description[] = "description";
static constexpr const char type[] = "type"; static constexpr const char type[] = "type";
@ -47,6 +48,7 @@ namespace AZ
static const AZStd::string_view AcceptedFields[] = static const AZStd::string_view AcceptedFields[] =
{ {
Field::id, Field::id,
Field::name,
Field::displayName, Field::displayName,
Field::description, Field::description,
Field::type, Field::type,
@ -218,7 +220,10 @@ namespace AZ
} }
} }
result.Combine(ContinueLoadingFromJsonObjectField(&property->m_nameId, azrtti_typeid<AZStd::string>(), inputValue, Field::id, context)); // Field::id is the legacy field, replaced by Field::name. If both are present, Field::name will take priority.
result.Combine(ContinueLoadingFromJsonObjectField(&property->m_name, azrtti_typeid<AZStd::string>(), inputValue, Field::id, context));
result.Combine(ContinueLoadingFromJsonObjectField(&property->m_name, azrtti_typeid<AZStd::string>(), inputValue, Field::name, context));
result.Combine(ContinueLoadingFromJsonObjectField(&property->m_displayName, azrtti_typeid<AZStd::string>(), inputValue, Field::displayName, context)); result.Combine(ContinueLoadingFromJsonObjectField(&property->m_displayName, azrtti_typeid<AZStd::string>(), inputValue, Field::displayName, context));
result.Combine(ContinueLoadingFromJsonObjectField(&property->m_description, azrtti_typeid<AZStd::string>(), inputValue, Field::description, context)); result.Combine(ContinueLoadingFromJsonObjectField(&property->m_description, azrtti_typeid<AZStd::string>(), inputValue, Field::description, context));
result.Combine(ContinueLoadingFromJsonObjectField(&property->m_dataType, azrtti_typeid<MaterialPropertyDataType>(), inputValue, Field::type, context)); result.Combine(ContinueLoadingFromJsonObjectField(&property->m_dataType, azrtti_typeid<MaterialPropertyDataType>(), inputValue, Field::type, context));
@ -374,7 +379,7 @@ namespace AZ
outputValue.SetObject(); outputValue.SetObject();
const AZStd::string emptyString; const AZStd::string emptyString;
result.Combine(ContinueStoringToJsonObjectField(outputValue, Field::id, &property->m_nameId, &emptyString, azrtti_typeid<AZStd::string>(), context)); result.Combine(ContinueStoringToJsonObjectField(outputValue, Field::name, &property->m_name, &emptyString, azrtti_typeid<AZStd::string>(), context));
result.Combine(ContinueStoringToJsonObjectField(outputValue, Field::displayName, &property->m_displayName, &emptyString, azrtti_typeid<AZStd::string>(), context)); result.Combine(ContinueStoringToJsonObjectField(outputValue, Field::displayName, &property->m_displayName, &emptyString, azrtti_typeid<AZStd::string>(), context));
result.Combine(ContinueStoringToJsonObjectField(outputValue, Field::description, &property->m_description, &emptyString, azrtti_typeid<AZStd::string>(), context)); result.Combine(ContinueStoringToJsonObjectField(outputValue, Field::description, &property->m_description, &emptyString, azrtti_typeid<AZStd::string>(), context));

@ -62,18 +62,18 @@ namespace AZ
return context.Report(JsonSerializationResult::Tasks::ReadField, JsonSerializationResult::Outcomes::Catastrophic, "Material type reference not found."); return context.Report(JsonSerializationResult::Tasks::ReadField, JsonSerializationResult::Outcomes::Catastrophic, "Material type reference not found.");
} }
// Construct the full property name (groupId.propertyId) by parsing it from the JSON path string. // Construct the full property name (groupName.propertyName) by parsing it from the JSON path string.
size_t startPropertyNameId = context.GetPath().Get().rfind('/'); size_t startPropertyName = context.GetPath().Get().rfind('/');
size_t startGroupNameId = context.GetPath().Get().rfind('/', startPropertyNameId-1); size_t startGroupName = context.GetPath().Get().rfind('/', startPropertyName-1);
AZStd::string_view groupNameId = context.GetPath().Get().substr(startGroupNameId + 1, startPropertyNameId - startGroupNameId - 1); AZStd::string_view groupName = context.GetPath().Get().substr(startGroupName + 1, startPropertyName - startGroupName - 1);
AZStd::string_view propertyNameId = context.GetPath().Get().substr(startPropertyNameId + 1); AZStd::string_view propertyName = context.GetPath().Get().substr(startPropertyName + 1);
JSR::ResultCode result(JSR::Tasks::ReadField); JSR::ResultCode result(JSR::Tasks::ReadField);
auto propertyDefinition = materialType->FindProperty(groupNameId, propertyNameId); auto propertyDefinition = materialType->FindProperty(groupName, propertyName);
if (!propertyDefinition) if (!propertyDefinition)
{ {
AZStd::string message = AZStd::string::format("Property '%.*s.%.*s' not found in material type.", AZ_STRING_ARG(groupNameId), AZ_STRING_ARG(propertyNameId)); AZStd::string message = AZStd::string::format("Property '%.*s.%.*s' not found in material type.", AZ_STRING_ARG(groupName), AZ_STRING_ARG(propertyName));
return context.Report(JsonSerializationResult::Tasks::ReadField, JsonSerializationResult::Outcomes::Unsupported, message); return context.Report(JsonSerializationResult::Tasks::ReadField, JsonSerializationResult::Outcomes::Unsupported, message);
} }
else else

@ -52,7 +52,8 @@ namespace AZ
serializeContext->Class<PropertyConnection>() serializeContext->Class<PropertyConnection>()
->Version(1) ->Version(1)
->Field("type", &PropertyConnection::m_type) ->Field("type", &PropertyConnection::m_type)
->Field("id", &PropertyConnection::m_nameId) ->Field("id", &PropertyConnection::m_fieldName) // The old reflection, replaced by "name"
->Field("name", &PropertyConnection::m_fieldName)
->Field("shaderIndex", &PropertyConnection::m_shaderIndex) ->Field("shaderIndex", &PropertyConnection::m_shaderIndex)
; ;
@ -60,7 +61,8 @@ namespace AZ
serializeContext->Class<GroupDefinition>() serializeContext->Class<GroupDefinition>()
->Version(1) ->Version(1)
->Field("id", &GroupDefinition::m_nameId) ->Field("id", &GroupDefinition::m_name) // The old reflection, replaced by "name"
->Field("name", &GroupDefinition::m_name)
->Field("displayName", &GroupDefinition::m_displayName) ->Field("displayName", &GroupDefinition::m_displayName)
->Field("description", &GroupDefinition::m_description) ->Field("description", &GroupDefinition::m_description)
; ;
@ -96,9 +98,9 @@ namespace AZ
} }
} }
MaterialTypeSourceData::PropertyConnection::PropertyConnection(MaterialPropertyOutputType type, AZStd::string_view nameId, int32_t shaderIndex) MaterialTypeSourceData::PropertyConnection::PropertyConnection(MaterialPropertyOutputType type, AZStd::string_view fieldName, int32_t shaderIndex)
: m_type(type) : m_type(type)
, m_nameId(nameId) , m_fieldName(fieldName)
, m_shaderIndex(shaderIndex) , m_shaderIndex(shaderIndex)
{ {
} }
@ -107,11 +109,11 @@ namespace AZ
const float MaterialTypeSourceData::PropertyDefinition::DefaultMax = std::numeric_limits<float>::max(); const float MaterialTypeSourceData::PropertyDefinition::DefaultMax = std::numeric_limits<float>::max();
const float MaterialTypeSourceData::PropertyDefinition::DefaultStep = 0.1f; const float MaterialTypeSourceData::PropertyDefinition::DefaultStep = 0.1f;
const MaterialTypeSourceData::GroupDefinition* MaterialTypeSourceData::FindGroup(AZStd::string_view groupNameId) const const MaterialTypeSourceData::GroupDefinition* MaterialTypeSourceData::FindGroup(AZStd::string_view groupName) const
{ {
for (const GroupDefinition& group : m_propertyLayout.m_groups) for (const GroupDefinition& group : m_propertyLayout.m_groups)
{ {
if (group.m_nameId == groupNameId) if (group.m_name == groupName)
{ {
return &group; return &group;
} }
@ -120,9 +122,9 @@ namespace AZ
return nullptr; return nullptr;
} }
const MaterialTypeSourceData::PropertyDefinition* MaterialTypeSourceData::FindProperty(AZStd::string_view groupNameId, AZStd::string_view propertyNameId) const const MaterialTypeSourceData::PropertyDefinition* MaterialTypeSourceData::FindProperty(AZStd::string_view groupName, AZStd::string_view propertyName) const
{ {
auto groupIter = m_propertyLayout.m_properties.find(groupNameId); auto groupIter = m_propertyLayout.m_properties.find(groupName);
if (groupIter == m_propertyLayout.m_properties.end()) if (groupIter == m_propertyLayout.m_properties.end())
{ {
return nullptr; return nullptr;
@ -130,7 +132,7 @@ namespace AZ
for (const PropertyDefinition& property : groupIter->second) for (const PropertyDefinition& property : groupIter->second)
{ {
if (property.m_nameId == propertyNameId) if (property.m_name == propertyName)
{ {
return &property; return &property;
} }
@ -169,24 +171,24 @@ namespace AZ
AZStd::unordered_set<AZStd::string> foundGroups; AZStd::unordered_set<AZStd::string> foundGroups;
for (const auto& groupDefinition : m_propertyLayout.m_groups) for (const auto& groupDefinition : m_propertyLayout.m_groups)
{ {
if (foundGroups.insert(groupDefinition.m_nameId).second) if (foundGroups.insert(groupDefinition.m_name).second)
{ {
groupDefinitions.push_back(groupDefinition); groupDefinitions.push_back(groupDefinition);
} }
else else
{ {
AZ_Warning("Material source data", false, "Duplicate group '%s' found.", groupDefinition.m_nameId.c_str()); AZ_Warning("Material source data", false, "Duplicate group '%s' found.", groupDefinition.m_name.c_str());
} }
} }
// Some groups are defined implicitly, in the "properties" section where a group name is used but not explicitly defined in the "groups" section. // Some groups are defined implicitly, in the "properties" section where a group name is used but not explicitly defined in the "groups" section.
for (const auto& propertyListPair : m_propertyLayout.m_properties) for (const auto& propertyListPair : m_propertyLayout.m_properties)
{ {
const AZStd::string& groupNameId = propertyListPair.first; const AZStd::string& groupName = propertyListPair.first;
if (foundGroups.insert(groupNameId).second) if (foundGroups.insert(groupName).second)
{ {
MaterialTypeSourceData::GroupDefinition groupDefinition; MaterialTypeSourceData::GroupDefinition groupDefinition;
groupDefinition.m_nameId = groupNameId; groupDefinition.m_name = groupName;
groupDefinitions.push_back(groupDefinition); groupDefinitions.push_back(groupDefinition);
} }
} }
@ -203,12 +205,12 @@ namespace AZ
for (const auto& propertyListPair : m_propertyLayout.m_properties) for (const auto& propertyListPair : m_propertyLayout.m_properties)
{ {
const AZStd::string& groupNameId = propertyListPair.first; const AZStd::string& groupName = propertyListPair.first;
const auto& propertyList = propertyListPair.second; const auto& propertyList = propertyListPair.second;
for (const auto& propertyDefinition : propertyList) for (const auto& propertyDefinition : propertyList)
{ {
const AZStd::string& propertyNameId = propertyDefinition.m_nameId; const AZStd::string& propertyName = propertyDefinition.m_name;
if (!callback(groupNameId, propertyNameId, propertyDefinition)) if (!callback(groupName, propertyName, propertyDefinition))
{ {
return; return;
} }
@ -225,15 +227,15 @@ namespace AZ
for (const auto& groupDefinition : GetGroupDefinitionsInDisplayOrder()) for (const auto& groupDefinition : GetGroupDefinitionsInDisplayOrder())
{ {
const AZStd::string& groupNameId = groupDefinition.m_nameId; const AZStd::string& groupName = groupDefinition.m_name;
const auto propertyListItr = m_propertyLayout.m_properties.find(groupNameId); const auto propertyListItr = m_propertyLayout.m_properties.find(groupName);
if (propertyListItr != m_propertyLayout.m_properties.end()) if (propertyListItr != m_propertyLayout.m_properties.end())
{ {
const auto& propertyList = propertyListItr->second; const auto& propertyList = propertyListItr->second;
for (const auto& propertyDefinition : propertyList) for (const auto& propertyDefinition : propertyList)
{ {
const AZStd::string& propertyNameId = propertyDefinition.m_nameId; const AZStd::string& propertyName = propertyDefinition.m_name;
if (!callback(groupNameId, propertyNameId, propertyDefinition)) if (!callback(groupName, propertyName, propertyDefinition))
{ {
return; return;
} }
@ -249,7 +251,7 @@ namespace AZ
const uint32_t index = propertyValue.GetValue<uint32_t>(); const uint32_t index = propertyValue.GetValue<uint32_t>();
if (index >= propertyDefinition.m_enumValues.size()) if (index >= propertyDefinition.m_enumValues.size())
{ {
AZ_Error("Material source data", false, "Invalid value for material enum property: '%s'.", propertyDefinition.m_nameId.c_str()); AZ_Error("Material source data", false, "Invalid value for material enum property: '%s'.", propertyDefinition.m_name.c_str());
return false; return false;
} }
@ -272,7 +274,7 @@ namespace AZ
imageAsset.GetId(), imageAsset.GetType(), platformName, imageAssetInfo, rootFilePath); imageAsset.GetId(), imageAsset.GetType(), platformName, imageAssetInfo, rootFilePath);
if (!result) if (!result)
{ {
AZ_Error("Material source data", false, "Image asset could not be found for property: '%s'.", propertyDefinition.m_nameId.c_str()); AZ_Error("Material source data", false, "Image asset could not be found for property: '%s'.", propertyDefinition.m_name.c_str());
return false; return false;
} }
} }
@ -340,13 +342,13 @@ namespace AZ
for (auto& groupIter : m_propertyLayout.m_properties) for (auto& groupIter : m_propertyLayout.m_properties)
{ {
const AZStd::string& groupNameId = groupIter.first; const AZStd::string& groupName = groupIter.first;
for (const PropertyDefinition& property : groupIter.second) for (const PropertyDefinition& property : groupIter.second)
{ {
// Register the property... // Register the property...
MaterialPropertyId propertyId{ groupNameId, property.m_nameId }; MaterialPropertyId propertyId{ groupName, property.m_name };
if (!propertyId.IsValid()) if (!propertyId.IsValid())
{ {
@ -366,16 +368,16 @@ namespace AZ
switch (output.m_type) switch (output.m_type)
{ {
case MaterialPropertyOutputType::ShaderInput: case MaterialPropertyOutputType::ShaderInput:
materialTypeAssetCreator.ConnectMaterialPropertyToShaderInput(Name{ output.m_nameId.data() }); materialTypeAssetCreator.ConnectMaterialPropertyToShaderInput(Name{ output.m_fieldName.data() });
break; break;
case MaterialPropertyOutputType::ShaderOption: case MaterialPropertyOutputType::ShaderOption:
if (output.m_shaderIndex >= 0) if (output.m_shaderIndex >= 0)
{ {
materialTypeAssetCreator.ConnectMaterialPropertyToShaderOption(Name{ output.m_nameId.data() }, output.m_shaderIndex); materialTypeAssetCreator.ConnectMaterialPropertyToShaderOption(Name{ output.m_fieldName.data() }, output.m_shaderIndex);
} }
else else
{ {
materialTypeAssetCreator.ConnectMaterialPropertyToShaderOptions(Name{ output.m_nameId.data() }); materialTypeAssetCreator.ConnectMaterialPropertyToShaderOptions(Name{ output.m_fieldName.data() });
} }
break; break;
case MaterialPropertyOutputType::Invalid: case MaterialPropertyOutputType::Invalid:

@ -386,9 +386,9 @@ namespace AZ
return m_currentChangeId; return m_currentChangeId;
} }
MaterialPropertyIndex Material::FindPropertyIndex(const Name& name) const MaterialPropertyIndex Material::FindPropertyIndex(const Name& propertyId) const
{ {
return m_layout->FindPropertyIndex(name); return m_layout->FindPropertyIndex(propertyId);
} }
template<typename Type> template<typename Type>

@ -34,9 +34,9 @@ namespace AZ
return m_materialPropertyDescriptors.size(); return m_materialPropertyDescriptors.size();
} }
MaterialPropertyIndex MaterialPropertiesLayout::FindPropertyIndex(const Name& propertyName) const MaterialPropertyIndex MaterialPropertiesLayout::FindPropertyIndex(const Name& propertyId) const
{ {
return m_materialPropertyIndexes.Find(propertyName); return m_materialPropertyIndexes.Find(propertyId);
} }
const MaterialPropertyDescriptor* MaterialPropertiesLayout::GetPropertyDescriptor(MaterialPropertyIndex index) const const MaterialPropertyDescriptor* MaterialPropertiesLayout::GetPropertyDescriptor(MaterialPropertyIndex index) const

@ -89,14 +89,14 @@ namespace UnitTest
} }
}; };
void AddPropertyGroup(MaterialSourceData& material, AZStd::string_view groupNameId) void AddPropertyGroup(MaterialSourceData& material, AZStd::string_view groupName)
{ {
material.m_properties.insert(groupNameId); material.m_properties.insert(groupName);
} }
void AddProperty(MaterialSourceData& material, AZStd::string_view groupNameId, AZStd::string_view propertyNameId, const MaterialPropertyValue& anyValue) void AddProperty(MaterialSourceData& material, AZStd::string_view groupName, AZStd::string_view propertyName, const MaterialPropertyValue& anyValue)
{ {
material.m_properties[groupNameId][propertyNameId].m_value = anyValue; material.m_properties[groupName][propertyName].m_value = anyValue;
} }
TEST_F(MaterialSourceDataTests, CreateMaterialAsset_BasicProperties) TEST_F(MaterialSourceDataTests, CreateMaterialAsset_BasicProperties)

@ -32,10 +32,10 @@ namespace AtomToolsFramework
// AtomToolsDocumentRequestBus::Handler implementation // AtomToolsDocumentRequestBus::Handler implementation
AZStd::string_view GetAbsolutePath() const override; AZStd::string_view GetAbsolutePath() const override;
AZStd::string_view GetRelativePath() const override; AZStd::string_view GetRelativePath() const override;
const AZStd::any& GetPropertyValue(const AZ::Name& propertyFullName) const override; const AZStd::any& GetPropertyValue(const AZ::Name& propertyId) const override;
const AtomToolsFramework::DynamicProperty& GetProperty(const AZ::Name& propertyFullName) const override; const AtomToolsFramework::DynamicProperty& GetProperty(const AZ::Name& propertyId) const override;
bool IsPropertyGroupVisible(const AZ::Name& propertyGroupFullName) const override; bool IsPropertyGroupVisible(const AZ::Name& propertyGroupFullName) const override;
void SetPropertyValue(const AZ::Name& propertyFullName, const AZStd::any& value) override; void SetPropertyValue(const AZ::Name& propertyId, const AZStd::any& value) override;
bool Open(AZStd::string_view loadPath) override; bool Open(AZStd::string_view loadPath) override;
bool Reopen() override; bool Reopen() override;
bool Save() override; bool Save() override;

@ -42,8 +42,8 @@ namespace AtomToolsFramework
AZ_CLASS_ALLOCATOR(DynamicPropertyConfig, AZ::SystemAllocator, 0); AZ_CLASS_ALLOCATOR(DynamicPropertyConfig, AZ::SystemAllocator, 0);
DynamicPropertyType m_dataType = DynamicPropertyType::Invalid; DynamicPropertyType m_dataType = DynamicPropertyType::Invalid;
AZ::Name m_id; AZ::Name m_id; //!< The full property ID, which will normally be "groupName.propertyName"
AZStd::string m_nameId; AZStd::string m_name;
AZStd::string m_displayName; AZStd::string m_displayName;
AZStd::string m_groupName; AZStd::string m_groupName;
AZStd::string m_description; AZStd::string m_description;

@ -41,27 +41,27 @@ namespace AtomToolsFramework
//! Add a group consisting of a collapsable header and widget //! Add a group consisting of a collapsable header and widget
virtual void AddGroup( virtual void AddGroup(
const AZStd::string& groupNameId, const AZStd::string& groupName,
const AZStd::string& groupDisplayName, const AZStd::string& groupDisplayName,
const AZStd::string& groupDescription, const AZStd::string& groupDescription,
QWidget* groupWidget) = 0; QWidget* groupWidget) = 0;
//! Sets the visibility of a specific property group. This impacts both the header and the widget. //! Sets the visibility of a specific property group. This impacts both the header and the widget.
virtual void SetGroupVisible(const AZStd::string& groupNameId, bool visible) = 0; virtual void SetGroupVisible(const AZStd::string& groupName, bool visible) = 0;
//! Returns whether a specific property is visible. //! Returns whether a specific property is visible.
//! Note this follows the same rules as QWidget::isVisible(), meaning a group could be not visible due to the widget's parents being not visible. //! Note this follows the same rules as QWidget::isVisible(), meaning a group could be not visible due to the widget's parents being not visible.
virtual bool IsGroupVisible(const AZStd::string& groupNameId) const = 0; virtual bool IsGroupVisible(const AZStd::string& groupName) const = 0;
//! Returns whether a specific property is explicitly hidden. //! Returns whether a specific property is explicitly hidden.
//! Note this follows the same rules as QWidget::isHidden(), meaning a group that is hidden will not become visible automatically when the parent becomes visible. //! Note this follows the same rules as QWidget::isHidden(), meaning a group that is hidden will not become visible automatically when the parent becomes visible.
virtual bool IsGroupHidden(const AZStd::string& groupNameId) const = 0; virtual bool IsGroupHidden(const AZStd::string& groupName) const = 0;
//! Calls Refresh for a specific InspectorGroupWidget, allowing for non-destructive UI changes //! Calls Refresh for a specific InspectorGroupWidget, allowing for non-destructive UI changes
virtual void RefreshGroup(const AZStd::string& groupNameId) = 0; virtual void RefreshGroup(const AZStd::string& groupName) = 0;
//! Calls Rebuild for a specific InspectorGroupWidget, allowing for destructive UI changes //! Calls Rebuild for a specific InspectorGroupWidget, allowing for destructive UI changes
virtual void RebuildGroup(const AZStd::string& groupNameId) = 0; virtual void RebuildGroup(const AZStd::string& groupName) = 0;
//! Calls Refresh for all InspectorGroupWidget, allowing for non-destructive UI changes //! Calls Refresh for all InspectorGroupWidget, allowing for non-destructive UI changes
virtual void RefreshAll() = 0; virtual void RefreshAll() = 0;
@ -70,13 +70,13 @@ namespace AtomToolsFramework
virtual void RebuildAll() = 0; virtual void RebuildAll() = 0;
//! Expands a specific group //! Expands a specific group
virtual void ExpandGroup(const AZStd::string& groupNameId) = 0; virtual void ExpandGroup(const AZStd::string& groupName) = 0;
//! Collapses a specific group //! Collapses a specific group
virtual void CollapseGroup(const AZStd::string& groupNameId) = 0; virtual void CollapseGroup(const AZStd::string& groupName) = 0;
//! Checks the expansion state of a specific group //! Checks the expansion state of a specific group
virtual bool IsGroupExpanded(const AZStd::string& groupNameId) const = 0; virtual bool IsGroupExpanded(const AZStd::string& groupName) const = 0;
//! Expands all groups and headers //! Expands all groups and headers
virtual void ExpandAll() = 0; virtual void ExpandAll() = 0;

@ -52,33 +52,33 @@ namespace AtomToolsFramework
void AddGroupsEnd() override; void AddGroupsEnd() override;
void AddGroup( void AddGroup(
const AZStd::string& groupNameId, const AZStd::string& groupName,
const AZStd::string& groupDisplayName, const AZStd::string& groupDisplayName,
const AZStd::string& groupDescription, const AZStd::string& groupDescription,
QWidget* groupWidget) override; QWidget* groupWidget) override;
void SetGroupVisible(const AZStd::string& groupNameId, bool visible) override; void SetGroupVisible(const AZStd::string& groupName, bool visible) override;
bool IsGroupVisible(const AZStd::string& groupNameId) const override; bool IsGroupVisible(const AZStd::string& groupName) const override;
bool IsGroupHidden(const AZStd::string& groupNameId) const override; bool IsGroupHidden(const AZStd::string& groupName) const override;
void RefreshGroup(const AZStd::string& groupNameId) override; void RefreshGroup(const AZStd::string& groupName) override;
void RebuildGroup(const AZStd::string& groupNameId) override; void RebuildGroup(const AZStd::string& groupName) override;
void RefreshAll() override; void RefreshAll() override;
void RebuildAll() override; void RebuildAll() override;
void ExpandGroup(const AZStd::string& groupNameId) override; void ExpandGroup(const AZStd::string& groupName) override;
void CollapseGroup(const AZStd::string& groupNameId) override; void CollapseGroup(const AZStd::string& groupName) override;
bool IsGroupExpanded(const AZStd::string& groupNameId) const override; bool IsGroupExpanded(const AZStd::string& groupName) const override;
void ExpandAll() override; void ExpandAll() override;
void CollapseAll() override; void CollapseAll() override;
protected: protected:
virtual bool ShouldGroupAutoExpanded(const AZStd::string& groupNameId) const; virtual bool ShouldGroupAutoExpanded(const AZStd::string& groupName) const;
virtual void OnGroupExpanded(const AZStd::string& groupNameId); virtual void OnGroupExpanded(const AZStd::string& groupName);
virtual void OnGroupCollapsed(const AZStd::string& groupNameId); virtual void OnGroupCollapsed(const AZStd::string& groupName);
virtual void OnHeaderClicked(const AZStd::string& groupNameId, QMouseEvent* event); virtual void OnHeaderClicked(const AZStd::string& groupName, QMouseEvent* event);
private: private:
QScopedPointer<Ui::InspectorWidget> m_ui; QScopedPointer<Ui::InspectorWidget> m_ui;

@ -38,16 +38,16 @@ namespace AtomToolsFramework
return m_relativePath; return m_relativePath;
} }
const AZStd::any& AtomToolsDocument::GetPropertyValue([[maybe_unused]] const AZ::Name& propertyFullName) const const AZStd::any& AtomToolsDocument::GetPropertyValue([[maybe_unused]] const AZ::Name& propertyId) const
{ {
AZ_UNUSED(propertyFullName); AZ_UNUSED(propertyId);
AZ_Error("AtomToolsDocument", false, "%s not implemented.", __FUNCTION__); AZ_Error("AtomToolsDocument", false, "%s not implemented.", __FUNCTION__);
return m_invalidValue; return m_invalidValue;
} }
const AtomToolsFramework::DynamicProperty& AtomToolsDocument::GetProperty([[maybe_unused]] const AZ::Name& propertyFullName) const const AtomToolsFramework::DynamicProperty& AtomToolsDocument::GetProperty([[maybe_unused]] const AZ::Name& propertyId) const
{ {
AZ_UNUSED(propertyFullName); AZ_UNUSED(propertyId);
AZ_Error("AtomToolsDocument", false, "%s not implemented.", __FUNCTION__); AZ_Error("AtomToolsDocument", false, "%s not implemented.", __FUNCTION__);
return m_invalidProperty; return m_invalidProperty;
} }
@ -59,9 +59,9 @@ namespace AtomToolsFramework
return false; return false;
} }
void AtomToolsDocument::SetPropertyValue([[maybe_unused]] const AZ::Name& propertyFullName, [[maybe_unused]] const AZStd::any& value) void AtomToolsDocument::SetPropertyValue([[maybe_unused]] const AZ::Name& propertyId, [[maybe_unused]] const AZStd::any& value)
{ {
AZ_UNUSED(propertyFullName); AZ_UNUSED(propertyId);
AZ_UNUSED(value); AZ_UNUSED(value);
AZ_Error("AtomToolsDocument", false, "%s not implemented.", __FUNCTION__); AZ_Error("AtomToolsDocument", false, "%s not implemented.", __FUNCTION__);
} }

@ -192,7 +192,7 @@ namespace AtomToolsFramework
AZStd::string DynamicProperty::GetDisplayName() const AZStd::string DynamicProperty::GetDisplayName() const
{ {
return !m_config.m_displayName.empty() ? m_config.m_displayName : m_config.m_nameId; return !m_config.m_displayName.empty() ? m_config.m_displayName : m_config.m_name;
} }
AZStd::string DynamicProperty::GetGroupName() const AZStd::string DynamicProperty::GetGroupName() const

@ -66,7 +66,7 @@ namespace AtomToolsFramework
} }
void InspectorWidget::AddGroup( void InspectorWidget::AddGroup(
const AZStd::string& groupNameId, const AZStd::string& groupName,
const AZStd::string& groupDisplayName, const AZStd::string& groupDisplayName,
const AZStd::string& groupDescription, const AZStd::string& groupDescription,
QWidget* groupWidget) QWidget* groupWidget)
@ -76,31 +76,31 @@ namespace AtomToolsFramework
groupHeader->setToolTip(groupDescription.c_str()); groupHeader->setToolTip(groupDescription.c_str());
m_ui->m_groupContentsLayout->addWidget(groupHeader); m_ui->m_groupContentsLayout->addWidget(groupHeader);
groupWidget->setObjectName(groupNameId.c_str()); groupWidget->setObjectName(groupName.c_str());
groupWidget->setParent(m_ui->m_groupContents); groupWidget->setParent(m_ui->m_groupContents);
m_ui->m_groupContentsLayout->addWidget(groupWidget); m_ui->m_groupContentsLayout->addWidget(groupWidget);
m_groups[groupNameId] = {groupHeader, groupWidget}; m_groups[groupName] = {groupHeader, groupWidget};
connect(groupHeader, &InspectorGroupHeaderWidget::clicked, this, [this, groupNameId](QMouseEvent* event) { connect(groupHeader, &InspectorGroupHeaderWidget::clicked, this, [this, groupName](QMouseEvent* event) {
OnHeaderClicked(groupNameId, event); OnHeaderClicked(groupName, event);
}); });
connect(groupHeader, &InspectorGroupHeaderWidget::expanded, this, [this, groupNameId]() { OnGroupExpanded(groupNameId); }); connect(groupHeader, &InspectorGroupHeaderWidget::expanded, this, [this, groupName]() { OnGroupExpanded(groupName); });
connect(groupHeader, &InspectorGroupHeaderWidget::collapsed, this, [this, groupNameId]() { OnGroupCollapsed(groupNameId); }); connect(groupHeader, &InspectorGroupHeaderWidget::collapsed, this, [this, groupName]() { OnGroupCollapsed(groupName); });
if (ShouldGroupAutoExpanded(groupNameId)) if (ShouldGroupAutoExpanded(groupName))
{ {
ExpandGroup(groupNameId); ExpandGroup(groupName);
} }
else else
{ {
CollapseGroup(groupNameId); CollapseGroup(groupName);
} }
} }
void InspectorWidget::SetGroupVisible(const AZStd::string& groupNameId, bool visible) void InspectorWidget::SetGroupVisible(const AZStd::string& groupName, bool visible)
{ {
auto groupItr = m_groups.find(groupNameId); auto groupItr = m_groups.find(groupName);
if (groupItr != m_groups.end()) if (groupItr != m_groups.end())
{ {
groupItr->second.m_header->setVisible(visible); groupItr->second.m_header->setVisible(visible);
@ -108,29 +108,29 @@ namespace AtomToolsFramework
} }
} }
bool InspectorWidget::IsGroupVisible(const AZStd::string& groupNameId) const bool InspectorWidget::IsGroupVisible(const AZStd::string& groupName) const
{ {
auto groupItr = m_groups.find(groupNameId); auto groupItr = m_groups.find(groupName);
return groupItr != m_groups.end() ? groupItr->second.m_header->isVisible() : false; return groupItr != m_groups.end() ? groupItr->second.m_header->isVisible() : false;
} }
bool InspectorWidget::IsGroupHidden(const AZStd::string& groupNameId) const bool InspectorWidget::IsGroupHidden(const AZStd::string& groupName) const
{ {
auto groupItr = m_groups.find(groupNameId); auto groupItr = m_groups.find(groupName);
return groupItr != m_groups.end() ? groupItr->second.m_header->isHidden() : false; return groupItr != m_groups.end() ? groupItr->second.m_header->isHidden() : false;
} }
void InspectorWidget::RefreshGroup(const AZStd::string& groupNameId) void InspectorWidget::RefreshGroup(const AZStd::string& groupName)
{ {
for (auto groupWidget : m_ui->m_groupContents->findChildren<InspectorGroupWidget*>(groupNameId.c_str())) for (auto groupWidget : m_ui->m_groupContents->findChildren<InspectorGroupWidget*>(groupName.c_str()))
{ {
groupWidget->Refresh(); groupWidget->Refresh();
} }
} }
void InspectorWidget::RebuildGroup(const AZStd::string& groupNameId) void InspectorWidget::RebuildGroup(const AZStd::string& groupName)
{ {
for (auto groupWidget : m_ui->m_groupContents->findChildren<InspectorGroupWidget*>(groupNameId.c_str())) for (auto groupWidget : m_ui->m_groupContents->findChildren<InspectorGroupWidget*>(groupName.c_str()))
{ {
groupWidget->Rebuild(); groupWidget->Rebuild();
} }
@ -152,9 +152,9 @@ namespace AtomToolsFramework
} }
} }
void InspectorWidget::ExpandGroup(const AZStd::string& groupNameId) void InspectorWidget::ExpandGroup(const AZStd::string& groupName)
{ {
auto groupItr = m_groups.find(groupNameId); auto groupItr = m_groups.find(groupName);
if (groupItr != m_groups.end()) if (groupItr != m_groups.end())
{ {
groupItr->second.m_header->SetExpanded(true); groupItr->second.m_header->SetExpanded(true);
@ -162,9 +162,9 @@ namespace AtomToolsFramework
} }
} }
void InspectorWidget::CollapseGroup(const AZStd::string& groupNameId) void InspectorWidget::CollapseGroup(const AZStd::string& groupName)
{ {
auto groupItr = m_groups.find(groupNameId); auto groupItr = m_groups.find(groupName);
if (groupItr != m_groups.end()) if (groupItr != m_groups.end())
{ {
groupItr->second.m_header->SetExpanded(false); groupItr->second.m_header->SetExpanded(false);
@ -172,9 +172,9 @@ namespace AtomToolsFramework
} }
} }
bool InspectorWidget::IsGroupExpanded(const AZStd::string& groupNameId) const bool InspectorWidget::IsGroupExpanded(const AZStd::string& groupName) const
{ {
auto groupItr = m_groups.find(groupNameId); auto groupItr = m_groups.find(groupName);
return groupItr != m_groups.end() ? groupItr->second.m_header->IsExpanded() : false; return groupItr != m_groups.end() ? groupItr->second.m_header->IsExpanded() : false;
} }
@ -196,33 +196,33 @@ namespace AtomToolsFramework
} }
} }
bool InspectorWidget::ShouldGroupAutoExpanded(const AZStd::string& groupNameId) const bool InspectorWidget::ShouldGroupAutoExpanded(const AZStd::string& groupName) const
{ {
AZ_UNUSED(groupNameId); AZ_UNUSED(groupName);
return true; return true;
} }
void InspectorWidget::OnGroupExpanded(const AZStd::string& groupNameId) void InspectorWidget::OnGroupExpanded(const AZStd::string& groupName)
{ {
AZ_UNUSED(groupNameId); AZ_UNUSED(groupName);
} }
void InspectorWidget::OnGroupCollapsed(const AZStd::string& groupNameId) void InspectorWidget::OnGroupCollapsed(const AZStd::string& groupName)
{ {
AZ_UNUSED(groupNameId); AZ_UNUSED(groupName);
} }
void InspectorWidget::OnHeaderClicked(const AZStd::string& groupNameId, QMouseEvent* event) void InspectorWidget::OnHeaderClicked(const AZStd::string& groupName, QMouseEvent* event)
{ {
if (event->button() == Qt::MouseButton::LeftButton) if (event->button() == Qt::MouseButton::LeftButton)
{ {
if (!IsGroupExpanded(groupNameId)) if (!IsGroupExpanded(groupName))
{ {
ExpandGroup(groupNameId); ExpandGroup(groupName);
} }
else else
{ {
CollapseGroup(groupNameId); CollapseGroup(groupName);
} }
return; return;
} }
@ -230,8 +230,8 @@ namespace AtomToolsFramework
if (event->button() == Qt::MouseButton::RightButton) if (event->button() == Qt::MouseButton::RightButton)
{ {
QMenu menu; QMenu menu;
menu.addAction("Expand", [this, groupNameId]() { ExpandGroup(groupNameId); })->setEnabled(!IsGroupExpanded(groupNameId)); menu.addAction("Expand", [this, groupName]() { ExpandGroup(groupName); })->setEnabled(!IsGroupExpanded(groupName));
menu.addAction("Collapse", [this, groupNameId]() { CollapseGroup(groupNameId); })->setEnabled(IsGroupExpanded(groupNameId)); menu.addAction("Collapse", [this, groupName]() { CollapseGroup(groupName); })->setEnabled(IsGroupExpanded(groupName));
menu.addAction("Expand All", [this]() { ExpandAll(); }); menu.addAction("Expand All", [this]() { ExpandAll(); });
menu.addAction("Collapse All", [this]() { CollapseAll(); }); menu.addAction("Collapse All", [this]() { CollapseAll(); });
menu.exec(event->globalPos()); menu.exec(event->globalPos());

@ -74,7 +74,7 @@ namespace AtomToolsFramework
void ConvertToPropertyConfig(AtomToolsFramework::DynamicPropertyConfig& propertyConfig, const AZ::RPI::MaterialTypeSourceData::PropertyDefinition& propertyDefinition) void ConvertToPropertyConfig(AtomToolsFramework::DynamicPropertyConfig& propertyConfig, const AZ::RPI::MaterialTypeSourceData::PropertyDefinition& propertyDefinition)
{ {
propertyConfig.m_dataType = ConvertToEditableType(propertyDefinition.m_dataType); propertyConfig.m_dataType = ConvertToEditableType(propertyDefinition.m_dataType);
propertyConfig.m_nameId = propertyDefinition.m_nameId; propertyConfig.m_name = propertyDefinition.m_name;
propertyConfig.m_displayName = propertyDefinition.m_displayName; propertyConfig.m_displayName = propertyDefinition.m_displayName;
propertyConfig.m_description = propertyDefinition.m_description; propertyConfig.m_description = propertyDefinition.m_description;
propertyConfig.m_defaultValue = ConvertToEditableType(propertyDefinition.m_value); propertyConfig.m_defaultValue = ConvertToEditableType(propertyDefinition.m_value);

@ -59,7 +59,7 @@ namespace MaterialEditor
return &m_materialTypeSourceData; return &m_materialTypeSourceData;
} }
const AZStd::any& MaterialDocument::GetPropertyValue(const AZ::Name& propertyFullName) const const AZStd::any& MaterialDocument::GetPropertyValue(const AZ::Name& propertyId) const
{ {
using namespace AZ; using namespace AZ;
using namespace RPI; using namespace RPI;
@ -70,10 +70,10 @@ namespace MaterialEditor
return m_invalidValue; return m_invalidValue;
} }
const auto it = m_properties.find(propertyFullName); const auto it = m_properties.find(propertyId);
if (it == m_properties.end()) if (it == m_properties.end())
{ {
AZ_Error("MaterialDocument", false, "Material document property could not be found: '%s'.", propertyFullName.GetCStr()); AZ_Error("MaterialDocument", false, "Material document property could not be found: '%s'.", propertyId.GetCStr());
return m_invalidValue; return m_invalidValue;
} }
@ -81,7 +81,7 @@ namespace MaterialEditor
return property.GetValue(); return property.GetValue();
} }
const AtomToolsFramework::DynamicProperty& MaterialDocument::GetProperty(const AZ::Name& propertyFullName) const const AtomToolsFramework::DynamicProperty& MaterialDocument::GetProperty(const AZ::Name& propertyId) const
{ {
if (!IsOpen()) if (!IsOpen())
{ {
@ -89,10 +89,10 @@ namespace MaterialEditor
return m_invalidProperty; return m_invalidProperty;
} }
const auto it = m_properties.find(propertyFullName); const auto it = m_properties.find(propertyId);
if (it == m_properties.end()) if (it == m_properties.end())
{ {
AZ_Error("MaterialDocument", false, "Material document property could not be found: '%s'.", propertyFullName.GetCStr()); AZ_Error("MaterialDocument", false, "Material document property could not be found: '%s'.", propertyId.GetCStr());
return m_invalidProperty; return m_invalidProperty;
} }
@ -118,7 +118,7 @@ namespace MaterialEditor
return it->second; return it->second;
} }
void MaterialDocument::SetPropertyValue(const AZ::Name& propertyFullName, const AZStd::any& value) void MaterialDocument::SetPropertyValue(const AZ::Name& propertyId, const AZStd::any& value)
{ {
using namespace AZ; using namespace AZ;
using namespace RPI; using namespace RPI;
@ -129,10 +129,10 @@ namespace MaterialEditor
return; return;
} }
const auto it = m_properties.find(propertyFullName); const auto it = m_properties.find(propertyId);
if (it == m_properties.end()) if (it == m_properties.end())
{ {
AZ_Error("MaterialDocument", false, "Material document property could not be found: '%s'.", propertyFullName.GetCStr()); AZ_Error("MaterialDocument", false, "Material document property could not be found: '%s'.", propertyId.GetCStr());
return; return;
} }
@ -143,8 +143,7 @@ namespace MaterialEditor
AtomToolsFramework::DynamicProperty& property = it->second; AtomToolsFramework::DynamicProperty& property = it->second;
property.SetValue(AtomToolsFramework::ConvertToEditableType(propertyValue)); property.SetValue(AtomToolsFramework::ConvertToEditableType(propertyValue));
const AZ::RPI::MaterialPropertyId propertyId = AZ::RPI::MaterialPropertyId::Parse(propertyFullName.GetStringView()); const auto propertyIndex = m_materialInstance->FindPropertyIndex(propertyId);
const auto propertyIndex = m_materialInstance->FindPropertyIndex(propertyFullName);
if (!propertyIndex.IsNull()) if (!propertyIndex.IsNull())
{ {
if (m_materialInstance->SetPropertyValue(propertyIndex, propertyValue)) if (m_materialInstance->SetPropertyValue(propertyIndex, propertyValue))
@ -593,8 +592,9 @@ namespace MaterialEditor
bool result = true; bool result = true;
// populate sourceData with properties that meet the filter // populate sourceData with properties that meet the filter
m_materialTypeSourceData.EnumerateProperties([this, &sourceData, &propertyFilter, &result](const AZStd::string& groupNameId, const AZStd::string& propertyNameId, const auto& propertyDefinition) { m_materialTypeSourceData.EnumerateProperties([this, &sourceData, &propertyFilter, &result](const AZStd::string& groupName, const AZStd::string& propertyName, const auto& propertyDefinition) {
const MaterialPropertyId propertyId(groupNameId, propertyNameId);
const MaterialPropertyId propertyId(groupName, propertyName);
const auto it = m_properties.find(propertyId.GetFullName()); const auto it = m_properties.find(propertyId.GetFullName());
if (it != m_properties.end() && propertyFilter(it->second)) if (it != m_properties.end() && propertyFilter(it->second))
@ -609,7 +609,7 @@ namespace MaterialEditor
return false; return false;
} }
sourceData.m_properties[groupNameId][propertyNameId].m_value = propertyValue; sourceData.m_properties[groupName][propertyName].m_value = propertyValue;
} }
} }
return true; return true;
@ -770,11 +770,11 @@ namespace MaterialEditor
// Populate the property map from a combination of source data and assets // Populate the property map from a combination of source data and assets
// Assets must still be used for now because they contain the final accumulated value after all other materials // Assets must still be used for now because they contain the final accumulated value after all other materials
// in the hierarchy are applied // in the hierarchy are applied
m_materialTypeSourceData.EnumerateProperties([this, &parentPropertyValues](const AZStd::string& groupNameId, const AZStd::string& propertyNameId, const auto& propertyDefinition) { m_materialTypeSourceData.EnumerateProperties([this, &parentPropertyValues](const AZStd::string& groupName, const AZStd::string& propertyName, const auto& propertyDefinition) {
AtomToolsFramework::DynamicPropertyConfig propertyConfig; AtomToolsFramework::DynamicPropertyConfig propertyConfig;
// Assign id before conversion so it can be used in dynamic description // Assign id before conversion so it can be used in dynamic description
propertyConfig.m_id = MaterialPropertyId(groupNameId, propertyNameId).GetCStr(); propertyConfig.m_id = MaterialPropertyId(groupName, propertyName).GetCStr();
const auto& propertyIndex = m_materialAsset->GetMaterialPropertiesLayout()->FindPropertyIndex(propertyConfig.m_id); const auto& propertyIndex = m_materialAsset->GetMaterialPropertiesLayout()->FindPropertyIndex(propertyConfig.m_id);
const bool propertyIndexInBounds = propertyIndex.IsValid() && propertyIndex.GetIndex() < m_materialAsset->GetPropertyValues().size(); const bool propertyIndexInBounds = propertyIndex.IsValid() && propertyIndex.GetIndex() < m_materialAsset->GetPropertyValues().size();
@ -786,8 +786,8 @@ namespace MaterialEditor
propertyConfig.m_showThumbnail = true; propertyConfig.m_showThumbnail = true;
propertyConfig.m_originalValue = AtomToolsFramework::ConvertToEditableType(m_materialAsset->GetPropertyValues()[propertyIndex.GetIndex()]); propertyConfig.m_originalValue = AtomToolsFramework::ConvertToEditableType(m_materialAsset->GetPropertyValues()[propertyIndex.GetIndex()]);
propertyConfig.m_parentValue = AtomToolsFramework::ConvertToEditableType(parentPropertyValues[propertyIndex.GetIndex()]); propertyConfig.m_parentValue = AtomToolsFramework::ConvertToEditableType(parentPropertyValues[propertyIndex.GetIndex()]);
auto groupDefinition = m_materialTypeSourceData.FindGroup(groupNameId); auto groupDefinition = m_materialTypeSourceData.FindGroup(groupName);
propertyConfig.m_groupName = groupDefinition ? groupDefinition->m_displayName : groupNameId; propertyConfig.m_groupName = groupDefinition ? groupDefinition->m_displayName : groupName;
m_properties[propertyConfig.m_id] = AtomToolsFramework::DynamicProperty(propertyConfig); m_properties[propertyConfig.m_id] = AtomToolsFramework::DynamicProperty(propertyConfig);
} }
return true; return true;
@ -796,7 +796,7 @@ namespace MaterialEditor
// Populate the property group visibility map // Populate the property group visibility map
for (MaterialTypeSourceData::GroupDefinition& group : m_materialTypeSourceData.GetGroupDefinitionsInDisplayOrder()) for (MaterialTypeSourceData::GroupDefinition& group : m_materialTypeSourceData.GetGroupDefinitionsInDisplayOrder())
{ {
m_propertyGroupVisibility[AZ::Name{group.m_nameId}] = true; m_propertyGroupVisibility[AZ::Name{group.m_name}] = true;
} }
// Adding properties for material type and parent as part of making dynamic // Adding properties for material type and parent as part of making dynamic
@ -808,7 +808,7 @@ namespace MaterialEditor
AtomToolsFramework::DynamicPropertyConfig propertyConfig; AtomToolsFramework::DynamicPropertyConfig propertyConfig;
propertyConfig.m_dataType = AtomToolsFramework::DynamicPropertyType::Asset; propertyConfig.m_dataType = AtomToolsFramework::DynamicPropertyType::Asset;
propertyConfig.m_id = "overview.materialType"; propertyConfig.m_id = "overview.materialType";
propertyConfig.m_nameId = "materialType"; propertyConfig.m_name = "materialType";
propertyConfig.m_displayName = "Material Type"; propertyConfig.m_displayName = "Material Type";
propertyConfig.m_groupName = "Overview"; propertyConfig.m_groupName = "Overview";
propertyConfig.m_description = "The material type defines the layout, properties, default values, shader connections, and other " propertyConfig.m_description = "The material type defines the layout, properties, default values, shader connections, and other "
@ -823,7 +823,7 @@ namespace MaterialEditor
propertyConfig = {}; propertyConfig = {};
propertyConfig.m_dataType = AtomToolsFramework::DynamicPropertyType::Asset; propertyConfig.m_dataType = AtomToolsFramework::DynamicPropertyType::Asset;
propertyConfig.m_id = "overview.parentMaterial"; propertyConfig.m_id = "overview.parentMaterial";
propertyConfig.m_nameId = "parentMaterial"; propertyConfig.m_name = "parentMaterial";
propertyConfig.m_displayName = "Parent Material"; propertyConfig.m_displayName = "Parent Material";
propertyConfig.m_groupName = "Overview"; propertyConfig.m_groupName = "Overview";
propertyConfig.m_description = propertyConfig.m_description =
@ -846,7 +846,7 @@ namespace MaterialEditor
propertyConfig = {}; propertyConfig = {};
propertyConfig.m_dataType = AtomToolsFramework::DynamicPropertyType::String; propertyConfig.m_dataType = AtomToolsFramework::DynamicPropertyType::String;
propertyConfig.m_id = MaterialPropertyId(UvGroupName, shaderInput).GetCStr(); propertyConfig.m_id = MaterialPropertyId(UvGroupName, shaderInput).GetCStr();
propertyConfig.m_nameId = shaderInput; propertyConfig.m_name = shaderInput;
propertyConfig.m_displayName = shaderInput; propertyConfig.m_displayName = shaderInput;
propertyConfig.m_groupName = "UV Sets"; propertyConfig.m_groupName = "UV Sets";
propertyConfig.m_description = shaderInput; propertyConfig.m_description = shaderInput;

@ -43,10 +43,10 @@ namespace MaterialEditor
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
// AtomToolsFramework::AtomToolsDocument // AtomToolsFramework::AtomToolsDocument
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
const AZStd::any& GetPropertyValue(const AZ::Name& propertyFullName) const override; const AZStd::any& GetPropertyValue(const AZ::Name& propertyId) const override;
const AtomToolsFramework::DynamicProperty& GetProperty(const AZ::Name& propertyFullName) const override; const AtomToolsFramework::DynamicProperty& GetProperty(const AZ::Name& propertyId) const override;
bool IsPropertyGroupVisible(const AZ::Name& propertyGroupFullName) const override; bool IsPropertyGroupVisible(const AZ::Name& propertyGroupFullName) const override;
void SetPropertyValue(const AZ::Name& propertyFullName, const AZStd::any& value) override; void SetPropertyValue(const AZ::Name& propertyId, const AZStd::any& value) override;
bool Open(AZStd::string_view loadPath) override; bool Open(AZStd::string_view loadPath) override;
bool Reopen() override; bool Reopen() override;
bool Save() override; bool Save() override;

@ -44,20 +44,20 @@ namespace MaterialEditor
AtomToolsFramework::InspectorWidget::Reset(); AtomToolsFramework::InspectorWidget::Reset();
} }
bool MaterialInspector::ShouldGroupAutoExpanded(const AZStd::string& groupNameId) const bool MaterialInspector::ShouldGroupAutoExpanded(const AZStd::string& groupName) const
{ {
auto stateItr = m_windowSettings->m_inspectorCollapsedGroups.find(GetGroupSaveStateKey(groupNameId)); auto stateItr = m_windowSettings->m_inspectorCollapsedGroups.find(GetGroupSaveStateKey(groupName));
return stateItr == m_windowSettings->m_inspectorCollapsedGroups.end(); return stateItr == m_windowSettings->m_inspectorCollapsedGroups.end();
} }
void MaterialInspector::OnGroupExpanded(const AZStd::string& groupNameId) void MaterialInspector::OnGroupExpanded(const AZStd::string& groupName)
{ {
m_windowSettings->m_inspectorCollapsedGroups.erase(GetGroupSaveStateKey(groupNameId)); m_windowSettings->m_inspectorCollapsedGroups.erase(GetGroupSaveStateKey(groupName));
} }
void MaterialInspector::OnGroupCollapsed(const AZStd::string& groupNameId) void MaterialInspector::OnGroupCollapsed(const AZStd::string& groupName)
{ {
m_windowSettings->m_inspectorCollapsedGroups.insert(GetGroupSaveStateKey(groupNameId)); m_windowSettings->m_inspectorCollapsedGroups.insert(GetGroupSaveStateKey(groupName));
} }
void MaterialInspector::OnDocumentOpened(const AZ::Uuid& documentId) void MaterialInspector::OnDocumentOpened(const AZ::Uuid& documentId)
@ -86,9 +86,9 @@ namespace MaterialEditor
AddGroupsEnd(); AddGroupsEnd();
} }
AZ::Crc32 MaterialInspector::GetGroupSaveStateKey(const AZStd::string& groupNameId) const AZ::Crc32 MaterialInspector::GetGroupSaveStateKey(const AZStd::string& groupName) const
{ {
return AZ::Crc32(AZStd::string::format("MaterialInspector::PropertyGroup::%s::%s", m_documentPath.c_str(), groupNameId.c_str())); return AZ::Crc32(AZStd::string::format("MaterialInspector::PropertyGroup::%s::%s", m_documentPath.c_str(), groupName.c_str()));
} }
bool MaterialInspector::CompareInstanceNodeProperties( bool MaterialInspector::CompareInstanceNodeProperties(
@ -105,10 +105,10 @@ namespace MaterialEditor
MaterialDocumentRequestBus::EventResult( MaterialDocumentRequestBus::EventResult(
materialTypeSourceData, m_documentId, &MaterialDocumentRequestBus::Events::GetMaterialTypeSourceData); materialTypeSourceData, m_documentId, &MaterialDocumentRequestBus::Events::GetMaterialTypeSourceData);
const AZStd::string groupNameId = "overview"; const AZStd::string groupName = "overview";
const AZStd::string groupDisplayName = "Overview"; const AZStd::string groupDisplayName = "Overview";
const AZStd::string groupDescription = materialTypeSourceData->m_description; const AZStd::string groupDescription = materialTypeSourceData->m_description;
auto& group = m_groups[groupNameId]; auto& group = m_groups[groupName];
AtomToolsFramework::DynamicProperty property; AtomToolsFramework::DynamicProperty property;
AtomToolsFramework::AtomToolsDocumentRequestBus::EventResult( AtomToolsFramework::AtomToolsDocumentRequestBus::EventResult(
@ -122,9 +122,9 @@ namespace MaterialEditor
// Passing in same group as main and comparison instance to enable custom value comparison for highlighting modified properties // Passing in same group as main and comparison instance to enable custom value comparison for highlighting modified properties
auto propertyGroupWidget = new AtomToolsFramework::InspectorPropertyGroupWidget( auto propertyGroupWidget = new AtomToolsFramework::InspectorPropertyGroupWidget(
&group, &group, group.TYPEINFO_Uuid(), this, this, GetGroupSaveStateKey(groupNameId), &group, &group, group.TYPEINFO_Uuid(), this, this, GetGroupSaveStateKey(groupName),
[this](const auto source, const auto target) { return CompareInstanceNodeProperties(source, target); }); [this](const auto source, const auto target) { return CompareInstanceNodeProperties(source, target); });
AddGroup(groupNameId, groupDisplayName, groupDescription, propertyGroupWidget); AddGroup(groupName, groupDisplayName, groupDescription, propertyGroupWidget);
} }
void MaterialInspector::AddUvNamesGroup() void MaterialInspector::AddUvNamesGroup()
@ -132,10 +132,10 @@ namespace MaterialEditor
AZ::Data::Asset<AZ::RPI::MaterialAsset> materialAsset; AZ::Data::Asset<AZ::RPI::MaterialAsset> materialAsset;
MaterialDocumentRequestBus::EventResult(materialAsset, m_documentId, &MaterialDocumentRequestBus::Events::GetAsset); MaterialDocumentRequestBus::EventResult(materialAsset, m_documentId, &MaterialDocumentRequestBus::Events::GetAsset);
const AZStd::string groupNameId = UvGroupName; const AZStd::string groupName = UvGroupName;
const AZStd::string groupDisplayName = "UV Sets"; const AZStd::string groupDisplayName = "UV Sets";
const AZStd::string groupDescription = "UV set names in this material, which can be renamed to match those in the model."; const AZStd::string groupDescription = "UV set names in this material, which can be renamed to match those in the model.";
auto& group = m_groups[groupNameId]; auto& group = m_groups[groupName];
const auto& uvNameMap = materialAsset->GetMaterialTypeAsset()->GetUvNameMap(); const auto& uvNameMap = materialAsset->GetMaterialTypeAsset()->GetUvNameMap();
group.m_properties.reserve(uvNameMap.size()); group.m_properties.reserve(uvNameMap.size());
@ -145,7 +145,7 @@ namespace MaterialEditor
AtomToolsFramework::DynamicProperty property; AtomToolsFramework::DynamicProperty property;
AtomToolsFramework::AtomToolsDocumentRequestBus::EventResult( AtomToolsFramework::AtomToolsDocumentRequestBus::EventResult(
property, m_documentId, &AtomToolsFramework::AtomToolsDocumentRequestBus::Events::GetProperty, property, m_documentId, &AtomToolsFramework::AtomToolsDocumentRequestBus::Events::GetProperty,
AZ::RPI::MaterialPropertyId(groupNameId, uvNamePair.m_shaderInput.ToString()).GetFullName()); AZ::RPI::MaterialPropertyId(groupName, uvNamePair.m_shaderInput.ToString()).GetFullName());
group.m_properties.push_back(property); group.m_properties.push_back(property);
property.SetValue(property.GetConfig().m_parentValue); property.SetValue(property.GetConfig().m_parentValue);
@ -153,9 +153,9 @@ namespace MaterialEditor
// Passing in same group as main and comparison instance to enable custom value comparison for highlighting modified properties // Passing in same group as main and comparison instance to enable custom value comparison for highlighting modified properties
auto propertyGroupWidget = new AtomToolsFramework::InspectorPropertyGroupWidget( auto propertyGroupWidget = new AtomToolsFramework::InspectorPropertyGroupWidget(
&group, &group, group.TYPEINFO_Uuid(), this, this, GetGroupSaveStateKey(groupNameId), &group, &group, group.TYPEINFO_Uuid(), this, this, GetGroupSaveStateKey(groupName),
[this](const auto source, const auto target) { return CompareInstanceNodeProperties(source, target); }); [this](const auto source, const auto target) { return CompareInstanceNodeProperties(source, target); });
AddGroup(groupNameId, groupDisplayName, groupDescription, propertyGroupWidget); AddGroup(groupName, groupDisplayName, groupDescription, propertyGroupWidget);
} }
void MaterialInspector::AddPropertiesGroup() void MaterialInspector::AddPropertiesGroup()
@ -166,14 +166,14 @@ namespace MaterialEditor
for (const auto& groupDefinition : materialTypeSourceData->GetGroupDefinitionsInDisplayOrder()) for (const auto& groupDefinition : materialTypeSourceData->GetGroupDefinitionsInDisplayOrder())
{ {
const AZStd::string& groupNameId = groupDefinition.m_nameId; const AZStd::string& groupName = groupDefinition.m_name;
const AZStd::string& groupDisplayName = !groupDefinition.m_displayName.empty() ? groupDefinition.m_displayName : groupNameId; const AZStd::string& groupDisplayName = !groupDefinition.m_displayName.empty() ? groupDefinition.m_displayName : groupName;
const AZStd::string& groupDescription = const AZStd::string& groupDescription =
!groupDefinition.m_description.empty() ? groupDefinition.m_description : groupDisplayName; !groupDefinition.m_description.empty() ? groupDefinition.m_description : groupDisplayName;
auto& group = m_groups[groupNameId]; auto& group = m_groups[groupName];
const auto& propertyLayout = materialTypeSourceData->m_propertyLayout; const auto& propertyLayout = materialTypeSourceData->m_propertyLayout;
const auto& propertyListItr = propertyLayout.m_properties.find(groupNameId); const auto& propertyListItr = propertyLayout.m_properties.find(groupName);
if (propertyListItr != propertyLayout.m_properties.end()) if (propertyListItr != propertyLayout.m_properties.end())
{ {
group.m_properties.reserve(propertyListItr->second.size()); group.m_properties.reserve(propertyListItr->second.size());
@ -182,21 +182,21 @@ namespace MaterialEditor
AtomToolsFramework::DynamicProperty property; AtomToolsFramework::DynamicProperty property;
AtomToolsFramework::AtomToolsDocumentRequestBus::EventResult( AtomToolsFramework::AtomToolsDocumentRequestBus::EventResult(
property, m_documentId, &AtomToolsFramework::AtomToolsDocumentRequestBus::Events::GetProperty, property, m_documentId, &AtomToolsFramework::AtomToolsDocumentRequestBus::Events::GetProperty,
AZ::RPI::MaterialPropertyId(groupNameId, propertyDefinition.m_nameId).GetFullName()); AZ::RPI::MaterialPropertyId(groupName, propertyDefinition.m_name).GetFullName());
group.m_properties.push_back(property); group.m_properties.push_back(property);
} }
} }
// Passing in same group as main and comparison instance to enable custom value comparison for highlighting modified properties // Passing in same group as main and comparison instance to enable custom value comparison for highlighting modified properties
auto propertyGroupWidget = new AtomToolsFramework::InspectorPropertyGroupWidget( auto propertyGroupWidget = new AtomToolsFramework::InspectorPropertyGroupWidget(
&group, &group, group.TYPEINFO_Uuid(), this, this, GetGroupSaveStateKey(groupNameId), &group, &group, group.TYPEINFO_Uuid(), this, this, GetGroupSaveStateKey(groupName),
[this](const auto source, const auto target) { return CompareInstanceNodeProperties(source, target); }); [this](const auto source, const auto target) { return CompareInstanceNodeProperties(source, target); });
AddGroup(groupNameId, groupDisplayName, groupDescription, propertyGroupWidget); AddGroup(groupName, groupDisplayName, groupDescription, propertyGroupWidget);
bool isGroupVisible = false; bool isGroupVisible = false;
AtomToolsFramework::AtomToolsDocumentRequestBus::EventResult( AtomToolsFramework::AtomToolsDocumentRequestBus::EventResult(
isGroupVisible, m_documentId, &AtomToolsFramework::AtomToolsDocumentRequestBus::Events::IsPropertyGroupVisible, AZ::Name{groupNameId}); isGroupVisible, m_documentId, &AtomToolsFramework::AtomToolsDocumentRequestBus::Events::IsPropertyGroupVisible, AZ::Name{groupName});
SetGroupVisible(groupNameId, isGroupVisible); SetGroupVisible(groupName, isGroupVisible);
} }
} }

@ -37,12 +37,12 @@ namespace MaterialEditor
void Reset() override; void Reset() override;
protected: protected:
bool ShouldGroupAutoExpanded(const AZStd::string& groupNameId) const override; bool ShouldGroupAutoExpanded(const AZStd::string& groupName) const override;
void OnGroupExpanded(const AZStd::string& groupNameId) override; void OnGroupExpanded(const AZStd::string& groupName) override;
void OnGroupCollapsed(const AZStd::string& groupNameId) override; void OnGroupCollapsed(const AZStd::string& groupName) override;
private: private:
AZ::Crc32 GetGroupSaveStateKey(const AZStd::string& groupNameId) const; AZ::Crc32 GetGroupSaveStateKey(const AZStd::string& groupName) const;
bool CompareInstanceNodeProperties( bool CompareInstanceNodeProperties(
const AzToolsFramework::InstanceDataNode* source, const AzToolsFramework::InstanceDataNode* target) const; const AzToolsFramework::InstanceDataNode* source, const AzToolsFramework::InstanceDataNode* target) const;

@ -35,26 +35,26 @@ namespace MaterialEditor
void SettingsWidget::AddDocumentSettingsGroup() void SettingsWidget::AddDocumentSettingsGroup()
{ {
const AZStd::string groupNameId = "documentSettings"; const AZStd::string groupName = "documentSettings";
const AZStd::string groupDisplayName = "Document Settings"; const AZStd::string groupDisplayName = "Document Settings";
const AZStd::string groupDescription = "Document Settings"; const AZStd::string groupDescription = "Document Settings";
const AZ::Crc32 saveStateKey(AZStd::string::format("SettingsWidget::DocumentSettingsGroup")); const AZ::Crc32 saveStateKey(AZStd::string::format("SettingsWidget::DocumentSettingsGroup"));
AddGroup( AddGroup(
groupNameId, groupDisplayName, groupDescription, groupName, groupDisplayName, groupDescription,
new AtomToolsFramework::InspectorPropertyGroupWidget( new AtomToolsFramework::InspectorPropertyGroupWidget(
m_documentSettings.get(), nullptr, m_documentSettings->TYPEINFO_Uuid(), this, this, saveStateKey)); m_documentSettings.get(), nullptr, m_documentSettings->TYPEINFO_Uuid(), this, this, saveStateKey));
} }
void SettingsWidget::AddDocumentSystemSettingsGroup() void SettingsWidget::AddDocumentSystemSettingsGroup()
{ {
const AZStd::string groupNameId = "documentSystemSettings"; const AZStd::string groupName = "documentSystemSettings";
const AZStd::string groupDisplayName = "Document System Settings"; const AZStd::string groupDisplayName = "Document System Settings";
const AZStd::string groupDescription = "Document System Settings"; const AZStd::string groupDescription = "Document System Settings";
const AZ::Crc32 saveStateKey(AZStd::string::format("SettingsWidget::DocumentSystemSettingsGroup")); const AZ::Crc32 saveStateKey(AZStd::string::format("SettingsWidget::DocumentSystemSettingsGroup"));
AddGroup( AddGroup(
groupNameId, groupDisplayName, groupDescription, groupName, groupDisplayName, groupDescription,
new AtomToolsFramework::InspectorPropertyGroupWidget( new AtomToolsFramework::InspectorPropertyGroupWidget(
m_documentSystemSettings.get(), nullptr, m_documentSystemSettings->TYPEINFO_Uuid(), this, this, saveStateKey)); m_documentSystemSettings.get(), nullptr, m_documentSystemSettings->TYPEINFO_Uuid(), this, this, saveStateKey));
} }

@ -53,19 +53,19 @@ namespace MaterialEditor
void ViewportSettingsInspector::AddGeneralGroup() void ViewportSettingsInspector::AddGeneralGroup()
{ {
const AZStd::string groupNameId = "generalSettings"; const AZStd::string groupName = "generalSettings";
const AZStd::string groupDisplayName = "General Settings"; const AZStd::string groupDisplayName = "General Settings";
const AZStd::string groupDescription = "General Settings"; const AZStd::string groupDescription = "General Settings";
AddGroup( AddGroup(
groupNameId, groupDisplayName, groupDescription, groupName, groupDisplayName, groupDescription,
new AtomToolsFramework::InspectorPropertyGroupWidget( new AtomToolsFramework::InspectorPropertyGroupWidget(
m_viewportSettings.get(), nullptr, m_viewportSettings->TYPEINFO_Uuid(), this, this, GetGroupSaveStateKey(groupNameId))); m_viewportSettings.get(), nullptr, m_viewportSettings->TYPEINFO_Uuid(), this, this, GetGroupSaveStateKey(groupName)));
} }
void ViewportSettingsInspector::AddModelGroup() void ViewportSettingsInspector::AddModelGroup()
{ {
const AZStd::string groupNameId = "modelSettings"; const AZStd::string groupName = "modelSettings";
const AZStd::string groupDisplayName = "Model Settings"; const AZStd::string groupDisplayName = "Model Settings";
const AZStd::string groupDescription = "Model Settings"; const AZStd::string groupDescription = "Model Settings";
@ -93,12 +93,12 @@ namespace MaterialEditor
if (m_modelPreset) if (m_modelPreset)
{ {
auto inspectorWidget = new AtomToolsFramework::InspectorPropertyGroupWidget( auto inspectorWidget = new AtomToolsFramework::InspectorPropertyGroupWidget(
m_modelPreset.get(), nullptr, m_modelPreset.get()->TYPEINFO_Uuid(), this, groupWidget, GetGroupSaveStateKey(groupNameId)); m_modelPreset.get(), nullptr, m_modelPreset.get()->TYPEINFO_Uuid(), this, groupWidget, GetGroupSaveStateKey(groupName));
groupWidget->layout()->addWidget(inspectorWidget); groupWidget->layout()->addWidget(inspectorWidget);
} }
AddGroup(groupNameId, groupDisplayName, groupDescription, groupWidget); AddGroup(groupName, groupDisplayName, groupDescription, groupWidget);
} }
void ViewportSettingsInspector::AddModelPreset() void ViewportSettingsInspector::AddModelPreset()
@ -152,7 +152,7 @@ namespace MaterialEditor
void ViewportSettingsInspector::AddLightingGroup() void ViewportSettingsInspector::AddLightingGroup()
{ {
const AZStd::string groupNameId = "lightingSettings"; const AZStd::string groupName = "lightingSettings";
const AZStd::string groupDisplayName = "Lighting Settings"; const AZStd::string groupDisplayName = "Lighting Settings";
const AZStd::string groupDescription = "Lighting Settings"; const AZStd::string groupDescription = "Lighting Settings";
@ -181,12 +181,12 @@ namespace MaterialEditor
{ {
auto inspectorWidget = new AtomToolsFramework::InspectorPropertyGroupWidget( auto inspectorWidget = new AtomToolsFramework::InspectorPropertyGroupWidget(
m_lightingPreset.get(), nullptr, m_lightingPreset.get()->TYPEINFO_Uuid(), this, groupWidget, m_lightingPreset.get(), nullptr, m_lightingPreset.get()->TYPEINFO_Uuid(), this, groupWidget,
GetGroupSaveStateKey(groupNameId)); GetGroupSaveStateKey(groupName));
groupWidget->layout()->addWidget(inspectorWidget); groupWidget->layout()->addWidget(inspectorWidget);
} }
AddGroup(groupNameId, groupDisplayName, groupDescription, groupWidget); AddGroup(groupName, groupDisplayName, groupDescription, groupWidget);
} }
void ViewportSettingsInspector::AddLightingPreset() void ViewportSettingsInspector::AddLightingPreset()
@ -354,25 +354,25 @@ namespace MaterialEditor
return savePath; return savePath;
} }
AZ::Crc32 ViewportSettingsInspector::GetGroupSaveStateKey(const AZStd::string& groupNameId) const AZ::Crc32 ViewportSettingsInspector::GetGroupSaveStateKey(const AZStd::string& groupName) const
{ {
return AZ::Crc32(AZStd::string::format("ViewportSettingsInspector::PropertyGroup::%s", groupNameId.c_str())); return AZ::Crc32(AZStd::string::format("ViewportSettingsInspector::PropertyGroup::%s", groupName.c_str()));
} }
bool ViewportSettingsInspector::ShouldGroupAutoExpanded(const AZStd::string& groupNameId) const bool ViewportSettingsInspector::ShouldGroupAutoExpanded(const AZStd::string& groupName) const
{ {
auto stateItr = m_windowSettings->m_inspectorCollapsedGroups.find(GetGroupSaveStateKey(groupNameId)); auto stateItr = m_windowSettings->m_inspectorCollapsedGroups.find(GetGroupSaveStateKey(groupName));
return stateItr == m_windowSettings->m_inspectorCollapsedGroups.end(); return stateItr == m_windowSettings->m_inspectorCollapsedGroups.end();
} }
void ViewportSettingsInspector::OnGroupExpanded(const AZStd::string& groupNameId) void ViewportSettingsInspector::OnGroupExpanded(const AZStd::string& groupName)
{ {
m_windowSettings->m_inspectorCollapsedGroups.erase(GetGroupSaveStateKey(groupNameId)); m_windowSettings->m_inspectorCollapsedGroups.erase(GetGroupSaveStateKey(groupName));
} }
void ViewportSettingsInspector::OnGroupCollapsed(const AZStd::string& groupNameId) void ViewportSettingsInspector::OnGroupCollapsed(const AZStd::string& groupName)
{ {
m_windowSettings->m_inspectorCollapsedGroups.insert(GetGroupSaveStateKey(groupNameId)); m_windowSettings->m_inspectorCollapsedGroups.insert(GetGroupSaveStateKey(groupName));
} }
} // namespace MaterialEditor } // namespace MaterialEditor

@ -75,10 +75,10 @@ namespace MaterialEditor
AZStd::string GetDefaultUniqueSaveFilePath(const AZStd::string& baseName) const; AZStd::string GetDefaultUniqueSaveFilePath(const AZStd::string& baseName) const;
AZ::Crc32 GetGroupSaveStateKey(const AZStd::string& groupNameId) const; AZ::Crc32 GetGroupSaveStateKey(const AZStd::string& groupName) const;
bool ShouldGroupAutoExpanded(const AZStd::string& groupNameId) const override; bool ShouldGroupAutoExpanded(const AZStd::string& groupName) const override;
void OnGroupExpanded(const AZStd::string& groupNameId) override; void OnGroupExpanded(const AZStd::string& groupName) override;
void OnGroupCollapsed(const AZStd::string& groupNameId) override; void OnGroupCollapsed(const AZStd::string& groupName) override;
AZ::Render::ModelPresetPtr m_modelPreset; AZ::Render::ModelPresetPtr m_modelPreset;
AZ::Render::LightingPresetPtr m_lightingPreset; AZ::Render::LightingPresetPtr m_lightingPreset;

@ -169,7 +169,7 @@ namespace AZ
void MaterialPropertyInspector::AddDetailsGroup() void MaterialPropertyInspector::AddDetailsGroup()
{ {
const AZStd::string& groupNameId = "Details"; const AZStd::string& groupName = "Details";
const AZStd::string& groupDisplayName = "Details"; const AZStd::string& groupDisplayName = "Details";
const AZStd::string& groupDescription = ""; const AZStd::string& groupDescription = "";
@ -235,15 +235,15 @@ namespace AZ
propertyGroupContainer->layout()->addWidget(materialInfoWidget); propertyGroupContainer->layout()->addWidget(materialInfoWidget);
AddGroup(groupNameId, groupDisplayName, groupDescription, propertyGroupContainer); AddGroup(groupName, groupDisplayName, groupDescription, propertyGroupContainer);
} }
void MaterialPropertyInspector::AddUvNamesGroup() void MaterialPropertyInspector::AddUvNamesGroup()
{ {
const AZStd::string groupNameId = AZ::RPI::UvGroupName; const AZStd::string groupName = AZ::RPI::UvGroupName;
const AZStd::string groupDisplayName = "UV Sets"; const AZStd::string groupDisplayName = "UV Sets";
const AZStd::string groupDescription = "UV set names in this material, which can be renamed to match those in the model."; const AZStd::string groupDescription = "UV set names in this material, which can be renamed to match those in the model.";
auto& group = m_groups[groupNameId]; auto& group = m_groups[groupName];
const RPI::MaterialUvNameMap& uvNameMap = m_editData.m_materialAsset->GetMaterialTypeAsset()->GetUvNameMap(); const RPI::MaterialUvNameMap& uvNameMap = m_editData.m_materialAsset->GetMaterialTypeAsset()->GetUvNameMap();
group.m_properties.reserve(uvNameMap.size()); group.m_properties.reserve(uvNameMap.size());
@ -257,8 +257,8 @@ namespace AZ
propertyConfig = {}; propertyConfig = {};
propertyConfig.m_dataType = AtomToolsFramework::DynamicPropertyType::String; propertyConfig.m_dataType = AtomToolsFramework::DynamicPropertyType::String;
propertyConfig.m_id = AZ::RPI::MaterialPropertyId(groupNameId, shaderInputStr).GetCStr(); propertyConfig.m_id = AZ::RPI::MaterialPropertyId(groupName, shaderInputStr).GetCStr();
propertyConfig.m_nameId = shaderInputStr; propertyConfig.m_name = shaderInputStr;
propertyConfig.m_displayName = shaderInputStr; propertyConfig.m_displayName = shaderInputStr;
propertyConfig.m_groupName = groupDisplayName; propertyConfig.m_groupName = groupDisplayName;
propertyConfig.m_description = shaderInputStr; propertyConfig.m_description = shaderInputStr;
@ -271,8 +271,8 @@ namespace AZ
// Passing in same group as main and comparison instance to enable custom value comparison for highlighting modified properties // Passing in same group as main and comparison instance to enable custom value comparison for highlighting modified properties
auto propertyGroupWidget = new AtomToolsFramework::InspectorPropertyGroupWidget( auto propertyGroupWidget = new AtomToolsFramework::InspectorPropertyGroupWidget(
&group, nullptr, group.TYPEINFO_Uuid(), this, this, GetSaveStateKeyForGroup(groupNameId)); &group, nullptr, group.TYPEINFO_Uuid(), this, this, GetSaveStateKeyForGroup(groupName));
AddGroup(groupNameId, groupDisplayName, groupDescription, propertyGroupWidget); AddGroup(groupName, groupDisplayName, groupDescription, propertyGroupWidget);
} }
void MaterialPropertyInspector::Populate() void MaterialPropertyInspector::Populate()
@ -285,13 +285,13 @@ namespace AZ
// Copy all of the properties from the material asset to the source data that will be exported // Copy all of the properties from the material asset to the source data that will be exported
for (const auto& groupDefinition : m_editData.m_materialTypeSourceData.GetGroupDefinitionsInDisplayOrder()) for (const auto& groupDefinition : m_editData.m_materialTypeSourceData.GetGroupDefinitionsInDisplayOrder())
{ {
const AZStd::string& groupNameId = groupDefinition.m_nameId; const AZStd::string& groupName = groupDefinition.m_name;
const AZStd::string& groupDisplayName = !groupDefinition.m_displayName.empty() ? groupDefinition.m_displayName : groupNameId; const AZStd::string& groupDisplayName = !groupDefinition.m_displayName.empty() ? groupDefinition.m_displayName : groupName;
const AZStd::string& groupDescription = !groupDefinition.m_description.empty() ? groupDefinition.m_description : groupDisplayName; const AZStd::string& groupDescription = !groupDefinition.m_description.empty() ? groupDefinition.m_description : groupDisplayName;
auto& group = m_groups[groupNameId]; auto& group = m_groups[groupName];
const auto& propertyLayout = m_editData.m_materialTypeSourceData.m_propertyLayout; const auto& propertyLayout = m_editData.m_materialTypeSourceData.m_propertyLayout;
const auto& propertyListItr = propertyLayout.m_properties.find(groupNameId); const auto& propertyListItr = propertyLayout.m_properties.find(groupName);
if (propertyListItr != propertyLayout.m_properties.end()) if (propertyListItr != propertyLayout.m_properties.end())
{ {
group.m_properties.reserve(propertyListItr->second.size()); group.m_properties.reserve(propertyListItr->second.size());
@ -300,7 +300,7 @@ namespace AZ
AtomToolsFramework::DynamicPropertyConfig propertyConfig; AtomToolsFramework::DynamicPropertyConfig propertyConfig;
// Assign id before conversion so it can be used in dynamic description // Assign id before conversion so it can be used in dynamic description
propertyConfig.m_id = AZ::RPI::MaterialPropertyId(groupNameId, propertyDefinition.m_nameId).GetFullName(); propertyConfig.m_id = AZ::RPI::MaterialPropertyId(groupName, propertyDefinition.m_name).GetFullName();
AtomToolsFramework::ConvertToPropertyConfig(propertyConfig, propertyDefinition); AtomToolsFramework::ConvertToPropertyConfig(propertyConfig, propertyDefinition);
@ -316,8 +316,8 @@ namespace AZ
// Passing in same group as main and comparison instance to enable custom value comparison for highlighting modified properties // Passing in same group as main and comparison instance to enable custom value comparison for highlighting modified properties
auto propertyGroupWidget = new AtomToolsFramework::InspectorPropertyGroupWidget( auto propertyGroupWidget = new AtomToolsFramework::InspectorPropertyGroupWidget(
&group, nullptr, group.TYPEINFO_Uuid(), this, this, GetSaveStateKeyForGroup(groupNameId)); &group, nullptr, group.TYPEINFO_Uuid(), this, this, GetSaveStateKeyForGroup(groupName));
AddGroup(groupNameId, groupDisplayName, groupDescription, propertyGroupWidget); AddGroup(groupName, groupDisplayName, groupDescription, propertyGroupWidget);
} }
AddGroupsEnd(); AddGroupsEnd();
@ -496,11 +496,11 @@ namespace AZ
} }
} }
AZ::Crc32 MaterialPropertyInspector::GetSaveStateKeyForGroup(const AZStd::string& groupNameId) const AZ::Crc32 MaterialPropertyInspector::GetSaveStateKeyForGroup(const AZStd::string& groupName) const
{ {
return AZ::Crc32(AZStd::string::format( return AZ::Crc32(AZStd::string::format(
"MaterialPropertyInspector::PropertyGroup::%s::%s", m_editData.m_materialAssetId.ToString<AZStd::string>().c_str(), "MaterialPropertyInspector::PropertyGroup::%s::%s", m_editData.m_materialAssetId.ToString<AZStd::string>().c_str(),
groupNameId.c_str())); groupName.c_str()));
} }
bool MaterialPropertyInspector::AreNodePropertyValuesEqual( bool MaterialPropertyInspector::AreNodePropertyValuesEqual(

@ -100,7 +100,7 @@ namespace AZ
void RunEditorMaterialFunctors(); void RunEditorMaterialFunctors();
void UpdateMaterialInstanceProperty(const AtomToolsFramework::DynamicProperty& property); void UpdateMaterialInstanceProperty(const AtomToolsFramework::DynamicProperty& property);
AZ::Crc32 GetSaveStateKeyForGroup(const AZStd::string& groupNameId) const; AZ::Crc32 GetSaveStateKeyForGroup(const AZStd::string& groupName) const;
static bool AreNodePropertyValuesEqual( static bool AreNodePropertyValuesEqual(
const AzToolsFramework::InstanceDataNode* source, const AzToolsFramework::InstanceDataNode* target); const AzToolsFramework::InstanceDataNode* source, const AzToolsFramework::InstanceDataNode* target);

@ -137,8 +137,8 @@ namespace AZ
// Copy all of the properties from the material asset to the source data that will be exported // Copy all of the properties from the material asset to the source data that will be exported
result = true; result = true;
editData.m_materialTypeSourceData.EnumerateProperties([&](const AZStd::string& groupNameId, const AZStd::string& propertyNameId, const auto& propertyDefinition) { editData.m_materialTypeSourceData.EnumerateProperties([&](const AZStd::string& groupName, const AZStd::string& propertyName, const auto& propertyDefinition) {
const AZ::RPI::MaterialPropertyId propertyId(groupNameId, propertyNameId); const AZ::RPI::MaterialPropertyId propertyId(groupName, propertyName);
const AZ::RPI::MaterialPropertyIndex propertyIndex = const AZ::RPI::MaterialPropertyIndex propertyIndex =
editData.m_materialAsset->GetMaterialPropertiesLayout()->FindPropertyIndex(propertyId.GetFullName()); editData.m_materialAsset->GetMaterialPropertiesLayout()->FindPropertyIndex(propertyId.GetFullName());
@ -170,7 +170,7 @@ namespace AZ
return true; return true;
} }
exportData.m_properties[groupNameId][propertyDefinition.m_nameId].m_value = propertyValue; exportData.m_properties[groupName][propertyDefinition.m_name].m_value = propertyValue;
return true; return true;
}); });

@ -81,7 +81,7 @@ namespace AZ
{ {
AddGroupsBegin(); AddGroupsBegin();
const AZStd::string groupNameId = "ModelUvMap"; const AZStd::string groupName = "ModelUvMap";
const AZStd::string groupDisplayName = "Material to Model UV Map"; const AZStd::string groupDisplayName = "Material to Model UV Map";
const AZStd::string groupDescription = "Custom map that maps a UV name from the material to one from the model."; const AZStd::string groupDescription = "Custom map that maps a UV name from the material to one from the model.";
@ -96,8 +96,8 @@ namespace AZ
const AZStd::string materialUvName = m_materialUvNames[i].m_uvName.GetStringView(); const AZStd::string materialUvName = m_materialUvNames[i].m_uvName.GetStringView();
propertyConfig.m_dataType = AtomToolsFramework::DynamicPropertyType::Enum; propertyConfig.m_dataType = AtomToolsFramework::DynamicPropertyType::Enum;
propertyConfig.m_id = AZ::RPI::MaterialPropertyId(groupNameId, shaderInput).GetFullName(); propertyConfig.m_id = AZ::RPI::MaterialPropertyId(groupName, shaderInput).GetFullName();
propertyConfig.m_nameId = shaderInput; propertyConfig.m_name = shaderInput;
propertyConfig.m_displayName = materialUvName; propertyConfig.m_displayName = materialUvName;
propertyConfig.m_description = shaderInput; propertyConfig.m_description = shaderInput;
propertyConfig.m_defaultValue = 0u; propertyConfig.m_defaultValue = 0u;
@ -108,7 +108,7 @@ namespace AZ
m_group.m_properties.back().SetValue(AZStd::any(m_modelUvNameIndices[i])); m_group.m_properties.back().SetValue(AZStd::any(m_modelUvNameIndices[i]));
} }
AddGroup(groupNameId, groupDisplayName, groupDescription, AddGroup(groupName, groupDisplayName, groupDescription,
new AtomToolsFramework::InspectorPropertyGroupWidget(&m_group, nullptr, m_group.TYPEINFO_Uuid(), this)); new AtomToolsFramework::InspectorPropertyGroupWidget(&m_group, nullptr, m_group.TYPEINFO_Uuid(), this));
AddGroupsEnd(); AddGroupsEnd();
@ -238,7 +238,7 @@ namespace AZ
ResetModelUvNameIndices(); ResetModelUvNameIndices();
const AZStd::string groupNameId = "ModelUvMap"; const AZStd::string groupName = "ModelUvMap";
size_t uvSize = m_materialUvNames.size(); size_t uvSize = m_materialUvNames.size();
for (size_t i = 0u; i < uvSize; ++i) for (size_t i = 0u; i < uvSize; ++i)
@ -248,8 +248,8 @@ namespace AZ
const AZStd::string materialUvName = m_materialUvNames[i].m_uvName.GetStringView(); const AZStd::string materialUvName = m_materialUvNames[i].m_uvName.GetStringView();
propertyConfig.m_dataType = AtomToolsFramework::DynamicPropertyType::Enum; propertyConfig.m_dataType = AtomToolsFramework::DynamicPropertyType::Enum;
propertyConfig.m_id = AZ::RPI::MaterialPropertyId(groupNameId, shaderInput).GetFullName(); propertyConfig.m_id = AZ::RPI::MaterialPropertyId(groupName, shaderInput).GetFullName();
propertyConfig.m_nameId = shaderInput; propertyConfig.m_name = shaderInput;
propertyConfig.m_displayName = materialUvName; propertyConfig.m_displayName = materialUvName;
propertyConfig.m_description = shaderInput; propertyConfig.m_description = shaderInput;
propertyConfig.m_defaultValue = 0u; propertyConfig.m_defaultValue = 0u;

Loading…
Cancel
Save