Switched back to making MaterialAsset::GetPropertyValues automatically finalize the material asset. I realized that it's too burdensome to expect client code to call Finalize on the MaterialAsset; every code that calls GetPropertyValues would have to call Finalize(). Instead of using const_cast in GetPropertyValues like I was doing before, I just changed GetPropertyValues to be a non-const function. There were a few places in Decal code I had to update to pass non-const MaterialAsset pointers. This isn't ideal, but I think it's better than the alternatives.
Signed-off-by: santorac <55155825+santorac@users.noreply.github.com>
This commit is contained in:
@@ -25,7 +25,7 @@ namespace AZ
|
||||
{
|
||||
namespace
|
||||
{
|
||||
static AZ::RHI::Size GetTextureSizeFromMaterialAsset(const AZ::RPI::MaterialAsset* materialAsset)
|
||||
static AZ::RHI::Size GetTextureSizeFromMaterialAsset(AZ::RPI::MaterialAsset* materialAsset)
|
||||
{
|
||||
for (const auto& elem : materialAsset->GetPropertyValues())
|
||||
{
|
||||
@@ -375,7 +375,7 @@ namespace AZ
|
||||
}
|
||||
}
|
||||
|
||||
AZStd::optional<AZ::Render::DecalTextureArrayFeatureProcessor::DecalLocation> DecalTextureArrayFeatureProcessor::AddMaterialToTextureArrays(const AZ::RPI::MaterialAsset* materialAsset)
|
||||
AZStd::optional<AZ::Render::DecalTextureArrayFeatureProcessor::DecalLocation> DecalTextureArrayFeatureProcessor::AddMaterialToTextureArrays(AZ::RPI::MaterialAsset* materialAsset)
|
||||
{
|
||||
const RHI::Size textureSize = GetTextureSizeFromMaterialAsset(materialAsset);
|
||||
|
||||
@@ -410,7 +410,7 @@ namespace AZ
|
||||
AZ_PROFILE_SCOPE(AzRender, "DecalTextureArrayFeatureProcessor: OnAssetReady");
|
||||
const Data::AssetId& assetId = asset->GetId();
|
||||
|
||||
const RPI::MaterialAsset* materialAsset = asset.GetAs<AZ::RPI::MaterialAsset>();
|
||||
RPI::MaterialAsset* materialAsset = asset.GetAs<AZ::RPI::MaterialAsset>();
|
||||
const bool validDecalMaterial = materialAsset && DecalTextureArray::IsValidDecalMaterial(*materialAsset);
|
||||
if (validDecalMaterial)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user