From b9ba9f5ca83f31687f6b3c94e092e8c49759fb8d Mon Sep 17 00:00:00 2001 From: santorac <55155825+santorac@users.noreply.github.com> Date: Thu, 20 Jan 2022 16:11:31 -0800 Subject: [PATCH] Got RPI unit tests building and passing again. Signed-off-by: santorac <55155825+santorac@users.noreply.github.com> --- .../RPI.Edit/Material/MaterialPropertyId.cpp | 4 +++- .../RPI.Edit/Material/MaterialSourceData.cpp | 6 +++--- .../Material/MaterialTypeSourceData.cpp | 17 +++++++++++------ .../Tests/Material/MaterialSourceDataTests.cpp | 2 +- 4 files changed, 18 insertions(+), 11 deletions(-) diff --git a/Gems/Atom/RPI/Code/Source/RPI.Edit/Material/MaterialPropertyId.cpp b/Gems/Atom/RPI/Code/Source/RPI.Edit/Material/MaterialPropertyId.cpp index 4880de33fe..d123fe33b7 100644 --- a/Gems/Atom/RPI/Code/Source/RPI.Edit/Material/MaterialPropertyId.cpp +++ b/Gems/Atom/RPI/Code/Source/RPI.Edit/Material/MaterialPropertyId.cpp @@ -99,7 +99,9 @@ namespace AZ } } - AzFramework::StringFunc::Join(m_fullName, names.begin(), names.end(), "."); + AZStd::string fullName; // m_fullName is a Name, not a string, so we have to join into a local variable temporarily. + AzFramework::StringFunc::Join(fullName, names.begin(), names.end(), "."); + m_fullName = fullName; } MaterialPropertyId::operator const Name&() const 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 b921b186c0..2fa4ff648e 100644 --- a/Gems/Atom/RPI/Code/Source/RPI.Edit/Material/MaterialSourceData.cpp +++ b/Gems/Atom/RPI/Code/Source/RPI.Edit/Material/MaterialSourceData.cpp @@ -340,16 +340,16 @@ namespace AZ if (result == MaterialUtils::GetImageAssetResult::Missing) { materialAssetCreator.ReportWarning( - "Material property '%s': Could not find the image '%s'", propertyId.GetFullName().GetCStr(), + "Material property '%s': Could not find the image '%s'", propertyId.GetCStr(), property.second.m_value.GetValue().data()); } imageAsset.SetAutoLoadBehavior(Data::AssetLoadBehavior::PreLoad); - materialAssetCreator.SetPropertyValue(propertyId.GetFullName(), imageAsset); + materialAssetCreator.SetPropertyValue(propertyId, imageAsset); } else { - materialAssetCreator.SetPropertyValue(propertyId.GetFullName(), property.second.m_value); + materialAssetCreator.SetPropertyValue(propertyId, property.second.m_value); } } } diff --git a/Gems/Atom/RPI/Code/Source/RPI.Edit/Material/MaterialTypeSourceData.cpp b/Gems/Atom/RPI/Code/Source/RPI.Edit/Material/MaterialTypeSourceData.cpp index ddc2bc842b..3a5992f8dd 100644 --- a/Gems/Atom/RPI/Code/Source/RPI.Edit/Material/MaterialTypeSourceData.cpp +++ b/Gems/Atom/RPI/Code/Source/RPI.Edit/Material/MaterialTypeSourceData.cpp @@ -140,7 +140,7 @@ namespace AZ { if (action.m_operation == "rename") { - if (action.m_renameFrom == propertyId.GetFullName().GetStringView()) + if (action.m_renameFrom == propertyId.GetStringView()) { propertyId = MaterialPropertyId::Parse(action.m_renameTo); renamed = true; @@ -177,14 +177,19 @@ namespace AZ // Do the search again with the new names - groupIter = m_propertyLayout.m_properties.find(propertyId.GetGroupName().GetStringView()); - if (groupIter != m_propertyLayout.m_properties.end()) + AZStd::vector tokens; + AZ::StringFunc::Tokenize(propertyId.GetStringView(), tokens, ".", true, true); + if (tokens.size() == 2) { - for (const PropertyDefinition& property : groupIter->second) + groupIter = m_propertyLayout.m_properties.find(tokens[0]); + if (groupIter != m_propertyLayout.m_properties.end()) { - if (property.m_name == propertyId.GetPropertyName().GetStringView()) + for (const PropertyDefinition& property : groupIter->second) { - return &property; + if (property.m_name == tokens[1]) + { + return &property; + } } } } diff --git a/Gems/Atom/RPI/Code/Tests/Material/MaterialSourceDataTests.cpp b/Gems/Atom/RPI/Code/Tests/Material/MaterialSourceDataTests.cpp index 5e09fe6612..94518c6aef 100644 --- a/Gems/Atom/RPI/Code/Tests/Material/MaterialSourceDataTests.cpp +++ b/Gems/Atom/RPI/Code/Tests/Material/MaterialSourceDataTests.cpp @@ -905,7 +905,7 @@ namespace UnitTest JsonTestResult loadResult = LoadTestDataFromJson(material, inputJson); auto materialAssetResult = material.CreateMaterialAsset(Uuid::CreateRandom(), "test.material", AZ::RPI::MaterialAssetProcessingMode::PreBake); EXPECT_TRUE(materialAssetResult); - MaterialPropertyIndex propertyIndex = materialAssetResult.GetValue()->GetMaterialPropertiesLayout()->FindPropertyIndex(MaterialPropertyId{groupName, propertyName}.GetFullName()); + MaterialPropertyIndex propertyIndex = materialAssetResult.GetValue()->GetMaterialPropertiesLayout()->FindPropertyIndex(MaterialPropertyId{groupName, propertyName}); CheckSimilar(expectedFinalValue, materialAssetResult.GetValue()->GetPropertyValues()[propertyIndex.GetIndex()].GetValue()); }