Combined common thumbnail classes
Signed-off-by: Guthrie Adams <guthadam@amazon.com>
This commit is contained in:
+5
-25
@@ -6,9 +6,6 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include <EditorCommonFeaturesSystemComponent.h>
|
||||
#include <SkinnedMesh/SkinnedMeshDebugDisplay.h>
|
||||
|
||||
#include <AzCore/Serialization/EditContext.h>
|
||||
#include <AzCore/Serialization/EditContextConstants.inl>
|
||||
#include <AzCore/Serialization/SerializeContext.h>
|
||||
@@ -17,10 +14,9 @@
|
||||
#include <AzToolsFramework/API/EditorCameraBus.h>
|
||||
#include <AzToolsFramework/API/ToolsApplicationAPI.h>
|
||||
#include <AzToolsFramework/Thumbnails/ThumbnailContext.h>
|
||||
|
||||
#include <Previewer/MaterialThumbnail.h>
|
||||
#include <Previewer/ModelThumbnail.h>
|
||||
#include <Previewer/LightingPresetThumbnail.h>
|
||||
#include <EditorCommonFeaturesSystemComponent.h>
|
||||
#include <Previewer/CommonThumbnail.h>
|
||||
#include <SkinnedMesh/SkinnedMeshDebugDisplay.h>
|
||||
|
||||
#include <IEditor.h>
|
||||
|
||||
@@ -220,15 +216,7 @@ namespace AZ
|
||||
using namespace LyIntegration;
|
||||
|
||||
ThumbnailerRequestsBus::Broadcast(
|
||||
&ThumbnailerRequests::RegisterThumbnailProvider, MAKE_TCACHE(Thumbnails::MaterialThumbnailCache),
|
||||
ThumbnailContext::DefaultContext);
|
||||
|
||||
ThumbnailerRequestsBus::Broadcast(
|
||||
&ThumbnailerRequests::RegisterThumbnailProvider, MAKE_TCACHE(Thumbnails::ModelThumbnailCache),
|
||||
ThumbnailContext::DefaultContext);
|
||||
|
||||
ThumbnailerRequestsBus::Broadcast(
|
||||
&ThumbnailerRequests::RegisterThumbnailProvider, MAKE_TCACHE(Thumbnails::LightingPresetThumbnailCache),
|
||||
&ThumbnailerRequests::RegisterThumbnailProvider, MAKE_TCACHE(Thumbnails::CommonThumbnailCache),
|
||||
ThumbnailContext::DefaultContext);
|
||||
|
||||
m_renderer = AZStd::make_unique<AZ::LyIntegration::Thumbnails::CommonThumbnailRenderer>();
|
||||
@@ -241,15 +229,7 @@ namespace AZ
|
||||
using namespace LyIntegration;
|
||||
|
||||
ThumbnailerRequestsBus::Broadcast(
|
||||
&ThumbnailerRequests::UnregisterThumbnailProvider, Thumbnails::MaterialThumbnailCache::ProviderName,
|
||||
ThumbnailContext::DefaultContext);
|
||||
|
||||
ThumbnailerRequestsBus::Broadcast(
|
||||
&ThumbnailerRequests::UnregisterThumbnailProvider, Thumbnails::ModelThumbnailCache::ProviderName,
|
||||
ThumbnailContext::DefaultContext);
|
||||
|
||||
ThumbnailerRequestsBus::Broadcast(
|
||||
&ThumbnailerRequests::UnregisterThumbnailProvider, Thumbnails::LightingPresetThumbnailCache::ProviderName,
|
||||
&ThumbnailerRequests::UnregisterThumbnailProvider, Thumbnails::CommonThumbnailCache::ProviderName,
|
||||
ThumbnailContext::DefaultContext);
|
||||
|
||||
m_renderer.reset();
|
||||
|
||||
@@ -13,15 +13,15 @@
|
||||
#include <AzToolsFramework/Thumbnails/Thumbnail.h>
|
||||
#include <AzToolsFramework/Thumbnails/ThumbnailContext.h>
|
||||
#include <Previewer/CommonPreviewer.h>
|
||||
#include <Previewer/ThumbnailUtils.h>
|
||||
#include <Previewer/CommonThumbnailUtils.h>
|
||||
|
||||
// Disables warning messages triggered by the Qt library
|
||||
// 4251: class needs to have dll-interface to be used by clients of class
|
||||
// 4251: class needs to have dll-interface to be used by clients of class
|
||||
// 4800: forcing value to bool 'true' or 'false' (performance warning)
|
||||
AZ_PUSH_DISABLE_WARNING(4251 4800, "-Wunknown-warning-option")
|
||||
#include <Previewer/ui_CommonPreviewer.h>
|
||||
#include <QString>
|
||||
#include <QResizeEvent>
|
||||
#include <QString>
|
||||
AZ_POP_DISABLE_WARNING
|
||||
|
||||
namespace AZ
|
||||
@@ -41,6 +41,10 @@ namespace AZ
|
||||
{
|
||||
}
|
||||
|
||||
void CommonPreviewer::Clear() const
|
||||
{
|
||||
}
|
||||
|
||||
void CommonPreviewer::Display(const AzToolsFramework::AssetBrowser::AssetBrowserEntry* entry)
|
||||
{
|
||||
using namespace AzToolsFramework::AssetBrowser;
|
||||
|
||||
@@ -5,16 +5,17 @@
|
||||
* SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#if !defined(Q_MOC_RUN)
|
||||
#include <AzCore/Memory/SystemAllocator.h>
|
||||
#include <AzCore/Asset/AssetCommon.h>
|
||||
#include <AzCore/Memory/SystemAllocator.h>
|
||||
#include <AzToolsFramework/AssetBrowser/Previewer/Previewer.h>
|
||||
|
||||
AZ_PUSH_DISABLE_WARNING(4251 4800, "-Wunknown-warning-option") // disable warnings spawned by QT
|
||||
#include <QWidget>
|
||||
#include <QScopedPointer>
|
||||
#include <QWidget>
|
||||
AZ_POP_DISABLE_WARNING
|
||||
#endif
|
||||
|
||||
@@ -30,8 +31,8 @@ namespace AzToolsFramework
|
||||
class ProductAssetBrowserEntry;
|
||||
class SourceAssetBrowserEntry;
|
||||
class AssetBrowserEntry;
|
||||
}
|
||||
}
|
||||
} // namespace AssetBrowser
|
||||
} // namespace AzToolsFramework
|
||||
|
||||
class QResizeEvent;
|
||||
|
||||
@@ -39,8 +40,7 @@ namespace AZ
|
||||
{
|
||||
namespace LyIntegration
|
||||
{
|
||||
class CommonPreviewer final
|
||||
: public AzToolsFramework::AssetBrowser::Previewer
|
||||
class CommonPreviewer final : public AzToolsFramework::AssetBrowser::Previewer
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
@@ -50,7 +50,7 @@ namespace AZ
|
||||
~CommonPreviewer();
|
||||
|
||||
// AzToolsFramework::AssetBrowser::Previewer overrides...
|
||||
void Clear() const override {}
|
||||
void Clear() const override;
|
||||
void Display(const AzToolsFramework::AssetBrowser::AssetBrowserEntry* entry) override;
|
||||
const QString& GetName() const override;
|
||||
|
||||
|
||||
+2
-23
@@ -13,7 +13,7 @@
|
||||
#include <AzToolsFramework/AssetBrowser/AssetBrowserEntry.h>
|
||||
#include <Previewer/CommonPreviewer.h>
|
||||
#include <Previewer/CommonPreviewerFactory.h>
|
||||
#include <Previewer/ThumbnailUtils.h>
|
||||
#include <Previewer/CommonThumbnailUtils.h>
|
||||
|
||||
namespace AZ
|
||||
{
|
||||
@@ -26,28 +26,7 @@ namespace AZ
|
||||
|
||||
bool CommonPreviewerFactory::IsEntrySupported(const AzToolsFramework::AssetBrowser::AssetBrowserEntry* entry) const
|
||||
{
|
||||
AZ::Data::AssetId assetId = Thumbnails::GetAssetId(entry->GetThumbnailKey(), RPI::ModelAsset::RTTI_Type());
|
||||
if (assetId.IsValid())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
assetId = Thumbnails::GetAssetId(entry->GetThumbnailKey(), RPI::MaterialAsset::RTTI_Type());
|
||||
if (assetId.IsValid())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
assetId = Thumbnails::GetAssetId(entry->GetThumbnailKey(), RPI::AnyAsset::RTTI_Type());
|
||||
if (assetId.IsValid())
|
||||
{
|
||||
AZ::Data::AssetInfo assetInfo;
|
||||
AZ::Data::AssetCatalogRequestBus::BroadcastResult(
|
||||
assetInfo, &AZ::Data::AssetCatalogRequestBus::Events::GetAssetInfoById, assetId);
|
||||
return AzFramework::StringFunc::EndsWith(assetInfo.m_relativePath.c_str(), "lightingpreset.azasset");
|
||||
}
|
||||
|
||||
return false;
|
||||
return Thumbnails::IsSupportedThumbnail(entry->GetThumbnailKey());
|
||||
}
|
||||
|
||||
const QString& CommonPreviewerFactory::GetName() const
|
||||
|
||||
+2
-2
@@ -5,6 +5,7 @@
|
||||
* SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <AzCore/Memory/SystemAllocator.h>
|
||||
@@ -18,8 +19,7 @@ namespace AZ
|
||||
{
|
||||
namespace LyIntegration
|
||||
{
|
||||
class CommonPreviewerFactory final
|
||||
: public AzToolsFramework::AssetBrowser::PreviewerFactory
|
||||
class CommonPreviewerFactory final : public AzToolsFramework::AssetBrowser::PreviewerFactory
|
||||
{
|
||||
public:
|
||||
AZ_CLASS_ALLOCATOR(CommonPreviewerFactory, AZ::SystemAllocator, 0);
|
||||
|
||||
@@ -0,0 +1,113 @@
|
||||
/*
|
||||
* Copyright (c) Contributors to the Open 3D Engine Project.
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include <Atom/RPI.Reflect/Material/MaterialAsset.h>
|
||||
#include <Atom/RPI.Reflect/Model/ModelAsset.h>
|
||||
#include <Atom/RPI.Reflect/System/AnyAsset.h>
|
||||
#include <AzToolsFramework/API/EditorAssetSystemAPI.h>
|
||||
#include <Previewer/CommonThumbnail.h>
|
||||
#include <Previewer/CommonThumbnailUtils.h>
|
||||
#include <QtConcurrent/QtConcurrent>
|
||||
|
||||
namespace AZ
|
||||
{
|
||||
namespace LyIntegration
|
||||
{
|
||||
namespace Thumbnails
|
||||
{
|
||||
static constexpr const int CommonThumbnailSize = 256;
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// CommonThumbnail
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
CommonThumbnail::CommonThumbnail(AzToolsFramework::Thumbnailer::SharedThumbnailKey key)
|
||||
: Thumbnail(key)
|
||||
{
|
||||
for (const AZ::Uuid& typeId : GetSupportedThumbnailAssetTypes())
|
||||
{
|
||||
const AZ::Data::AssetId& assetId = GetAssetId(key, typeId);
|
||||
if (assetId.IsValid())
|
||||
{
|
||||
m_assetId = assetId;
|
||||
m_typeId = typeId;
|
||||
AzToolsFramework::Thumbnailer::ThumbnailerRendererNotificationBus::Handler::BusConnect(key);
|
||||
AzFramework::AssetCatalogEventBus::Handler::BusConnect();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
AZ_Error("CommonThumbnail", false, "Failed to find matching assetId for the thumbnailKey.");
|
||||
m_state = State::Failed;
|
||||
}
|
||||
|
||||
void CommonThumbnail::LoadThread()
|
||||
{
|
||||
AzToolsFramework::Thumbnailer::ThumbnailerRendererRequestBus::QueueEvent(
|
||||
m_typeId, &AzToolsFramework::Thumbnailer::ThumbnailerRendererRequests::RenderThumbnail, m_key,
|
||||
CommonThumbnailSize);
|
||||
// wait for response from thumbnail renderer
|
||||
m_renderWait.acquire();
|
||||
}
|
||||
|
||||
CommonThumbnail::~CommonThumbnail()
|
||||
{
|
||||
AzToolsFramework::Thumbnailer::ThumbnailerRendererNotificationBus::Handler::BusDisconnect();
|
||||
AzFramework::AssetCatalogEventBus::Handler::BusDisconnect();
|
||||
}
|
||||
|
||||
void CommonThumbnail::ThumbnailRendered(const QPixmap& thumbnailImage)
|
||||
{
|
||||
m_pixmap = thumbnailImage;
|
||||
m_renderWait.release();
|
||||
}
|
||||
|
||||
void CommonThumbnail::ThumbnailFailedToRender()
|
||||
{
|
||||
m_state = State::Failed;
|
||||
m_renderWait.release();
|
||||
}
|
||||
|
||||
void CommonThumbnail::OnCatalogAssetChanged([[maybe_unused]] const AZ::Data::AssetId& assetId)
|
||||
{
|
||||
if (m_assetId == assetId && m_state == State::Ready)
|
||||
{
|
||||
m_state = State::Unloaded;
|
||||
Load();
|
||||
}
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// CommonThumbnailCache
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
CommonThumbnailCache::CommonThumbnailCache()
|
||||
: ThumbnailCache<CommonThumbnail>()
|
||||
{
|
||||
}
|
||||
|
||||
CommonThumbnailCache::~CommonThumbnailCache() = default;
|
||||
|
||||
int CommonThumbnailCache::GetPriority() const
|
||||
{
|
||||
// Thumbnails override default source thumbnails, so carry higher priority
|
||||
return 1;
|
||||
}
|
||||
|
||||
const char* CommonThumbnailCache::GetProviderName() const
|
||||
{
|
||||
return ProviderName;
|
||||
}
|
||||
|
||||
bool CommonThumbnailCache::IsSupportedThumbnail(AzToolsFramework::Thumbnailer::SharedThumbnailKey key) const
|
||||
{
|
||||
return Thumbnails::IsSupportedThumbnail(key);
|
||||
}
|
||||
} // namespace Thumbnails
|
||||
} // namespace LyIntegration
|
||||
} // namespace AZ
|
||||
|
||||
#include <Previewer/moc_CommonThumbnail.cpp>
|
||||
+8
-7
@@ -22,15 +22,15 @@ namespace AZ
|
||||
namespace Thumbnails
|
||||
{
|
||||
//! Custom thumbnail that detects when an asset changes and updates the thumbnail
|
||||
class ModelThumbnail
|
||||
class CommonThumbnail
|
||||
: public AzToolsFramework::Thumbnailer::Thumbnail
|
||||
, public AzToolsFramework::Thumbnailer::ThumbnailerRendererNotificationBus::Handler
|
||||
, private AzFramework::AssetCatalogEventBus::Handler
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
ModelThumbnail(AzToolsFramework::Thumbnailer::SharedThumbnailKey key);
|
||||
~ModelThumbnail() override;
|
||||
CommonThumbnail(AzToolsFramework::Thumbnailer::SharedThumbnailKey key);
|
||||
~CommonThumbnail() override;
|
||||
|
||||
//! AzToolsFramework::ThumbnailerRendererNotificationBus::Handler overrides...
|
||||
void ThumbnailRendered(const QPixmap& thumbnailImage) override;
|
||||
@@ -45,19 +45,20 @@ namespace AZ
|
||||
|
||||
AZStd::binary_semaphore m_renderWait;
|
||||
Data::AssetId m_assetId;
|
||||
AZ::Uuid m_typeId;
|
||||
};
|
||||
|
||||
//! Cache configuration for large thumbnails
|
||||
class ModelThumbnailCache : public AzToolsFramework::Thumbnailer::ThumbnailCache<ModelThumbnail>
|
||||
class CommonThumbnailCache : public AzToolsFramework::Thumbnailer::ThumbnailCache<CommonThumbnail>
|
||||
{
|
||||
public:
|
||||
ModelThumbnailCache();
|
||||
~ModelThumbnailCache() override;
|
||||
CommonThumbnailCache();
|
||||
~CommonThumbnailCache() override;
|
||||
|
||||
int GetPriority() const override;
|
||||
const char* GetProviderName() const override;
|
||||
|
||||
static constexpr const char* ProviderName = "Model Thumbnails";
|
||||
static constexpr const char* ProviderName = "Common Thumbnails";
|
||||
|
||||
protected:
|
||||
bool IsSupportedThumbnail(AzToolsFramework::Thumbnailer::SharedThumbnailKey key) const override;
|
||||
+5
-5
@@ -10,7 +10,7 @@
|
||||
#include <AzToolsFramework/Thumbnails/ThumbnailerBus.h>
|
||||
#include <Previewer/CommonPreviewContent.h>
|
||||
#include <Previewer/CommonThumbnailRenderer.h>
|
||||
#include <Previewer/ThumbnailUtils.h>
|
||||
#include <Previewer/CommonThumbnailUtils.h>
|
||||
|
||||
namespace AZ
|
||||
{
|
||||
@@ -27,10 +27,10 @@ namespace AZ
|
||||
m_defaultMaterialAsset.Create(DefaultMaterialAssetId, true);
|
||||
m_defaultLightingPresetAsset.Create(DefaultLightingPresetAssetId, true);
|
||||
|
||||
// CommonThumbnailRenderer supports both models and materials
|
||||
AzToolsFramework::Thumbnailer::ThumbnailerRendererRequestBus::MultiHandler::BusConnect(RPI::MaterialAsset::RTTI_Type());
|
||||
AzToolsFramework::Thumbnailer::ThumbnailerRendererRequestBus::MultiHandler::BusConnect(RPI::ModelAsset::RTTI_Type());
|
||||
AzToolsFramework::Thumbnailer::ThumbnailerRendererRequestBus::MultiHandler::BusConnect(RPI::AnyAsset::RTTI_Type());
|
||||
for (const AZ::Uuid& typeId : GetSupportedThumbnailAssetTypes())
|
||||
{
|
||||
AzToolsFramework::Thumbnailer::ThumbnailerRendererRequestBus::MultiHandler::BusConnect(typeId);
|
||||
}
|
||||
SystemTickBus::Handler::BusConnect();
|
||||
}
|
||||
|
||||
|
||||
+33
-4
@@ -9,9 +9,10 @@
|
||||
#include <API/EditorAssetSystemAPI.h>
|
||||
#include <AssetBrowser/Thumbnails/ProductThumbnail.h>
|
||||
#include <AssetBrowser/Thumbnails/SourceThumbnail.h>
|
||||
#include <Previewer/CommonThumbnailUtils.h>
|
||||
#include <Atom/RPI.Reflect/Material/MaterialAsset.h>
|
||||
#include <Atom/RPI.Reflect/Model/ModelAsset.h>
|
||||
#include <Previewer/ThumbnailUtils.h>
|
||||
#include <Atom/RPI.Reflect/System/AnyAsset.h>
|
||||
|
||||
namespace AZ
|
||||
{
|
||||
@@ -30,12 +31,15 @@ namespace AZ
|
||||
{
|
||||
bool foundIt = false;
|
||||
AZStd::vector<Data::AssetInfo> productsAssetInfo;
|
||||
AzToolsFramework::AssetSystemRequestBus::BroadcastResult(foundIt, &AzToolsFramework::AssetSystemRequestBus::Events::GetAssetsProducedBySourceUUID, sourceKey->GetSourceUuid(), productsAssetInfo);
|
||||
AzToolsFramework::AssetSystemRequestBus::BroadcastResult(
|
||||
foundIt, &AzToolsFramework::AssetSystemRequestBus::Events::GetAssetsProducedBySourceUUID,
|
||||
sourceKey->GetSourceUuid(), productsAssetInfo);
|
||||
if (!foundIt)
|
||||
{
|
||||
return defaultAssetId;
|
||||
}
|
||||
auto assetInfoIt = AZStd::find_if(productsAssetInfo.begin(), productsAssetInfo.end(),
|
||||
auto assetInfoIt = AZStd::find_if(
|
||||
productsAssetInfo.begin(), productsAssetInfo.end(),
|
||||
[&assetType](const Data::AssetInfo& assetInfo)
|
||||
{
|
||||
return assetInfo.m_assetType == assetType;
|
||||
@@ -57,7 +61,6 @@ namespace AZ
|
||||
return defaultAssetId;
|
||||
}
|
||||
|
||||
|
||||
QString WordWrap(const QString& string, int maxLength)
|
||||
{
|
||||
QString result;
|
||||
@@ -82,6 +85,32 @@ namespace AZ
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
AZStd::unordered_set<AZ::Uuid> GetSupportedThumbnailAssetTypes()
|
||||
{
|
||||
return { RPI::AnyAsset::RTTI_Type(), RPI::MaterialAsset::RTTI_Type(), RPI::ModelAsset::RTTI_Type() };
|
||||
}
|
||||
|
||||
bool IsSupportedThumbnail(AzToolsFramework::Thumbnailer::SharedThumbnailKey key)
|
||||
{
|
||||
for (const AZ::Uuid& typeId : GetSupportedThumbnailAssetTypes())
|
||||
{
|
||||
const AZ::Data::AssetId& assetId = GetAssetId(key, typeId);
|
||||
if (assetId.IsValid())
|
||||
{
|
||||
if (typeId == RPI::AnyAsset::RTTI_Type())
|
||||
{
|
||||
AZ::Data::AssetInfo assetInfo;
|
||||
AZ::Data::AssetCatalogRequestBus::BroadcastResult(
|
||||
assetInfo, &AZ::Data::AssetCatalogRequestBus::Events::GetAssetInfoById, assetId);
|
||||
return AzFramework::StringFunc::EndsWith(assetInfo.m_relativePath.c_str(), "lightingpreset.azasset");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
} // namespace Thumbnails
|
||||
} // namespace LyIntegration
|
||||
} // namespace AZ
|
||||
+6
-1
@@ -26,8 +26,13 @@ namespace AZ
|
||||
const Data::AssetType& assetType,
|
||||
const Data::AssetId& defaultAssetId = {});
|
||||
|
||||
//! Word wrap function for previewer QLabel, since by default it does not break long words such as filenames, so manual word wrap needed
|
||||
//! Word wrap function for previewer QLabel, since by default it does not break long words such as filenames, so manual word
|
||||
//! wrap needed
|
||||
QString WordWrap(const QString& string, int maxLength);
|
||||
|
||||
AZStd::unordered_set<AZ::Uuid> GetSupportedThumbnailAssetTypes();
|
||||
|
||||
bool IsSupportedThumbnail(AzToolsFramework::Thumbnailer::SharedThumbnailKey key);
|
||||
} // namespace Thumbnails
|
||||
} // namespace LyIntegration
|
||||
} // namespace AZ
|
||||
-115
@@ -1,115 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) Contributors to the Open 3D Engine Project.
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include <Atom/RPI.Reflect/System/AnyAsset.h>
|
||||
#include <AzToolsFramework/API/EditorAssetSystemAPI.h>
|
||||
#include <QtConcurrent/QtConcurrent>
|
||||
#include <Previewer/LightingPresetThumbnail.h>
|
||||
#include <Previewer/ThumbnailUtils.h>
|
||||
|
||||
namespace AZ
|
||||
{
|
||||
namespace LyIntegration
|
||||
{
|
||||
namespace Thumbnails
|
||||
{
|
||||
static constexpr const int LightingPresetThumbnailSize = 512; // 512 is the default size in render to texture pass
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// LightingPresetThumbnail
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
LightingPresetThumbnail::LightingPresetThumbnail(AzToolsFramework::Thumbnailer::SharedThumbnailKey key)
|
||||
: Thumbnail(key)
|
||||
{
|
||||
m_assetId = GetAssetId(key, RPI::AnyAsset::RTTI_Type());
|
||||
if (!m_assetId.IsValid())
|
||||
{
|
||||
AZ_Error("LightingPresetThumbnail", false, "Failed to find matching assetId for the thumbnailKey.");
|
||||
m_state = State::Failed;
|
||||
return;
|
||||
}
|
||||
|
||||
AzToolsFramework::Thumbnailer::ThumbnailerRendererNotificationBus::Handler::BusConnect(key);
|
||||
AzFramework::AssetCatalogEventBus::Handler::BusConnect();
|
||||
}
|
||||
|
||||
void LightingPresetThumbnail::LoadThread()
|
||||
{
|
||||
AzToolsFramework::Thumbnailer::ThumbnailerRendererRequestBus::QueueEvent(
|
||||
RPI::AnyAsset::RTTI_Type(), &AzToolsFramework::Thumbnailer::ThumbnailerRendererRequests::RenderThumbnail, m_key,
|
||||
LightingPresetThumbnailSize);
|
||||
// wait for response from thumbnail renderer
|
||||
m_renderWait.acquire();
|
||||
}
|
||||
|
||||
LightingPresetThumbnail::~LightingPresetThumbnail()
|
||||
{
|
||||
AzToolsFramework::Thumbnailer::ThumbnailerRendererNotificationBus::Handler::BusDisconnect();
|
||||
AzFramework::AssetCatalogEventBus::Handler::BusDisconnect();
|
||||
}
|
||||
|
||||
void LightingPresetThumbnail::ThumbnailRendered(const QPixmap& thumbnailImage)
|
||||
{
|
||||
m_pixmap = thumbnailImage;
|
||||
m_renderWait.release();
|
||||
}
|
||||
|
||||
void LightingPresetThumbnail::ThumbnailFailedToRender()
|
||||
{
|
||||
m_state = State::Failed;
|
||||
m_renderWait.release();
|
||||
}
|
||||
|
||||
void LightingPresetThumbnail::OnCatalogAssetChanged([[maybe_unused]] const AZ::Data::AssetId& assetId)
|
||||
{
|
||||
if (m_assetId == assetId && m_state == State::Ready)
|
||||
{
|
||||
m_state = State::Unloaded;
|
||||
Load();
|
||||
}
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// LightingPresetThumbnailCache
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
LightingPresetThumbnailCache::LightingPresetThumbnailCache()
|
||||
: ThumbnailCache<LightingPresetThumbnail>()
|
||||
{
|
||||
}
|
||||
|
||||
LightingPresetThumbnailCache::~LightingPresetThumbnailCache() = default;
|
||||
|
||||
int LightingPresetThumbnailCache::GetPriority() const
|
||||
{
|
||||
// Thumbnails override default source thumbnails, so carry higher priority
|
||||
return 1;
|
||||
}
|
||||
|
||||
const char* LightingPresetThumbnailCache::GetProviderName() const
|
||||
{
|
||||
return ProviderName;
|
||||
}
|
||||
|
||||
bool LightingPresetThumbnailCache::IsSupportedThumbnail(AzToolsFramework::Thumbnailer::SharedThumbnailKey key) const
|
||||
{
|
||||
const auto assetId = Thumbnails::GetAssetId(key, RPI::AnyAsset::RTTI_Type());
|
||||
if (assetId.IsValid())
|
||||
{
|
||||
AZ::Data::AssetInfo assetInfo;
|
||||
AZ::Data::AssetCatalogRequestBus::BroadcastResult(
|
||||
assetInfo, &AZ::Data::AssetCatalogRequestBus::Events::GetAssetInfoById, assetId);
|
||||
return AzFramework::StringFunc::EndsWith(assetInfo.m_relativePath.c_str(), "lightingpreset.azasset");
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
} // namespace Thumbnails
|
||||
} // namespace LyIntegration
|
||||
} // namespace AZ
|
||||
|
||||
#include <Previewer/moc_LightingPresetThumbnail.cpp>
|
||||
@@ -1,67 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) Contributors to the Open 3D Engine Project.
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#if !defined(Q_MOC_RUN)
|
||||
#include <AzCore/std/parallel/binary_semaphore.h>
|
||||
#include <AzFramework/Asset/AssetCatalogBus.h>
|
||||
#include <AzToolsFramework/Thumbnails/Thumbnail.h>
|
||||
#include <AzToolsFramework/Thumbnails/ThumbnailerBus.h>
|
||||
#endif
|
||||
|
||||
namespace AZ
|
||||
{
|
||||
namespace LyIntegration
|
||||
{
|
||||
namespace Thumbnails
|
||||
{
|
||||
//! Custom thumbnail that detects when an asset changes and updates the thumbnail
|
||||
class LightingPresetThumbnail
|
||||
: public AzToolsFramework::Thumbnailer::Thumbnail
|
||||
, public AzToolsFramework::Thumbnailer::ThumbnailerRendererNotificationBus::Handler
|
||||
, private AzFramework::AssetCatalogEventBus::Handler
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
LightingPresetThumbnail(AzToolsFramework::Thumbnailer::SharedThumbnailKey key);
|
||||
~LightingPresetThumbnail() override;
|
||||
|
||||
//! AzToolsFramework::ThumbnailerRendererNotificationBus::Handler overrides...
|
||||
void ThumbnailRendered(const QPixmap& thumbnailImage) override;
|
||||
void ThumbnailFailedToRender() override;
|
||||
|
||||
protected:
|
||||
void LoadThread() override;
|
||||
|
||||
private:
|
||||
// AzFramework::AssetCatalogEventBus::Handler interface overrides...
|
||||
void OnCatalogAssetChanged(const AZ::Data::AssetId& assetId) override;
|
||||
|
||||
AZStd::binary_semaphore m_renderWait;
|
||||
Data::AssetId m_assetId;
|
||||
};
|
||||
|
||||
//! Cache configuration for large thumbnails
|
||||
class LightingPresetThumbnailCache : public AzToolsFramework::Thumbnailer::ThumbnailCache<LightingPresetThumbnail>
|
||||
{
|
||||
public:
|
||||
LightingPresetThumbnailCache();
|
||||
~LightingPresetThumbnailCache() override;
|
||||
|
||||
int GetPriority() const override;
|
||||
const char* GetProviderName() const override;
|
||||
|
||||
static constexpr const char* ProviderName = "LightingPreset Thumbnails";
|
||||
|
||||
protected:
|
||||
bool IsSupportedThumbnail(AzToolsFramework::Thumbnailer::SharedThumbnailKey key) const override;
|
||||
};
|
||||
} // namespace Thumbnails
|
||||
} // namespace LyIntegration
|
||||
} // namespace AZ
|
||||
@@ -1,106 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) Contributors to the Open 3D Engine Project.
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include <Atom/RPI.Reflect/Material/MaterialAsset.h>
|
||||
#include <AzToolsFramework/API/EditorAssetSystemAPI.h>
|
||||
#include <QtConcurrent/QtConcurrent>
|
||||
#include <Previewer/MaterialThumbnail.h>
|
||||
#include <Previewer/ThumbnailUtils.h>
|
||||
|
||||
namespace AZ
|
||||
{
|
||||
namespace LyIntegration
|
||||
{
|
||||
namespace Thumbnails
|
||||
{
|
||||
static constexpr const int MaterialThumbnailSize = 512; // 512 is the default size in render to texture pass
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// MaterialThumbnail
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
MaterialThumbnail::MaterialThumbnail(AzToolsFramework::Thumbnailer::SharedThumbnailKey key)
|
||||
: Thumbnail(key)
|
||||
{
|
||||
m_assetId = GetAssetId(key, RPI::MaterialAsset::RTTI_Type());
|
||||
if (!m_assetId.IsValid())
|
||||
{
|
||||
AZ_Error("MaterialThumbnail", false, "Failed to find matching assetId for the thumbnailKey.");
|
||||
m_state = State::Failed;
|
||||
return;
|
||||
}
|
||||
|
||||
AzToolsFramework::Thumbnailer::ThumbnailerRendererNotificationBus::Handler::BusConnect(key);
|
||||
AzFramework::AssetCatalogEventBus::Handler::BusConnect();
|
||||
}
|
||||
|
||||
void MaterialThumbnail::LoadThread()
|
||||
{
|
||||
AzToolsFramework::Thumbnailer::ThumbnailerRendererRequestBus::QueueEvent(
|
||||
RPI::MaterialAsset::RTTI_Type(), &AzToolsFramework::Thumbnailer::ThumbnailerRendererRequests::RenderThumbnail, m_key,
|
||||
MaterialThumbnailSize);
|
||||
// wait for response from thumbnail renderer
|
||||
m_renderWait.acquire();
|
||||
}
|
||||
|
||||
MaterialThumbnail::~MaterialThumbnail()
|
||||
{
|
||||
AzToolsFramework::Thumbnailer::ThumbnailerRendererNotificationBus::Handler::BusDisconnect();
|
||||
AzFramework::AssetCatalogEventBus::Handler::BusDisconnect();
|
||||
}
|
||||
|
||||
void MaterialThumbnail::ThumbnailRendered(const QPixmap& thumbnailImage)
|
||||
{
|
||||
m_pixmap = thumbnailImage;
|
||||
m_renderWait.release();
|
||||
}
|
||||
|
||||
void MaterialThumbnail::ThumbnailFailedToRender()
|
||||
{
|
||||
m_state = State::Failed;
|
||||
m_renderWait.release();
|
||||
}
|
||||
|
||||
void MaterialThumbnail::OnCatalogAssetChanged([[maybe_unused]] const AZ::Data::AssetId& assetId)
|
||||
{
|
||||
if (m_assetId == assetId && m_state == State::Ready)
|
||||
{
|
||||
m_state = State::Unloaded;
|
||||
Load();
|
||||
}
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// MaterialThumbnailCache
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
MaterialThumbnailCache::MaterialThumbnailCache()
|
||||
: ThumbnailCache<MaterialThumbnail>()
|
||||
{
|
||||
}
|
||||
|
||||
MaterialThumbnailCache::~MaterialThumbnailCache() = default;
|
||||
|
||||
int MaterialThumbnailCache::GetPriority() const
|
||||
{
|
||||
// Thumbnails override default source thumbnails, so carry higher priority
|
||||
return 1;
|
||||
}
|
||||
|
||||
const char* MaterialThumbnailCache::GetProviderName() const
|
||||
{
|
||||
return ProviderName;
|
||||
}
|
||||
|
||||
bool MaterialThumbnailCache::IsSupportedThumbnail(AzToolsFramework::Thumbnailer::SharedThumbnailKey key) const
|
||||
{
|
||||
return GetAssetId(key, RPI::MaterialAsset::RTTI_Type()).IsValid();
|
||||
}
|
||||
} // namespace Thumbnails
|
||||
} // namespace LyIntegration
|
||||
} // namespace AZ
|
||||
|
||||
#include <Previewer/moc_MaterialThumbnail.cpp>
|
||||
@@ -1,67 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) Contributors to the Open 3D Engine Project.
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#if !defined(Q_MOC_RUN)
|
||||
#include <AzCore/std/parallel/binary_semaphore.h>
|
||||
#include <AzFramework/Asset/AssetCatalogBus.h>
|
||||
#include <AzToolsFramework/Thumbnails/Thumbnail.h>
|
||||
#include <AzToolsFramework/Thumbnails/ThumbnailerBus.h>
|
||||
#endif
|
||||
|
||||
namespace AZ
|
||||
{
|
||||
namespace LyIntegration
|
||||
{
|
||||
namespace Thumbnails
|
||||
{
|
||||
//! Custom thumbnail that detects when an asset changes and updates the thumbnail
|
||||
class MaterialThumbnail
|
||||
: public AzToolsFramework::Thumbnailer::Thumbnail
|
||||
, public AzToolsFramework::Thumbnailer::ThumbnailerRendererNotificationBus::Handler
|
||||
, private AzFramework::AssetCatalogEventBus::Handler
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
MaterialThumbnail(AzToolsFramework::Thumbnailer::SharedThumbnailKey key);
|
||||
~MaterialThumbnail() override;
|
||||
|
||||
//! AzToolsFramework::ThumbnailerRendererNotificationBus::Handler overrides...
|
||||
void ThumbnailRendered(const QPixmap& thumbnailImage) override;
|
||||
void ThumbnailFailedToRender() override;
|
||||
|
||||
protected:
|
||||
void LoadThread() override;
|
||||
|
||||
private:
|
||||
// AzFramework::AssetCatalogEventBus::Handler interface overrides...
|
||||
void OnCatalogAssetChanged(const AZ::Data::AssetId& assetId) override;
|
||||
|
||||
AZStd::binary_semaphore m_renderWait;
|
||||
Data::AssetId m_assetId;
|
||||
};
|
||||
|
||||
//! Cache configuration for large thumbnails
|
||||
class MaterialThumbnailCache : public AzToolsFramework::Thumbnailer::ThumbnailCache<MaterialThumbnail>
|
||||
{
|
||||
public:
|
||||
MaterialThumbnailCache();
|
||||
~MaterialThumbnailCache() override;
|
||||
|
||||
int GetPriority() const override;
|
||||
const char* GetProviderName() const override;
|
||||
|
||||
static constexpr const char* ProviderName = "Material Thumbnails";
|
||||
|
||||
protected:
|
||||
bool IsSupportedThumbnail(AzToolsFramework::Thumbnailer::SharedThumbnailKey key) const override;
|
||||
};
|
||||
} // namespace Thumbnails
|
||||
} // namespace LyIntegration
|
||||
} // namespace AZ
|
||||
@@ -1,106 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) Contributors to the Open 3D Engine Project.
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include <Atom/RPI.Reflect/Model/ModelAsset.h>
|
||||
#include <AzToolsFramework/API/EditorAssetSystemAPI.h>
|
||||
#include <QtConcurrent/QtConcurrent>
|
||||
#include <Previewer/ModelThumbnail.h>
|
||||
#include <Previewer/ThumbnailUtils.h>
|
||||
|
||||
namespace AZ
|
||||
{
|
||||
namespace LyIntegration
|
||||
{
|
||||
namespace Thumbnails
|
||||
{
|
||||
static constexpr const int ModelThumbnailSize = 512; // 512 is the default size in render to texture pass
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// ModelThumbnail
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
ModelThumbnail::ModelThumbnail(AzToolsFramework::Thumbnailer::SharedThumbnailKey key)
|
||||
: Thumbnail(key)
|
||||
{
|
||||
m_assetId = GetAssetId(key, RPI::ModelAsset::RTTI_Type());
|
||||
if (!m_assetId.IsValid())
|
||||
{
|
||||
AZ_Error("ModelThumbnail", false, "Failed to find matching assetId for the thumbnailKey.");
|
||||
m_state = State::Failed;
|
||||
return;
|
||||
}
|
||||
|
||||
AzToolsFramework::Thumbnailer::ThumbnailerRendererNotificationBus::Handler::BusConnect(key);
|
||||
AzFramework::AssetCatalogEventBus::Handler::BusConnect();
|
||||
}
|
||||
|
||||
void ModelThumbnail::LoadThread()
|
||||
{
|
||||
AzToolsFramework::Thumbnailer::ThumbnailerRendererRequestBus::QueueEvent(
|
||||
RPI::ModelAsset::RTTI_Type(), &AzToolsFramework::Thumbnailer::ThumbnailerRendererRequests::RenderThumbnail, m_key,
|
||||
ModelThumbnailSize);
|
||||
// wait for response from thumbnail renderer
|
||||
m_renderWait.acquire();
|
||||
}
|
||||
|
||||
ModelThumbnail::~ModelThumbnail()
|
||||
{
|
||||
AzToolsFramework::Thumbnailer::ThumbnailerRendererNotificationBus::Handler::BusDisconnect();
|
||||
AzFramework::AssetCatalogEventBus::Handler::BusDisconnect();
|
||||
}
|
||||
|
||||
void ModelThumbnail::ThumbnailRendered(const QPixmap& thumbnailImage)
|
||||
{
|
||||
m_pixmap = thumbnailImage;
|
||||
m_renderWait.release();
|
||||
}
|
||||
|
||||
void ModelThumbnail::ThumbnailFailedToRender()
|
||||
{
|
||||
m_state = State::Failed;
|
||||
m_renderWait.release();
|
||||
}
|
||||
|
||||
void ModelThumbnail::OnCatalogAssetChanged([[maybe_unused]] const AZ::Data::AssetId& assetId)
|
||||
{
|
||||
if (m_assetId == assetId && m_state == State::Ready)
|
||||
{
|
||||
m_state = State::Unloaded;
|
||||
Load();
|
||||
}
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// ModelThumbnailCache
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
ModelThumbnailCache::ModelThumbnailCache()
|
||||
: ThumbnailCache<ModelThumbnail>()
|
||||
{
|
||||
}
|
||||
|
||||
ModelThumbnailCache::~ModelThumbnailCache() = default;
|
||||
|
||||
int ModelThumbnailCache::GetPriority() const
|
||||
{
|
||||
// Thumbnails override default source thumbnails, so carry higher priority
|
||||
return 1;
|
||||
}
|
||||
|
||||
const char* ModelThumbnailCache::GetProviderName() const
|
||||
{
|
||||
return ProviderName;
|
||||
}
|
||||
|
||||
bool ModelThumbnailCache::IsSupportedThumbnail(AzToolsFramework::Thumbnailer::SharedThumbnailKey key) const
|
||||
{
|
||||
return GetAssetId(key, RPI::ModelAsset::RTTI_Type()).IsValid();
|
||||
}
|
||||
} // namespace Thumbnails
|
||||
} // namespace LyIntegration
|
||||
} // namespace AZ
|
||||
|
||||
#include <Previewer/moc_ModelThumbnail.cpp>
|
||||
+4
-8
@@ -91,8 +91,6 @@ set(FILES
|
||||
Source/SkyBox/EditorHDRiSkyboxComponent.h
|
||||
Source/SkyBox/EditorPhysicalSkyComponent.cpp
|
||||
Source/SkyBox/EditorPhysicalSkyComponent.h
|
||||
Source/Previewer/ThumbnailUtils.h
|
||||
Source/Previewer/ThumbnailUtils.cpp
|
||||
Source/Previewer/CommonPreviewer.cpp
|
||||
Source/Previewer/CommonPreviewer.h
|
||||
Source/Previewer/CommonPreviewer.ui
|
||||
@@ -100,14 +98,12 @@ set(FILES
|
||||
Source/Previewer/CommonPreviewerFactory.h
|
||||
Source/Previewer/CommonPreviewContent.cpp
|
||||
Source/Previewer/CommonPreviewContent.h
|
||||
Source/Previewer/CommonThumbnail.cpp
|
||||
Source/Previewer/CommonThumbnail.h
|
||||
Source/Previewer/CommonThumbnailRenderer.cpp
|
||||
Source/Previewer/CommonThumbnailRenderer.h
|
||||
Source/Previewer/MaterialThumbnail.cpp
|
||||
Source/Previewer/MaterialThumbnail.h
|
||||
Source/Previewer/ModelThumbnail.cpp
|
||||
Source/Previewer/ModelThumbnail.h
|
||||
Source/Previewer/LightingPresetThumbnail.cpp
|
||||
Source/Previewer/LightingPresetThumbnail.h
|
||||
Source/Previewer/CommonThumbnailUtils.cpp
|
||||
Source/Previewer/CommonThumbnailUtils.h
|
||||
Source/Scripting/EditorEntityReferenceComponent.cpp
|
||||
Source/Scripting/EditorEntityReferenceComponent.h
|
||||
Source/SurfaceData/EditorSurfaceDataMeshComponent.cpp
|
||||
|
||||
Reference in New Issue
Block a user