diff --git a/Gems/Atom/Feature/Common/Code/Source/Material/MaterialConverterSystemComponent.cpp b/Gems/Atom/Feature/Common/Code/Source/Material/MaterialConverterSystemComponent.cpp index d5096d7a0b..835aa90ceb 100644 --- a/Gems/Atom/Feature/Common/Code/Source/Material/MaterialConverterSystemComponent.cpp +++ b/Gems/Atom/Feature/Common/Code/Source/Material/MaterialConverterSystemComponent.cpp @@ -101,7 +101,7 @@ namespace AZ if (assetFound) { - properties["textureMap"].m_value = texturePath; + properties["textureMap"] = texturePath; } else if (!texturePath.empty()) { @@ -120,7 +120,7 @@ namespace AZ { anyPBRInUse = true; handleTexture("baseColor", SceneAPI::DataTypes::IMaterialData::TextureMapType::BaseColor); - sourceData.m_properties["baseColor"]["textureBlendMode"].m_value = AZStd::string("Lerp"); + sourceData.m_properties["baseColor"]["textureBlendMode"] = AZStd::string("Lerp"); } else { @@ -135,10 +135,10 @@ namespace AZ if (baseColor.has_value()) { anyPBRInUse = true; - sourceData.m_properties["baseColor"]["color"].m_value = toColor(baseColor.value()); + sourceData.m_properties["baseColor"]["color"] = toColor(baseColor.value()); } - sourceData.m_properties["opacity"]["factor"].m_value = materialData.GetOpacity(); + sourceData.m_properties["opacity"]["factor"] = materialData.GetOpacity(); auto applyOptionalPropertiesFunc = [&sourceData, &anyPBRInUse](const auto& propertyGroup, const auto& propertyName, const auto& propertyOptional) { @@ -147,7 +147,7 @@ namespace AZ if (propertyOptional.has_value()) { anyPBRInUse = true; - sourceData.m_properties[propertyGroup][propertyName].m_value = propertyOptional.value(); + sourceData.m_properties[propertyGroup][propertyName] = propertyOptional.value(); } }; @@ -160,7 +160,7 @@ namespace AZ applyOptionalPropertiesFunc("roughness", "useTexture", materialData.GetUseRoughnessMap()); handleTexture("emissive", SceneAPI::DataTypes::IMaterialData::TextureMapType::Emissive); - sourceData.m_properties["emissive"]["color"].m_value = toColor(materialData.GetEmissiveColor()); + sourceData.m_properties["emissive"]["color"] = toColor(materialData.GetEmissiveColor()); applyOptionalPropertiesFunc("emissive", "intensity", materialData.GetEmissiveIntensity()); applyOptionalPropertiesFunc("emissive", "useTexture", materialData.GetUseEmissiveMap()); @@ -171,7 +171,7 @@ namespace AZ { // If it doesn't have the useColorMap property, then it's a non-PBR material and the baseColor // texture needs to be set to the diffuse color. - sourceData.m_properties["baseColor"]["color"].m_value = toColor(materialData.GetDiffuseColor()); + sourceData.m_properties["baseColor"]["color"] = toColor(materialData.GetDiffuseColor()); } return true; } 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 0a9371f722..8b782fe66c 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 @@ -59,14 +59,7 @@ namespace AZ uint32_t m_materialTypeVersion = 0; //!< The version of the material type that was used to configure this material - struct Property - { - AZ_TYPE_INFO(AZ::RPI::MaterialSourceData::Property, "{8D613464-3750-4122-AFFE-9238010D5AFC}"); - - MaterialPropertyValue m_value; - }; - - using PropertyMap = AZStd::map; + using PropertyMap = AZStd::map; using PropertyGroupMap = AZStd::map; PropertyGroupMap m_properties; diff --git a/Gems/Atom/RPI/Code/Source/RPI.Edit/Material/MaterialPropertyValueSerializer.cpp b/Gems/Atom/RPI/Code/Source/RPI.Edit/Material/MaterialPropertyValueSerializer.cpp index cb345e1d93..07d8c919d0 100644 --- a/Gems/Atom/RPI/Code/Source/RPI.Edit/Material/MaterialPropertyValueSerializer.cpp +++ b/Gems/Atom/RPI/Code/Source/RPI.Edit/Material/MaterialPropertyValueSerializer.cpp @@ -47,61 +47,61 @@ namespace AZ { namespace JSR = JsonSerializationResult; - AZ_Assert(azrtti_typeid() == outputValueTypeId, + AZ_Assert(azrtti_typeid() == outputValueTypeId, "Unable to deserialize material property value to json because the provided type is %s", outputValueTypeId.ToString().c_str()); AZ_UNUSED(outputValueTypeId); - MaterialSourceData::Property* property = reinterpret_cast(outputValue); + MaterialPropertyValue* property = reinterpret_cast(outputValue); AZ_Assert(property, "Output value for JsonMaterialPropertyValueSerializer can't be null."); JSR::ResultCode result(JSR::Tasks::ReadField); if (inputValue.IsBool()) { - result.Combine(LoadVariant(property->m_value, false, inputValue, context)); + result.Combine(LoadVariant(*property, false, inputValue, context)); } else if (inputValue.IsInt() || inputValue.IsInt64()) { - result.Combine(LoadVariant(property->m_value, 0, inputValue, context)); + result.Combine(LoadVariant(*property, 0, inputValue, context)); } else if (inputValue.IsUint() || inputValue.IsUint64()) { - result.Combine(LoadVariant(property->m_value, 0u, inputValue, context)); + result.Combine(LoadVariant(*property, 0u, inputValue, context)); } else if (inputValue.IsFloat() || inputValue.IsDouble()) { - result.Combine(LoadVariant(property->m_value, 0.0f, inputValue, context)); + result.Combine(LoadVariant(*property, 0.0f, inputValue, context)); } else if (inputValue.IsArray() && inputValue.Size() == 4) { - result.Combine(LoadVariant(property->m_value, Vector4{0.0f, 0.0f, 0.0f, 0.0f}, inputValue, context)); + result.Combine(LoadVariant(*property, Vector4{0.0f, 0.0f, 0.0f, 0.0f}, inputValue, context)); } else if (inputValue.IsArray() && inputValue.Size() == 3) { - result.Combine(LoadVariant(property->m_value, Vector3{0.0f, 0.0f, 0.0f}, inputValue, context)); + result.Combine(LoadVariant(*property, Vector3{0.0f, 0.0f, 0.0f}, inputValue, context)); } else if (inputValue.IsArray() && inputValue.Size() == 2) { - result.Combine(LoadVariant(property->m_value, Vector2{0.0f, 0.0f}, inputValue, context)); + result.Combine(LoadVariant(*property, Vector2{0.0f, 0.0f}, inputValue, context)); } else if (inputValue.IsObject()) { - JsonSerializationResult::ResultCode resultCode = LoadVariant(property->m_value, Color::CreateZero(), inputValue, context); + JsonSerializationResult::ResultCode resultCode = LoadVariant(*property, Color::CreateZero(), inputValue, context); if(resultCode.GetProcessing() != JsonSerializationResult::Processing::Completed) { - resultCode = LoadVariant(property->m_value, Vector4::CreateZero(), inputValue, context); + resultCode = LoadVariant(*property, Vector4::CreateZero(), inputValue, context); } if(resultCode.GetProcessing() != JsonSerializationResult::Processing::Completed) { - resultCode = LoadVariant(property->m_value, Vector3::CreateZero(), inputValue, context); + resultCode = LoadVariant(*property, Vector3::CreateZero(), inputValue, context); } if(resultCode.GetProcessing() != JsonSerializationResult::Processing::Completed) { - resultCode = LoadVariant(property->m_value, Vector2::CreateZero(), inputValue, context); + resultCode = LoadVariant(*property, Vector2::CreateZero(), inputValue, context); } if(resultCode.GetProcessing() == JsonSerializationResult::Processing::Completed) @@ -115,7 +115,7 @@ namespace AZ } else if (inputValue.IsString()) { - result.Combine(LoadVariant(property->m_value, AZStd::string{}, inputValue, context)); + result.Combine(LoadVariant(*property, AZStd::string{}, inputValue, context)); } else { @@ -137,51 +137,51 @@ namespace AZ { namespace JSR = JsonSerializationResult; - AZ_Assert(azrtti_typeid() == valueTypeId, + AZ_Assert(azrtti_typeid() == valueTypeId, "Unable to serialize material property value to json because the provided type is %s", valueTypeId.ToString().c_str()); AZ_UNUSED(valueTypeId); - const MaterialSourceData::Property* property = reinterpret_cast(inputValue); + const MaterialPropertyValue* property = reinterpret_cast(inputValue); AZ_Assert(property, "Input value for JsonMaterialPropertyValueSerializer can't be null."); JSR::ResultCode result(JSR::Tasks::WriteValue); - if (property->m_value.Is()) + if (property->Is()) { - result.Combine(ContinueStoring(outputValue, &property->m_value.GetValue(), nullptr, azrtti_typeid(), context)); + result.Combine(ContinueStoring(outputValue, &property->GetValue(), nullptr, azrtti_typeid(), context)); } - else if (property->m_value.Is()) + else if (property->Is()) { - result.Combine(ContinueStoring(outputValue, &property->m_value.GetValue(), nullptr, azrtti_typeid(), context)); + result.Combine(ContinueStoring(outputValue, &property->GetValue(), nullptr, azrtti_typeid(), context)); } - else if (property->m_value.Is()) + else if (property->Is()) { - result.Combine(ContinueStoring(outputValue, &property->m_value.GetValue(), nullptr, azrtti_typeid(), context)); + result.Combine(ContinueStoring(outputValue, &property->GetValue(), nullptr, azrtti_typeid(), context)); } - else if (property->m_value.Is()) + else if (property->Is()) { - result.Combine(ContinueStoring(outputValue, &property->m_value.GetValue(), nullptr, azrtti_typeid(), context)); + result.Combine(ContinueStoring(outputValue, &property->GetValue(), nullptr, azrtti_typeid(), context)); } - else if (property->m_value.Is()) + else if (property->Is()) { - result.Combine(ContinueStoring(outputValue, &property->m_value.GetValue(), nullptr, azrtti_typeid(), context)); + result.Combine(ContinueStoring(outputValue, &property->GetValue(), nullptr, azrtti_typeid(), context)); } - else if (property->m_value.Is()) + else if (property->Is()) { - result.Combine(ContinueStoring(outputValue, &property->m_value.GetValue(), nullptr, azrtti_typeid(), context)); + result.Combine(ContinueStoring(outputValue, &property->GetValue(), nullptr, azrtti_typeid(), context)); } - else if (property->m_value.Is()) + else if (property->Is()) { - result.Combine(ContinueStoring(outputValue, &property->m_value.GetValue(), nullptr, azrtti_typeid(), context)); + result.Combine(ContinueStoring(outputValue, &property->GetValue(), nullptr, azrtti_typeid(), context)); } - else if (property->m_value.Is()) + else if (property->Is()) { - result.Combine(ContinueStoring(outputValue, &property->m_value.GetValue(), nullptr, azrtti_typeid(), context)); + result.Combine(ContinueStoring(outputValue, &property->GetValue(), nullptr, azrtti_typeid(), context)); } - else if (property->m_value.Is()) + else if (property->Is()) { - result.Combine(ContinueStoring(outputValue, &property->m_value.GetValue(), nullptr, azrtti_typeid(), context)); + result.Combine(ContinueStoring(outputValue, &property->GetValue(), nullptr, azrtti_typeid(), context)); } if (result.GetProcessing() == JsonSerializationResult::Processing::Completed) 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 ae7889aa93..c2b80e726b 100644 --- a/Gems/Atom/RPI/Code/Source/RPI.Edit/Material/MaterialSourceData.cpp +++ b/Gems/Atom/RPI/Code/Source/RPI.Edit/Material/MaterialSourceData.cpp @@ -44,7 +44,7 @@ namespace AZ { if (JsonRegistrationContext* jsonContext = azrtti_cast(context)) { - jsonContext->Serializer()->HandlesType(); + jsonContext->Serializer()->HandlesType(); } else if (auto* serializeContext = azrtti_cast(context)) { @@ -59,10 +59,6 @@ namespace AZ serializeContext->RegisterGenericType(); serializeContext->RegisterGenericType(); - - serializeContext->Class() - ->Version(1) - ; } } @@ -323,25 +319,25 @@ namespace AZ for (auto& property : group.second) { MaterialPropertyId propertyId{ group.first, property.first }; - if (!property.second.m_value.IsValid()) + if (!property.second.IsValid()) { materialAssetCreator.ReportWarning("Source data for material property value is invalid."); } // If the source value type is a string, there are two possible property types: Image and Enum. If there is a "." in // the string (for the extension) we assume it's an Image and look up the referenced Asset. Otherwise, we can assume // it's an Enum value and just preserve the original string. - else if (property.second.m_value.Is() && AzFramework::StringFunc::Contains(property.second.m_value.GetValue(), ".")) + else if (property.second.Is() && AzFramework::StringFunc::Contains(property.second.GetValue(), ".")) { Data::Asset imageAsset; MaterialUtils::GetImageAssetResult result = MaterialUtils::GetImageAssetReference( - imageAsset, materialSourceFilePath, property.second.m_value.GetValue()); + imageAsset, materialSourceFilePath, property.second.GetValue()); if (result == MaterialUtils::GetImageAssetResult::Missing) { materialAssetCreator.ReportWarning( "Material property '%s': Could not find the image '%s'", propertyId.GetCStr(), - property.second.m_value.GetValue().data()); + property.second.GetValue().data()); } imageAsset.SetAutoLoadBehavior(Data::AssetLoadBehavior::PreLoad); @@ -349,7 +345,7 @@ namespace AZ } else { - materialAssetCreator.SetPropertyValue(propertyId, property.second.m_value); + materialAssetCreator.SetPropertyValue(propertyId, property.second); } } } diff --git a/Gems/Atom/RPI/Code/Tests/Material/MaterialSourceDataTests.cpp b/Gems/Atom/RPI/Code/Tests/Material/MaterialSourceDataTests.cpp index 2bd257d55b..2ac363058c 100644 --- a/Gems/Atom/RPI/Code/Tests/Material/MaterialSourceDataTests.cpp +++ b/Gems/Atom/RPI/Code/Tests/Material/MaterialSourceDataTests.cpp @@ -160,7 +160,7 @@ namespace UnitTest void AddProperty(MaterialSourceData& material, AZStd::string_view groupName, AZStd::string_view propertyName, const MaterialPropertyValue& anyValue) { - material.m_properties[groupName][propertyName].m_value = anyValue; + material.m_properties[groupName][propertyName] = anyValue; } TEST_F(MaterialSourceDataTests, CreateMaterialAsset_BasicProperties) @@ -398,33 +398,33 @@ namespace UnitTest // We allow some types like Vector4 and Color or Int and UInt to be interchangeable since they serialize the same and can be converted when the MaterialAsset is finalized. - if (AreTypesCompatible(propertyA.m_value, propertyB.m_value)) + if (AreTypesCompatible(propertyA, propertyB)) { - EXPECT_EQ(propertyA.m_value.GetValue(), propertyB.m_value.GetValue()) << propertyReference.c_str(); + EXPECT_EQ(propertyA.GetValue(), propertyB.GetValue()) << propertyReference.c_str(); } - else if (AreTypesCompatible(propertyA.m_value, propertyB.m_value)) + else if (AreTypesCompatible(propertyA, propertyB)) { - EXPECT_EQ(GetAsInt(propertyA.m_value), GetAsInt(propertyB.m_value)) << propertyReference.c_str(); + EXPECT_EQ(GetAsInt(propertyA), GetAsInt(propertyB)) << propertyReference.c_str(); } - else if (AreTypesCompatible(propertyA.m_value, propertyB.m_value)) + else if (AreTypesCompatible(propertyA, propertyB)) { - EXPECT_NEAR(propertyA.m_value.GetValue(), propertyB.m_value.GetValue(), 0.01) << propertyReference.c_str(); + EXPECT_NEAR(propertyA.GetValue(), propertyB.GetValue(), 0.01) << propertyReference.c_str(); } - else if (AreTypesCompatible(propertyA.m_value, propertyB.m_value)) + else if (AreTypesCompatible(propertyA, propertyB)) { - EXPECT_TRUE(propertyA.m_value.GetValue().IsClose(propertyB.m_value.GetValue())) << propertyReference.c_str(); + EXPECT_TRUE(propertyA.GetValue().IsClose(propertyB.GetValue())) << propertyReference.c_str(); } - else if (AreTypesCompatible(propertyA.m_value, propertyB.m_value)) + else if (AreTypesCompatible(propertyA, propertyB)) { - EXPECT_TRUE(propertyA.m_value.GetValue().IsClose(propertyB.m_value.GetValue())) << propertyReference.c_str(); + EXPECT_TRUE(propertyA.GetValue().IsClose(propertyB.GetValue())) << propertyReference.c_str(); } - else if (AreTypesCompatible(propertyA.m_value, propertyB.m_value)) + else if (AreTypesCompatible(propertyA, propertyB)) { - EXPECT_TRUE(GetAsVector4(propertyA.m_value).IsClose(GetAsVector4(propertyB.m_value))) << propertyReference.c_str(); + EXPECT_TRUE(GetAsVector4(propertyA).IsClose(GetAsVector4(propertyB))) << propertyReference.c_str(); } - else if (AreTypesCompatible(propertyA.m_value, propertyB.m_value)) + else if (AreTypesCompatible(propertyA, propertyB)) { - EXPECT_STREQ(propertyA.m_value.GetValue().c_str(), propertyB.m_value.GetValue().c_str()) << propertyReference.c_str(); + EXPECT_STREQ(propertyA.GetValue().c_str(), propertyB.GetValue().c_str()) << propertyReference.c_str(); } else { @@ -513,7 +513,7 @@ namespace UnitTest EXPECT_EQ(AZ::JsonSerializationResult::Tasks::ReadField, loadResult.m_jsonResultCode.GetTask()); EXPECT_EQ(AZ::JsonSerializationResult::Processing::Completed, loadResult.m_jsonResultCode.GetProcessing()); - float testValue = material.m_properties["general"]["testValue"].m_value.GetValue(); + float testValue = material.m_properties["general"]["testValue"].GetValue(); EXPECT_FLOAT_EQ(1.2f, testValue); } diff --git a/Gems/Atom/Tools/MaterialEditor/Code/Source/Document/MaterialDocument.cpp b/Gems/Atom/Tools/MaterialEditor/Code/Source/Document/MaterialDocument.cpp index 283b7a8a7f..28de56c75e 100644 --- a/Gems/Atom/Tools/MaterialEditor/Code/Source/Document/MaterialDocument.cpp +++ b/Gems/Atom/Tools/MaterialEditor/Code/Source/Document/MaterialDocument.cpp @@ -363,7 +363,7 @@ namespace MaterialEditor // TODO: Support populating the Material Editor with nested property groups, not just the top level. const AZStd::string groupName = propertyId.GetStringView().substr(0, propertyId.GetStringView().size() - propertyDefinition->GetName().size() - 1); - sourceData.m_properties[groupName][propertyDefinition->GetName()].m_value = propertyValue; + sourceData.m_properties[groupName][propertyDefinition->GetName()] = propertyValue; } } return true; diff --git a/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Material/EditorMaterialComponentUtil.cpp b/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Material/EditorMaterialComponentUtil.cpp index dde9644c50..1e5e25fa30 100644 --- a/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Material/EditorMaterialComponentUtil.cpp +++ b/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Material/EditorMaterialComponentUtil.cpp @@ -150,7 +150,7 @@ namespace AZ // TODO: Support populating the Material Editor with nested property groups, not just the top level. const AZStd::string groupName = propertyId.GetStringView().substr(0, propertyId.GetStringView().size() - propertyDefinition->GetName().size() - 1); - exportData.m_properties[groupName][propertyDefinition->GetName()].m_value = propertyValue; + exportData.m_properties[groupName][propertyDefinition->GetName()] = propertyValue; return true; });