From 65e375bb422017a01fb5d94c883ee493ad917ded Mon Sep 17 00:00:00 2001 From: mrieggeramzn Date: Thu, 30 Sep 2021 13:44:06 -0700 Subject: [PATCH] Guthries excellent recommendation Signed-off-by: mrieggeramzn --- .../DecalTextureArrayFeatureProcessor.cpp | 4 +++- .../Source/Decals/EditorDecalComponent.cpp | 18 +----------------- .../Code/Source/Decals/EditorDecalComponent.h | 6 ------ 3 files changed, 4 insertions(+), 24 deletions(-) diff --git a/Gems/Atom/Feature/Common/Code/Source/Decals/DecalTextureArrayFeatureProcessor.cpp b/Gems/Atom/Feature/Common/Code/Source/Decals/DecalTextureArrayFeatureProcessor.cpp index c0b8f3315a..3975df52b9 100644 --- a/Gems/Atom/Feature/Common/Code/Source/Decals/DecalTextureArrayFeatureProcessor.cpp +++ b/Gems/Atom/Feature/Common/Code/Source/Decals/DecalTextureArrayFeatureProcessor.cpp @@ -303,7 +303,9 @@ namespace AZ if (material.IsValid()) { - AZ_Assert(m_decalData.GetData(handle.GetIndex()).m_textureArrayIndex == DecalData::UnusedIndex, "Setting Material on a decal more than once is not currently supported."); + AZ_Assert( + m_decalData.GetData(handle.GetIndex()).m_textureArrayIndex == DecalData::UnusedIndex || GetMaterialUsedByDecal(handle) == material, + "Setting Material on a decal more than once is not currently supported."); const auto iter = m_materialToTextureArrayLookupTable.find(material); if (iter != m_materialToTextureArrayLookupTable.end()) diff --git a/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Decals/EditorDecalComponent.cpp b/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Decals/EditorDecalComponent.cpp index 02a2e1c0c9..f8865e8d34 100644 --- a/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Decals/EditorDecalComponent.cpp +++ b/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Decals/EditorDecalComponent.cpp @@ -15,11 +15,6 @@ namespace AZ { namespace Render { - static AZ::Data::Asset QueueLoad(const AZ::Data::AssetId id) - { - return AZ::Data::AssetManager::Instance().GetAsset(id, AZ::Data::AssetLoadBehavior::QueueLoad); - } - EditorDecalComponent::EditorDecalComponent(const DecalComponentConfig& config) : BaseClass(config) { @@ -92,26 +87,16 @@ namespace AZ AzFramework::EntityDebugDisplayEventBus::Handler::BusConnect(GetEntityId()); AzToolsFramework::EditorComponentSelectionRequestsBus::Handler::BusConnect(GetEntityId()); AzFramework::BoundsRequestBus::Handler::BusConnect(GetEntityId()); - CacheMaterial(); } void EditorDecalComponent::Deactivate() { - m_cachedMaterial = {}; AzFramework::BoundsRequestBus::Handler::BusDisconnect(); AzToolsFramework::EditorComponentSelectionRequestsBus::Handler::BusDisconnect(); AzFramework::EntityDebugDisplayEventBus::Handler::BusDisconnect(); BaseClass::Deactivate(); } - void EditorDecalComponent::CacheMaterial() - { - DecalComponentConfig decalComponentConfig; - GetConfiguration(decalComponentConfig); - const auto& materialAsset = decalComponentConfig.m_materialAsset; - m_cachedMaterial = QueueLoad(materialAsset.GetId()); - } - AZ::Transform EditorDecalComponent::GetWorldTransform() const { AZ::Transform transform = AZ::Transform::CreateIdentity(); @@ -207,8 +192,7 @@ namespace AZ u32 EditorDecalComponent::OnConfigurationChanged() { - BaseClass::OnConfigurationChanged(); - CacheMaterial(); + m_controller.ConfigurationChanged(); return Edit::PropertyRefreshLevels::AttributesAndValues; } diff --git a/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Decals/EditorDecalComponent.h b/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Decals/EditorDecalComponent.h index 1a3d8f3844..1ca88d23fc 100644 --- a/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Decals/EditorDecalComponent.h +++ b/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Decals/EditorDecalComponent.h @@ -64,12 +64,6 @@ namespace AZ //! EditorRenderComponentAdapter overrides ... u32 OnConfigurationChanged() override; - - // Hold onto the material for the lifespan of the EditorDecalComponent to smooth out performance. This is so we can avoid - // duplicate loads as the DecalTextureArrayFeatureProcessor will unload the materials after texture packing. - void CacheMaterial(); - - AZ::Data::Asset m_cachedMaterial; }; } // namespace Render } // namespace AZ