• Created interface for preview rendering content
• moved all thumbnail classes and registration back to the common feature editor component • added lighting preset thumbnail as a quick test Signed-off-by: Guthrie Adams <guthadam@amazon.com>
This commit is contained in:
+52
-6
@@ -9,12 +9,18 @@
|
||||
#include <EditorCommonFeaturesSystemComponent.h>
|
||||
#include <SkinnedMesh/SkinnedMeshDebugDisplay.h>
|
||||
|
||||
#include <AzCore/Serialization/SerializeContext.h>
|
||||
#include <AzCore/Serialization/EditContext.h>
|
||||
#include <AzCore/Serialization/EditContextConstants.inl>
|
||||
#include <AzCore/Serialization/SerializeContext.h>
|
||||
#include <AzCore/Utils/Utils.h>
|
||||
#include <AzFramework/API/ApplicationAPI.h>
|
||||
#include <AzToolsFramework/API/EditorCameraBus.h>
|
||||
#include <AzToolsFramework/API/ToolsApplicationAPI.h>
|
||||
#include <AzToolsFramework/Thumbnails/ThumbnailContext.h>
|
||||
|
||||
#include <Thumbnails/MaterialThumbnail.h>
|
||||
#include <Thumbnails/ModelThumbnail.h>
|
||||
#include <Thumbnails/LightingPresetThumbnail.h>
|
||||
|
||||
#include <IEditor.h>
|
||||
|
||||
@@ -68,7 +74,7 @@ namespace AZ
|
||||
|
||||
void EditorCommonFeaturesSystemComponent::GetRequiredServices(AZ::ComponentDescriptor::DependencyArrayType& required)
|
||||
{
|
||||
AZ_UNUSED(required);
|
||||
required.push_back(AZ_CRC_CE("ThumbnailerService"));
|
||||
}
|
||||
|
||||
void EditorCommonFeaturesSystemComponent::GetDependentServices(AZ::ComponentDescriptor::DependencyArrayType& dependent)
|
||||
@@ -98,8 +104,7 @@ namespace AZ
|
||||
AzToolsFramework::AssetBrowser::PreviewerRequestBus::Handler::BusDisconnect();
|
||||
|
||||
m_skinnedMeshDebugDisplay.reset();
|
||||
m_previewerFactory.reset();
|
||||
m_renderer.reset();
|
||||
TeardownThumbnails();
|
||||
}
|
||||
|
||||
void EditorCommonFeaturesSystemComponent::OnNewLevelCreated()
|
||||
@@ -194,8 +199,7 @@ namespace AZ
|
||||
void EditorCommonFeaturesSystemComponent::OnCatalogLoaded([[maybe_unused]] const char* catalogFile)
|
||||
{
|
||||
AZ::TickBus::QueueFunction([this](){
|
||||
m_renderer = AZStd::make_unique<AZ::LyIntegration::Thumbnails::CommonPreviewRenderer>();
|
||||
m_previewerFactory = AZStd::make_unique<LyIntegration::CommonPreviewerFactory>();
|
||||
SetupThumbnails();
|
||||
});
|
||||
}
|
||||
|
||||
@@ -207,7 +211,49 @@ namespace AZ
|
||||
|
||||
void EditorCommonFeaturesSystemComponent::OnApplicationAboutToStop()
|
||||
{
|
||||
TeardownThumbnails();
|
||||
}
|
||||
|
||||
void EditorCommonFeaturesSystemComponent::SetupThumbnails()
|
||||
{
|
||||
using namespace AzToolsFramework::Thumbnailer;
|
||||
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),
|
||||
ThumbnailContext::DefaultContext);
|
||||
|
||||
m_renderer = AZStd::make_unique<AZ::LyIntegration::Thumbnails::CommonThumbnailRenderer>();
|
||||
m_previewerFactory = AZStd::make_unique<LyIntegration::CommonPreviewerFactory>();
|
||||
}
|
||||
|
||||
void EditorCommonFeaturesSystemComponent::TeardownThumbnails()
|
||||
{
|
||||
using namespace AzToolsFramework::Thumbnailer;
|
||||
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,
|
||||
ThumbnailContext::DefaultContext);
|
||||
|
||||
m_renderer.reset();
|
||||
m_previewerFactory.reset();
|
||||
}
|
||||
} // namespace Render
|
||||
} // namespace AZ
|
||||
|
||||
+9
-4
@@ -14,7 +14,7 @@
|
||||
#include <AzToolsFramework/AssetBrowser/Previewer/PreviewerBus.h>
|
||||
#include <AzToolsFramework/Entity/SliceEditorEntityOwnershipServiceBus.h>
|
||||
#include <Source/Thumbnails/Preview/CommonPreviewerFactory.h>
|
||||
#include <Thumbnails/Rendering/CommonPreviewRenderer.h>
|
||||
#include <Thumbnails/CommonThumbnailRenderer.h>
|
||||
|
||||
namespace AZ
|
||||
{
|
||||
@@ -54,18 +54,23 @@ namespace AZ
|
||||
void OnNewLevelCreated() override;
|
||||
|
||||
// SliceEditorEntityOwnershipServiceBus overrides ...
|
||||
void OnSliceInstantiated(const AZ::Data::AssetId&, AZ::SliceComponent::SliceInstanceAddress&, const AzFramework::SliceInstantiationTicket&) override;
|
||||
void OnSliceInstantiated(
|
||||
const AZ::Data::AssetId&, AZ::SliceComponent::SliceInstanceAddress&, const AzFramework::SliceInstantiationTicket&) override;
|
||||
void OnSliceInstantiationFailed(const AZ::Data::AssetId&, const AzFramework::SliceInstantiationTicket&) override;
|
||||
|
||||
// AzFramework::AssetCatalogEventBus::Handler overrides ...
|
||||
void OnCatalogLoaded(const char* catalogFile) override;
|
||||
|
||||
// AzToolsFramework::AssetBrowser::PreviewerRequestBus::Handler overrides...
|
||||
const AzToolsFramework::AssetBrowser::PreviewerFactory* GetPreviewerFactory(const AzToolsFramework::AssetBrowser::AssetBrowserEntry* entry) const override;
|
||||
const AzToolsFramework::AssetBrowser::PreviewerFactory* GetPreviewerFactory(
|
||||
const AzToolsFramework::AssetBrowser::AssetBrowserEntry* entry) const override;
|
||||
|
||||
// AzFramework::ApplicationLifecycleEvents overrides...
|
||||
void OnApplicationAboutToStop() override;
|
||||
|
||||
void SetupThumbnails();
|
||||
void TeardownThumbnails();
|
||||
|
||||
private:
|
||||
AZStd::unique_ptr<SkinnedMeshDebugDisplay> m_skinnedMeshDebugDisplay;
|
||||
|
||||
@@ -73,7 +78,7 @@ namespace AZ
|
||||
AZStd::string m_atomLevelDefaultAssetPath{ "LevelAssets/default.slice" };
|
||||
float m_envProbeHeight{ 200.0f };
|
||||
|
||||
AZStd::unique_ptr<AZ::LyIntegration::Thumbnails::CommonPreviewRenderer> m_renderer;
|
||||
AZStd::unique_ptr<AZ::LyIntegration::Thumbnails::CommonThumbnailRenderer> m_renderer;
|
||||
AZStd::unique_ptr<LyIntegration::CommonPreviewerFactory> m_previewerFactory;
|
||||
};
|
||||
} // namespace Render
|
||||
|
||||
-36
@@ -16,11 +16,9 @@
|
||||
#include <AzFramework/Application/Application.h>
|
||||
#include <AzToolsFramework/API/EditorAssetSystemAPI.h>
|
||||
#include <AzToolsFramework/API/ViewPaneOptions.h>
|
||||
#include <AzToolsFramework/Thumbnails/ThumbnailContext.h>
|
||||
#include <Editor/LyViewPaneNames.h>
|
||||
#include <Material/EditorMaterialComponentInspector.h>
|
||||
#include <Material/EditorMaterialSystemComponent.h>
|
||||
#include <Material/MaterialThumbnail.h>
|
||||
|
||||
// Disables warning messages triggered by the Qt library
|
||||
// 4251: class needs to have dll-interface to be used by clients of class
|
||||
@@ -72,11 +70,6 @@ namespace AZ
|
||||
incompatible.push_back(AZ_CRC("EditorMaterialSystem", 0x5c93bc4e));
|
||||
}
|
||||
|
||||
void EditorMaterialSystemComponent::GetRequiredServices(AZ::ComponentDescriptor::DependencyArrayType& required)
|
||||
{
|
||||
required.push_back(AZ_CRC("ThumbnailerService", 0x65422b97));
|
||||
}
|
||||
|
||||
void EditorMaterialSystemComponent::GetDependentServices(AZ::ComponentDescriptor::DependencyArrayType& dependent)
|
||||
{
|
||||
AZ_UNUSED(dependent);
|
||||
@@ -90,24 +83,20 @@ namespace AZ
|
||||
void EditorMaterialSystemComponent::Activate()
|
||||
{
|
||||
EditorMaterialSystemComponentRequestBus::Handler::BusConnect();
|
||||
AzFramework::ApplicationLifecycleEvents::Bus::Handler::BusConnect();
|
||||
AzToolsFramework::AssetBrowser::AssetBrowserInteractionNotificationBus::Handler::BusConnect();
|
||||
AzToolsFramework::EditorMenuNotificationBus::Handler::BusConnect();
|
||||
AzToolsFramework::EditorEvents::Bus::Handler::BusConnect();
|
||||
|
||||
SetupThumbnails();
|
||||
m_materialBrowserInteractions.reset(aznew MaterialBrowserInteractions);
|
||||
}
|
||||
|
||||
void EditorMaterialSystemComponent::Deactivate()
|
||||
{
|
||||
EditorMaterialSystemComponentRequestBus::Handler::BusDisconnect();
|
||||
AzFramework::ApplicationLifecycleEvents::Bus::Handler::BusDisconnect();
|
||||
AzToolsFramework::AssetBrowser::AssetBrowserInteractionNotificationBus::Handler::BusDisconnect();
|
||||
AzToolsFramework::EditorMenuNotificationBus::Handler::BusDisconnect();
|
||||
AzToolsFramework::EditorEvents::Bus::Handler::BusDisconnect();
|
||||
|
||||
TeardownThumbnails();
|
||||
m_materialBrowserInteractions.reset();
|
||||
|
||||
if (m_openMaterialEditorAction)
|
||||
@@ -154,11 +143,6 @@ namespace AZ
|
||||
}
|
||||
}
|
||||
|
||||
void EditorMaterialSystemComponent::OnApplicationAboutToStop()
|
||||
{
|
||||
TeardownThumbnails();
|
||||
}
|
||||
|
||||
void EditorMaterialSystemComponent::OnPopulateToolMenuItems()
|
||||
{
|
||||
if (!m_openMaterialEditorAction)
|
||||
@@ -201,26 +185,6 @@ namespace AZ
|
||||
"Material Property Inspector", LyViewPane::CategoryTools, inspectorOptions);
|
||||
}
|
||||
|
||||
void EditorMaterialSystemComponent::SetupThumbnails()
|
||||
{
|
||||
using namespace AzToolsFramework::Thumbnailer;
|
||||
using namespace LyIntegration;
|
||||
|
||||
ThumbnailerRequestsBus::Broadcast(
|
||||
&ThumbnailerRequests::RegisterThumbnailProvider, MAKE_TCACHE(Thumbnails::MaterialThumbnailCache),
|
||||
ThumbnailContext::DefaultContext);
|
||||
}
|
||||
|
||||
void EditorMaterialSystemComponent::TeardownThumbnails()
|
||||
{
|
||||
using namespace AzToolsFramework::Thumbnailer;
|
||||
using namespace LyIntegration;
|
||||
|
||||
ThumbnailerRequestsBus::Broadcast(
|
||||
&ThumbnailerRequests::UnregisterThumbnailProvider, Thumbnails::MaterialThumbnailCache::ProviderName,
|
||||
ThumbnailContext::DefaultContext);
|
||||
}
|
||||
|
||||
AzToolsFramework::AssetBrowser::SourceFileDetails EditorMaterialSystemComponent::GetSourceFileDetails(
|
||||
const char* fullSourceFileName)
|
||||
{
|
||||
|
||||
-10
@@ -8,10 +8,8 @@
|
||||
#pragma once
|
||||
|
||||
#include <AzCore/Component/Component.h>
|
||||
#include <AzFramework/Application/Application.h>
|
||||
#include <AzToolsFramework/API/ToolsApplicationAPI.h>
|
||||
#include <AzToolsFramework/AssetBrowser/AssetBrowserBus.h>
|
||||
#include <AzToolsFramework/Thumbnails/Thumbnail.h>
|
||||
#include <AzToolsFramework/Viewport/ActionBus.h>
|
||||
|
||||
#include <AtomLyIntegration/CommonFeatures/Material/EditorMaterialSystemComponentRequestBus.h>
|
||||
@@ -26,7 +24,6 @@ namespace AZ
|
||||
class EditorMaterialSystemComponent
|
||||
: public AZ::Component
|
||||
, private EditorMaterialSystemComponentRequestBus::Handler
|
||||
, private AzFramework::ApplicationLifecycleEvents::Bus::Handler
|
||||
, private AzToolsFramework::AssetBrowser::AssetBrowserInteractionNotificationBus::Handler
|
||||
, private AzToolsFramework::EditorMenuNotificationBus::Handler
|
||||
, private AzToolsFramework::EditorEvents::Bus::Handler
|
||||
@@ -38,7 +35,6 @@ namespace AZ
|
||||
|
||||
static void GetProvidedServices(AZ::ComponentDescriptor::DependencyArrayType& provided);
|
||||
static void GetIncompatibleServices(AZ::ComponentDescriptor::DependencyArrayType& incompatible);
|
||||
static void GetRequiredServices(AZ::ComponentDescriptor::DependencyArrayType& required);
|
||||
static void GetDependentServices(AZ::ComponentDescriptor::DependencyArrayType& dependent);
|
||||
|
||||
protected:
|
||||
@@ -52,9 +48,6 @@ namespace AZ
|
||||
void OpenMaterialEditor(const AZStd::string& sourcePath) override;
|
||||
void OpenMaterialInspector(const AZ::EntityId& entityId, const AZ::Render::MaterialAssignmentId& materialAssignmentId) override;
|
||||
|
||||
// AzFramework::ApplicationLifecycleEvents overrides...
|
||||
void OnApplicationAboutToStop() override;
|
||||
|
||||
//! AssetBrowserInteractionNotificationBus::Handler overrides...
|
||||
AzToolsFramework::AssetBrowser::SourceFileDetails GetSourceFileDetails(const char* fullSourceFileName) override;
|
||||
|
||||
@@ -65,9 +58,6 @@ namespace AZ
|
||||
// AztoolsFramework::EditorEvents::Bus::Handler overrides...
|
||||
void NotifyRegisterViews() override;
|
||||
|
||||
void SetupThumbnails();
|
||||
void TeardownThumbnails();
|
||||
|
||||
QAction* m_openMaterialEditorAction = nullptr;
|
||||
|
||||
AZStd::unique_ptr<MaterialBrowserInteractions> m_materialBrowserInteractions;
|
||||
|
||||
+2
-39
@@ -6,13 +6,10 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include <AzCore/Serialization/SerializeContext.h>
|
||||
#include <AzCore/Serialization/EditContext.h>
|
||||
#include <AzCore/Serialization/EditContextConstants.inl>
|
||||
#include <AzCore/Utils/Utils.h>
|
||||
#include <AzToolsFramework/Thumbnails/ThumbnailContext.h>
|
||||
#include <Source/Mesh/EditorMeshSystemComponent.h>
|
||||
#include <Source/Mesh/MeshThumbnail.h>
|
||||
#include <AzCore/Serialization/SerializeContext.h>
|
||||
#include <Mesh/EditorMeshSystemComponent.h>
|
||||
|
||||
namespace AZ
|
||||
{
|
||||
@@ -47,11 +44,6 @@ namespace AZ
|
||||
incompatible.push_back(AZ_CRC_CE("EditorMeshSystem"));
|
||||
}
|
||||
|
||||
void EditorMeshSystemComponent::GetRequiredServices(AZ::ComponentDescriptor::DependencyArrayType& required)
|
||||
{
|
||||
required.push_back(AZ_CRC_CE("ThumbnailerService"));
|
||||
}
|
||||
|
||||
void EditorMeshSystemComponent::GetDependentServices(AZ::ComponentDescriptor::DependencyArrayType& dependent)
|
||||
{
|
||||
AZ_UNUSED(dependent);
|
||||
@@ -59,39 +51,10 @@ namespace AZ
|
||||
|
||||
void EditorMeshSystemComponent::Activate()
|
||||
{
|
||||
AzFramework::ApplicationLifecycleEvents::Bus::Handler::BusConnect();
|
||||
SetupThumbnails();
|
||||
}
|
||||
|
||||
void EditorMeshSystemComponent::Deactivate()
|
||||
{
|
||||
TeardownThumbnails();
|
||||
AzFramework::ApplicationLifecycleEvents::Bus::Handler::BusDisconnect();
|
||||
}
|
||||
|
||||
void EditorMeshSystemComponent::OnApplicationAboutToStop()
|
||||
{
|
||||
TeardownThumbnails();
|
||||
}
|
||||
|
||||
void EditorMeshSystemComponent::SetupThumbnails()
|
||||
{
|
||||
using namespace AzToolsFramework::Thumbnailer;
|
||||
using namespace LyIntegration;
|
||||
|
||||
ThumbnailerRequestsBus::Broadcast(&ThumbnailerRequests::RegisterThumbnailProvider,
|
||||
MAKE_TCACHE(Thumbnails::MeshThumbnailCache),
|
||||
ThumbnailContext::DefaultContext);
|
||||
}
|
||||
|
||||
void EditorMeshSystemComponent::TeardownThumbnails()
|
||||
{
|
||||
using namespace AzToolsFramework::Thumbnailer;
|
||||
using namespace LyIntegration;
|
||||
|
||||
ThumbnailerRequestsBus::Broadcast(&ThumbnailerRequests::UnregisterThumbnailProvider,
|
||||
Thumbnails::MeshThumbnailCache::ProviderName,
|
||||
ThumbnailContext::DefaultContext);
|
||||
}
|
||||
} // namespace Render
|
||||
} // namespace AZ
|
||||
|
||||
@@ -8,7 +8,6 @@
|
||||
#pragma once
|
||||
|
||||
#include <AzCore/Component/Component.h>
|
||||
#include <AzFramework/Application/Application.h>
|
||||
|
||||
namespace AZ
|
||||
{
|
||||
@@ -17,7 +16,6 @@ namespace AZ
|
||||
//! System component that sets up necessary logic related to EditorMeshComponent.
|
||||
class EditorMeshSystemComponent
|
||||
: public AZ::Component
|
||||
, private AzFramework::ApplicationLifecycleEvents::Bus::Handler
|
||||
{
|
||||
public:
|
||||
AZ_COMPONENT(EditorMeshSystemComponent, "{4D332E3D-C4FC-410B-A915-8E234CBDD4EC}");
|
||||
@@ -26,20 +24,12 @@ namespace AZ
|
||||
|
||||
static void GetProvidedServices(AZ::ComponentDescriptor::DependencyArrayType& provided);
|
||||
static void GetIncompatibleServices(AZ::ComponentDescriptor::DependencyArrayType& incompatible);
|
||||
static void GetRequiredServices(AZ::ComponentDescriptor::DependencyArrayType& required);
|
||||
static void GetDependentServices(AZ::ComponentDescriptor::DependencyArrayType& dependent);
|
||||
|
||||
protected:
|
||||
// AZ::Component interface overrides...
|
||||
void Activate() override;
|
||||
void Deactivate() override;
|
||||
|
||||
private:
|
||||
// AzFramework::ApplicationLifecycleEvents overrides...
|
||||
void OnApplicationAboutToStop() override;
|
||||
|
||||
void SetupThumbnails();
|
||||
void TeardownThumbnails();
|
||||
};
|
||||
} // namespace Render
|
||||
} // namespace AZ
|
||||
|
||||
+20
-18
@@ -23,7 +23,7 @@
|
||||
#include <AzCore/Math/Transform.h>
|
||||
#include <AzFramework/Components/TransformComponent.h>
|
||||
#include <AzFramework/Entity/EntityContextBus.h>
|
||||
#include <Thumbnails/Rendering/CommonPreviewContent.h>
|
||||
#include <Thumbnails/CommonThumbnailPreviewContent.h>
|
||||
|
||||
namespace AZ
|
||||
{
|
||||
@@ -31,7 +31,7 @@ namespace AZ
|
||||
{
|
||||
namespace Thumbnails
|
||||
{
|
||||
CommonPreviewContent::CommonPreviewContent(
|
||||
CommonThumbnailPreviewContent::CommonThumbnailPreviewContent(
|
||||
RPI::ScenePtr scene,
|
||||
RPI::ViewPtr view,
|
||||
AZ::Uuid entityContextId,
|
||||
@@ -65,7 +65,7 @@ namespace AZ
|
||||
m_lightingPresetAsset.Create(lightingPresetAssetId.IsValid() ? lightingPresetAssetId : DefaultLightingPresetAssetId, false);
|
||||
}
|
||||
|
||||
CommonPreviewContent::~CommonPreviewContent()
|
||||
CommonThumbnailPreviewContent::~CommonThumbnailPreviewContent()
|
||||
{
|
||||
if (m_modelEntity)
|
||||
{
|
||||
@@ -75,44 +75,46 @@ namespace AZ
|
||||
}
|
||||
}
|
||||
|
||||
void CommonPreviewContent::Load()
|
||||
void CommonThumbnailPreviewContent::Load()
|
||||
{
|
||||
m_modelAsset.QueueLoad();
|
||||
m_materialAsset.QueueLoad();
|
||||
m_lightingPresetAsset.QueueLoad();
|
||||
}
|
||||
|
||||
bool CommonPreviewContent::IsReady() const
|
||||
bool CommonThumbnailPreviewContent::IsReady() const
|
||||
{
|
||||
return m_modelAsset.IsReady() && m_materialAsset.IsReady() && m_lightingPresetAsset.IsReady();
|
||||
return (!m_modelAsset.GetId().IsValid() || m_modelAsset.IsReady()) &&
|
||||
(!m_materialAsset.GetId().IsValid() || m_materialAsset.IsReady()) &&
|
||||
(!m_lightingPresetAsset.GetId().IsValid() || m_lightingPresetAsset.IsReady());
|
||||
}
|
||||
|
||||
bool CommonPreviewContent::IsError() const
|
||||
bool CommonThumbnailPreviewContent::IsError() const
|
||||
{
|
||||
return m_modelAsset.IsError() || m_materialAsset.IsError() || m_lightingPresetAsset.IsError();
|
||||
}
|
||||
|
||||
void CommonPreviewContent::ReportErrors()
|
||||
void CommonThumbnailPreviewContent::ReportErrors()
|
||||
{
|
||||
AZ_Warning(
|
||||
"CommonPreviewContent", m_modelAsset.IsReady(), "Asset failed to load in time: %s",
|
||||
m_modelAsset.ToString<AZStd::string>().c_str());
|
||||
"CommonThumbnailPreviewContent", !m_modelAsset.GetId().IsValid() || m_modelAsset.IsReady(),
|
||||
"Asset failed to load in time: %s", m_modelAsset.ToString<AZStd::string>().c_str());
|
||||
AZ_Warning(
|
||||
"CommonPreviewContent", m_materialAsset.IsReady(), "Asset failed to load in time: %s",
|
||||
m_materialAsset.ToString<AZStd::string>().c_str());
|
||||
"CommonThumbnailPreviewContent", !m_materialAsset.GetId().IsValid() || m_materialAsset.IsReady(),
|
||||
"Asset failed to load in time: %s", m_materialAsset.ToString<AZStd::string>().c_str());
|
||||
AZ_Warning(
|
||||
"CommonPreviewContent", m_lightingPresetAsset.IsReady(), "Asset failed to load in time: %s",
|
||||
m_lightingPresetAsset.ToString<AZStd::string>().c_str());
|
||||
"CommonThumbnailPreviewContent", !m_lightingPresetAsset.GetId().IsValid() || m_lightingPresetAsset.IsReady(),
|
||||
"Asset failed to load in time: %s", m_lightingPresetAsset.ToString<AZStd::string>().c_str());
|
||||
}
|
||||
|
||||
void CommonPreviewContent::UpdateScene()
|
||||
void CommonThumbnailPreviewContent::UpdateScene()
|
||||
{
|
||||
UpdateModel();
|
||||
UpdateLighting();
|
||||
UpdateCamera();
|
||||
}
|
||||
|
||||
void CommonPreviewContent::UpdateModel()
|
||||
void CommonThumbnailPreviewContent::UpdateModel()
|
||||
{
|
||||
Render::MeshComponentRequestBus::Event(
|
||||
m_modelEntity->GetId(), &Render::MeshComponentRequestBus::Events::SetModelAsset, m_modelAsset);
|
||||
@@ -122,7 +124,7 @@ namespace AZ
|
||||
m_materialAsset.GetId());
|
||||
}
|
||||
|
||||
void CommonPreviewContent::UpdateLighting()
|
||||
void CommonThumbnailPreviewContent::UpdateLighting()
|
||||
{
|
||||
auto preset = m_lightingPresetAsset->GetDataAs<Render::LightingPreset>();
|
||||
if (preset)
|
||||
@@ -152,7 +154,7 @@ namespace AZ
|
||||
}
|
||||
}
|
||||
|
||||
void CommonPreviewContent::UpdateCamera()
|
||||
void CommonThumbnailPreviewContent::UpdateCamera()
|
||||
{
|
||||
// Get bounding sphere of the model asset and estimate how far the camera needs to be see all of it
|
||||
Vector3 center = {};
|
||||
+82
@@ -0,0 +1,82 @@
|
||||
/*
|
||||
* 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
|
||||
|
||||
#include <Atom/RPI.Public/Base.h>
|
||||
#include <Atom/RPI.Reflect/Asset/AssetUtils.h>
|
||||
#include <Atom/RPI.Reflect/Material/MaterialAsset.h>
|
||||
#include <Atom/RPI.Reflect/Model/ModelAsset.h>
|
||||
#include <Atom/RPI.Reflect/System/AnyAsset.h>
|
||||
#include <Thumbnails/Rendering/CommonPreviewContent.h>
|
||||
|
||||
namespace AZ
|
||||
{
|
||||
namespace LyIntegration
|
||||
{
|
||||
namespace Thumbnails
|
||||
{
|
||||
//! Provides custom rendering of material and model previews
|
||||
class CommonThumbnailPreviewContent final
|
||||
: public CommonPreviewContent
|
||||
{
|
||||
public:
|
||||
AZ_CLASS_ALLOCATOR(CommonThumbnailPreviewContent, AZ::SystemAllocator, 0);
|
||||
|
||||
CommonThumbnailPreviewContent(
|
||||
RPI::ScenePtr scene,
|
||||
RPI::ViewPtr view,
|
||||
AZ::Uuid entityContextId,
|
||||
const Data::AssetId& modelAssetId,
|
||||
const Data::AssetId& materialAssetId,
|
||||
const Data::AssetId& lightingPresetAssetId);
|
||||
|
||||
~CommonThumbnailPreviewContent() override;
|
||||
|
||||
void Load() override;
|
||||
bool IsReady() const override;
|
||||
bool IsError() const override;
|
||||
void ReportErrors() override;
|
||||
void UpdateScene() override;
|
||||
|
||||
private:
|
||||
void UpdateModel();
|
||||
void UpdateLighting();
|
||||
void UpdateCamera();
|
||||
|
||||
static constexpr float AspectRatio = 1.0f;
|
||||
static constexpr float NearDist = 0.001f;
|
||||
static constexpr float FarDist = 100.0f;
|
||||
static constexpr float FieldOfView = Constants::HalfPi;
|
||||
static constexpr float CameraRotationAngle = Constants::QuarterPi / 2.0f;
|
||||
|
||||
RPI::ScenePtr m_scene;
|
||||
RPI::ViewPtr m_view;
|
||||
AZ::Uuid m_entityContextId;
|
||||
Entity* m_modelEntity = nullptr;
|
||||
|
||||
static constexpr const char* DefaultLightingPresetPath = "lightingpresets/thumbnail.lightingpreset.azasset";
|
||||
const Data::AssetId DefaultLightingPresetAssetId = AZ::RPI::AssetUtils::GetAssetIdForProductPath(DefaultLightingPresetPath);
|
||||
Data::Asset<RPI::AnyAsset> m_defaultLightingPresetAsset;
|
||||
Data::Asset<RPI::AnyAsset> m_lightingPresetAsset;
|
||||
|
||||
//! Model asset about to be rendered
|
||||
static constexpr const char* DefaultModelPath = "models/sphere.azmodel";
|
||||
const Data::AssetId DefaultModelAssetId = AZ::RPI::AssetUtils::GetAssetIdForProductPath(DefaultModelPath);
|
||||
Data::Asset<RPI::ModelAsset> m_defaultModelAsset;
|
||||
Data::Asset<RPI::ModelAsset> m_modelAsset;
|
||||
|
||||
//! Material asset about to be rendered
|
||||
static constexpr const char* DefaultMaterialPath = "materials/basic_grey.azmaterial";
|
||||
const Data::AssetId DefaultMaterialAssetId = AZ::RPI::AssetUtils::GetAssetIdForProductPath(DefaultMaterialPath);
|
||||
Data::Asset<RPI::MaterialAsset> m_defaultMaterialAsset;
|
||||
Data::Asset<RPI::MaterialAsset> m_materialAsset;
|
||||
};
|
||||
} // namespace Thumbnails
|
||||
} // namespace LyIntegration
|
||||
} // namespace AZ
|
||||
+71
@@ -0,0 +1,71 @@
|
||||
/*
|
||||
* 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 <AzToolsFramework/AssetBrowser/AssetBrowserBus.h>
|
||||
#include <AzToolsFramework/Thumbnails/ThumbnailerBus.h>
|
||||
#include <Thumbnails/CommonThumbnailPreviewContent.h>
|
||||
#include <Thumbnails/CommonThumbnailRenderer.h>
|
||||
#include <Thumbnails/ThumbnailUtils.h>
|
||||
|
||||
namespace AZ
|
||||
{
|
||||
namespace LyIntegration
|
||||
{
|
||||
namespace Thumbnails
|
||||
{
|
||||
CommonThumbnailRenderer::CommonThumbnailRenderer()
|
||||
{
|
||||
// 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());
|
||||
SystemTickBus::Handler::BusConnect();
|
||||
}
|
||||
|
||||
CommonThumbnailRenderer::~CommonThumbnailRenderer()
|
||||
{
|
||||
AzToolsFramework::Thumbnailer::ThumbnailerRendererRequestBus::MultiHandler::BusDisconnect();
|
||||
SystemTickBus::Handler::BusDisconnect();
|
||||
}
|
||||
|
||||
void CommonThumbnailRenderer::RenderThumbnail(AzToolsFramework::Thumbnailer::SharedThumbnailKey thumbnailKey, int thumbnailSize)
|
||||
{
|
||||
m_previewRenderer.AddCaptureRequest(
|
||||
{ thumbnailSize,
|
||||
AZStd::make_shared<CommonThumbnailPreviewContent>(
|
||||
m_previewRenderer.GetScene(),
|
||||
m_previewRenderer.GetView(),
|
||||
m_previewRenderer.GetEntityContextId(),
|
||||
GetAssetId(thumbnailKey, RPI::ModelAsset::RTTI_Type()),
|
||||
GetAssetId(thumbnailKey, RPI::MaterialAsset::RTTI_Type()),
|
||||
GetAssetId(thumbnailKey, RPI::AnyAsset::RTTI_Type())),
|
||||
[thumbnailKey]()
|
||||
{
|
||||
AzToolsFramework::Thumbnailer::ThumbnailerRendererNotificationBus::Event(
|
||||
thumbnailKey, &AzToolsFramework::Thumbnailer::ThumbnailerRendererNotifications::ThumbnailFailedToRender);
|
||||
},
|
||||
[thumbnailKey](const QImage& image)
|
||||
{
|
||||
AzToolsFramework::Thumbnailer::ThumbnailerRendererNotificationBus::Event(
|
||||
thumbnailKey, &AzToolsFramework::Thumbnailer::ThumbnailerRendererNotifications::ThumbnailRendered,
|
||||
QPixmap::fromImage(image));
|
||||
} });
|
||||
}
|
||||
|
||||
bool CommonThumbnailRenderer::Installed() const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
void CommonThumbnailRenderer::OnSystemTick()
|
||||
{
|
||||
AzToolsFramework::Thumbnailer::ThumbnailerRendererRequestBus::ExecuteQueuedEvents();
|
||||
}
|
||||
} // namespace Thumbnails
|
||||
} // namespace LyIntegration
|
||||
} // namespace AZ
|
||||
+46
@@ -0,0 +1,46 @@
|
||||
/*
|
||||
* 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
|
||||
|
||||
#include <AzCore/Component/TickBus.h>
|
||||
#include <AzToolsFramework/Thumbnails/Thumbnail.h>
|
||||
#include <AzToolsFramework/Thumbnails/ThumbnailerBus.h>
|
||||
#include <Thumbnails/Rendering/CommonPreviewRenderer.h>
|
||||
#include <Thumbnails/Thumbnail.h>
|
||||
|
||||
namespace AZ
|
||||
{
|
||||
namespace LyIntegration
|
||||
{
|
||||
namespace Thumbnails
|
||||
{
|
||||
//! Provides custom rendering of material and model thumbnails
|
||||
class CommonThumbnailRenderer
|
||||
: public AzToolsFramework::Thumbnailer::ThumbnailerRendererRequestBus::MultiHandler
|
||||
, public SystemTickBus::Handler
|
||||
{
|
||||
public:
|
||||
AZ_CLASS_ALLOCATOR(CommonThumbnailRenderer, AZ::SystemAllocator, 0);
|
||||
|
||||
CommonThumbnailRenderer();
|
||||
~CommonThumbnailRenderer();
|
||||
|
||||
private:
|
||||
//! ThumbnailerRendererRequestsBus::Handler interface overrides...
|
||||
void RenderThumbnail(AzToolsFramework::Thumbnailer::SharedThumbnailKey thumbnailKey, int thumbnailSize) override;
|
||||
bool Installed() const override;
|
||||
|
||||
//! SystemTickBus::Handler interface overrides...
|
||||
void OnSystemTick() override;
|
||||
|
||||
CommonPreviewRenderer m_previewRenderer;
|
||||
};
|
||||
} // namespace Thumbnails
|
||||
} // namespace LyIntegration
|
||||
} // namespace AZ
|
||||
+115
@@ -0,0 +1,115 @@
|
||||
/*
|
||||
* 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 <Thumbnails/LightingPresetThumbnail.h>
|
||||
#include <Thumbnails/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(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 <Thumbnails/moc_LightingPresetThumbnail.cpp>
|
||||
+9
-14
@@ -21,18 +21,16 @@ namespace AZ
|
||||
{
|
||||
namespace Thumbnails
|
||||
{
|
||||
/**
|
||||
* Custom material or model thumbnail that detects when an asset changes and updates the thumbnail
|
||||
*/
|
||||
class MeshThumbnail
|
||||
//! 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:
|
||||
MeshThumbnail(AzToolsFramework::Thumbnailer::SharedThumbnailKey key);
|
||||
~MeshThumbnail() override;
|
||||
LightingPresetThumbnail(AzToolsFramework::Thumbnailer::SharedThumbnailKey key);
|
||||
~LightingPresetThumbnail() override;
|
||||
|
||||
//! AzToolsFramework::ThumbnailerRendererNotificationBus::Handler overrides...
|
||||
void ThumbnailRendered(QPixmap& thumbnailImage) override;
|
||||
@@ -49,20 +47,17 @@ namespace AZ
|
||||
Data::AssetId m_assetId;
|
||||
};
|
||||
|
||||
/**
|
||||
* Cache configuration for large material thumbnails
|
||||
*/
|
||||
class MeshThumbnailCache
|
||||
: public AzToolsFramework::Thumbnailer::ThumbnailCache<MeshThumbnail>
|
||||
//! Cache configuration for large thumbnails
|
||||
class LightingPresetThumbnailCache : public AzToolsFramework::Thumbnailer::ThumbnailCache<LightingPresetThumbnail>
|
||||
{
|
||||
public:
|
||||
MeshThumbnailCache();
|
||||
~MeshThumbnailCache() override;
|
||||
LightingPresetThumbnailCache();
|
||||
~LightingPresetThumbnailCache() override;
|
||||
|
||||
int GetPriority() const override;
|
||||
const char* GetProviderName() const override;
|
||||
|
||||
static constexpr const char* ProviderName = "Mesh Thumbnails";
|
||||
static constexpr const char* ProviderName = "LightingPreset Thumbnails";
|
||||
|
||||
protected:
|
||||
bool IsSupportedThumbnail(AzToolsFramework::Thumbnailer::SharedThumbnailKey key) const override;
|
||||
+8
-14
@@ -6,10 +6,11 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include <Atom/RPI.Reflect/Material/MaterialAsset.h>
|
||||
#include <AzToolsFramework/API/EditorAssetSystemAPI.h>
|
||||
#include <QtConcurrent/QtConcurrent>
|
||||
#include <Source/Material/MaterialThumbnail.h>
|
||||
#include <Source/Thumbnails/ThumbnailUtils.h>
|
||||
#include <Thumbnails/MaterialThumbnail.h>
|
||||
#include <Thumbnails/ThumbnailUtils.h>
|
||||
|
||||
namespace AZ
|
||||
{
|
||||
@@ -40,9 +41,7 @@ namespace AZ
|
||||
void MaterialThumbnail::LoadThread()
|
||||
{
|
||||
AzToolsFramework::Thumbnailer::ThumbnailerRendererRequestBus::QueueEvent(
|
||||
RPI::MaterialAsset::RTTI_Type(),
|
||||
&AzToolsFramework::Thumbnailer::ThumbnailerRendererRequests::RenderThumbnail,
|
||||
m_key,
|
||||
RPI::MaterialAsset::RTTI_Type(), &AzToolsFramework::Thumbnailer::ThumbnailerRendererRequests::RenderThumbnail, m_key,
|
||||
MaterialThumbnailSize);
|
||||
// wait for response from thumbnail renderer
|
||||
m_renderWait.acquire();
|
||||
@@ -68,8 +67,7 @@ namespace AZ
|
||||
|
||||
void MaterialThumbnail::OnCatalogAssetChanged([[maybe_unused]] const AZ::Data::AssetId& assetId)
|
||||
{
|
||||
if (m_assetId == assetId &&
|
||||
m_state == State::Ready)
|
||||
if (m_assetId == assetId && m_state == State::Ready)
|
||||
{
|
||||
m_state = State::Unloaded;
|
||||
Load();
|
||||
@@ -88,7 +86,7 @@ namespace AZ
|
||||
|
||||
int MaterialThumbnailCache::GetPriority() const
|
||||
{
|
||||
// Material thumbnails override default source thumbnails, so carry higher priority
|
||||
// Thumbnails override default source thumbnails, so carry higher priority
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -99,14 +97,10 @@ namespace AZ
|
||||
|
||||
bool MaterialThumbnailCache::IsSupportedThumbnail(AzToolsFramework::Thumbnailer::SharedThumbnailKey key) const
|
||||
{
|
||||
return
|
||||
GetAssetId(key, RPI::MaterialAsset::RTTI_Type()).IsValid() &&
|
||||
// in case it's a source scene file, it will contain both material and model products
|
||||
// model thumbnails are handled by MeshThumbnail
|
||||
!GetAssetId(key, RPI::ModelAsset::RTTI_Type()).IsValid();
|
||||
return GetAssetId(key, RPI::MaterialAsset::RTTI_Type()).IsValid();
|
||||
}
|
||||
} // namespace Thumbnails
|
||||
} // namespace LyIntegration
|
||||
} // namespace AZ
|
||||
|
||||
#include <Material/moc_MaterialThumbnail.cpp>
|
||||
#include <Thumbnails/moc_MaterialThumbnail.cpp>
|
||||
+3
-9
@@ -13,7 +13,6 @@
|
||||
#include <AzFramework/Asset/AssetCatalogBus.h>
|
||||
#include <AzToolsFramework/Thumbnails/Thumbnail.h>
|
||||
#include <AzToolsFramework/Thumbnails/ThumbnailerBus.h>
|
||||
#include <Thumbnails/Rendering/CommonPreviewRenderer.h>
|
||||
#endif
|
||||
|
||||
namespace AZ
|
||||
@@ -22,9 +21,7 @@ namespace AZ
|
||||
{
|
||||
namespace Thumbnails
|
||||
{
|
||||
/**
|
||||
* Custom material or model thumbnail that detects when an asset changes and updates the thumbnail
|
||||
*/
|
||||
//! Custom thumbnail that detects when an asset changes and updates the thumbnail
|
||||
class MaterialThumbnail
|
||||
: public AzToolsFramework::Thumbnailer::Thumbnail
|
||||
, public AzToolsFramework::Thumbnailer::ThumbnailerRendererNotificationBus::Handler
|
||||
@@ -50,11 +47,8 @@ namespace AZ
|
||||
Data::AssetId m_assetId;
|
||||
};
|
||||
|
||||
/**
|
||||
* Cache configuration for large material thumbnails
|
||||
*/
|
||||
class MaterialThumbnailCache
|
||||
: public AzToolsFramework::Thumbnailer::ThumbnailCache<MaterialThumbnail>
|
||||
//! Cache configuration for large thumbnails
|
||||
class MaterialThumbnailCache : public AzToolsFramework::Thumbnailer::ThumbnailCache<MaterialThumbnail>
|
||||
{
|
||||
public:
|
||||
MaterialThumbnailCache();
|
||||
+24
-27
@@ -6,11 +6,11 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include <AzToolsFramework/API/EditorAssetSystemAPI.h>
|
||||
#include <Atom/RPI.Reflect/Model/ModelAsset.h>
|
||||
#include <AzToolsFramework/API/EditorAssetSystemAPI.h>
|
||||
#include <QtConcurrent/QtConcurrent>
|
||||
#include <Source/Mesh/MeshThumbnail.h>
|
||||
#include <Source/Thumbnails/ThumbnailUtils.h>
|
||||
#include <Thumbnails/ModelThumbnail.h>
|
||||
#include <Thumbnails/ThumbnailUtils.h>
|
||||
|
||||
namespace AZ
|
||||
{
|
||||
@@ -18,18 +18,18 @@ namespace AZ
|
||||
{
|
||||
namespace Thumbnails
|
||||
{
|
||||
static constexpr const int MeshThumbnailSize = 512; // 512 is the default size in render to texture pass
|
||||
static constexpr const int ModelThumbnailSize = 512; // 512 is the default size in render to texture pass
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// MeshThumbnail
|
||||
// ModelThumbnail
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
MeshThumbnail::MeshThumbnail(AzToolsFramework::Thumbnailer::SharedThumbnailKey key)
|
||||
ModelThumbnail::ModelThumbnail(AzToolsFramework::Thumbnailer::SharedThumbnailKey key)
|
||||
: Thumbnail(key)
|
||||
{
|
||||
m_assetId = GetAssetId(key, RPI::ModelAsset::RTTI_Type());
|
||||
if (!m_assetId.IsValid())
|
||||
{
|
||||
AZ_Error("MeshThumbnail", false, "Failed to find matching assetId for the thumbnailKey.");
|
||||
AZ_Error("ModelThumbnail", false, "Failed to find matching assetId for the thumbnailKey.");
|
||||
m_state = State::Failed;
|
||||
return;
|
||||
}
|
||||
@@ -38,39 +38,36 @@ namespace AZ
|
||||
AzFramework::AssetCatalogEventBus::Handler::BusConnect();
|
||||
}
|
||||
|
||||
void MeshThumbnail::LoadThread()
|
||||
void ModelThumbnail::LoadThread()
|
||||
{
|
||||
AzToolsFramework::Thumbnailer::ThumbnailerRendererRequestBus::QueueEvent(
|
||||
RPI::ModelAsset::RTTI_Type(),
|
||||
&AzToolsFramework::Thumbnailer::ThumbnailerRendererRequests::RenderThumbnail,
|
||||
m_key,
|
||||
MeshThumbnailSize);
|
||||
RPI::ModelAsset::RTTI_Type(), &AzToolsFramework::Thumbnailer::ThumbnailerRendererRequests::RenderThumbnail, m_key,
|
||||
ModelThumbnailSize);
|
||||
// wait for response from thumbnail renderer
|
||||
m_renderWait.acquire();
|
||||
}
|
||||
|
||||
MeshThumbnail::~MeshThumbnail()
|
||||
ModelThumbnail::~ModelThumbnail()
|
||||
{
|
||||
AzToolsFramework::Thumbnailer::ThumbnailerRendererNotificationBus::Handler::BusDisconnect();
|
||||
AzFramework::AssetCatalogEventBus::Handler::BusDisconnect();
|
||||
}
|
||||
|
||||
void MeshThumbnail::ThumbnailRendered(QPixmap& thumbnailImage)
|
||||
void ModelThumbnail::ThumbnailRendered(QPixmap& thumbnailImage)
|
||||
{
|
||||
m_pixmap = thumbnailImage;
|
||||
m_renderWait.release();
|
||||
}
|
||||
|
||||
void MeshThumbnail::ThumbnailFailedToRender()
|
||||
void ModelThumbnail::ThumbnailFailedToRender()
|
||||
{
|
||||
m_state = State::Failed;
|
||||
m_renderWait.release();
|
||||
}
|
||||
|
||||
void MeshThumbnail::OnCatalogAssetChanged([[maybe_unused]] const AZ::Data::AssetId& assetId)
|
||||
void ModelThumbnail::OnCatalogAssetChanged([[maybe_unused]] const AZ::Data::AssetId& assetId)
|
||||
{
|
||||
if (m_assetId == assetId &&
|
||||
m_state == State::Ready)
|
||||
if (m_assetId == assetId && m_state == State::Ready)
|
||||
{
|
||||
m_state = State::Unloaded;
|
||||
Load();
|
||||
@@ -78,27 +75,27 @@ namespace AZ
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// MeshThumbnailCache
|
||||
// ModelThumbnailCache
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
MeshThumbnailCache::MeshThumbnailCache()
|
||||
: ThumbnailCache<MeshThumbnail>()
|
||||
ModelThumbnailCache::ModelThumbnailCache()
|
||||
: ThumbnailCache<ModelThumbnail>()
|
||||
{
|
||||
}
|
||||
|
||||
MeshThumbnailCache::~MeshThumbnailCache() = default;
|
||||
ModelThumbnailCache::~ModelThumbnailCache() = default;
|
||||
|
||||
int MeshThumbnailCache::GetPriority() const
|
||||
int ModelThumbnailCache::GetPriority() const
|
||||
{
|
||||
// Material thumbnails override default source thumbnails, so carry higher priority
|
||||
// Thumbnails override default source thumbnails, so carry higher priority
|
||||
return 1;
|
||||
}
|
||||
|
||||
const char* MeshThumbnailCache::GetProviderName() const
|
||||
const char* ModelThumbnailCache::GetProviderName() const
|
||||
{
|
||||
return ProviderName;
|
||||
}
|
||||
|
||||
bool MeshThumbnailCache::IsSupportedThumbnail(AzToolsFramework::Thumbnailer::SharedThumbnailKey key) const
|
||||
bool ModelThumbnailCache::IsSupportedThumbnail(AzToolsFramework::Thumbnailer::SharedThumbnailKey key) const
|
||||
{
|
||||
return GetAssetId(key, RPI::ModelAsset::RTTI_Type()).IsValid();
|
||||
}
|
||||
@@ -106,4 +103,4 @@ namespace AZ
|
||||
} // namespace LyIntegration
|
||||
} // namespace AZ
|
||||
|
||||
#include <Mesh/moc_MeshThumbnail.cpp>
|
||||
#include <Thumbnails/moc_ModelThumbnail.cpp>
|
||||
@@ -0,0 +1,67 @@
|
||||
/*
|
||||
* 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 ModelThumbnail
|
||||
: public AzToolsFramework::Thumbnailer::Thumbnail
|
||||
, public AzToolsFramework::Thumbnailer::ThumbnailerRendererNotificationBus::Handler
|
||||
, private AzFramework::AssetCatalogEventBus::Handler
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
ModelThumbnail(AzToolsFramework::Thumbnailer::SharedThumbnailKey key);
|
||||
~ModelThumbnail() override;
|
||||
|
||||
//! AzToolsFramework::ThumbnailerRendererNotificationBus::Handler overrides...
|
||||
void ThumbnailRendered(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 ModelThumbnailCache : public AzToolsFramework::Thumbnailer::ThumbnailCache<ModelThumbnail>
|
||||
{
|
||||
public:
|
||||
ModelThumbnailCache();
|
||||
~ModelThumbnailCache() override;
|
||||
|
||||
int GetPriority() const override;
|
||||
const char* GetProviderName() const override;
|
||||
|
||||
static constexpr const char* ProviderName = "Model Thumbnails";
|
||||
|
||||
protected:
|
||||
bool IsSupportedThumbnail(AzToolsFramework::Thumbnailer::SharedThumbnailKey key) const override;
|
||||
};
|
||||
} // namespace Thumbnails
|
||||
} // namespace LyIntegration
|
||||
} // namespace AZ
|
||||
+25
-4
@@ -6,9 +6,11 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include <AzToolsFramework/AssetBrowser/AssetBrowserEntry.h>
|
||||
#include <Atom/RPI.Reflect/Asset/AssetUtils.h>
|
||||
#include <Atom/RPI.Reflect/Material/MaterialAsset.h>
|
||||
#include <Atom/RPI.Reflect/Model/ModelAsset.h>
|
||||
#include <Atom/RPI.Reflect/System/AnyAsset.h>
|
||||
#include <AzToolsFramework/AssetBrowser/AssetBrowserEntry.h>
|
||||
#include <Source/Thumbnails/Preview/CommonPreviewer.h>
|
||||
#include <Source/Thumbnails/Preview/CommonPreviewerFactory.h>
|
||||
#include <Source/Thumbnails/ThumbnailUtils.h>
|
||||
@@ -24,9 +26,28 @@ namespace AZ
|
||||
|
||||
bool CommonPreviewerFactory::IsEntrySupported(const AzToolsFramework::AssetBrowser::AssetBrowserEntry* entry) const
|
||||
{
|
||||
return
|
||||
Thumbnails::GetAssetId(entry->GetThumbnailKey(), RPI::MaterialAsset::RTTI_Type()).IsValid() ||
|
||||
Thumbnails::GetAssetId(entry->GetThumbnailKey(), RPI::ModelAsset::RTTI_Type()).IsValid();
|
||||
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;
|
||||
}
|
||||
|
||||
const QString& CommonPreviewerFactory::GetName() const
|
||||
|
||||
+9
-53
@@ -8,11 +8,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <Atom/RPI.Public/Base.h>
|
||||
#include <Atom/RPI.Reflect/Asset/AssetUtils.h>
|
||||
#include <Atom/RPI.Reflect/Material/MaterialAsset.h>
|
||||
#include <Atom/RPI.Reflect/Model/ModelAsset.h>
|
||||
#include <Atom/RPI.Reflect/System/AnyAsset.h>
|
||||
#include <AzCore/Memory/Memory.h>
|
||||
|
||||
namespace AZ
|
||||
{
|
||||
@@ -20,59 +16,19 @@ namespace AZ
|
||||
{
|
||||
namespace Thumbnails
|
||||
{
|
||||
//! Provides custom rendering of material and model thumbnails
|
||||
//! Provides custom rendering of preeview images
|
||||
class CommonPreviewContent
|
||||
{
|
||||
public:
|
||||
AZ_CLASS_ALLOCATOR(CommonPreviewContent, AZ::SystemAllocator, 0);
|
||||
|
||||
CommonPreviewContent(
|
||||
RPI::ScenePtr scene,
|
||||
RPI::ViewPtr view,
|
||||
AZ::Uuid entityContextId,
|
||||
const Data::AssetId& modelAssetId,
|
||||
const Data::AssetId& materialAssetId,
|
||||
const Data::AssetId& lightingPresetAssetId);
|
||||
~CommonPreviewContent();
|
||||
|
||||
void Load();
|
||||
bool IsReady() const;
|
||||
bool IsError() const;
|
||||
void ReportErrors();
|
||||
void UpdateScene();
|
||||
|
||||
private:
|
||||
void UpdateModel();
|
||||
void UpdateLighting();
|
||||
void UpdateCamera();
|
||||
|
||||
static constexpr float AspectRatio = 1.0f;
|
||||
static constexpr float NearDist = 0.001f;
|
||||
static constexpr float FarDist = 100.0f;
|
||||
static constexpr float FieldOfView = Constants::HalfPi;
|
||||
static constexpr float CameraRotationAngle = Constants::QuarterPi / 2.0f;
|
||||
|
||||
RPI::ScenePtr m_scene;
|
||||
RPI::ViewPtr m_view;
|
||||
AZ::Uuid m_entityContextId;
|
||||
Entity* m_modelEntity = nullptr;
|
||||
|
||||
static constexpr const char* DefaultLightingPresetPath = "lightingpresets/thumbnail.lightingpreset.azasset";
|
||||
const Data::AssetId DefaultLightingPresetAssetId = AZ::RPI::AssetUtils::GetAssetIdForProductPath(DefaultLightingPresetPath);
|
||||
Data::Asset<RPI::AnyAsset> m_defaultLightingPresetAsset;
|
||||
Data::Asset<RPI::AnyAsset> m_lightingPresetAsset;
|
||||
|
||||
//! Model asset about to be rendered
|
||||
static constexpr const char* DefaultModelPath = "models/sphere.azmodel";
|
||||
const Data::AssetId DefaultModelAssetId = AZ::RPI::AssetUtils::GetAssetIdForProductPath(DefaultModelPath);
|
||||
Data::Asset<RPI::ModelAsset> m_defaultModelAsset;
|
||||
Data::Asset<RPI::ModelAsset> m_modelAsset;
|
||||
|
||||
//! Material asset about to be rendered
|
||||
static constexpr const char* DefaultMaterialPath = "materials/basic_grey.azmaterial";
|
||||
const Data::AssetId DefaultMaterialAssetId = AZ::RPI::AssetUtils::GetAssetIdForProductPath(DefaultMaterialPath);
|
||||
Data::Asset<RPI::MaterialAsset> m_defaultMaterialAsset;
|
||||
Data::Asset<RPI::MaterialAsset> m_materialAsset;
|
||||
CommonPreviewContent() = default;
|
||||
virtual ~CommonPreviewContent() = default;
|
||||
virtual void Load() = 0;
|
||||
virtual bool IsReady() const = 0;
|
||||
virtual bool IsError() const = 0;
|
||||
virtual void ReportErrors() = 0;
|
||||
virtual void UpdateScene() = 0;
|
||||
};
|
||||
} // namespace Thumbnails
|
||||
} // namespace LyIntegration
|
||||
|
||||
+15
-41
@@ -19,13 +19,10 @@
|
||||
#include <AzCore/Math/Transform.h>
|
||||
#include <AzFramework/Scene/Scene.h>
|
||||
#include <AzFramework/Scene/SceneSystemInterface.h>
|
||||
#include <AzToolsFramework/AssetBrowser/AssetBrowserBus.h>
|
||||
#include <AzToolsFramework/Thumbnails/ThumbnailerBus.h>
|
||||
#include <Thumbnails/Rendering/CommonPreviewRenderer.h>
|
||||
#include <Thumbnails/Rendering/CommonPreviewRendererCaptureState.h>
|
||||
#include <Thumbnails/Rendering/CommonPreviewRendererIdleState.h>
|
||||
#include <Thumbnails/Rendering/CommonPreviewRendererLoadState.h>
|
||||
#include <Thumbnails/ThumbnailUtils.h>
|
||||
|
||||
namespace AZ
|
||||
{
|
||||
@@ -35,11 +32,7 @@ namespace AZ
|
||||
{
|
||||
CommonPreviewRenderer::CommonPreviewRenderer()
|
||||
{
|
||||
// CommonPreviewRenderer supports both models and materials
|
||||
AzToolsFramework::Thumbnailer::ThumbnailerRendererRequestBus::MultiHandler::BusConnect(RPI::MaterialAsset::RTTI_Type());
|
||||
AzToolsFramework::Thumbnailer::ThumbnailerRendererRequestBus::MultiHandler::BusConnect(RPI::ModelAsset::RTTI_Type());
|
||||
PreviewerFeatureProcessorProviderBus::Handler::BusConnect();
|
||||
SystemTickBus::Handler::BusConnect();
|
||||
|
||||
m_entityContext = AZStd::make_unique<AzFramework::EntityContext>();
|
||||
m_entityContext->InitContext();
|
||||
@@ -95,8 +88,6 @@ namespace AZ
|
||||
|
||||
CommonPreviewRenderer::~CommonPreviewRenderer()
|
||||
{
|
||||
AzToolsFramework::Thumbnailer::ThumbnailerRendererRequestBus::MultiHandler::BusDisconnect();
|
||||
SystemTickBus::Handler::BusDisconnect();
|
||||
PreviewerFeatureProcessorProviderBus::Handler::BusDisconnect();
|
||||
|
||||
SetState(CommonPreviewRenderer::State::None);
|
||||
@@ -110,6 +101,21 @@ namespace AZ
|
||||
m_frameworkScene->UnsetSubsystem(m_entityContext.get());
|
||||
}
|
||||
|
||||
RPI::ScenePtr CommonPreviewRenderer::GetScene() const
|
||||
{
|
||||
return m_scene;
|
||||
}
|
||||
|
||||
RPI::ViewPtr CommonPreviewRenderer::GetView() const
|
||||
{
|
||||
return m_view;
|
||||
}
|
||||
|
||||
AZ::Uuid CommonPreviewRenderer::GetEntityContextId() const
|
||||
{
|
||||
return m_entityContext->GetContextId();
|
||||
}
|
||||
|
||||
void CommonPreviewRenderer::AddCaptureRequest(const CaptureRequest& captureRequest)
|
||||
{
|
||||
m_captureRequestQueue.push(captureRequest);
|
||||
@@ -227,11 +233,6 @@ namespace AZ
|
||||
m_renderPipeline->RemoveFromRenderTick();
|
||||
}
|
||||
|
||||
void CommonPreviewRenderer::OnSystemTick()
|
||||
{
|
||||
AzToolsFramework::Thumbnailer::ThumbnailerRendererRequestBus::ExecuteQueuedEvents();
|
||||
}
|
||||
|
||||
void CommonPreviewRenderer::GetRequiredFeatureProcessors(AZStd::unordered_set<AZStd::string>& featureProcessors) const
|
||||
{
|
||||
featureProcessors.insert({
|
||||
@@ -253,33 +254,6 @@ namespace AZ
|
||||
"AZ::Render::PostProcessFeatureProcessor",
|
||||
"AZ::Render::SkyBoxFeatureProcessor" });
|
||||
}
|
||||
|
||||
void CommonPreviewRenderer::RenderThumbnail(AzToolsFramework::Thumbnailer::SharedThumbnailKey thumbnailKey, int thumbnailSize)
|
||||
{
|
||||
AddCaptureRequest(
|
||||
{ thumbnailSize,
|
||||
AZStd::make_shared<CommonPreviewContent>(
|
||||
m_scene, m_view, m_entityContext->GetContextId(),
|
||||
GetAssetId(thumbnailKey, RPI::ModelAsset::RTTI_Type()),
|
||||
GetAssetId(thumbnailKey, RPI::MaterialAsset::RTTI_Type()),
|
||||
GetAssetId(thumbnailKey, RPI::AnyAsset::RTTI_Type())),
|
||||
[thumbnailKey]()
|
||||
{
|
||||
AzToolsFramework::Thumbnailer::ThumbnailerRendererNotificationBus::Event(
|
||||
thumbnailKey, &AzToolsFramework::Thumbnailer::ThumbnailerRendererNotifications::ThumbnailFailedToRender);
|
||||
},
|
||||
[thumbnailKey](const QImage& image)
|
||||
{
|
||||
AzToolsFramework::Thumbnailer::ThumbnailerRendererNotificationBus::Event(
|
||||
thumbnailKey, &AzToolsFramework::Thumbnailer::ThumbnailerRendererNotifications::ThumbnailRendered,
|
||||
QPixmap::fromImage(image));
|
||||
} });
|
||||
}
|
||||
|
||||
bool CommonPreviewRenderer::Installed() const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
} // namespace Thumbnails
|
||||
} // namespace LyIntegration
|
||||
} // namespace AZ
|
||||
|
||||
+9
-23
@@ -12,22 +12,15 @@
|
||||
#include <Atom/RPI.Public/Pass/AttachmentReadback.h>
|
||||
#include <AtomLyIntegration/CommonFeatures/Thumbnails/PreviewerFeatureProcessorProviderBus.h>
|
||||
#include <AzFramework/Entity/GameEntityContextComponent.h>
|
||||
#include <AzToolsFramework/Thumbnails/Thumbnail.h>
|
||||
#include <AzToolsFramework/Thumbnails/ThumbnailerBus.h>
|
||||
#include <Thumbnails/Rendering/CommonPreviewContent.h>
|
||||
#include <Thumbnails/Thumbnail.h>
|
||||
#include <Thumbnails/Rendering/CommonPreviewRendererState.h>
|
||||
|
||||
namespace AzFramework
|
||||
{
|
||||
class Scene;
|
||||
}
|
||||
|
||||
// Disables warning messages triggered by the Qt library
|
||||
// 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 <QPixmap>
|
||||
AZ_POP_DISABLE_WARNING
|
||||
class QImage;
|
||||
|
||||
namespace AZ
|
||||
{
|
||||
@@ -35,13 +28,9 @@ namespace AZ
|
||||
{
|
||||
namespace Thumbnails
|
||||
{
|
||||
class CommonPreviewRendererState;
|
||||
|
||||
//! Provides custom rendering of material and model thumbnails
|
||||
class CommonPreviewRenderer
|
||||
: public AzToolsFramework::Thumbnailer::ThumbnailerRendererRequestBus::MultiHandler
|
||||
, public SystemTickBus::Handler
|
||||
, public PreviewerFeatureProcessorProviderBus::Handler
|
||||
class CommonPreviewRenderer final
|
||||
: public PreviewerFeatureProcessorProviderBus::Handler
|
||||
{
|
||||
public:
|
||||
AZ_CLASS_ALLOCATOR(CommonPreviewRenderer, AZ::SystemAllocator, 0);
|
||||
@@ -49,7 +38,7 @@ namespace AZ
|
||||
CommonPreviewRenderer();
|
||||
~CommonPreviewRenderer();
|
||||
|
||||
struct CaptureRequest
|
||||
struct CaptureRequest final
|
||||
{
|
||||
int m_size = 512;
|
||||
AZStd::shared_ptr<CommonPreviewContent> m_content;
|
||||
@@ -57,6 +46,10 @@ namespace AZ
|
||||
AZStd::function<void(const QImage&)> m_captureCompleteCallback;
|
||||
};
|
||||
|
||||
RPI::ScenePtr GetScene() const;
|
||||
RPI::ViewPtr GetView() const;
|
||||
AZ::Uuid GetEntityContextId() const;
|
||||
|
||||
void AddCaptureRequest(const CaptureRequest& captureRequest);
|
||||
|
||||
enum class State : AZ::s8
|
||||
@@ -84,16 +77,9 @@ namespace AZ
|
||||
void EndCapture();
|
||||
|
||||
private:
|
||||
//! SystemTickBus::Handler interface overrides...
|
||||
void OnSystemTick() override;
|
||||
|
||||
//! Render::PreviewerFeatureProcessorProviderBus::Handler interface overrides...
|
||||
void GetRequiredFeatureProcessors(AZStd::unordered_set<AZStd::string>& featureProcessors) const override;
|
||||
|
||||
//! ThumbnailerRendererRequestsBus::Handler interface overrides...
|
||||
void RenderThumbnail(AzToolsFramework::Thumbnailer::SharedThumbnailKey thumbnailKey, int thumbnailSize) override;
|
||||
bool Installed() const override;
|
||||
|
||||
static constexpr float AspectRatio = 1.0f;
|
||||
static constexpr float NearDist = 0.001f;
|
||||
static constexpr float FarDist = 100.0f;
|
||||
|
||||
+10
-5
@@ -45,8 +45,6 @@ set(FILES
|
||||
Source/Material/EditorMaterialSystemComponent.h
|
||||
Source/Material/MaterialBrowserInteractions.h
|
||||
Source/Material/MaterialBrowserInteractions.cpp
|
||||
Source/Material/MaterialThumbnail.cpp
|
||||
Source/Material/MaterialThumbnail.h
|
||||
Source/Mesh/EditorMeshComponent.h
|
||||
Source/Mesh/EditorMeshComponent.cpp
|
||||
Source/Mesh/EditorMeshStats.h
|
||||
@@ -55,8 +53,6 @@ set(FILES
|
||||
Source/Mesh/EditorMeshSystemComponent.h
|
||||
Source/Mesh/EditorMeshStatsSerializer.cpp
|
||||
Source/Mesh/EditorMeshStatsSerializer.h
|
||||
Source/Mesh/MeshThumbnail.h
|
||||
Source/Mesh/MeshThumbnail.cpp
|
||||
Source/OcclusionCullingPlane/EditorOcclusionCullingPlaneComponent.h
|
||||
Source/OcclusionCullingPlane/EditorOcclusionCullingPlaneComponent.cpp
|
||||
Source/PostProcess/EditorPostFxLayerComponent.cpp
|
||||
@@ -102,7 +98,6 @@ set(FILES
|
||||
Source/Thumbnails/Preview/CommonPreviewer.ui
|
||||
Source/Thumbnails/Preview/CommonPreviewerFactory.cpp
|
||||
Source/Thumbnails/Preview/CommonPreviewerFactory.h
|
||||
Source/Thumbnails/Rendering/CommonPreviewContent.cpp
|
||||
Source/Thumbnails/Rendering/CommonPreviewContent.h
|
||||
Source/Thumbnails/Rendering/CommonPreviewRenderer.cpp
|
||||
Source/Thumbnails/Rendering/CommonPreviewRenderer.h
|
||||
@@ -113,6 +108,16 @@ set(FILES
|
||||
Source/Thumbnails/Rendering/CommonPreviewRendererLoadState.h
|
||||
Source/Thumbnails/Rendering/CommonPreviewRendererCaptureState.cpp
|
||||
Source/Thumbnails/Rendering/CommonPreviewRendererCaptureState.h
|
||||
Source/Thumbnails/CommonThumbnailPreviewContent.cpp
|
||||
Source/Thumbnails/CommonThumbnailPreviewContent.h
|
||||
Source/Thumbnails/CommonThumbnailRenderer.cpp
|
||||
Source/Thumbnails/CommonThumbnailRenderer.h
|
||||
Source/Thumbnails/MaterialThumbnail.cpp
|
||||
Source/Thumbnails/MaterialThumbnail.h
|
||||
Source/Thumbnails/ModelThumbnail.cpp
|
||||
Source/Thumbnails/ModelThumbnail.h
|
||||
Source/Thumbnails/LightingPresetThumbnail.cpp
|
||||
Source/Thumbnails/LightingPresetThumbnail.h
|
||||
Source/Scripting/EditorEntityReferenceComponent.cpp
|
||||
Source/Scripting/EditorEntityReferenceComponent.h
|
||||
Source/SurfaceData/EditorSurfaceDataMeshComponent.cpp
|
||||
|
||||
Reference in New Issue
Block a user