Fix for events that should have been consumed by manipulators (#3108)

* fix for events that should have been consumed by manipulators making their way to the main viewport handler

Signed-off-by: hultonha <hultonha@amazon.co.uk>

* add missing include for SANDBOX_API macro

Signed-off-by: hultonha <hultonha@amazon.co.uk>

* add dependency on Qt::Test for AzToolsFrameworkTestCommon

Signed-off-by: hultonha <hultonha@amazon.co.uk>

* fix order of buttons passed to QMouseEvent

Signed-off-by: hultonha <hultonha@amazon.co.uk>

* potential fix for vtable error on linux

Signed-off-by: hultonha <hultonha@amazon.co.uk>

* potential fix for vtable error on linux again

Signed-off-by: hultonha <hultonha@amazon.co.uk>
This commit is contained in:
hultonha
2021-08-17 17:09:17 +01:00
committed by GitHub
parent b98a67e836
commit 7f603c59ad
12 changed files with 253 additions and 75 deletions
+16 -7
View File
@@ -28,6 +28,8 @@ namespace SandboxEditor
{
}
ViewportManipulatorControllerInstance::~ViewportManipulatorControllerInstance() = default;
AzToolsFramework::ViewportInteraction::MouseButton ViewportManipulatorControllerInstance::GetMouseButton(
const AzFramework::InputChannel& inputChannel)
{
@@ -103,14 +105,21 @@ namespace SandboxEditor
// Cache the ray trace results when doing manipulator interaction checks, no need to recalculate after
if (event.m_priority == ManipulatorPriority)
{
AzFramework::ScreenPoint screenPosition = AzFramework::ScreenPoint(0, 0);
ViewportMouseCursorRequestBus::EventResult(
screenPosition, GetViewportId(), &ViewportMouseCursorRequestBus::Events::ViewportCursorScreenPosition);
const auto* position = event.m_inputChannel.GetCustomData<AzFramework::InputChannel::PositionData2D>();
AZ_Assert(position, "Expected PositionData2D but found nullptr");
m_mouseInteraction.m_mousePick.m_screenCoordinates = screenPosition;
AzFramework::WindowSize windowSize;
AzFramework::WindowRequestBus::EventResult(
windowSize, event.m_windowHandle, &AzFramework::WindowRequestBus::Events::GetClientAreaSize);
auto screenPoint = AzFramework::ScreenPoint(
position->m_normalizedPosition.GetX() * windowSize.m_width,
position->m_normalizedPosition.GetY() * windowSize.m_height);
m_mouseInteraction.m_mousePick.m_screenCoordinates = screenPoint;
AZStd::optional<ProjectedViewportRay> ray;
ViewportInteractionRequestBus::EventResult(
ray, GetViewportId(), &ViewportInteractionRequestBus::Events::ViewportScreenToWorldRay, screenPosition);
ray, GetViewportId(), &ViewportInteractionRequestBus::Events::ViewportScreenToWorldRay, screenPoint);
if (ray.has_value())
{
@@ -118,6 +127,7 @@ namespace SandboxEditor
m_mouseInteraction.m_mousePick.m_rayDirection = ray.value().direction;
}
}
eventType = MouseEvent::Move;
}
else if (auto mouseButton = GetMouseButton(event.m_inputChannel); mouseButton != MouseButton::None)
@@ -217,8 +227,7 @@ namespace SandboxEditor
interactionHandled, AzToolsFramework::GetEntityContextId(), targetInteractionEvent, mouseInteractionEvent);
}
// Only filter button/key press events, not release events
return interactionHandled && event.m_inputChannel.IsActive();
return interactionHandled;
}
void ViewportManipulatorControllerInstance::ResetInputChannels()