diff --git a/Gems/Atom/RPI/Code/Include/Atom/RPI.Edit/Material/MaterialSourceData.h b/Gems/Atom/RPI/Code/Include/Atom/RPI.Edit/Material/MaterialSourceData.h index 9557d51849..a8bf790ad8 100644 --- a/Gems/Atom/RPI/Code/Include/Atom/RPI.Edit/Material/MaterialSourceData.h +++ b/Gems/Atom/RPI/Code/Include/Atom/RPI.Edit/Material/MaterialSourceData.h @@ -64,10 +64,16 @@ namespace AZ PropertyGroupMap m_properties; + enum class ApplyVersionUpdatesResult + { + Failed, + NoUpdates, + UpdatesApplied + }; + //! Checks the material type version and potentially applies a series of property changes (most common are simple property renames) //! based on the MaterialTypeAsset's version update procedure. - //! @return true if any changes were applied - bool ApplyVersionUpdates(); + ApplyVersionUpdatesResult ApplyVersionUpdates(AZStd::string_view materialSourceFilePath); //! Creates a MaterialAsset from the MaterialSourceData content. //! @param assetId ID for the MaterialAsset diff --git a/Gems/Atom/RPI/Code/Source/RPI.Builders/Material/MaterialBuilder.cpp b/Gems/Atom/RPI/Code/Source/RPI.Builders/Material/MaterialBuilder.cpp index 0680c5c428..02fd11bdff 100644 --- a/Gems/Atom/RPI/Code/Source/RPI.Builders/Material/MaterialBuilder.cpp +++ b/Gems/Atom/RPI/Code/Source/RPI.Builders/Material/MaterialBuilder.cpp @@ -287,7 +287,7 @@ namespace AZ return {}; } - if (!material.GetValue().ApplyVersionUpdates()) + if (MaterialSourceData::ApplyVersionUpdatesResult::Failed == material.GetValue().ApplyVersionUpdates(materialSourceFilePath)) { return {}; } diff --git a/Gems/Atom/RPI/Code/Source/RPI.Edit/Material/MaterialSourceData.cpp b/Gems/Atom/RPI/Code/Source/RPI.Edit/Material/MaterialSourceData.cpp index c3a63fa883..9d44963942 100644 --- a/Gems/Atom/RPI/Code/Source/RPI.Edit/Material/MaterialSourceData.cpp +++ b/Gems/Atom/RPI/Code/Source/RPI.Edit/Material/MaterialSourceData.cpp @@ -73,19 +73,20 @@ namespace AZ } } - bool MaterialSourceData::ApplyVersionUpdates() + MaterialSourceData::ApplyVersionUpdatesResult MaterialSourceData::ApplyVersionUpdates(AZStd::string_view materialSourceFilePath) { - auto materialTypeSourceDataOutcome = MaterialUtils::LoadMaterialTypeSourceData(m_materialType); + AZStd::string materialTypeFullPath = AssetUtils::ResolvePathReference(materialSourceFilePath, m_materialType); + auto materialTypeSourceDataOutcome = MaterialUtils::LoadMaterialTypeSourceData(materialTypeFullPath); if (!materialTypeSourceDataOutcome.IsSuccess()) { - return false; + return ApplyVersionUpdatesResult::Failed; } MaterialTypeSourceData materialTypeSourceData = materialTypeSourceDataOutcome.TakeValue(); if (m_materialTypeVersion == materialTypeSourceData.m_version) { - return false; + return ApplyVersionUpdatesResult::NoUpdates; } bool changesWereApplied = false; @@ -125,7 +126,7 @@ namespace AZ m_materialTypeVersion = materialTypeSourceData.m_version; - return true; + return changesWereApplied ? ApplyVersionUpdatesResult::UpdatesApplied : ApplyVersionUpdatesResult::NoUpdates; } Outcome > MaterialSourceData::CreateMaterialAsset(Data::AssetId assetId, AZStd::string_view materialSourceFilePath, bool elevateWarnings, bool includeMaterialPropertyNames) const