Cleanup up and resolving conflicts after the latest merge.

Signed-off-by: santorac <55155825+santorac@users.noreply.github.com>
monroegm-disable-blank-issue-2
santorac 4 years ago
parent 1a10369adb
commit 74f6d1ec74

@ -40,6 +40,9 @@ namespace AZ
bool ContextualizeProperty(Name& propertyName) const;
bool ContextualizeSrgInput(Name& srgInputName) const;
bool ContextualizeShaderOption(Name& shaderOptionName) const;
bool ContextualizeProperty(AZStd::string& propertyName) const;
bool ContextualizeSrgInput(AZStd::string& srgInputName) const;
bool ContextualizeShaderOption(AZStd::string& shaderOptionName) const;
//! Returns true if there is some non-default name context.
bool HasContextForProperties() const { return !m_propertyIdContext.empty(); }

@ -84,6 +84,39 @@ namespace AZ
shaderOptionName = m_shaderOptionNameContext + shaderOptionName.GetCStr();
return true;
}
bool MaterialNameContext::ContextualizeProperty(AZStd::string& propertyName) const
{
if (m_propertyIdContext.empty())
{
return false;
}
propertyName = m_propertyIdContext + propertyName;
return true;
}
bool MaterialNameContext::ContextualizeSrgInput(AZStd::string& srgInputName) const
{
if (m_srgInputNameContext.empty())
{
return false;
}
srgInputName = m_srgInputNameContext + srgInputName;
return true;
}
bool MaterialNameContext::ContextualizeShaderOption(AZStd::string& shaderOptionName) const
{
if (m_shaderOptionNameContext.empty())
{
return false;
}
shaderOptionName = m_shaderOptionNameContext + shaderOptionName;
return true;
}
} // namespace RPI
} // namespace AZ

@ -336,9 +336,9 @@ namespace MaterialEditor
bool addPropertiesResult = true;
// populate sourceData with properties that meet the filter
m_materialTypeSourceData.EnumerateProperties([&](const auto& propertyDefinition, const MaterialNameContext& nameContext) {
m_materialTypeSourceData.EnumerateProperties([&](const auto& propertyDefinition, const AZ::RPI::MaterialNameContext& nameContext) {
Name propertyId{propertyDefinition->GetName()};
AZ::Name propertyId{propertyDefinition->GetName()};
nameContext.ContextualizeProperty(propertyId);
const auto property = FindProperty(propertyId);
@ -551,16 +551,19 @@ namespace MaterialEditor
// in the hierarchy are applied
bool enumerateResult = m_materialTypeSourceData.EnumeratePropertyGroups(
[this, &parentPropertyValues](
const AZStd::string& propertyIdContext, const AZ::RPI::MaterialTypeSourceData::PropertyGroup* propertyGroup)
const AZ::RPI::MaterialTypeSourceData::PropertyGroup* propertyGroup,
const AZ::RPI::MaterialNameContext& groupNameContext,
const AZ::RPI::MaterialNameContext& parentNameContext)
{
// Add any material functors that are located inside each property group.
if (!AddEditorMaterialFunctors(propertyGroup->GetFunctors()))
if (!AddEditorMaterialFunctors(propertyGroup->GetFunctors(), groupNameContext))
{
return false;
}
m_groups.emplace_back(aznew AtomToolsFramework::DynamicPropertyGroup);
m_groups.back()->m_name = propertyIdContext + propertyGroup->GetName();
m_groups.back()->m_name = propertyGroup->GetName();
parentNameContext.ContextualizeProperty(m_groups.back()->m_name);
m_groups.back()->m_displayName = propertyGroup->GetDisplayName();
m_groups.back()->m_description = propertyGroup->GetDescription();
@ -568,7 +571,8 @@ namespace MaterialEditor
{
// Assign id before conversion so it can be used in dynamic description
AtomToolsFramework::DynamicPropertyConfig propertyConfig;
propertyConfig.m_id = m_groups.back()->m_name + "." + propertyDefinition->GetName();
propertyConfig.m_id = propertyDefinition->GetName();
groupNameContext.ContextualizeProperty(m_groups.back()->m_name);
const auto& propertyIndex = m_materialAsset->GetMaterialPropertiesLayout()->FindPropertyIndex(propertyConfig.m_id);
const bool propertyIndexInBounds =
@ -610,7 +614,8 @@ namespace MaterialEditor
}
// Add material functors that are in the top-level functors list.
if (!AddEditorMaterialFunctors(m_materialTypeSourceData.m_materialFunctorSourceData))
AZ::RPI::MaterialNameContext materialNameContext; // There is no name context for top-level functors, only functors inside PropertyGroups
if (!AddEditorMaterialFunctors(m_materialTypeSourceData.m_materialFunctorSourceData, materialNameContext))
{
return OpenFailed();
}
@ -736,10 +741,11 @@ namespace MaterialEditor
}
bool MaterialDocument::AddEditorMaterialFunctors(
const AZStd::vector<AZ::RPI::Ptr<AZ::RPI::MaterialFunctorSourceDataHolder>>& functorSourceDataHolders)
const AZStd::vector<AZ::RPI::Ptr<AZ::RPI::MaterialFunctorSourceDataHolder>>& functorSourceDataHolders,
const AZ::RPI::MaterialNameContext& nameContext)
{
const AZ::RPI::MaterialFunctorSourceData::EditorContext editorContext = AZ::RPI::MaterialFunctorSourceData::EditorContext(
m_materialSourceData.m_materialType, m_materialAsset->GetMaterialPropertiesLayout());
m_materialSourceData.m_materialType, m_materialAsset->GetMaterialPropertiesLayout(), &nameContext);
for (AZ::RPI::Ptr<AZ::RPI::MaterialFunctorSourceDataHolder> functorData : functorSourceDataHolders)
{

@ -82,7 +82,8 @@ namespace MaterialEditor
void RestorePropertyValues(const PropertyValueMap& propertyValues);
bool AddEditorMaterialFunctors(
const AZStd::vector<AZ::RPI::Ptr<AZ::RPI::MaterialFunctorSourceDataHolder>>& functorSourceDataHolders);
const AZStd::vector<AZ::RPI::Ptr<AZ::RPI::MaterialFunctorSourceDataHolder>>& functorSourceDataHolders,
const AZ::RPI::MaterialNameContext& nameContext);
// Run editor material functor to update editor metadata.
// @param dirtyFlags indicates which properties have changed, and thus which MaterialFunctors need to be run.

Loading…
Cancel
Save