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

Signed-off-by: Tom Hulton-Harrop <82228511+hultonha@users.noreply.github.com>
monroegm-disable-blank-issue-2
Tom Hulton-Harrop 4 years ago committed by GitHub
parent d222aeef48
commit b533a9566a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -10,6 +10,7 @@
#include <Atom/RPI.Public/Base.h> #include <Atom/RPI.Public/Base.h>
#include <Atom/RPI.Public/View.h> #include <Atom/RPI.Public/View.h>
#include <Atom/RPI.Public/ViewportContextBus.h>
#include <AzFramework/Viewport/CameraState.h> #include <AzFramework/Viewport/CameraState.h>
#include <AzToolsFramework/Viewport/ViewportMessages.h> #include <AzToolsFramework/Viewport/ViewportMessages.h>
@ -17,7 +18,9 @@ namespace AtomToolsFramework
{ {
//! A concrete implementation of the ViewportInteractionRequestBus. //! A concrete implementation of the ViewportInteractionRequestBus.
//! Primarily concerned with picking (screen to world and world to screen transformations). //! 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: public:
explicit ViewportInteractionImpl(AZ::RPI::ViewPtr viewPtr); explicit ViewportInteractionImpl(AZ::RPI::ViewPtr viewPtr);
@ -37,6 +40,9 @@ namespace AtomToolsFramework
AZStd::function<float()> m_deviceScalingFactorFn; //! Callback to determine the device scaling factor. AZStd::function<float()> m_deviceScalingFactorFn; //! Callback to determine the device scaling factor.
private: private:
// ViewportContextIdNotificationBus overrides ...
void OnViewportDefaultViewChanged(AZ::RPI::ViewPtr view) override;
AZ::RPI::ViewPtr m_viewPtr; AZ::RPI::ViewPtr m_viewPtr;
}; };
} // namespace AtomToolsFramework } // namespace AtomToolsFramework

@ -19,10 +19,12 @@ namespace AtomToolsFramework
void ViewportInteractionImpl::Connect(const AzFramework::ViewportId viewportId) void ViewportInteractionImpl::Connect(const AzFramework::ViewportId viewportId)
{ {
AzToolsFramework::ViewportInteraction::ViewportInteractionRequestBus::Handler::BusConnect(viewportId); AzToolsFramework::ViewportInteraction::ViewportInteractionRequestBus::Handler::BusConnect(viewportId);
AZ::RPI::ViewportContextIdNotificationBus::Handler::BusConnect(viewportId);
} }
void ViewportInteractionImpl::Disconnect() void ViewportInteractionImpl::Disconnect()
{ {
AZ::RPI::ViewportContextIdNotificationBus::Handler::BusDisconnect();
AzToolsFramework::ViewportInteraction::ViewportInteractionRequestBus::Handler::BusDisconnect(); AzToolsFramework::ViewportInteraction::ViewportInteractionRequestBus::Handler::BusDisconnect();
} }
@ -58,4 +60,9 @@ namespace AtomToolsFramework
{ {
return m_deviceScalingFactorFn(); return m_deviceScalingFactorFn();
} }
void ViewportInteractionImpl::OnViewportDefaultViewChanged(AZ::RPI::ViewPtr view)
{
m_viewPtr = AZStd::move(view);
}
} // namespace AtomToolsFramework } // namespace AtomToolsFramework

Loading…
Cancel
Save