From e5729fbefe03287f6a968427b90e400d8a9e8697 Mon Sep 17 00:00:00 2001 From: Guthrie Adams Date: Wed, 27 Oct 2021 17:32:43 -0500 Subject: [PATCH] =?UTF-8?q?Fix=20clearing=20material=20component=20default?= =?UTF-8?q?=20material=20not=20clearing=20materials=20or=20updating=20prev?= =?UTF-8?q?iew=20=E2=80=A2=20Changed=20thumbnail=20property=20control=20to?= =?UTF-8?q?=20track=20asset=20key=20even=20if=20image=20is=20overridden=20?= =?UTF-8?q?so=20that=20it=20will=20be=20restored=20if=20the=20image=20is?= =?UTF-8?q?=20cleared.=20=E2=80=A2=20Changed=20property=20asset=20control?= =?UTF-8?q?=20to=20disable=20the=20thumbnail=20image=20by=20default=20when?= =?UTF-8?q?ever=20the=20attribute=20is=20applied.=20It=20will=20only=20ena?= =?UTF-8?q?ble=20the=20thumbnail=20image=20if=20the=20pixmap=20is=20valid.?= =?UTF-8?q?=20=E2=80=A2=20Changed=20the=20material=20component=20controlle?= =?UTF-8?q?r=20to=20always=20use=20an=20empty=20material=20assignment=20ma?= =?UTF-8?q?p=20on=20deactivation=20so=20that=20no=20persistent=20materials?= =?UTF-8?q?=20are=20reapplied.=20=E2=80=A2=20Changed=20the=20material=20co?= =?UTF-8?q?mponent=20controller=20to=20immediately=20send=20a=20notificati?= =?UTF-8?q?on=20that=20materials=20have=20updated=20if=20no=20materials=20?= =?UTF-8?q?were=20queued=20for=20load=20but=20the=20configuration=20contai?= =?UTF-8?q?ned=20pre=20created=20or=20persistent=20material=20instances.?= =?UTF-8?q?=20This=20mainly=20affects=20the=20material=20editor=20because?= =?UTF-8?q?=20it=20manages=20its=20own=20material=20instances.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Guthrie Adams --- .../UI/PropertyEditor/PropertyAssetCtrl.cpp | 14 +++++++++++--- .../UI/PropertyEditor/ThumbnailPropertyCtrl.cpp | 13 +++---------- .../Material/MaterialComponentController.cpp | 12 ++++++++++-- 3 files changed, 24 insertions(+), 15 deletions(-) diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/UI/PropertyEditor/PropertyAssetCtrl.cpp b/Code/Framework/AzToolsFramework/AzToolsFramework/UI/PropertyEditor/PropertyAssetCtrl.cpp index 7f3b9e61fd..24b2c7466e 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/UI/PropertyEditor/PropertyAssetCtrl.cpp +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/UI/PropertyEditor/PropertyAssetCtrl.cpp @@ -1387,7 +1387,10 @@ namespace AzToolsFramework QDataStream stream(&pixmapBytes, QIODevice::ReadOnly); QPixmap pixmap; stream >> pixmap; - GUI->SetBrowseButtonIcon(pixmap); + if (!pixmap.isNull()) + { + GUI->SetBrowseButtonIcon(pixmap); + } } } } @@ -1417,6 +1420,8 @@ namespace AzToolsFramework } else if (attrib == AZ_CRC_CE("ThumbnailIcon")) { + GUI->SetCustomThumbnailEnabled(false); + AZStd::string iconPath; if (attrValue->Read(iconPath) && !iconPath.empty()) { @@ -1434,8 +1439,11 @@ namespace AzToolsFramework QDataStream stream(&pixmapBytes, QIODevice::ReadOnly); QPixmap pixmap; stream >> pixmap; - GUI->SetCustomThumbnailEnabled(true); - GUI->SetCustomThumbnailPixmap(pixmap); + if (!pixmap.isNull()) + { + GUI->SetCustomThumbnailEnabled(true); + GUI->SetCustomThumbnailPixmap(pixmap); + } } } } diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/UI/PropertyEditor/ThumbnailPropertyCtrl.cpp b/Code/Framework/AzToolsFramework/AzToolsFramework/UI/PropertyEditor/ThumbnailPropertyCtrl.cpp index d8ddee6b76..0bbb898196 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/UI/PropertyEditor/ThumbnailPropertyCtrl.cpp +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/UI/PropertyEditor/ThumbnailPropertyCtrl.cpp @@ -67,16 +67,9 @@ namespace AzToolsFramework void ThumbnailPropertyCtrl::SetThumbnailKey(Thumbnailer::SharedThumbnailKey key, const char* contextName) { - if (m_customThumbnailEnabled) - { - ClearThumbnail(); - } - else - { - m_key = key; - m_thumbnail->SetThumbnailKey(m_key, contextName); - m_thumbnailEnlarged->SetThumbnailKey(m_key, contextName); - } + m_key = key; + m_thumbnail->SetThumbnailKey(m_key, contextName); + m_thumbnailEnlarged->SetThumbnailKey(m_key, contextName); UpdateVisibility(); } diff --git a/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Material/MaterialComponentController.cpp b/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Material/MaterialComponentController.cpp index 07082a87d5..ed6904b4ef 100644 --- a/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Material/MaterialComponentController.cpp +++ b/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Material/MaterialComponentController.cpp @@ -121,8 +121,13 @@ namespace AZ MaterialComponentRequestBus::Handler::BusDisconnect(); MaterialReceiverNotificationBus::Handler::BusDisconnect(); TickBus::Handler::BusDisconnect(); + ReleaseMaterials(); + // Sending notification to wipe any previously assigned material overrides + MaterialComponentNotificationBus::Event( + m_entityId, &MaterialComponentNotifications::OnMaterialsUpdated, MaterialAssignmentMap()); + m_queuedMaterialUpdateNotification = false; m_entityId = AZ::EntityId(AZ::EntityId::InvalidEntityId); } @@ -221,6 +226,11 @@ namespace AZ if (!anyQueued) { ReleaseMaterials(); + + // If no other materials were loaded, the notification must still be sent in case there are externally managed material + // instances in the configuration + MaterialComponentNotificationBus::Event( + m_entityId, &MaterialComponentNotifications::OnMaterialsUpdated, m_configuration.m_materials); } } @@ -268,8 +278,6 @@ namespace AZ { materialPair.second.Release(); } - - MaterialComponentNotificationBus::Event(m_entityId, &MaterialComponentNotifications::OnMaterialsUpdated, m_configuration.m_materials); } MaterialAssignmentMap MaterialComponentController::GetOriginalMaterialAssignments() const