Made StandardMultilayerPBR hide a layer's property groups when that layer is disabled.
ATOM-14688 Disable Individual Layers - Added new SetMaterialPropertyGroupVisibility functions to the material functors. - Updated the MaterialFunctor::EditorContext to include parameters for handling material property group metadata. - Updated the material inspector(s) to apply the property group visiblity changes from the material functor, to hide or show the property groups. - Moved some code from MaterialPropertyDescriptor.h/cpp to a new MaterialDynamicMetadata.h/cpp, since these aren't really related to the MaterialPropertyDescriptor code. It's more for material functors to use. - Also fixed the casing for the "GetMaterialPropertyValue_Image" lua function, since I was already in this code (ATOM-14793 "Fix Inconsistent Casing For LuaMaterialFunctorRuntimeContext") Tested in MaterialEditor and in in the main Editor's MaterialComponent property override inspector.
This commit is contained in:
@@ -117,6 +117,24 @@ namespace MaterialEditor
|
||||
const AtomToolsFramework::DynamicProperty& property = it->second;
|
||||
return property;
|
||||
}
|
||||
|
||||
bool MaterialDocument::IsPropertyGroupVisible(const AZ::Name& propertyGroupFullName) const
|
||||
{
|
||||
if (!IsOpen())
|
||||
{
|
||||
AZ_Error("MaterialDocument", false, "Material document is not open.");
|
||||
return false;
|
||||
}
|
||||
|
||||
const auto it = m_propertyGroupVisibility.find(propertyGroupFullName);
|
||||
if (it == m_propertyGroupVisibility.end())
|
||||
{
|
||||
AZ_Error("MaterialDocument", false, "Material document property group could not be found: '%s'.", propertyGroupFullName.GetCStr());
|
||||
return false;
|
||||
}
|
||||
|
||||
return it->second;
|
||||
}
|
||||
|
||||
void MaterialDocument::SetPropertyValue(const AZ::Name& propertyFullName, const AZStd::any& value)
|
||||
{
|
||||
@@ -153,8 +171,12 @@ namespace MaterialEditor
|
||||
|
||||
Recompile();
|
||||
|
||||
AZStd::unordered_set<Name> changedPropertyNames = RunEditorMaterialFunctors(dirtyFlags);
|
||||
for (const Name& changedPropertyName : changedPropertyNames)
|
||||
EditorMaterialFunctorResult result = RunEditorMaterialFunctors(dirtyFlags);
|
||||
for (const Name& changedPropertyGroupName : result.m_updatedPropertyGroups)
|
||||
{
|
||||
MaterialDocumentNotificationBus::Broadcast(&MaterialDocumentNotificationBus::Events::OnDocumentPropertyGroupVisibilityChanged, m_id, changedPropertyGroupName, IsPropertyGroupVisible(changedPropertyGroupName));
|
||||
}
|
||||
for (const Name& changedPropertyName : result.m_updatedProperties)
|
||||
{
|
||||
MaterialDocumentNotificationBus::Broadcast(&MaterialDocumentNotificationBus::Events::OnDocumentPropertyConfigModified, m_id, GetProperty(changedPropertyName));
|
||||
}
|
||||
@@ -782,6 +804,12 @@ namespace MaterialEditor
|
||||
return true;
|
||||
});
|
||||
|
||||
// Populate the property group visibility map
|
||||
for (MaterialTypeSourceData::GroupDefinition& group : m_materialTypeSourceData.GetGroupDefinitionsInDisplayOrder())
|
||||
{
|
||||
m_propertyGroupVisibility[AZ::Name{group.m_nameId}] = true;
|
||||
}
|
||||
|
||||
// Adding properties for material type and parent as part of making dynamic
|
||||
// properties and the inspector more general purpose.
|
||||
// This allows the read only properties to appear in the inspector like any
|
||||
@@ -914,16 +942,26 @@ namespace MaterialEditor
|
||||
}
|
||||
}
|
||||
|
||||
AZStd::unordered_set<AZ::Name> MaterialDocument::RunEditorMaterialFunctors(AZ::RPI::MaterialPropertyFlags dirtyFlags)
|
||||
MaterialDocument::EditorMaterialFunctorResult MaterialDocument::RunEditorMaterialFunctors(AZ::RPI::MaterialPropertyFlags dirtyFlags)
|
||||
{
|
||||
AZStd::unordered_set<AZ::Name> changedPropertyNames;
|
||||
EditorMaterialFunctorResult result;
|
||||
|
||||
AZStd::unordered_map<AZ::Name, AZ::RPI::MaterialPropertyDynamicMetadata> propertyDynamicMetadata;
|
||||
AZStd::unordered_map<AZ::Name, AZ::RPI::MaterialPropertyGroupDynamicMetadata> propertyGroupDynamicMetadata;
|
||||
for (auto& propertyPair : m_properties)
|
||||
{
|
||||
AtomToolsFramework::DynamicProperty& property = propertyPair.second;
|
||||
AtomToolsFramework::ConvertToPropertyMetaData(propertyDynamicMetadata[property.GetId()], property.GetConfig());
|
||||
}
|
||||
for (auto& groupPair : m_propertyGroupVisibility)
|
||||
{
|
||||
AZ::RPI::MaterialPropertyGroupDynamicMetadata& metadata = propertyGroupDynamicMetadata[AZ::Name{groupPair.first}];
|
||||
|
||||
bool visible = groupPair.second;
|
||||
metadata.m_visibility = visible ?
|
||||
AZ::RPI::MaterialPropertyGroupVisibility::Enabled : AZ::RPI::MaterialPropertyGroupVisibility::Hidden;
|
||||
}
|
||||
|
||||
for (AZ::RPI::Ptr<AZ::RPI::MaterialFunctor>& functor : m_editorFunctors)
|
||||
{
|
||||
const AZ::RPI::MaterialPropertyFlags& materialPropertyDependencies = functor->GetMaterialPropertyDependencies();
|
||||
@@ -935,7 +973,9 @@ namespace MaterialEditor
|
||||
m_materialInstance->GetPropertyValues(),
|
||||
m_materialInstance->GetMaterialPropertiesLayout(),
|
||||
propertyDynamicMetadata,
|
||||
changedPropertyNames,
|
||||
propertyGroupDynamicMetadata,
|
||||
result.m_updatedProperties,
|
||||
result.m_updatedPropertyGroups,
|
||||
&materialPropertyDependencies
|
||||
);
|
||||
functor->Process(context);
|
||||
@@ -950,7 +990,13 @@ namespace MaterialEditor
|
||||
property.SetConfig(propertyConfig);
|
||||
}
|
||||
|
||||
return changedPropertyNames;
|
||||
for (auto& updatedPropertyGroup : result.m_updatedPropertyGroups)
|
||||
{
|
||||
bool visible = propertyGroupDynamicMetadata[updatedPropertyGroup].m_visibility == AZ::RPI::MaterialPropertyGroupVisibility::Enabled;
|
||||
m_propertyGroupVisibility[updatedPropertyGroup] = visible;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
} // namespace MaterialEditor
|
||||
|
||||
Reference in New Issue
Block a user