Ensure camera system correctly consumes events when it is active (#2346)
* add typename for struct initializer Signed-off-by: hultonha <hultonha@amazon.co.uk> * fix for ensuring while the camera is 'active', events are consumed and not propagated Signed-off-by: hultonha <hultonha@amazon.co.uk> * refactor how we decide which priority to repsond to events to Signed-off-by: hultonha <hultonha@amazon.co.uk> * also -> only Signed-off-by: hultonha <hultonha@amazon.co.uk>
This commit is contained in:
+13
-8
@@ -117,19 +117,24 @@ namespace AtomToolsFramework
|
||||
AzFramework::ViewportDebugDisplayEventBus::Handler::BusDisconnect();
|
||||
}
|
||||
|
||||
// should the camera system respond to this particular event
|
||||
static bool ShouldHandle(const AzFramework::ViewportControllerPriority priority, const bool exclusive)
|
||||
// what priority should the camera system respond to
|
||||
static AzFramework::ViewportControllerPriority GetPriority(const AzFramework::CameraSystem& cameraSystem)
|
||||
{
|
||||
// ModernViewportCameraControllerInstance receives events at all priorities, it should only respond
|
||||
// to normal priority events if it is not in 'exclusive' mode and when in 'exclusive' mode it should
|
||||
// only respond to the highest priority events
|
||||
return !exclusive && priority == AzFramework::ViewportControllerPriority::Normal ||
|
||||
exclusive && priority == AzFramework::ViewportControllerPriority::Highest;
|
||||
// ModernViewportCameraControllerInstance receives events at all priorities, when it is in 'exclusive' mode
|
||||
// or it is actively handling events (essentially when the camera system is 'active' and responding to inputs)
|
||||
// it should only respond to the highest priority
|
||||
if (cameraSystem.m_cameras.Exclusive() || cameraSystem.HandlingEvents())
|
||||
{
|
||||
return AzFramework::ViewportControllerPriority::Highest;
|
||||
}
|
||||
|
||||
// otherwise it should only respond to normal priority events
|
||||
return AzFramework::ViewportControllerPriority::Normal;
|
||||
}
|
||||
|
||||
bool ModernViewportCameraControllerInstance::HandleInputChannelEvent(const AzFramework::ViewportControllerInputEvent& event)
|
||||
{
|
||||
if (ShouldHandle(event.m_priority, m_cameraSystem.m_cameras.Exclusive()))
|
||||
if (event.m_priority == GetPriority(m_cameraSystem))
|
||||
{
|
||||
return m_cameraSystem.HandleEvents(AzFramework::BuildInputEvent(event.m_inputChannel));
|
||||
}
|
||||
|
||||
@@ -88,7 +88,7 @@ namespace AtomToolsFramework
|
||||
[this](const AzFramework::InputChannel* inputChannel, QEvent* event)
|
||||
{
|
||||
AzFramework::NativeWindowHandle windowId = reinterpret_cast<AzFramework::NativeWindowHandle>(winId());
|
||||
if (m_controllerList->HandleInputChannelEvent({GetId(), windowId, *inputChannel}))
|
||||
if (m_controllerList->HandleInputChannelEvent(AzFramework::ViewportControllerInputEvent{GetId(), windowId, *inputChannel}))
|
||||
{
|
||||
// If the controller handled the input event, mark the event as accepted so it doesn't continue to propagate.
|
||||
if (event)
|
||||
|
||||
Reference in New Issue
Block a user