Got the unit tests working again.
I made MaterialAsset::Finalize private so I could add some parameters specifically for MaterialAssetCreator to use. Now MaterialAssetCreator::Begin has an option to finalize the material or not. Moved MaterialAssetCreatorCommon::ValidateDataType to MaterialPropertyDescriptor as "ValidateMaterialPropertyDataType" so that MaterialAsset::Finalize could use it too Signed-off-by: santorac <55155825+santorac@users.noreply.github.com>
This commit is contained in:
@@ -114,13 +114,29 @@ namespace AZ
|
||||
return m_isFinalized;
|
||||
}
|
||||
|
||||
void MaterialAsset::Finalize()
|
||||
void MaterialAsset::Finalize(AZStd::function<void(const char*)> reportWarning, AZStd::function<void(const char*)> reportError)
|
||||
{
|
||||
if (IsFinalized())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!reportWarning)
|
||||
{
|
||||
reportWarning = [](const char* message)
|
||||
{
|
||||
AZ_Warning(s_debugTraceName, false, "%s", message);
|
||||
};
|
||||
}
|
||||
|
||||
if (!reportError)
|
||||
{
|
||||
reportError = [](const char* message)
|
||||
{
|
||||
AZ_Error(s_debugTraceName, false, "%s", message);
|
||||
};
|
||||
}
|
||||
|
||||
const uint32_t materialTypeVersion = m_materialTypeAsset->GetVersion();
|
||||
if (m_materialTypeVersion < materialTypeVersion)
|
||||
{
|
||||
@@ -147,7 +163,7 @@ namespace AZ
|
||||
uint32_t enumValue = propertyDescriptor->GetEnumValue(enumName);
|
||||
if (enumValue == MaterialPropertyDescriptor::InvalidEnumValue)
|
||||
{
|
||||
AZ_Error(s_debugTraceName, false, "Material property name \"%s\" has invalid enum value \"%s\".", name.GetCStr(), enumName.GetCStr());
|
||||
reportWarning(AZStd::string::format("Material property name \"%s\" has invalid enum value \"%s\".", name.GetCStr(), enumName.GetCStr()).c_str());
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -164,12 +180,15 @@ namespace AZ
|
||||
}
|
||||
else
|
||||
{
|
||||
finalizedPropertyValues[propertyIndex.GetIndex()] = value;
|
||||
if (ValidateMaterialPropertyDataType(value.GetTypeId(), name, propertyDescriptor, reportError))
|
||||
{
|
||||
finalizedPropertyValues[propertyIndex.GetIndex()] = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
AZ_Warning(s_debugTraceName, false, "Material property name \"%s\" is not found in the material properties layout and will not be used.", name.GetCStr());
|
||||
reportWarning(AZStd::string::format("Material property name \"%s\" is not found in the material properties layout and will not be used.", name.GetCStr()).c_str());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user