Renamed property 'set' to property 'group' for consistency with the prior naming.

Signed-off-by: santorac <55155825+santorac@users.noreply.github.com>
This commit is contained in:
santorac
2022-01-27 16:11:26 -08:00
parent 1de540ae3f
commit c2e220ce49
9 changed files with 347 additions and 347 deletions
@@ -118,47 +118,47 @@ namespace AZ
using PropertyList = AZStd::vector<AZStd::unique_ptr<PropertyDefinition>>;
struct PropertySet
struct PropertyGroup
{
friend class MaterialTypeSourceData;
AZ_CLASS_ALLOCATOR(PropertySet, SystemAllocator, 0);
AZ_TYPE_INFO(AZ::RPI::MaterialTypeSourceData::PropertySet, "{BA3AA0E4-C74D-4FD0-ADB2-00B060F06314}");
AZ_CLASS_ALLOCATOR(PropertyGroup, SystemAllocator, 0);
AZ_TYPE_INFO(AZ::RPI::MaterialTypeSourceData::PropertyGroup, "{BA3AA0E4-C74D-4FD0-ADB2-00B060F06314}");
public:
PropertySet() = default;
AZ_DISABLE_COPY(PropertySet)
PropertyGroup() = default;
AZ_DISABLE_COPY(PropertyGroup)
const AZStd::string& GetName() const { return m_name; }
const AZStd::string& GetDisplayName() const { return m_displayName; }
const AZStd::string& GetDescription() const { return m_description; }
const PropertyList& GetProperties() const { return m_properties; }
const AZStd::vector<AZStd::unique_ptr<PropertySet>>& GetPropertySets() const { return m_propertySets; }
const AZStd::vector<AZStd::unique_ptr<PropertyGroup>>& GetPropertyGroups() const { return m_propertyGroups; }
const AZStd::vector<Ptr<MaterialFunctorSourceDataHolder>>& GetFunctors() const { return m_materialFunctorSourceData; }
void SetDisplayName(AZStd::string_view displayName) { m_displayName = displayName; }
void SetDescription(AZStd::string_view description) { m_description = description; }
//! Add a new property to this PropertySet.
//! Add a new property to this PropertyGroup.
//! @param name a unique for the property. Must be a C-style identifier.
//! @return the new PropertyDefinition, or null if the name was not valid.
PropertyDefinition* AddProperty(AZStd::string_view name);
//! Add a new nested PropertySet to this PropertySet.
//! @param name a unique for the property set. Must be a C-style identifier.
//! @return the new PropertySet, or null if the name was not valid.
PropertySet* AddPropertySet(AZStd::string_view name);
//! Add a new nested PropertyGroup to this PropertyGroup.
//! @param name a unique for the property group. Must be a C-style identifier.
//! @return the new PropertyGroup, or null if the name was not valid.
PropertyGroup* AddPropertyGroup(AZStd::string_view name);
private:
static PropertySet* AddPropertySet(AZStd::string_view name, AZStd::vector<AZStd::unique_ptr<PropertySet>>& toPropertySetList);
static PropertyGroup* AddPropertyGroup(AZStd::string_view name, AZStd::vector<AZStd::unique_ptr<PropertyGroup>>& toPropertyGroupList);
AZStd::string m_name;
AZStd::string m_displayName;
AZStd::string m_description;
PropertyList m_properties;
AZStd::vector<AZStd::unique_ptr<PropertySet>> m_propertySets;
AZStd::vector<AZStd::unique_ptr<PropertyGroup>> m_propertyGroups;
AZStd::vector<Ptr<MaterialFunctorSourceDataHolder>> m_materialFunctorSourceData;
};
@@ -215,15 +215,15 @@ namespace AZ
//! This field is unused, and has been replaced by MaterialTypeSourceData::m_version below. It is kept for legacy file compatibility to suppress warnings and errors.
uint32_t m_versionOld = 0;
//! [Deprecated] Use m_propertySets instead
//! [Deprecated] Use m_propertyGroups instead
//! List of groups that will contain the available properties
AZStd::vector<GroupDefinition> m_groupsOld;
//! [Deprecated] Use m_propertySets instead
//! [Deprecated] Use m_propertyGroups instead
AZStd::map<AZStd::string /*group name*/, AZStd::vector<PropertyDefinition>> m_propertiesOld;
//! Collection of all available user-facing properties
AZStd::vector<AZStd::unique_ptr<PropertySet>> m_propertySets;
AZStd::vector<AZStd::unique_ptr<PropertyGroup>> m_propertyGroups;
};
AZStd::string m_description;
@@ -247,24 +247,24 @@ namespace AZ
//! Copy over UV custom names to the properties enum values.
void ResolveUvEnums();
//! Add a new PropertySet for containing properties or other PropertySets.
//! @param propertySetId The ID of the new property set. To add as a nested PropertySet, use a full path ID like "levelA.levelB.levelC"; in this case a property set "levelA.levelB" must already exist.
//! @return a pointer to the new PropertySet or null if there was a problem (an AZ_Error will be reported).
PropertySet* AddPropertySet(AZStd::string_view propertySetId);
//! Add a new PropertyGroup for containing properties or other PropertyGroups.
//! @param propertyGroupId The ID of the new property group. To add as a nested PropertyGroup, use a full path ID like "levelA.levelB.levelC"; in this case a property group "levelA.levelB" must already exist.
//! @return a pointer to the new PropertyGroup or null if there was a problem (an AZ_Error will be reported).
PropertyGroup* AddPropertyGroup(AZStd::string_view propertyGroupId);
//! Add a new property to a PropertySet.
//! @param propertyId The ID of the new property, like "layerBlend.factor" or "layer2.roughness.texture". The indicated property set must already exist.
//! Add a new property to a PropertyGroup.
//! @param propertyId The ID of the new property, like "layerBlend.factor" or "layer2.roughness.texture". The indicated property group must already exist.
//! @return a pointer to the new PropertyDefinition or null if there was a problem (an AZ_Error will be reported).
PropertyDefinition* AddProperty(AZStd::string_view propertyId);
//! Return the PropertyLayout containing the tree of property sets and property definitions.
//! Return the PropertyLayout containing the tree of property groups and property definitions.
const PropertyLayout& GetPropertyLayout() const { return m_propertyLayout; }
//! Find the PropertySet with the given ID.
//! @param propertySetId The full ID of a property set to find, like "levelA.levelB.levelC".
//! @return the found PropertySet or null if it doesn't exist.
const PropertySet* FindPropertySet(AZStd::string_view propertySetId) const;
PropertySet* FindPropertySet(AZStd::string_view propertySetId);
//! Find the PropertyGroup with the given ID.
//! @param propertyGroupId The full ID of a property group to find, like "levelA.levelB.levelC".
//! @return the found PropertyGroup or null if it doesn't exist.
const PropertyGroup* FindPropertyGroup(AZStd::string_view propertyGroupId) const;
PropertyGroup* FindPropertyGroup(AZStd::string_view propertyGroupId);
//! Find the definition for a property with the given ID.
//! @param propertyId The full ID of a property to find, like "baseColor.texture".
@@ -280,14 +280,14 @@ namespace AZ
//! Call back function type used with the enumeration functions.
//! Return false to terminate the traversal.
using EnumeratePropertySetsCallback = AZStd::function<bool(
using EnumeratePropertyGroupsCallback = AZStd::function<bool(
const AZStd::string&, // The property ID context (i.e. "levelA.levelB.")
const PropertySet* // the next property set in the tree
const PropertyGroup* // the next property group in the tree
)>;
//! Recursively traverses all of the property sets contained in the material type, executing a callback function for each.
//! Recursively traverses all of the property groups contained in the material type, executing a callback function for each.
//! @return false if the enumeration was terminated early by the callback returning false.
bool EnumeratePropertySets(const EnumeratePropertySetsCallback& callback) const;
bool EnumeratePropertyGroups(const EnumeratePropertyGroupsCallback& callback) const;
//! Call back function type used with the numeration functions.
//! Return false to terminate the traversal.
@@ -303,31 +303,31 @@ namespace AZ
Outcome<Data::Asset<MaterialTypeAsset>> CreateMaterialTypeAsset(Data::AssetId assetId, AZStd::string_view materialTypeSourceFilePath = "", bool elevateWarnings = true) const;
//! If the data was loaded from an old format file (i.e. where "groups" and "properties" were separate sections),
//! this converts to the new format where properties are listed inside property sets.
//! this converts to the new format where properties are listed inside property groups.
bool ConvertToNewDataFormat();
private:
const PropertySet* FindPropertySet(AZStd::span<const AZStd::string_view> parsedPropertySetId, AZStd::span<const AZStd::unique_ptr<PropertySet>> inPropertySetList) const;
PropertySet* FindPropertySet(AZStd::span<AZStd::string_view> parsedPropertySetId, AZStd::span<AZStd::unique_ptr<PropertySet>> inPropertySetList);
const PropertyGroup* FindPropertyGroup(AZStd::span<const AZStd::string_view> parsedPropertyGroupId, AZStd::span<const AZStd::unique_ptr<PropertyGroup>> inPropertyGroupList) const;
PropertyGroup* FindPropertyGroup(AZStd::span<AZStd::string_view> parsedPropertyGroupId, AZStd::span<AZStd::unique_ptr<PropertyGroup>> inPropertyGroupList);
const PropertyDefinition* FindProperty(AZStd::span<const AZStd::string_view> parsedPropertyId, AZStd::span<const AZStd::unique_ptr<PropertySet>> inPropertySetList) const;
PropertyDefinition* FindProperty(AZStd::span<AZStd::string_view> parsedPropertyId, AZStd::span<AZStd::unique_ptr<PropertySet>> inPropertySetList);
const PropertyDefinition* FindProperty(AZStd::span<const AZStd::string_view> parsedPropertyId, AZStd::span<const AZStd::unique_ptr<PropertyGroup>> inPropertyGroupList) const;
PropertyDefinition* FindProperty(AZStd::span<AZStd::string_view> parsedPropertyId, AZStd::span<AZStd::unique_ptr<PropertyGroup>> inPropertyGroupList);
// Function overloads for recursion, returns false to indicate that recursion should end.
bool EnumeratePropertySets(const EnumeratePropertySetsCallback& callback, AZStd::string propertyIdContext, const AZStd::vector<AZStd::unique_ptr<PropertySet>>& inPropertySetList) const;
bool EnumerateProperties(const EnumeratePropertiesCallback& callback, AZStd::string propertyIdContext, const AZStd::vector<AZStd::unique_ptr<PropertySet>>& inPropertySetList) const;
bool EnumeratePropertyGroups(const EnumeratePropertyGroupsCallback& callback, AZStd::string propertyIdContext, const AZStd::vector<AZStd::unique_ptr<PropertyGroup>>& inPropertyGroupList) const;
bool EnumerateProperties(const EnumeratePropertiesCallback& callback, AZStd::string propertyIdContext, const AZStd::vector<AZStd::unique_ptr<PropertyGroup>>& inPropertyGroupList) const;
//! Recursively populates a material asset with properties from the tree of material property sets.
//! Recursively populates a material asset with properties from the tree of material property groups.
//! @param materialTypeSourceFilePath path to the material type file that is being processed, used to look up relative paths
//! @param propertyNameContext the accumulated prefix that should be applied to any property names encountered in the current @propertySet
//! @param propertySet the current PropertySet that is being processed
//! @param propertyNameContext the accumulated prefix that should be applied to any property names encountered in the current @propertyGroup
//! @param propertyGroup the current PropertyGroup that is being processed
//! @return false if errors are detected and processing should abort
bool BuildPropertyList(
const AZStd::string& materialTypeSourceFilePath,
MaterialTypeAssetCreator& materialTypeAssetCreator,
AZStd::vector<AZStd::string>& propertyNameContext,
const MaterialTypeSourceData::PropertySet* propertySet) const;
const MaterialTypeSourceData::PropertyGroup* propertyGroup) const;
//! 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.
@@ -58,9 +58,9 @@ namespace AZ
serializeContext->Class<GroupDefinition>()->Version(4);
serializeContext->Class<PropertyDefinition>()->Version(1);
serializeContext->RegisterGenericType<AZStd::unique_ptr<PropertySet>>();
serializeContext->RegisterGenericType<AZStd::unique_ptr<PropertyGroup>>();
serializeContext->RegisterGenericType<AZStd::unique_ptr<PropertyDefinition>>();
serializeContext->RegisterGenericType<AZStd::vector<AZStd::unique_ptr<PropertySet>>>();
serializeContext->RegisterGenericType<AZStd::vector<AZStd::unique_ptr<PropertyGroup>>>();
serializeContext->RegisterGenericType<AZStd::vector<AZStd::unique_ptr<PropertyDefinition>>>();
serializeContext->RegisterGenericType<PropertyConnectionList>();
@@ -88,22 +88,22 @@ namespace AZ
->Field("options", &ShaderVariantReferenceData::m_shaderOptionValues)
;
serializeContext->Class<PropertySet>()
serializeContext->Class<PropertyGroup>()
->Version(1)
->Field("name", &PropertySet::m_name)
->Field("displayName", &PropertySet::m_displayName)
->Field("description", &PropertySet::m_description)
->Field("properties", &PropertySet::m_properties)
->Field("propertySets", &PropertySet::m_propertySets)
->Field("functors", &PropertySet::m_materialFunctorSourceData)
->Field("name", &PropertyGroup::m_name)
->Field("displayName", &PropertyGroup::m_displayName)
->Field("description", &PropertyGroup::m_description)
->Field("properties", &PropertyGroup::m_properties)
->Field("propertyGroups", &PropertyGroup::m_propertyGroups)
->Field("functors", &PropertyGroup::m_materialFunctorSourceData)
;
serializeContext->Class<PropertyLayout>()
->Version(3) // Added propertySets
->Version(3) // Added propertyGroups
->Field("version", &PropertyLayout::m_versionOld) //< Deprecated, preserved for backward compatibility, replaced by MaterialTypeSourceData::version
->Field("groups", &PropertyLayout::m_groupsOld) //< Deprecated, preserved for backward compatibility, replaced by propertySets
->Field("properties", &PropertyLayout::m_propertiesOld) //< Deprecated, preserved for backward compatibility, replaced by propertySets
->Field("propertySets", &PropertyLayout::m_propertySets)
->Field("groups", &PropertyLayout::m_groupsOld) //< Deprecated, preserved for backward compatibility, replaced by propertyGroups
->Field("properties", &PropertyLayout::m_propertiesOld) //< Deprecated, preserved for backward compatibility, replaced by propertyGroups
->Field("propertyGroups", &PropertyLayout::m_propertyGroups)
;
serializeContext->RegisterGenericType<UvNameMap>();
@@ -132,16 +132,16 @@ namespace AZ
const float MaterialTypeSourceData::PropertyDefinition::DefaultMax = std::numeric_limits<float>::max();
const float MaterialTypeSourceData::PropertyDefinition::DefaultStep = 0.1f;
/*static*/ MaterialTypeSourceData::PropertySet* MaterialTypeSourceData::PropertySet::AddPropertySet(AZStd::string_view name, AZStd::vector<AZStd::unique_ptr<PropertySet>>& toPropertySetList)
/*static*/ MaterialTypeSourceData::PropertyGroup* MaterialTypeSourceData::PropertyGroup::AddPropertyGroup(AZStd::string_view name, AZStd::vector<AZStd::unique_ptr<PropertyGroup>>& toPropertyGroupList)
{
auto iter = AZStd::find_if(toPropertySetList.begin(), toPropertySetList.end(), [name](const AZStd::unique_ptr<PropertySet>& existingPropertySet)
auto iter = AZStd::find_if(toPropertyGroupList.begin(), toPropertyGroupList.end(), [name](const AZStd::unique_ptr<PropertyGroup>& existingPropertyGroup)
{
return existingPropertySet->m_name == name;
return existingPropertyGroup->m_name == name;
});
if (iter != toPropertySetList.end())
if (iter != toPropertyGroupList.end())
{
AZ_Error("Material source data", false, "PropertySet named '%.*s' already exists", AZ_STRING_ARG(name));
AZ_Error("Material source data", false, "PropertyGroup named '%.*s' already exists", AZ_STRING_ARG(name));
return nullptr;
}
@@ -151,12 +151,12 @@ namespace AZ
return nullptr;
}
toPropertySetList.push_back(AZStd::make_unique<PropertySet>());
toPropertySetList.back()->m_name = name;
return toPropertySetList.back().get();
toPropertyGroupList.push_back(AZStd::make_unique<PropertyGroup>());
toPropertyGroupList.back()->m_name = name;
return toPropertyGroupList.back().get();
}
MaterialTypeSourceData::PropertyDefinition* MaterialTypeSourceData::PropertySet::AddProperty(AZStd::string_view name)
MaterialTypeSourceData::PropertyDefinition* MaterialTypeSourceData::PropertyGroup::AddProperty(AZStd::string_view name)
{
auto propertyIter = AZStd::find_if(m_properties.begin(), m_properties.end(), [name](const AZStd::unique_ptr<PropertyDefinition>& existingProperty)
{
@@ -165,18 +165,18 @@ namespace AZ
if (propertyIter != m_properties.end())
{
AZ_Error("Material source data", false, "PropertySet '%s' already contains a property named '%.*s'", m_name.c_str(), AZ_STRING_ARG(name));
AZ_Error("Material source data", false, "PropertyGroup '%s' already contains a property named '%.*s'", m_name.c_str(), AZ_STRING_ARG(name));
return nullptr;
}
auto propertySetIter = AZStd::find_if(m_propertySets.begin(), m_propertySets.end(), [name](const AZStd::unique_ptr<PropertySet>& existingPropertySet)
auto propertyGroupIter = AZStd::find_if(m_propertyGroups.begin(), m_propertyGroups.end(), [name](const AZStd::unique_ptr<PropertyGroup>& existingPropertyGroup)
{
return existingPropertySet->m_name == name;
return existingPropertyGroup->m_name == name;
});
if (propertySetIter != m_propertySets.end())
if (propertyGroupIter != m_propertyGroups.end())
{
AZ_Error("Material source data", false, "Property name '%.*s' collides with a PropertySet of the same name", AZ_STRING_ARG(name));
AZ_Error("Material source data", false, "Property name '%.*s' collides with a PropertyGroup of the same name", AZ_STRING_ARG(name));
return nullptr;
}
@@ -190,7 +190,7 @@ namespace AZ
return m_properties.back().get();
}
MaterialTypeSourceData::PropertySet* MaterialTypeSourceData::PropertySet::AddPropertySet(AZStd::string_view name)
MaterialTypeSourceData::PropertyGroup* MaterialTypeSourceData::PropertyGroup::AddPropertyGroup(AZStd::string_view name)
{
auto iter = AZStd::find_if(m_properties.begin(), m_properties.end(), [name](const AZStd::unique_ptr<PropertyDefinition>& existingProperty)
{
@@ -199,31 +199,31 @@ namespace AZ
if (iter != m_properties.end())
{
AZ_Error("Material source data", false, "PropertySet name '%.*s' collides with a Property of the same name", AZ_STRING_ARG(name));
AZ_Error("Material source data", false, "PropertyGroup name '%.*s' collides with a Property of the same name", AZ_STRING_ARG(name));
return nullptr;
}
return AddPropertySet(name, m_propertySets);
return AddPropertyGroup(name, m_propertyGroups);
}
MaterialTypeSourceData::PropertySet* MaterialTypeSourceData::AddPropertySet(AZStd::string_view propertySetId)
MaterialTypeSourceData::PropertyGroup* MaterialTypeSourceData::AddPropertyGroup(AZStd::string_view propertyGroupId)
{
AZStd::vector<AZStd::string_view> splitPropertySetId = SplitId(propertySetId);
AZStd::vector<AZStd::string_view> splitPropertyGroupId = SplitId(propertyGroupId);
if (splitPropertySetId.size() == 1)
if (splitPropertyGroupId.size() == 1)
{
return PropertySet::AddPropertySet(propertySetId, m_propertyLayout.m_propertySets);
return PropertyGroup::AddPropertyGroup(propertyGroupId, m_propertyLayout.m_propertyGroups);
}
PropertySet* parentPropertySet = FindPropertySet(splitPropertySetId[0]);
PropertyGroup* parentPropertyGroup = FindPropertyGroup(splitPropertyGroupId[0]);
if (!parentPropertySet)
if (!parentPropertyGroup)
{
AZ_Error("Material source data", false, "PropertySet '%.*s' does not exists", AZ_STRING_ARG(splitPropertySetId[0]));
AZ_Error("Material source data", false, "PropertyGroup '%.*s' does not exists", AZ_STRING_ARG(splitPropertyGroupId[0]));
return nullptr;
}
return parentPropertySet->AddPropertySet(splitPropertySetId[1]);
return parentPropertyGroup->AddPropertyGroup(splitPropertyGroupId[1]);
}
MaterialTypeSourceData::PropertyDefinition* MaterialTypeSourceData::AddProperty(AZStd::string_view propertyId)
@@ -232,40 +232,40 @@ namespace AZ
if (splitPropertyId.size() == 1)
{
AZ_Error("Material source data", false, "Property id '%.*s' is invalid. Properties must be added to a PropertySet (i.e. \"general.%.*s\").", AZ_STRING_ARG(propertyId), AZ_STRING_ARG(propertyId));
AZ_Error("Material source data", false, "Property id '%.*s' is invalid. Properties must be added to a PropertyGroup (i.e. \"general.%.*s\").", AZ_STRING_ARG(propertyId), AZ_STRING_ARG(propertyId));
return nullptr;
}
PropertySet* parentPropertySet = FindPropertySet(splitPropertyId[0]);
PropertyGroup* parentPropertyGroup = FindPropertyGroup(splitPropertyId[0]);
if (!parentPropertySet)
if (!parentPropertyGroup)
{
AZ_Error("Material source data", false, "PropertySet '%.*s' does not exists", AZ_STRING_ARG(splitPropertyId[0]));
AZ_Error("Material source data", false, "PropertyGroup '%.*s' does not exists", AZ_STRING_ARG(splitPropertyId[0]));
return nullptr;
}
return parentPropertySet->AddProperty(splitPropertyId[1]);
return parentPropertyGroup->AddProperty(splitPropertyId[1]);
}
const MaterialTypeSourceData::PropertySet* MaterialTypeSourceData::FindPropertySet(AZStd::span<const AZStd::string_view> parsedPropertySetId, AZStd::span<const AZStd::unique_ptr<PropertySet>> inPropertySetList) const
const MaterialTypeSourceData::PropertyGroup* MaterialTypeSourceData::FindPropertyGroup(AZStd::span<const AZStd::string_view> parsedPropertyGroupId, AZStd::span<const AZStd::unique_ptr<PropertyGroup>> inPropertyGroupList) const
{
for (const auto& propertySet : inPropertySetList)
for (const auto& propertyGroup : inPropertyGroupList)
{
if (propertySet->m_name != parsedPropertySetId[0])
if (propertyGroup->m_name != parsedPropertyGroupId[0])
{
continue;
}
else if (parsedPropertySetId.size() == 1)
else if (parsedPropertyGroupId.size() == 1)
{
return propertySet.get();
return propertyGroup.get();
}
else
{
AZStd::span<const AZStd::string_view> subPath{parsedPropertySetId.begin() + 1, parsedPropertySetId.end()};
AZStd::span<const AZStd::string_view> subPath{parsedPropertyGroupId.begin() + 1, parsedPropertyGroupId.end()};
if (!subPath.empty())
{
const MaterialTypeSourceData::PropertySet* propertySubset = FindPropertySet(subPath, propertySet->m_propertySets);
const MaterialTypeSourceData::PropertyGroup* propertySubset = FindPropertyGroup(subPath, propertyGroup->m_propertyGroups);
if (propertySubset)
{
return propertySubset;
@@ -277,36 +277,36 @@ namespace AZ
return nullptr;
}
MaterialTypeSourceData::PropertySet* MaterialTypeSourceData::FindPropertySet(AZStd::span<AZStd::string_view> parsedPropertySetId, AZStd::span<AZStd::unique_ptr<PropertySet>> inPropertySetList)
MaterialTypeSourceData::PropertyGroup* MaterialTypeSourceData::FindPropertyGroup(AZStd::span<AZStd::string_view> parsedPropertyGroupId, AZStd::span<AZStd::unique_ptr<PropertyGroup>> inPropertyGroupList)
{
return const_cast<PropertySet*>(const_cast<const MaterialTypeSourceData*>(this)->FindPropertySet(parsedPropertySetId, inPropertySetList));
return const_cast<PropertyGroup*>(const_cast<const MaterialTypeSourceData*>(this)->FindPropertyGroup(parsedPropertyGroupId, inPropertyGroupList));
}
const MaterialTypeSourceData::PropertySet* MaterialTypeSourceData::FindPropertySet(AZStd::string_view propertySetId) const
const MaterialTypeSourceData::PropertyGroup* MaterialTypeSourceData::FindPropertyGroup(AZStd::string_view propertyGroupId) const
{
AZStd::vector<AZStd::string_view> tokens = TokenizeId(propertySetId);
return FindPropertySet(tokens, m_propertyLayout.m_propertySets);
AZStd::vector<AZStd::string_view> tokens = TokenizeId(propertyGroupId);
return FindPropertyGroup(tokens, m_propertyLayout.m_propertyGroups);
}
MaterialTypeSourceData::PropertySet* MaterialTypeSourceData::FindPropertySet(AZStd::string_view propertySetId)
MaterialTypeSourceData::PropertyGroup* MaterialTypeSourceData::FindPropertyGroup(AZStd::string_view propertyGroupId)
{
AZStd::vector<AZStd::string_view> tokens = TokenizeId(propertySetId);
return FindPropertySet(tokens, m_propertyLayout.m_propertySets);
AZStd::vector<AZStd::string_view> tokens = TokenizeId(propertyGroupId);
return FindPropertyGroup(tokens, m_propertyLayout.m_propertyGroups);
}
const MaterialTypeSourceData::PropertyDefinition* MaterialTypeSourceData::FindProperty(
AZStd::span<const AZStd::string_view> parsedPropertyId,
AZStd::span<const AZStd::unique_ptr<PropertySet>> inPropertySetList) const
AZStd::span<const AZStd::unique_ptr<PropertyGroup>> inPropertyGroupList) const
{
for (const auto& propertySet : inPropertySetList)
for (const auto& propertyGroup : inPropertyGroupList)
{
if (propertySet->m_name == parsedPropertyId[0])
if (propertyGroup->m_name == parsedPropertyId[0])
{
AZStd::span<const AZStd::string_view> subPath {parsedPropertyId.begin() + 1, parsedPropertyId.end()};
if (subPath.size() == 1)
{
for (AZStd::unique_ptr<PropertyDefinition>& property : propertySet->m_properties)
for (AZStd::unique_ptr<PropertyDefinition>& property : propertyGroup->m_properties)
{
if (property->GetName() == subPath[0])
{
@@ -316,7 +316,7 @@ namespace AZ
}
else if(subPath.size() > 1)
{
const MaterialTypeSourceData::PropertyDefinition* property = FindProperty(subPath, propertySet->m_propertySets);
const MaterialTypeSourceData::PropertyDefinition* property = FindProperty(subPath, propertyGroup->m_propertyGroups);
if (property)
{
return property;
@@ -328,21 +328,21 @@ namespace AZ
return nullptr;
}
MaterialTypeSourceData::PropertyDefinition* MaterialTypeSourceData::FindProperty(AZStd::span<AZStd::string_view> parsedPropertyId, AZStd::span<AZStd::unique_ptr<PropertySet>> inPropertySetList)
MaterialTypeSourceData::PropertyDefinition* MaterialTypeSourceData::FindProperty(AZStd::span<AZStd::string_view> parsedPropertyId, AZStd::span<AZStd::unique_ptr<PropertyGroup>> inPropertyGroupList)
{
return const_cast<MaterialTypeSourceData::PropertyDefinition*>(const_cast<const MaterialTypeSourceData*>(this)->FindProperty(parsedPropertyId, inPropertySetList));
return const_cast<MaterialTypeSourceData::PropertyDefinition*>(const_cast<const MaterialTypeSourceData*>(this)->FindProperty(parsedPropertyId, inPropertyGroupList));
}
const MaterialTypeSourceData::PropertyDefinition* MaterialTypeSourceData::FindProperty(AZStd::string_view propertyId) const
{
AZStd::vector<AZStd::string_view> tokens = TokenizeId(propertyId);
return FindProperty(tokens, m_propertyLayout.m_propertySets);
return FindProperty(tokens, m_propertyLayout.m_propertyGroups);
}
MaterialTypeSourceData::PropertyDefinition* MaterialTypeSourceData::FindProperty(AZStd::string_view propertyId)
{
AZStd::vector<AZStd::string_view> tokens = TokenizeId(propertyId);
return FindProperty(tokens, m_propertyLayout.m_propertySets);
return FindProperty(tokens, m_propertyLayout.m_propertyGroups);
}
AZStd::vector<AZStd::string_view> MaterialTypeSourceData::TokenizeId(AZStd::string_view id)
@@ -376,18 +376,18 @@ namespace AZ
return parts;
}
bool MaterialTypeSourceData::EnumeratePropertySets(const EnumeratePropertySetsCallback& callback, AZStd::string propertyNameContext, const AZStd::vector<AZStd::unique_ptr<PropertySet>>& inPropertySetList) const
bool MaterialTypeSourceData::EnumeratePropertyGroups(const EnumeratePropertyGroupsCallback& callback, AZStd::string propertyNameContext, const AZStd::vector<AZStd::unique_ptr<PropertyGroup>>& inPropertyGroupList) const
{
for (auto& propertySet : inPropertySetList)
for (auto& propertyGroup : inPropertyGroupList)
{
if (!callback(propertyNameContext, propertySet.get()))
if (!callback(propertyNameContext, propertyGroup.get()))
{
return false; // Stop processing
}
const AZStd::string propertyNameContext2 = propertyNameContext + propertySet->m_name + ".";
const AZStd::string propertyNameContext2 = propertyNameContext + propertyGroup->m_name + ".";
if (!EnumeratePropertySets(callback, propertyNameContext2, propertySet->m_propertySets))
if (!EnumeratePropertyGroups(callback, propertyNameContext2, propertyGroup->m_propertyGroups))
{
return false; // Stop processing
}
@@ -396,24 +396,24 @@ namespace AZ
return true;
}
bool MaterialTypeSourceData::EnumeratePropertySets(const EnumeratePropertySetsCallback& callback) const
bool MaterialTypeSourceData::EnumeratePropertyGroups(const EnumeratePropertyGroupsCallback& callback) const
{
if (!callback)
{
return false;
}
return EnumeratePropertySets(callback, {}, m_propertyLayout.m_propertySets);
return EnumeratePropertyGroups(callback, {}, m_propertyLayout.m_propertyGroups);
}
bool MaterialTypeSourceData::EnumerateProperties(const EnumeratePropertiesCallback& callback, AZStd::string propertyNameContext, const AZStd::vector<AZStd::unique_ptr<PropertySet>>& inPropertySetList) const
bool MaterialTypeSourceData::EnumerateProperties(const EnumeratePropertiesCallback& callback, AZStd::string propertyNameContext, const AZStd::vector<AZStd::unique_ptr<PropertyGroup>>& inPropertyGroupList) const
{
for (auto& propertySet : inPropertySetList)
for (auto& propertyGroup : inPropertyGroupList)
{
const AZStd::string propertyNameContext2 = propertyNameContext + propertySet->m_name + ".";
const AZStd::string propertyNameContext2 = propertyNameContext + propertyGroup->m_name + ".";
for (auto& property : propertySet->m_properties)
for (auto& property : propertyGroup->m_properties)
{
if (!callback(propertyNameContext2, property.get()))
{
@@ -421,7 +421,7 @@ namespace AZ
}
}
if (!EnumerateProperties(callback, propertyNameContext2, propertySet->m_propertySets))
if (!EnumerateProperties(callback, propertyNameContext2, propertyGroup->m_propertyGroups))
{
return false; // Stop processing
}
@@ -437,7 +437,7 @@ namespace AZ
return false;
}
return EnumerateProperties(callback, {}, m_propertyLayout.m_propertySets);
return EnumerateProperties(callback, {}, m_propertyLayout.m_propertyGroups);
}
bool MaterialTypeSourceData::ConvertToNewDataFormat()
@@ -450,18 +450,18 @@ namespace AZ
const auto& propertyList = propertyListItr->second;
for (auto& propertyDefinition : propertyList)
{
PropertySet* propertySet = FindPropertySet(group.m_name);
PropertyGroup* propertyGroup = FindPropertyGroup(group.m_name);
if (!propertySet)
if (!propertyGroup)
{
m_propertyLayout.m_propertySets.emplace_back(AZStd::make_unique<PropertySet>());
m_propertyLayout.m_propertySets.back()->m_name = group.m_name;
m_propertyLayout.m_propertySets.back()->m_displayName = group.m_displayName;
m_propertyLayout.m_propertySets.back()->m_description = group.m_description;
propertySet = m_propertyLayout.m_propertySets.back().get();
m_propertyLayout.m_propertyGroups.emplace_back(AZStd::make_unique<PropertyGroup>());
m_propertyLayout.m_propertyGroups.back()->m_name = group.m_name;
m_propertyLayout.m_propertyGroups.back()->m_displayName = group.m_displayName;
m_propertyLayout.m_propertyGroups.back()->m_description = group.m_description;
propertyGroup = m_propertyLayout.m_propertyGroups.back().get();
}
PropertyDefinition* newProperty = propertySet->AddProperty(propertyDefinition.GetName());
PropertyDefinition* newProperty = propertyGroup->AddProperty(propertyDefinition.GetName());
*newProperty = propertyDefinition;
}
@@ -533,9 +533,9 @@ namespace AZ
const AZStd::string& materialTypeSourceFilePath,
MaterialTypeAssetCreator& materialTypeAssetCreator,
AZStd::vector<AZStd::string>& propertyNameContext,
const MaterialTypeSourceData::PropertySet* propertySet) const
const MaterialTypeSourceData::PropertyGroup* propertyGroup) const
{
for (const AZStd::unique_ptr<PropertyDefinition>& property : propertySet->m_properties)
for (const AZStd::unique_ptr<PropertyDefinition>& property : propertyGroup->m_properties)
{
// Register the property...
@@ -547,15 +547,15 @@ namespace AZ
return false;
}
auto propertySetIter = AZStd::find_if(propertySet->GetPropertySets().begin(), propertySet->GetPropertySets().end(),
[&property](const AZStd::unique_ptr<PropertySet>& existingPropertySet)
auto propertyGroupIter = AZStd::find_if(propertyGroup->GetPropertyGroups().begin(), propertyGroup->GetPropertyGroups().end(),
[&property](const AZStd::unique_ptr<PropertyGroup>& existingPropertyGroup)
{
return existingPropertySet->GetName() == property->GetName();
return existingPropertyGroup->GetName() == property->GetName();
});
if (propertySetIter != propertySet->GetPropertySets().end())
if (propertyGroupIter != propertyGroup->GetPropertyGroups().end())
{
AZ_Error("Material source data", false, "Material property '%s' collides with a PropertySet with the same ID.", propertyId.GetCStr());
AZ_Error("Material source data", false, "Material property '%s' collides with a PropertyGroup with the same ID.", propertyId.GetCStr());
return false;
}
@@ -650,7 +650,7 @@ namespace AZ
}
}
for (const AZStd::unique_ptr<PropertySet>& propertySubset : propertySet->m_propertySets)
for (const AZStd::unique_ptr<PropertyGroup>& propertySubset : propertyGroup->m_propertyGroups)
{
propertyNameContext.push_back(propertySubset->m_name);
@@ -670,7 +670,7 @@ namespace AZ
// We cannot create the MaterialFunctor until after all the properties are added because
// CreateFunctor() may need to look up properties in the MaterialPropertiesLayout
for (auto& functorData : propertySet->m_materialFunctorSourceData)
for (auto& functorData : propertyGroup->m_materialFunctorSourceData)
{
MaterialFunctorSourceData::FunctorResult result = functorData->CreateFunctor(
MaterialFunctorSourceData::RuntimeContext(
@@ -795,11 +795,11 @@ namespace AZ
}
}
for (const AZStd::unique_ptr<PropertySet>& propertySet : m_propertyLayout.m_propertySets)
for (const AZStd::unique_ptr<PropertyGroup>& propertyGroup : m_propertyLayout.m_propertyGroups)
{
AZStd::vector<AZStd::string> propertyNameContext;
propertyNameContext.push_back(propertySet->m_name);
bool success = BuildPropertyList(materialTypeSourceFilePath, materialTypeAssetCreator, propertyNameContext, propertySet.get());
propertyNameContext.push_back(propertyGroup->m_name);
bool success = BuildPropertyList(materialTypeSourceFilePath, materialTypeAssetCreator, propertyNameContext, propertyGroup.get());
if (!success)
{
@@ -93,7 +93,7 @@ namespace UnitTest
{
"version": 10,
"propertyLayout": {
"propertySets": [
"propertyGroups": [
{
"name": "general",
"properties": [
@@ -471,7 +471,7 @@ namespace UnitTest
const AZStd::string simpleMaterialTypeJson = R"(
{
"propertyLayout": {
"propertySets":
"propertyGroups":
[
{
"name": "general",
@@ -360,18 +360,18 @@ namespace UnitTest
{
MaterialTypeSourceData sourceData;
// Here we are building up multiple layers of property sets and properties, using a variety of different Add functions,
// going through the MaterialTypeSourceData or going to the PropertySet directly.
// Here we are building up multiple layers of property groups and properties, using a variety of different Add functions,
// going through the MaterialTypeSourceData or going to the PropertyGroup directly.
MaterialTypeSourceData::PropertySet* layer1 = sourceData.AddPropertySet("layer1");
MaterialTypeSourceData::PropertySet* layer2 = sourceData.AddPropertySet("layer2");
MaterialTypeSourceData::PropertySet* blend = sourceData.AddPropertySet("blend");
MaterialTypeSourceData::PropertyGroup* layer1 = sourceData.AddPropertyGroup("layer1");
MaterialTypeSourceData::PropertyGroup* layer2 = sourceData.AddPropertyGroup("layer2");
MaterialTypeSourceData::PropertyGroup* blend = sourceData.AddPropertyGroup("blend");
MaterialTypeSourceData::PropertySet* layer1_baseColor = layer1->AddPropertySet("baseColor");
MaterialTypeSourceData::PropertySet* layer2_baseColor = layer2->AddPropertySet("baseColor");
MaterialTypeSourceData::PropertyGroup* layer1_baseColor = layer1->AddPropertyGroup("baseColor");
MaterialTypeSourceData::PropertyGroup* layer2_baseColor = layer2->AddPropertyGroup("baseColor");
MaterialTypeSourceData::PropertySet* layer1_roughness = sourceData.AddPropertySet("layer1.roughness");
MaterialTypeSourceData::PropertySet* layer2_roughness = sourceData.AddPropertySet("layer2.roughness");
MaterialTypeSourceData::PropertyGroup* layer1_roughness = sourceData.AddPropertyGroup("layer1.roughness");
MaterialTypeSourceData::PropertyGroup* layer2_roughness = sourceData.AddPropertyGroup("layer2.roughness");
MaterialTypeSourceData::PropertyDefinition* layer1_baseColor_texture = layer1_baseColor->AddProperty("texture");
MaterialTypeSourceData::PropertyDefinition* layer2_baseColor_texture = layer2_baseColor->AddProperty("texture");
@@ -380,9 +380,9 @@ namespace UnitTest
MaterialTypeSourceData::PropertyDefinition* layer2_roughness_texture = sourceData.AddProperty("layer2.roughness.texture");
// We're doing clear coat only on layer2, for brevity
MaterialTypeSourceData::PropertySet* layer2_clearCoat = layer2->AddPropertySet("clearCoat");
MaterialTypeSourceData::PropertySet* layer2_clearCoat_roughness = layer2_clearCoat->AddPropertySet("roughness");
MaterialTypeSourceData::PropertySet* layer2_clearCoat_normal = layer2_clearCoat->AddPropertySet("normal");
MaterialTypeSourceData::PropertyGroup* layer2_clearCoat = layer2->AddPropertyGroup("clearCoat");
MaterialTypeSourceData::PropertyGroup* layer2_clearCoat_roughness = layer2_clearCoat->AddPropertyGroup("roughness");
MaterialTypeSourceData::PropertyGroup* layer2_clearCoat_normal = layer2_clearCoat->AddPropertyGroup("normal");
MaterialTypeSourceData::PropertyDefinition* layer2_clearCoat_enabled = layer2_clearCoat->AddProperty("enabled");
MaterialTypeSourceData::PropertyDefinition* layer2_clearCoat_roughness_texture = layer2_clearCoat_roughness->AddProperty("texture");
MaterialTypeSourceData::PropertyDefinition* layer2_clearCoat_normal_texture = layer2_clearCoat_normal->AddProperty("texture");
@@ -396,27 +396,27 @@ namespace UnitTest
EXPECT_EQ(nullptr, sourceData.FindProperty("layer1.DoesNotExist"));
EXPECT_EQ(nullptr, sourceData.FindProperty("layer1.baseColor.DoesNotExist"));
EXPECT_EQ(nullptr, sourceData.FindProperty("baseColor.texture"));
EXPECT_EQ(nullptr, sourceData.FindProperty("baseColor")); // This is a property set, not a property
EXPECT_EQ(nullptr, sourceData.FindPropertySet("baseColor.texture")); // This is a property, not a property set
EXPECT_EQ(nullptr, sourceData.FindProperty("baseColor")); // This is a property group, not a property
EXPECT_EQ(nullptr, sourceData.FindPropertyGroup("baseColor.texture")); // This is a property, not a property group
EXPECT_EQ(layer1, sourceData.FindPropertySet("layer1"));
EXPECT_EQ(layer2, sourceData.FindPropertySet("layer2"));
EXPECT_EQ(blend, sourceData.FindPropertySet("blend"));
EXPECT_EQ(layer1, sourceData.FindPropertyGroup("layer1"));
EXPECT_EQ(layer2, sourceData.FindPropertyGroup("layer2"));
EXPECT_EQ(blend, sourceData.FindPropertyGroup("blend"));
EXPECT_EQ(layer1_baseColor, sourceData.FindPropertySet("layer1.baseColor"));
EXPECT_EQ(layer2_baseColor, sourceData.FindPropertySet("layer2.baseColor"));
EXPECT_EQ(layer1_baseColor, sourceData.FindPropertyGroup("layer1.baseColor"));
EXPECT_EQ(layer2_baseColor, sourceData.FindPropertyGroup("layer2.baseColor"));
EXPECT_EQ(layer1_roughness, sourceData.FindPropertySet("layer1.roughness"));
EXPECT_EQ(layer2_roughness, sourceData.FindPropertySet("layer2.roughness"));
EXPECT_EQ(layer1_roughness, sourceData.FindPropertyGroup("layer1.roughness"));
EXPECT_EQ(layer2_roughness, sourceData.FindPropertyGroup("layer2.roughness"));
EXPECT_EQ(layer1_baseColor_texture, sourceData.FindProperty("layer1.baseColor.texture"));
EXPECT_EQ(layer2_baseColor_texture, sourceData.FindProperty("layer2.baseColor.texture"));
EXPECT_EQ(layer1_roughness_texture, sourceData.FindProperty("layer1.roughness.texture"));
EXPECT_EQ(layer2_roughness_texture, sourceData.FindProperty("layer2.roughness.texture"));
EXPECT_EQ(layer2_clearCoat, sourceData.FindPropertySet("layer2.clearCoat"));
EXPECT_EQ(layer2_clearCoat_roughness, sourceData.FindPropertySet("layer2.clearCoat.roughness"));
EXPECT_EQ(layer2_clearCoat_normal, sourceData.FindPropertySet("layer2.clearCoat.normal"));
EXPECT_EQ(layer2_clearCoat, sourceData.FindPropertyGroup("layer2.clearCoat"));
EXPECT_EQ(layer2_clearCoat_roughness, sourceData.FindPropertyGroup("layer2.clearCoat.roughness"));
EXPECT_EQ(layer2_clearCoat_normal, sourceData.FindPropertyGroup("layer2.clearCoat.normal"));
EXPECT_EQ(layer2_clearCoat_enabled, sourceData.FindProperty("layer2.clearCoat.enabled"));
EXPECT_EQ(layer2_clearCoat_roughness_texture, sourceData.FindProperty("layer2.clearCoat.roughness.texture"));
@@ -425,39 +425,39 @@ namespace UnitTest
EXPECT_EQ(blend_factor, sourceData.FindProperty("blend.factor"));
// Check EnumeratePropertySets
// Check EnumeratePropertyGroups
struct EnumeratePropertySetsResult
struct EnumeratePropertyGroupsResult
{
AZStd::string m_propertyIdContext;
const MaterialTypeSourceData::PropertySet* m_propertySet;
const MaterialTypeSourceData::PropertyGroup* m_propertyGroup;
void Check(AZStd::string expectedIdContext, const MaterialTypeSourceData::PropertySet* expectedPropertySet)
void Check(AZStd::string expectedIdContext, const MaterialTypeSourceData::PropertyGroup* expectedPropertyGroup)
{
EXPECT_EQ(expectedIdContext, m_propertyIdContext);
EXPECT_EQ(expectedPropertySet, m_propertySet);
EXPECT_EQ(expectedPropertyGroup, m_propertyGroup);
}
};
AZStd::vector<EnumeratePropertySetsResult> enumeratePropertySetsResults;
AZStd::vector<EnumeratePropertyGroupsResult> enumeratePropertyGroupsResults;
sourceData.EnumeratePropertySets([&enumeratePropertySetsResults](const AZStd::string& propertyIdContext, const MaterialTypeSourceData::PropertySet* propertySet)
sourceData.EnumeratePropertyGroups([&enumeratePropertyGroupsResults](const AZStd::string& propertyIdContext, const MaterialTypeSourceData::PropertyGroup* propertyGroup)
{
enumeratePropertySetsResults.push_back(EnumeratePropertySetsResult{propertyIdContext, propertySet});
enumeratePropertyGroupsResults.push_back(EnumeratePropertyGroupsResult{propertyIdContext, propertyGroup});
return true;
});
int resultIndex = 0;
enumeratePropertySetsResults[resultIndex++].Check("", layer1);
enumeratePropertySetsResults[resultIndex++].Check("layer1.", layer1_baseColor);
enumeratePropertySetsResults[resultIndex++].Check("layer1.", layer1_roughness);
enumeratePropertySetsResults[resultIndex++].Check("", layer2);
enumeratePropertySetsResults[resultIndex++].Check("layer2.", layer2_baseColor);
enumeratePropertySetsResults[resultIndex++].Check("layer2.", layer2_roughness);
enumeratePropertySetsResults[resultIndex++].Check("layer2.", layer2_clearCoat);
enumeratePropertySetsResults[resultIndex++].Check("layer2.clearCoat.", layer2_clearCoat_roughness);
enumeratePropertySetsResults[resultIndex++].Check("layer2.clearCoat.", layer2_clearCoat_normal);
enumeratePropertySetsResults[resultIndex++].Check("", blend);
EXPECT_EQ(resultIndex, enumeratePropertySetsResults.size());
enumeratePropertyGroupsResults[resultIndex++].Check("", layer1);
enumeratePropertyGroupsResults[resultIndex++].Check("layer1.", layer1_baseColor);
enumeratePropertyGroupsResults[resultIndex++].Check("layer1.", layer1_roughness);
enumeratePropertyGroupsResults[resultIndex++].Check("", layer2);
enumeratePropertyGroupsResults[resultIndex++].Check("layer2.", layer2_baseColor);
enumeratePropertyGroupsResults[resultIndex++].Check("layer2.", layer2_roughness);
enumeratePropertyGroupsResults[resultIndex++].Check("layer2.", layer2_clearCoat);
enumeratePropertyGroupsResults[resultIndex++].Check("layer2.clearCoat.", layer2_clearCoat_roughness);
enumeratePropertyGroupsResults[resultIndex++].Check("layer2.clearCoat.", layer2_clearCoat_normal);
enumeratePropertyGroupsResults[resultIndex++].Check("", blend);
EXPECT_EQ(resultIndex, enumeratePropertyGroupsResults.size());
// Check EnumerateProperties
@@ -497,39 +497,39 @@ namespace UnitTest
{
MaterialTypeSourceData sourceData;
MaterialTypeSourceData::PropertySet* propertySet = sourceData.AddPropertySet("main");
MaterialTypeSourceData::PropertyGroup* propertyGroup = sourceData.AddPropertyGroup("main");
ErrorMessageFinder errorMessageFinder;
errorMessageFinder.AddExpectedErrorMessage("'' is not a valid identifier");
errorMessageFinder.AddExpectedErrorMessage("'main.' is not a valid identifier");
errorMessageFinder.AddExpectedErrorMessage("'base-color' is not a valid identifier");
EXPECT_FALSE(propertySet->AddProperty(""));
EXPECT_FALSE(propertySet->AddProperty("main."));
EXPECT_FALSE(propertyGroup->AddProperty(""));
EXPECT_FALSE(propertyGroup->AddProperty("main."));
EXPECT_FALSE(sourceData.AddProperty("main.base-color"));
EXPECT_TRUE(propertySet->GetProperties().empty());
EXPECT_TRUE(propertyGroup->GetProperties().empty());
errorMessageFinder.CheckExpectedErrorsFound();
}
TEST_F(MaterialTypeSourceDataTests, AddPropertySet_Error_InvalidName)
TEST_F(MaterialTypeSourceDataTests, AddPropertyGroup_Error_InvalidName)
{
MaterialTypeSourceData sourceData;
MaterialTypeSourceData::PropertySet* propertySet = sourceData.AddPropertySet("general");
MaterialTypeSourceData::PropertyGroup* propertyGroup = sourceData.AddPropertyGroup("general");
ErrorMessageFinder errorMessageFinder;
errorMessageFinder.AddExpectedErrorMessage("'' is not a valid identifier", 2);
errorMessageFinder.AddExpectedErrorMessage("'base-color' is not a valid identifier");
errorMessageFinder.AddExpectedErrorMessage("'look@it' is not a valid identifier");
EXPECT_FALSE(propertySet->AddPropertySet(""));
EXPECT_FALSE(sourceData.AddPropertySet(""));
EXPECT_FALSE(sourceData.AddPropertySet("base-color"));
EXPECT_FALSE(sourceData.AddPropertySet("general.look@it"));
EXPECT_FALSE(propertyGroup->AddPropertyGroup(""));
EXPECT_FALSE(sourceData.AddPropertyGroup(""));
EXPECT_FALSE(sourceData.AddPropertyGroup("base-color"));
EXPECT_FALSE(sourceData.AddPropertyGroup("general.look@it"));
EXPECT_TRUE(propertySet->GetProperties().empty());
EXPECT_TRUE(propertyGroup->GetProperties().empty());
errorMessageFinder.CheckExpectedErrorsFound();
}
@@ -538,16 +538,16 @@ namespace UnitTest
{
MaterialTypeSourceData sourceData;
MaterialTypeSourceData::PropertySet* propertySet = sourceData.AddPropertySet("main");
MaterialTypeSourceData::PropertyGroup* propertyGroup = sourceData.AddPropertyGroup("main");
ErrorMessageFinder errorMessageFinder;
errorMessageFinder.AddExpectedErrorMessage("PropertySet 'main' already contains a property named 'foo'", 2);
errorMessageFinder.AddExpectedErrorMessage("PropertyGroup 'main' already contains a property named 'foo'", 2);
EXPECT_TRUE(propertySet->AddProperty("foo"));
EXPECT_FALSE(propertySet->AddProperty("foo"));
EXPECT_TRUE(propertyGroup->AddProperty("foo"));
EXPECT_FALSE(propertyGroup->AddProperty("foo"));
EXPECT_FALSE(sourceData.AddProperty("main.foo"));
EXPECT_EQ(propertySet->GetProperties().size(), 1);
EXPECT_EQ(propertyGroup->GetProperties().size(), 1);
errorMessageFinder.CheckExpectedErrorsFound();
}
@@ -555,66 +555,66 @@ namespace UnitTest
TEST_F(MaterialTypeSourceDataTests, AddProperty_Error_AddLooseProperty)
{
MaterialTypeSourceData sourceData;
ErrorMessageFinder errorMessageFinder("Property id 'foo' is invalid. Properties must be added to a PropertySet");
ErrorMessageFinder errorMessageFinder("Property id 'foo' is invalid. Properties must be added to a PropertyGroup");
EXPECT_FALSE(sourceData.AddProperty("foo"));
errorMessageFinder.CheckExpectedErrorsFound();
}
TEST_F(MaterialTypeSourceDataTests, AddProperty_Error_PropertySetDoesNotExist )
TEST_F(MaterialTypeSourceDataTests, AddProperty_Error_PropertyGroupDoesNotExist )
{
MaterialTypeSourceData sourceData;
ErrorMessageFinder errorMessageFinder("PropertySet 'DNE' does not exists");
ErrorMessageFinder errorMessageFinder("PropertyGroup 'DNE' does not exists");
EXPECT_FALSE(sourceData.AddProperty("DNE.foo"));
errorMessageFinder.CheckExpectedErrorsFound();
}
TEST_F(MaterialTypeSourceDataTests, AddPropertySet_Error_PropertySetDoesNotExist )
TEST_F(MaterialTypeSourceDataTests, AddPropertyGroup_Error_PropertyGroupDoesNotExist )
{
MaterialTypeSourceData sourceData;
ErrorMessageFinder errorMessageFinder("PropertySet 'DNE' does not exists");
EXPECT_FALSE(sourceData.AddPropertySet("DNE.foo"));
ErrorMessageFinder errorMessageFinder("PropertyGroup 'DNE' does not exists");
EXPECT_FALSE(sourceData.AddPropertyGroup("DNE.foo"));
errorMessageFinder.CheckExpectedErrorsFound();
}
TEST_F(MaterialTypeSourceDataTests, AddPropertySet_Error_AddDuplicatePropertySet)
TEST_F(MaterialTypeSourceDataTests, AddPropertyGroup_Error_AddDuplicatePropertyGroup)
{
MaterialTypeSourceData sourceData;
MaterialTypeSourceData::PropertySet* propertySet = sourceData.AddPropertySet("main");
sourceData.AddPropertySet("main.level2");
MaterialTypeSourceData::PropertyGroup* propertyGroup = sourceData.AddPropertyGroup("main");
sourceData.AddPropertyGroup("main.level2");
ErrorMessageFinder errorMessageFinder;
errorMessageFinder.AddExpectedErrorMessage("PropertySet named 'main' already exists", 1);
errorMessageFinder.AddExpectedErrorMessage("PropertySet named 'level2' already exists", 2);
errorMessageFinder.AddExpectedErrorMessage("PropertyGroup named 'main' already exists", 1);
errorMessageFinder.AddExpectedErrorMessage("PropertyGroup named 'level2' already exists", 2);
EXPECT_FALSE(sourceData.AddPropertySet("main"));
EXPECT_FALSE(sourceData.AddPropertySet("main.level2"));
EXPECT_FALSE(propertySet->AddPropertySet("level2"));
EXPECT_FALSE(sourceData.AddPropertyGroup("main"));
EXPECT_FALSE(sourceData.AddPropertyGroup("main.level2"));
EXPECT_FALSE(propertyGroup->AddPropertyGroup("level2"));
errorMessageFinder.CheckExpectedErrorsFound();
EXPECT_EQ(sourceData.GetPropertyLayout().m_propertySets.size(), 1);
EXPECT_EQ(propertySet->GetPropertySets().size(), 1);
EXPECT_EQ(sourceData.GetPropertyLayout().m_propertyGroups.size(), 1);
EXPECT_EQ(propertyGroup->GetPropertyGroups().size(), 1);
}
TEST_F(MaterialTypeSourceDataTests, AddPropertySet_Error_NameCollidesWithProperty )
TEST_F(MaterialTypeSourceDataTests, AddPropertyGroup_Error_NameCollidesWithProperty )
{
MaterialTypeSourceData sourceData;
sourceData.AddPropertySet("main");
sourceData.AddPropertyGroup("main");
sourceData.AddProperty("main.foo");
ErrorMessageFinder errorMessageFinder("PropertySet name 'foo' collides with a Property of the same name");
EXPECT_FALSE(sourceData.AddPropertySet("main.foo"));
ErrorMessageFinder errorMessageFinder("PropertyGroup name 'foo' collides with a Property of the same name");
EXPECT_FALSE(sourceData.AddPropertyGroup("main.foo"));
errorMessageFinder.CheckExpectedErrorsFound();
}
TEST_F(MaterialTypeSourceDataTests, AddProperty_Error_NameCollidesWithPropertySet )
TEST_F(MaterialTypeSourceDataTests, AddProperty_Error_NameCollidesWithPropertyGroup )
{
MaterialTypeSourceData sourceData;
sourceData.AddPropertySet("main");
sourceData.AddPropertySet("main.foo");
sourceData.AddPropertyGroup("main");
sourceData.AddPropertyGroup("main.foo");
ErrorMessageFinder errorMessageFinder("Property name 'foo' collides with a PropertySet of the same name");
ErrorMessageFinder errorMessageFinder("Property name 'foo' collides with a PropertyGroup of the same name");
EXPECT_FALSE(sourceData.AddProperty("main.foo"));
errorMessageFinder.CheckExpectedErrorsFound();
}
@@ -627,11 +627,11 @@ namespace UnitTest
sourceData.m_uvNameMap["UV1"] = "Unwrapped";
sourceData.m_uvNameMap["UV2"] = "Other";
sourceData.AddPropertySet("a");
sourceData.AddPropertySet("a.b");
sourceData.AddPropertySet("c");
sourceData.AddPropertySet("c.d");
sourceData.AddPropertySet("c.d.e");
sourceData.AddPropertyGroup("a");
sourceData.AddPropertyGroup("a.b");
sourceData.AddPropertyGroup("c");
sourceData.AddPropertyGroup("c.d");
sourceData.AddPropertyGroup("c.d.e");
MaterialTypeSourceData::PropertyDefinition* enum1 = sourceData.AddProperty("a.enum1");
MaterialTypeSourceData::PropertyDefinition* enum2 = sourceData.AddProperty("a.b.enum2");
@@ -820,8 +820,8 @@ namespace UnitTest
sourceData.m_shaderCollection.push_back(MaterialTypeSourceData::ShaderVariantReferenceData{ TestShaderFilename });
MaterialTypeSourceData::PropertySet* propertySet = sourceData.AddPropertySet("general");
MaterialTypeSourceData::PropertyDefinition* property = propertySet->AddProperty("MyBool");
MaterialTypeSourceData::PropertyGroup* propertyGroup = sourceData.AddPropertyGroup("general");
MaterialTypeSourceData::PropertyDefinition* property = propertyGroup->AddProperty("MyBool");
property->m_displayName = "My Bool";
property->m_description = "This is a bool";
property->m_dataType = MaterialPropertyDataType::Bool;
@@ -845,8 +845,8 @@ namespace UnitTest
sourceData.m_shaderCollection.push_back(MaterialTypeSourceData::ShaderVariantReferenceData{ TestShaderFilename });
MaterialTypeSourceData::PropertySet* propertySet = sourceData.AddPropertySet("general");
MaterialTypeSourceData::PropertyDefinition* property = propertySet->AddProperty("MyFloat");
MaterialTypeSourceData::PropertyGroup* propertyGroup = sourceData.AddPropertyGroup("general");
MaterialTypeSourceData::PropertyDefinition* property = propertyGroup->AddProperty("MyFloat");
property->m_displayName = "My Float";
property->m_description = "This is a float";
property->m_min = 0.0f;
@@ -874,8 +874,8 @@ namespace UnitTest
sourceData.m_shaderCollection.push_back(MaterialTypeSourceData::ShaderVariantReferenceData{ TestShaderFilename });
MaterialTypeSourceData::PropertySet* propertySet = sourceData.AddPropertySet("general");
MaterialTypeSourceData::PropertyDefinition* property = propertySet->AddProperty("MyImage");
MaterialTypeSourceData::PropertyGroup* propertyGroup = sourceData.AddPropertyGroup("general");
MaterialTypeSourceData::PropertyDefinition* property = propertyGroup->AddProperty("MyImage");
property->m_displayName = "My Image";
property->m_description = "This is an image";
property->m_dataType = MaterialPropertyDataType::Image;
@@ -898,8 +898,8 @@ namespace UnitTest
sourceData.m_shaderCollection.push_back(MaterialTypeSourceData::ShaderVariantReferenceData{TestShaderFilename});
MaterialTypeSourceData::PropertySet* propertySet = sourceData.AddPropertySet("general");
MaterialTypeSourceData::PropertyDefinition* property = propertySet->AddProperty("MyInt");
MaterialTypeSourceData::PropertyGroup* propertyGroup = sourceData.AddPropertyGroup("general");
MaterialTypeSourceData::PropertyDefinition* property = propertyGroup->AddProperty("MyInt");
property->m_displayName = "My Integer";
property->m_dataType = MaterialPropertyDataType::Int;
property->m_outputConnections.push_back(MaterialTypeSourceData::PropertyConnection{MaterialPropertyOutputType::ShaderOption, AZStd::string("o_foo"), 0});
@@ -920,8 +920,8 @@ namespace UnitTest
sourceData.m_shaderCollection.push_back(MaterialTypeSourceData::ShaderVariantReferenceData{TestShaderFilename});
MaterialTypeSourceData::PropertySet* propertySet = sourceData.AddPropertySet("general");
MaterialTypeSourceData::PropertyDefinition* property = propertySet->AddProperty("MyInt");
MaterialTypeSourceData::PropertyGroup* propertyGroup = sourceData.AddPropertyGroup("general");
MaterialTypeSourceData::PropertyDefinition* property = propertyGroup->AddProperty("MyInt");
property->m_dataType = MaterialPropertyDataType::Int;
property->m_outputConnections.push_back(MaterialTypeSourceData::PropertyConnection{MaterialPropertyOutputType::ShaderOption, AZStd::string("DoesNotExist"), 0});
@@ -937,7 +937,7 @@ namespace UnitTest
const AZStd::string inputJson = R"(
{
"propertyLayout": {
"propertySets": [
"propertyGroups": [
{
"name": "not a valid name because it has spaces",
"properties": [
@@ -967,7 +967,7 @@ namespace UnitTest
const AZStd::string inputJson = R"(
{
"propertyLayout": {
"propertySets": [
"propertyGroups": [
{
"name": "general",
"properties": [
@@ -997,7 +997,7 @@ namespace UnitTest
const AZStd::string inputJson = R"(
{
"propertyLayout": {
"propertySets": [
"propertyGroups": [
{
"name": "general",
"properties": [
@@ -1027,12 +1027,12 @@ namespace UnitTest
errorMessageFinder.CheckExpectedErrorsFound();
}
TEST_F(MaterialTypeSourceDataTests, CreateMaterialTypeAsset_Error_PropertyAndPropertySetNameCollision)
TEST_F(MaterialTypeSourceDataTests, CreateMaterialTypeAsset_Error_PropertyAndPropertyGroupNameCollision)
{
const AZStd::string inputJson = R"(
{
"propertyLayout": {
"propertySets": [
"propertyGroups": [
{
"name": "general",
"properties": [
@@ -1041,7 +1041,7 @@ namespace UnitTest
"type": "Bool"
}
],
"propertySets": [
"propertyGroups": [
{
"name": "foo",
"properties": [
@@ -1062,7 +1062,7 @@ namespace UnitTest
JsonTestResult loadResult = LoadTestDataFromJson(sourceData, inputJson);
EXPECT_EQ(loadResult.m_jsonResultCode.GetProcessing(), JsonSerializationResult::Processing::Completed);
ErrorMessageFinder errorMessageFinder("Material property 'general.foo' collides with a PropertySet with the same ID");
ErrorMessageFinder errorMessageFinder("Material property 'general.foo' collides with a PropertyGroup with the same ID");
auto materialTypeOutcome = sourceData.CreateMaterialTypeAsset(Uuid::CreateRandom());
EXPECT_FALSE(materialTypeOutcome.IsSuccess());
errorMessageFinder.CheckExpectedErrorsFound();
@@ -1117,8 +1117,8 @@ namespace UnitTest
sourceData.m_shaderCollection.push_back(MaterialTypeSourceData::ShaderVariantReferenceData{ "shaderB.shader" });
sourceData.m_shaderCollection.push_back(MaterialTypeSourceData::ShaderVariantReferenceData{ "shaderC.shader" });
MaterialTypeSourceData::PropertySet* propertySet = sourceData.AddPropertySet("general");
MaterialTypeSourceData::PropertyDefinition* property = propertySet->AddProperty("MyInt");
MaterialTypeSourceData::PropertyGroup* propertyGroup = sourceData.AddPropertyGroup("general");
MaterialTypeSourceData::PropertyDefinition* property = propertyGroup->AddProperty("MyInt");
property->m_displayName = "Integer";
property->m_description = "Integer property that is connected to multiple shader settings";
@@ -1176,8 +1176,8 @@ namespace UnitTest
{
MaterialTypeSourceData sourceData;
MaterialTypeSourceData::PropertySet* propertySet = sourceData.AddPropertySet("general");
MaterialTypeSourceData::PropertyDefinition* property = propertySet->AddProperty("floatForFunctor");
MaterialTypeSourceData::PropertyGroup* propertyGroup = sourceData.AddPropertyGroup("general");
MaterialTypeSourceData::PropertyDefinition* property = propertyGroup->AddProperty("floatForFunctor");
property->m_displayName = "Float for Functor";
property->m_description = "This float is processed by a functor, not with a direct connection";
@@ -1221,9 +1221,9 @@ namespace UnitTest
sourceData.m_shaderCollection.push_back(MaterialTypeSourceData::ShaderVariantReferenceData{TestShaderFilename});
sourceData.m_shaderCollection.push_back(MaterialTypeSourceData::ShaderVariantReferenceData{TestShaderFilename});
MaterialTypeSourceData::PropertySet* propertySet = sourceData.AddPropertySet("general");
MaterialTypeSourceData::PropertyDefinition* property1 = propertySet->AddProperty("EnableSpecialPassA");
MaterialTypeSourceData::PropertyDefinition* property2 = propertySet->AddProperty("EnableSpecialPassB");
MaterialTypeSourceData::PropertyGroup* propertyGroup = sourceData.AddPropertyGroup("general");
MaterialTypeSourceData::PropertyDefinition* property1 = propertyGroup->AddProperty("EnableSpecialPassA");
MaterialTypeSourceData::PropertyDefinition* property2 = propertyGroup->AddProperty("EnableSpecialPassB");
property1->m_displayName = property2->m_displayName = "Enable Special Pass";
property1->m_description = property2->m_description = "This is a bool to enable an extra shader/pass";
@@ -1279,8 +1279,8 @@ namespace UnitTest
sourceData.m_shaderCollection.push_back(MaterialTypeSourceData::ShaderVariantReferenceData{TestShaderFilename});
sourceData.m_shaderCollection.push_back(MaterialTypeSourceData::ShaderVariantReferenceData{TestShaderFilename});
MaterialTypeSourceData::PropertySet* propertySet = sourceData.AddPropertySet("general");
MaterialTypeSourceData::PropertyDefinition* property = propertySet->AddProperty("MyProperty");
MaterialTypeSourceData::PropertyGroup* propertyGroup = sourceData.AddPropertyGroup("general");
MaterialTypeSourceData::PropertyDefinition* property = propertyGroup->AddProperty("MyProperty");
property->m_dataType = MaterialPropertyDataType::Bool;
// Note that we don't fill property->m_outputConnections because this is not a direct-connected property
@@ -1307,12 +1307,12 @@ namespace UnitTest
EXPECT_TRUE(materialTypeAsset->GetShaderCollection()[0].MaterialOwnsShaderOption(Name{"o_bar"}));
}
TEST_F(MaterialTypeSourceDataTests, CreateMaterialTypeAsset_FunctorIsInsidePropertySet)
TEST_F(MaterialTypeSourceDataTests, CreateMaterialTypeAsset_FunctorIsInsidePropertyGroup)
{
MaterialTypeSourceData sourceData;
MaterialTypeSourceData::PropertySet* propertySet = sourceData.AddPropertySet("general");
MaterialTypeSourceData::PropertyDefinition* property = propertySet->AddProperty("floatForFunctor");
MaterialTypeSourceData::PropertyGroup* propertyGroup = sourceData.AddPropertyGroup("general");
MaterialTypeSourceData::PropertyDefinition* property = propertyGroup->AddProperty("floatForFunctor");
property->m_dataType = MaterialPropertyDataType::Float;
@@ -1360,7 +1360,7 @@ namespace UnitTest
property->m_value = value;
};
sourceData.AddPropertySet("general");
sourceData.AddPropertyGroup("general");
addProperty(MaterialPropertyDataType::Bool, "general.MyBool", "m_bool", true);
addProperty(MaterialPropertyDataType::Float, "general.MyFloat", "m_float", 1.2f);
@@ -1387,7 +1387,7 @@ namespace UnitTest
CheckPropertyValue<Data::Asset<ImageAsset>>(materialTypeAsset, Name{"general.MyImage"}, m_testImageAsset);
}
TEST_F(MaterialTypeSourceDataTests, CreateMaterialTypeAsset_NestedPropertySets)
TEST_F(MaterialTypeSourceDataTests, CreateMaterialTypeAsset_NestedPropertyGroups)
{
RHI::Ptr<RHI::ShaderResourceGroupLayout> layeredMaterialSrgLayout = RHI::ShaderResourceGroupLayout::Create();
layeredMaterialSrgLayout->SetName(Name{"MaterialSrg"});
@@ -1428,16 +1428,16 @@ namespace UnitTest
property->m_value = value;
};
sourceData.AddPropertySet("layer1");
sourceData.AddPropertySet("layer2");
sourceData.AddPropertySet("blend");
sourceData.AddPropertySet("layer1.baseColor");
sourceData.AddPropertySet("layer2.baseColor");
sourceData.AddPropertySet("layer1.roughness");
sourceData.AddPropertySet("layer2.roughness");
sourceData.AddPropertySet("layer2.clearCoat");
sourceData.AddPropertySet("layer2.clearCoat.roughness");
sourceData.AddPropertySet("layer2.clearCoat.normal");
sourceData.AddPropertyGroup("layer1");
sourceData.AddPropertyGroup("layer2");
sourceData.AddPropertyGroup("blend");
sourceData.AddPropertyGroup("layer1.baseColor");
sourceData.AddPropertyGroup("layer2.baseColor");
sourceData.AddPropertyGroup("layer1.roughness");
sourceData.AddPropertyGroup("layer2.roughness");
sourceData.AddPropertyGroup("layer2.clearCoat");
sourceData.AddPropertyGroup("layer2.clearCoat.roughness");
sourceData.AddPropertyGroup("layer2.clearCoat.normal");
addSrgProperty(MaterialPropertyDataType::Image, MaterialPropertyOutputType::ShaderInput, "layer1.baseColor.texture", "m_layer1_baseColor_texture", AZStd::string{TestImageFilename});
addSrgProperty(MaterialPropertyDataType::Image, MaterialPropertyOutputType::ShaderInput, "layer1.roughness.texture", "m_layer1_roughness_texture", AZStd::string{TestImageFilename});
@@ -1487,7 +1487,7 @@ namespace UnitTest
}
],
"propertyLayout": {
"propertySets": [
"propertyGroups": [
{
"name": "groupA",
"displayName": "Property Group A",
@@ -1545,8 +1545,8 @@ namespace UnitTest
{
"name": "groupC",
"displayName": "Property Group C",
"description": "Property group C has a nested property set",
"propertySets": [
"description": "Property group C has a nested property group",
"propertyGroups": [
{
"name": "groupD",
"displayName": "Property Group D",
@@ -1616,27 +1616,27 @@ namespace UnitTest
EXPECT_EQ(material.m_versionUpdates[0].m_actions[0].m_renameTo, "groupA.foo");
EXPECT_EQ(material.GetPropertyLayout().m_propertySets.size(), 3);
EXPECT_TRUE(material.FindPropertySet("groupA") != nullptr);
EXPECT_TRUE(material.FindPropertySet("groupB") != nullptr);
EXPECT_TRUE(material.FindPropertySet("groupC") != nullptr);
EXPECT_TRUE(material.FindPropertySet("groupC.groupD") != nullptr);
EXPECT_TRUE(material.FindPropertySet("groupC.groupE") != nullptr);
EXPECT_EQ(material.FindPropertySet("groupA")->GetDisplayName(), "Property Group A");
EXPECT_EQ(material.FindPropertySet("groupB")->GetDisplayName(), "Property Group B");
EXPECT_EQ(material.FindPropertySet("groupC")->GetDisplayName(), "Property Group C");
EXPECT_EQ(material.FindPropertySet("groupC.groupD")->GetDisplayName(), "Property Group D");
EXPECT_EQ(material.FindPropertySet("groupC.groupE")->GetDisplayName(), "Property Group E");
EXPECT_EQ(material.FindPropertySet("groupA")->GetDescription(), "Description of property group A");
EXPECT_EQ(material.FindPropertySet("groupB")->GetDescription(), "Description of property group B");
EXPECT_EQ(material.FindPropertySet("groupC")->GetDescription(), "Property group C has a nested property set");
EXPECT_EQ(material.FindPropertySet("groupC.groupD")->GetDescription(), "Description of property group D");
EXPECT_EQ(material.FindPropertySet("groupC.groupE")->GetDescription(), "Description of property group E");
EXPECT_EQ(material.FindPropertySet("groupA")->GetProperties().size(), 2);
EXPECT_EQ(material.FindPropertySet("groupB")->GetProperties().size(), 2);
EXPECT_EQ(material.FindPropertySet("groupC")->GetProperties().size(), 0);
EXPECT_EQ(material.FindPropertySet("groupC.groupD")->GetProperties().size(), 1);
EXPECT_EQ(material.FindPropertySet("groupC.groupE")->GetProperties().size(), 1);
EXPECT_EQ(material.GetPropertyLayout().m_propertyGroups.size(), 3);
EXPECT_TRUE(material.FindPropertyGroup("groupA") != nullptr);
EXPECT_TRUE(material.FindPropertyGroup("groupB") != nullptr);
EXPECT_TRUE(material.FindPropertyGroup("groupC") != nullptr);
EXPECT_TRUE(material.FindPropertyGroup("groupC.groupD") != nullptr);
EXPECT_TRUE(material.FindPropertyGroup("groupC.groupE") != nullptr);
EXPECT_EQ(material.FindPropertyGroup("groupA")->GetDisplayName(), "Property Group A");
EXPECT_EQ(material.FindPropertyGroup("groupB")->GetDisplayName(), "Property Group B");
EXPECT_EQ(material.FindPropertyGroup("groupC")->GetDisplayName(), "Property Group C");
EXPECT_EQ(material.FindPropertyGroup("groupC.groupD")->GetDisplayName(), "Property Group D");
EXPECT_EQ(material.FindPropertyGroup("groupC.groupE")->GetDisplayName(), "Property Group E");
EXPECT_EQ(material.FindPropertyGroup("groupA")->GetDescription(), "Description of property group A");
EXPECT_EQ(material.FindPropertyGroup("groupB")->GetDescription(), "Description of property group B");
EXPECT_EQ(material.FindPropertyGroup("groupC")->GetDescription(), "Property group C has a nested property group");
EXPECT_EQ(material.FindPropertyGroup("groupC.groupD")->GetDescription(), "Description of property group D");
EXPECT_EQ(material.FindPropertyGroup("groupC.groupE")->GetDescription(), "Description of property group E");
EXPECT_EQ(material.FindPropertyGroup("groupA")->GetProperties().size(), 2);
EXPECT_EQ(material.FindPropertyGroup("groupB")->GetProperties().size(), 2);
EXPECT_EQ(material.FindPropertyGroup("groupC")->GetProperties().size(), 0);
EXPECT_EQ(material.FindPropertyGroup("groupC.groupD")->GetProperties().size(), 1);
EXPECT_EQ(material.FindPropertyGroup("groupC.groupE")->GetProperties().size(), 1);
EXPECT_NE(material.FindProperty("groupA.foo"), nullptr);
EXPECT_NE(material.FindProperty("groupA.bar"), nullptr);
@@ -1670,10 +1670,10 @@ namespace UnitTest
EXPECT_EQ(material.FindProperty("groupC.groupD.foo")->m_value, -1);
EXPECT_EQ(material.FindProperty("groupC.groupE.bar")->m_value, 0u);
EXPECT_EQ(material.FindPropertySet("groupA")->GetFunctors().size(), 1);
EXPECT_EQ(material.FindPropertySet("groupB")->GetFunctors().size(), 1);
Ptr<MaterialFunctorSourceData> functorA = material.FindPropertySet("groupA")->GetFunctors()[0]->GetActualSourceData();
Ptr<MaterialFunctorSourceData> functorB = material.FindPropertySet("groupB")->GetFunctors()[0]->GetActualSourceData();
EXPECT_EQ(material.FindPropertyGroup("groupA")->GetFunctors().size(), 1);
EXPECT_EQ(material.FindPropertyGroup("groupB")->GetFunctors().size(), 1);
Ptr<MaterialFunctorSourceData> functorA = material.FindPropertyGroup("groupA")->GetFunctors()[0]->GetActualSourceData();
Ptr<MaterialFunctorSourceData> functorB = material.FindPropertyGroup("groupB")->GetFunctors()[0]->GetActualSourceData();
EXPECT_TRUE(azrtti_cast<const EnableShaderFunctorSourceData*>(functorA.get()));
EXPECT_EQ(azrtti_cast<const EnableShaderFunctorSourceData*>(functorA.get())->m_enablePassPropertyId, "foo");
EXPECT_EQ(azrtti_cast<const EnableShaderFunctorSourceData*>(functorA.get())->m_shaderIndex, 1);
@@ -1708,7 +1708,7 @@ namespace UnitTest
// (The "store" part of the test was not included because the saved data will be the new format).
// Notable differences include:
// 1) the key "id" is used instead of "name"
// 2) the group metadata, property definitions, and functors are all defined in different sections rather than in a property set
// 2) the group metadata, property definitions, and functors are all defined in different sections rather than in a unified property group definition
const AZStd::string inputJson = R"(
{
@@ -1798,25 +1798,25 @@ namespace UnitTest
// Before conversion to the new format, the data is in the old place
EXPECT_EQ(material.GetPropertyLayout().m_groupsOld.size(), 2);
EXPECT_EQ(material.GetPropertyLayout().m_propertiesOld.size(), 2);
EXPECT_EQ(material.GetPropertyLayout().m_propertySets.size(), 0);
EXPECT_EQ(material.GetPropertyLayout().m_propertyGroups.size(), 0);
material.ConvertToNewDataFormat();
// After conversion to the new format, the data is in the new place
EXPECT_EQ(material.GetPropertyLayout().m_groupsOld.size(), 0);
EXPECT_EQ(material.GetPropertyLayout().m_propertiesOld.size(), 0);
EXPECT_EQ(material.GetPropertyLayout().m_propertySets.size(), 2);
EXPECT_EQ(material.GetPropertyLayout().m_propertyGroups.size(), 2);
EXPECT_EQ(material.m_description, "This is a general description about the material");
EXPECT_TRUE(material.FindPropertySet("groupA") != nullptr);
EXPECT_TRUE(material.FindPropertySet("groupB") != nullptr);
EXPECT_EQ(material.FindPropertySet("groupA")->GetDisplayName(), "Property Group A");
EXPECT_EQ(material.FindPropertySet("groupB")->GetDisplayName(), "Property Group B");
EXPECT_EQ(material.FindPropertySet("groupA")->GetDescription(), "Description of property group A");
EXPECT_EQ(material.FindPropertySet("groupB")->GetDescription(), "Description of property group B");
EXPECT_EQ(material.FindPropertySet("groupA")->GetProperties().size(), 2);
EXPECT_EQ(material.FindPropertySet("groupB")->GetProperties().size(), 2);
EXPECT_TRUE(material.FindPropertyGroup("groupA") != nullptr);
EXPECT_TRUE(material.FindPropertyGroup("groupB") != nullptr);
EXPECT_EQ(material.FindPropertyGroup("groupA")->GetDisplayName(), "Property Group A");
EXPECT_EQ(material.FindPropertyGroup("groupB")->GetDisplayName(), "Property Group B");
EXPECT_EQ(material.FindPropertyGroup("groupA")->GetDescription(), "Description of property group A");
EXPECT_EQ(material.FindPropertyGroup("groupB")->GetDescription(), "Description of property group B");
EXPECT_EQ(material.FindPropertyGroup("groupA")->GetProperties().size(), 2);
EXPECT_EQ(material.FindPropertyGroup("groupB")->GetProperties().size(), 2);
EXPECT_TRUE(material.FindProperty("groupA.foo") != nullptr);
EXPECT_TRUE(material.FindProperty("groupA.bar") != nullptr);
@@ -1840,10 +1840,10 @@ namespace UnitTest
EXPECT_EQ(material.FindProperty("groupB.foo")->m_value, 0.5f);
EXPECT_EQ(material.FindProperty("groupB.bar")->m_value, AZ::Color(0.5f, 0.5f, 0.5f, 1.0f));
// The functors can appear either at the top level or within each property set. The format conversion
// The functors can appear either at the top level or within each property group. The format conversion
// function doesn't know how to move the functors, and they will be left at the top level.
EXPECT_EQ(material.FindPropertySet("groupA")->GetFunctors().size(), 0);
EXPECT_EQ(material.FindPropertySet("groupB")->GetFunctors().size(), 0);
EXPECT_EQ(material.FindPropertyGroup("groupA")->GetFunctors().size(), 0);
EXPECT_EQ(material.FindPropertyGroup("groupB")->GetFunctors().size(), 0);
EXPECT_EQ(material.m_shaderCollection.size(), 2);
EXPECT_EQ(material.m_shaderCollection[0].m_shaderFilePath, "ForwardPass.shader");
@@ -1873,7 +1873,7 @@ namespace UnitTest
{
"description": "",
"propertyLayout": {
"propertySets": [
"propertyGroups": [
{
"name": "general",
"displayName": "General",
@@ -1915,7 +1915,7 @@ namespace UnitTest
{
MaterialTypeSourceData sourceData;
MaterialTypeSourceData::PropertyDefinition* propertySource = sourceData.AddPropertySet("general")->AddProperty("a");
MaterialTypeSourceData::PropertyDefinition* propertySource = sourceData.AddPropertyGroup("general")->AddProperty("a");
propertySource->m_dataType = MaterialPropertyDataType::Int;
propertySource->m_value = 0;
@@ -2,7 +2,7 @@
"description": "Base Material with properties used to define Standard PBR, a metallic-roughness Physically-Based Rendering (PBR) material shading model.",
"version": 3,
"propertyLayout": {
"propertySets": [
"propertyGroups": [
{
"name": "settings",
"displayName": "Settings",
@@ -602,7 +602,7 @@ namespace MaterialEditor
return false;
}
// TODO: Support populating the Material Editor with nested property sets, not just the top level.
// TODO: Support populating the Material Editor with nested property groups, not just the top level.
const AZStd::string groupName = propertyId.GetStringView().substr(0, propertyId.GetStringView().size() - propertyDefinition->GetName().size() - 1);
sourceData.m_properties[groupName][propertyDefinition->GetName()].m_value = propertyValue;
}
@@ -781,14 +781,14 @@ namespace MaterialEditor
// 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
// in the hierarchy are applied
m_materialTypeSourceData.EnumeratePropertySets([this, &parentPropertyValues](const AZStd::string& propertyIdContext, const MaterialTypeSourceData::PropertySet* propertySet)
m_materialTypeSourceData.EnumeratePropertyGroups([this, &parentPropertyValues](const AZStd::string& propertyIdContext, const MaterialTypeSourceData::PropertyGroup* propertyGroup)
{
AtomToolsFramework::DynamicPropertyConfig propertyConfig;
for (const auto& propertyDefinition : propertySet->GetProperties())
for (const auto& propertyDefinition : propertyGroup->GetProperties())
{
// Assign id before conversion so it can be used in dynamic description
propertyConfig.m_id = propertyIdContext + propertySet->GetName() + "." + propertyDefinition->GetName();
propertyConfig.m_id = propertyIdContext + propertyGroup->GetName() + "." + propertyDefinition->GetName();
const auto& propertyIndex = m_materialAsset->GetMaterialPropertiesLayout()->FindPropertyIndex(propertyConfig.m_id);
const bool propertyIndexInBounds = propertyIndex.IsValid() && propertyIndex.GetIndex() < m_materialAsset->GetPropertyValues().size();
@@ -801,9 +801,9 @@ namespace MaterialEditor
propertyConfig.m_originalValue = AtomToolsFramework::ConvertToEditableType(m_materialAsset->GetPropertyValues()[propertyIndex.GetIndex()]);
propertyConfig.m_parentValue = AtomToolsFramework::ConvertToEditableType(parentPropertyValues[propertyIndex.GetIndex()]);
// TODO: Support populating the Material Editor with nested property sets, not just the top level.
// TODO: Support populating the Material Editor with nested property groups, not just the top level.
// (Does DynamicPropertyConfig really even need m_groupName?)
propertyConfig.m_groupName = propertySet->GetDisplayName();
propertyConfig.m_groupName = propertyGroup->GetDisplayName();
m_properties[propertyConfig.m_id] = AtomToolsFramework::DynamicProperty(propertyConfig);
}
}
@@ -812,10 +812,10 @@ namespace MaterialEditor
});
// Populate the property group visibility map
// TODO: Support populating the Material Editor with nested property sets, not just the top level.
for (const AZStd::unique_ptr<MaterialTypeSourceData::PropertySet>& propertySet : m_materialTypeSourceData.GetPropertyLayout().m_propertySets)
// TODO: Support populating the Material Editor with nested property groups, not just the top level.
for (const AZStd::unique_ptr<MaterialTypeSourceData::PropertyGroup>& propertyGroup : m_materialTypeSourceData.GetPropertyLayout().m_propertyGroups)
{
m_propertyGroupVisibility[AZ::Name{propertySet->GetName()}] = true;
m_propertyGroupVisibility[AZ::Name{propertyGroup->GetName()}] = true;
}
// Adding properties for material type and parent as part of making dynamic
@@ -899,14 +899,14 @@ namespace MaterialEditor
}
}
// Add any material functors that are located inside each property set.
bool enumerateResult = m_materialTypeSourceData.EnumeratePropertySets(
[this](const AZStd::string&, const MaterialTypeSourceData::PropertySet* propertySet)
// Add any material functors that are located inside each property group.
bool enumerateResult = m_materialTypeSourceData.EnumeratePropertyGroups(
[this](const AZStd::string&, const MaterialTypeSourceData::PropertyGroup* propertyGroup)
{
const MaterialFunctorSourceData::EditorContext editorContext = MaterialFunctorSourceData::EditorContext(
m_materialSourceData.m_materialType, m_materialAsset->GetMaterialPropertiesLayout());
for (Ptr<MaterialFunctorSourceDataHolder> functorData : propertySet->GetFunctors())
for (Ptr<MaterialFunctorSourceDataHolder> functorData : propertyGroup->GetFunctors())
{
MaterialFunctorSourceData::FunctorResult result = functorData->CreateFunctor(editorContext);
@@ -171,16 +171,16 @@ namespace MaterialEditor
MaterialDocumentRequestBus::EventResult(
materialTypeSourceData, m_documentId, &MaterialDocumentRequestBus::Events::GetMaterialTypeSourceData);
// TODO: Support populating the Material Editor with nested property sets, not just the top level.
for (const AZStd::unique_ptr<AZ::RPI::MaterialTypeSourceData::PropertySet>& propertySet : materialTypeSourceData->GetPropertyLayout().m_propertySets)
// TODO: Support populating the Material Editor with nested property groups, not just the top level.
for (const AZStd::unique_ptr<AZ::RPI::MaterialTypeSourceData::PropertyGroup>& propertyGroup : materialTypeSourceData->GetPropertyLayout().m_propertyGroups)
{
const AZStd::string& groupName = propertySet->GetName();
const AZStd::string& groupDisplayName = !propertySet->GetDisplayName().empty() ? propertySet->GetDisplayName() : groupName;
const AZStd::string& groupDescription = !propertySet->GetDescription().empty() ? propertySet->GetDescription() : groupDisplayName;
const AZStd::string& groupName = propertyGroup->GetName();
const AZStd::string& groupDisplayName = !propertyGroup->GetDisplayName().empty() ? propertyGroup->GetDisplayName() : groupName;
const AZStd::string& groupDescription = !propertyGroup->GetDescription().empty() ? propertyGroup->GetDescription() : groupDisplayName;
auto& group = m_groups[groupName];
group.m_properties.reserve(propertySet->GetProperties().size());
for (const auto& propertyDefinition : propertySet->GetProperties())
group.m_properties.reserve(propertyGroup->GetProperties().size());
for (const auto& propertyDefinition : propertyGroup->GetProperties())
{
AtomToolsFramework::DynamicProperty property;
AtomToolsFramework::AtomToolsDocumentRequestBus::EventResult(
@@ -293,16 +293,16 @@ namespace AZ
void MaterialPropertyInspector::AddPropertiesGroup()
{
// Copy all of the properties from the material asset to the source data that will be exported
// TODO: Support populating the Material Editor with nested property sets, not just the top level.
for (const AZStd::unique_ptr<AZ::RPI::MaterialTypeSourceData::PropertySet>& propertySet : m_editData.m_materialTypeSourceData.GetPropertyLayout().m_propertySets)
// TODO: Support populating the Material Editor with nested property groups, not just the top level.
for (const AZStd::unique_ptr<AZ::RPI::MaterialTypeSourceData::PropertyGroup>& propertyGroup : m_editData.m_materialTypeSourceData.GetPropertyLayout().m_propertyGroups)
{
const AZStd::string& groupName = propertySet->GetName();
const AZStd::string& groupDisplayName = !propertySet->GetDisplayName().empty() ? propertySet->GetDisplayName() : groupName;
const AZStd::string& groupDescription = !propertySet->GetDescription().empty() ? propertySet->GetDescription() : groupDisplayName;
const AZStd::string& groupName = propertyGroup->GetName();
const AZStd::string& groupDisplayName = !propertyGroup->GetDisplayName().empty() ? propertyGroup->GetDisplayName() : groupName;
const AZStd::string& groupDescription = !propertyGroup->GetDescription().empty() ? propertyGroup->GetDescription() : groupDisplayName;
auto& group = m_groups[groupName];
group.m_properties.reserve(propertySet->GetProperties().size());
for (const auto& propertyDefinition : propertySet->GetProperties())
group.m_properties.reserve(propertyGroup->GetProperties().size());
for (const auto& propertyDefinition : propertyGroup->GetProperties())
{
AtomToolsFramework::DynamicPropertyConfig propertyConfig;
@@ -148,7 +148,7 @@ namespace AZ
return true;
}
// TODO: Support populating the Material Editor with nested property sets, not just the top level.
// TODO: Support populating the Material Editor with nested property groups, not just the top level.
const AZStd::string groupName = propertyId.GetStringView().substr(0, propertyId.GetStringView().size() - propertyDefinition->GetName().size() - 1);
exportData.m_properties[groupName][propertyDefinition->GetName()].m_value = propertyValue;
return true;