You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
o3de/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Thumbnails/Rendering/CommonPreviewRendererCaptur...

58 lines
2.0 KiB
C++

/*
* 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 <Thumbnails/Rendering/CommonPreviewRenderer.h>
#include <Thumbnails/Rendering/CommonPreviewRendererCaptureState.h>
namespace AZ
{
namespace LyIntegration
{
namespace Thumbnails
{
CommonPreviewRendererCaptureState::CommonPreviewRendererCaptureState(CommonPreviewRenderer* renderer)
: CommonPreviewRendererState(renderer)
{
}
void CommonPreviewRendererCaptureState::Start()
{
m_ticksToCapture = 1;
m_renderer->UpdateScene();
TickBus::Handler::BusConnect();
}
void CommonPreviewRendererCaptureState::Stop()
{
m_renderer->EndCapture();
TickBus::Handler::BusDisconnect();
Render::FrameCaptureNotificationBus::Handler::BusDisconnect();
}
void CommonPreviewRendererCaptureState::OnTick([[maybe_unused]] float deltaTime, [[maybe_unused]] ScriptTimePoint time)
{
if (m_ticksToCapture-- <= 0)
{
// Reset the capture flag if the capture request was successful. Otherwise try capture it again next tick.
if (m_renderer->StartCapture())
{
Render::FrameCaptureNotificationBus::Handler::BusConnect();
TickBus::Handler::BusDisconnect();
}
}
}
void CommonPreviewRendererCaptureState::OnCaptureFinished(
[[maybe_unused]] Render::FrameCaptureResult result, [[maybe_unused]] const AZStd::string& info)
{
m_renderer->CompleteCaptureRequest();
}
} // namespace Thumbnails
} // namespace LyIntegration
} // namespace AZ