Fix for viewport not updating correctly when switching camera views (#5719)

Signed-off-by: Tom Hulton-Harrop <82228511+hultonha@users.noreply.github.com>
This commit is contained in:
Tom Hulton-Harrop
2021-11-18 09:11:46 +00:00
committed by GitHub
parent d222aeef48
commit b533a9566a
2 changed files with 14 additions and 1 deletions
@@ -10,6 +10,7 @@
#include <Atom/RPI.Public/Base.h>
#include <Atom/RPI.Public/View.h>
#include <Atom/RPI.Public/ViewportContextBus.h>
#include <AzFramework/Viewport/CameraState.h>
#include <AzToolsFramework/Viewport/ViewportMessages.h>
@@ -17,7 +18,9 @@ namespace AtomToolsFramework
{
//! A concrete implementation of the ViewportInteractionRequestBus.
//! Primarily concerned with picking (screen to world and world to screen transformations).
class ViewportInteractionImpl : public AzToolsFramework::ViewportInteraction::ViewportInteractionRequestBus::Handler
class ViewportInteractionImpl
: public AzToolsFramework::ViewportInteraction::ViewportInteractionRequestBus::Handler
, private AZ::RPI::ViewportContextIdNotificationBus::Handler
{
public:
explicit ViewportInteractionImpl(AZ::RPI::ViewPtr viewPtr);
@@ -37,6 +40,9 @@ namespace AtomToolsFramework
AZStd::function<float()> m_deviceScalingFactorFn; //! Callback to determine the device scaling factor.
private:
// ViewportContextIdNotificationBus overrides ...
void OnViewportDefaultViewChanged(AZ::RPI::ViewPtr view) override;
AZ::RPI::ViewPtr m_viewPtr;
};
} // namespace AtomToolsFramework
@@ -19,10 +19,12 @@ namespace AtomToolsFramework
void ViewportInteractionImpl::Connect(const AzFramework::ViewportId viewportId)
{
AzToolsFramework::ViewportInteraction::ViewportInteractionRequestBus::Handler::BusConnect(viewportId);
AZ::RPI::ViewportContextIdNotificationBus::Handler::BusConnect(viewportId);
}
void ViewportInteractionImpl::Disconnect()
{
AZ::RPI::ViewportContextIdNotificationBus::Handler::BusDisconnect();
AzToolsFramework::ViewportInteraction::ViewportInteractionRequestBus::Handler::BusDisconnect();
}
@@ -58,4 +60,9 @@ namespace AtomToolsFramework
{
return m_deviceScalingFactorFn();
}
void ViewportInteractionImpl::OnViewportDefaultViewChanged(AZ::RPI::ViewPtr view)
{
m_viewPtr = AZStd::move(view);
}
} // namespace AtomToolsFramework