Add material property names to material assets, disable FBX dependency on materialtype files. (#3408)
* Add material property names to material assets, disable FBX dependency on materialtype files. Signed-off-by: Robin <rbarrand@amazon.com> * Add reflection for MaterialAssets. Update member variable comment. Signed-off-by: Robin <rbarrand@amazon.com> * Switch cvar to using bus value. Refine comments. Signed-off-by: Robin <rbarrand@amazon.com> * Refactor functions and refine comments. Signed-off-by: Robin <rbarrand@amazon.com> * Realign property values when material property names are populated. Signed-off-by: Robin <rbarrand@amazon.com> * Switch PostLoadInit check to on asset status ready. Add realign property values code to PostLoadInit as well. Signed-off-by: Robin <rbarrand@amazon.com> * Stash@{1} code. Signed-off-by: Robin <rbarrand@amazon.com> * Refactor realignment code into the right places. Signed-off-by: Robin <rbarrand@amazon.com> * Remove pragma optmize off. Signed-off-by: Robin <rbarrand@amazon.com> * More refactoring. Signed-off-by: Robin <rbarrand@amazon.com> * Refactor comments and remove code no longer needed. Signed-off-by: Robin <rbarrand@amazon.com> * Refactor comments and remove unused include. Signed-off-by: Robin <rbarrand@amazon.com> * Comment refactor, corrected some code. Signed-off-by: Robin <rbarrand@amazon.com> Co-authored-by: Robin <rbarrand@amazon.com>
This commit is contained in:
@@ -16,7 +16,7 @@ namespace AZ
|
||||
{
|
||||
namespace RPI
|
||||
{
|
||||
void MaterialAssetCreator::Begin(const Data::AssetId& assetId, MaterialAsset& parentMaterial)
|
||||
void MaterialAssetCreator::Begin(const Data::AssetId& assetId, MaterialAsset& parentMaterial, bool includeMaterialPropertyNames)
|
||||
{
|
||||
BeginCommon(assetId);
|
||||
|
||||
@@ -36,6 +36,10 @@ namespace AZ
|
||||
ReportError("MaterialPropertiesLayout is null");
|
||||
return;
|
||||
}
|
||||
if (includeMaterialPropertyNames)
|
||||
{
|
||||
PopulatePropertyNameList();
|
||||
}
|
||||
|
||||
// Note we don't have to check the validity of these property values because the parent material's AssetCreator already did that.
|
||||
m_asset->m_propertyValues.assign(parentMaterial.GetPropertyValues().begin(), parentMaterial.GetPropertyValues().end());
|
||||
@@ -52,14 +56,14 @@ namespace AZ
|
||||
}
|
||||
}
|
||||
|
||||
void MaterialAssetCreator::Begin(const Data::AssetId& assetId, MaterialTypeAsset& materialType)
|
||||
void MaterialAssetCreator::Begin(const Data::AssetId& assetId, MaterialTypeAsset& materialType, bool includeMaterialPropertyNames)
|
||||
{
|
||||
BeginCommon(assetId);
|
||||
|
||||
if (ValidateIsReady())
|
||||
{
|
||||
m_asset->m_materialTypeAsset = { &materialType, AZ::Data::AssetLoadBehavior::PreLoad };
|
||||
|
||||
|
||||
if (!m_asset->m_materialTypeAsset)
|
||||
{
|
||||
ReportError("MaterialTypeAsset is null");
|
||||
@@ -67,6 +71,11 @@ namespace AZ
|
||||
}
|
||||
|
||||
m_materialPropertiesLayout = m_asset->GetMaterialPropertiesLayout();
|
||||
if (includeMaterialPropertyNames)
|
||||
{
|
||||
PopulatePropertyNameList();
|
||||
}
|
||||
|
||||
if (!m_materialPropertiesLayout)
|
||||
{
|
||||
ReportError("MaterialPropertiesLayout is null");
|
||||
@@ -101,5 +110,16 @@ namespace AZ
|
||||
m_asset->SetReady();
|
||||
return EndCommon(result);
|
||||
}
|
||||
|
||||
void MaterialAssetCreator::PopulatePropertyNameList()
|
||||
{
|
||||
for (int i = 0; i < m_materialPropertiesLayout->GetPropertyCount(); ++i)
|
||||
{
|
||||
MaterialPropertyIndex propertyIndex{ i };
|
||||
auto& propertyName = m_materialPropertiesLayout->GetPropertyDescriptor(propertyIndex)->GetName();
|
||||
m_asset->m_propertyNames.emplace_back(propertyName);
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace RPI
|
||||
} // namespace AZ
|
||||
|
||||
Reference in New Issue
Block a user