Formatting-only change - Update Manipulator and Viewport AzToolsFramework files (#1143)
* formatting changes to AzToolsFramework viewport related types + API comment style updates * minor format change - include ordering * improve formatting by moving comment * fix compile error and switch to use AZ_Printf * small polish changes after review feedback
This commit is contained in:
committed by
GitHub
parent
c751cda73d
commit
cf8a6761bf
@@ -1,14 +1,14 @@
|
||||
/*
|
||||
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
|
||||
* its licensors.
|
||||
*
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this
|
||||
* distribution (the "License"). All use of this software is governed by the License,
|
||||
* or, if provided, by the license below or the license accompanying this file. Do not
|
||||
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
*
|
||||
*/
|
||||
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
|
||||
* its licensors.
|
||||
*
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this
|
||||
* distribution (the "License"). All use of this software is governed by the License,
|
||||
* or, if provided, by the license below or the license accompanying this file. Do not
|
||||
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "EditorContextMenu.h"
|
||||
|
||||
@@ -16,8 +16,7 @@
|
||||
|
||||
namespace AzToolsFramework
|
||||
{
|
||||
void EditorContextMenuUpdate(
|
||||
EditorContextMenu& contextMenu, const ViewportInteraction::MouseInteractionEvent& mouseInteraction)
|
||||
void EditorContextMenuUpdate(EditorContextMenu& contextMenu, const ViewportInteraction::MouseInteractionEvent& mouseInteraction)
|
||||
{
|
||||
AZ_PROFILE_FUNCTION(AZ::Debug::ProfileCategory::AzToolsFramework);
|
||||
|
||||
@@ -26,18 +25,17 @@ namespace AzToolsFramework
|
||||
mouseInteraction.m_mouseEvent == ViewportInteraction::MouseEvent::Down)
|
||||
{
|
||||
contextMenu.m_shouldOpen = true;
|
||||
contextMenu.m_clickPoint = ViewportInteraction::QPointFromScreenPoint(
|
||||
mouseInteraction.m_mouseInteraction.m_mousePick.m_screenCoordinates);
|
||||
contextMenu.m_clickPoint =
|
||||
ViewportInteraction::QPointFromScreenPoint(mouseInteraction.m_mouseInteraction.m_mousePick.m_screenCoordinates);
|
||||
}
|
||||
|
||||
// disable shouldOpen if right clicking an moving the mouse
|
||||
if (mouseInteraction.m_mouseEvent == ViewportInteraction::MouseEvent::Move)
|
||||
{
|
||||
const QPoint currentScreenCoords = ViewportInteraction::QPointFromScreenPoint(
|
||||
mouseInteraction.m_mouseInteraction.m_mousePick.m_screenCoordinates);
|
||||
const QPoint currentScreenCoords =
|
||||
ViewportInteraction::QPointFromScreenPoint(mouseInteraction.m_mouseInteraction.m_mousePick.m_screenCoordinates);
|
||||
|
||||
contextMenu.m_shouldOpen = contextMenu.m_shouldOpen &&
|
||||
(currentScreenCoords - contextMenu.m_clickPoint).manhattanLength() < 2;
|
||||
contextMenu.m_shouldOpen = contextMenu.m_shouldOpen && (currentScreenCoords - contextMenu.m_clickPoint).manhattanLength() < 2;
|
||||
}
|
||||
|
||||
// do show the context menu
|
||||
@@ -58,9 +56,8 @@ namespace AzToolsFramework
|
||||
// Populate global context menu.
|
||||
const int contextMenuFlag = 0;
|
||||
EditorEvents::Bus::BroadcastReverse(
|
||||
&EditorEvents::PopulateEditorGlobalContextMenu,
|
||||
contextMenu.m_menu.data(), AzFramework::Vector2FromScreenPoint(
|
||||
mouseInteraction.m_mouseInteraction.m_mousePick.m_screenCoordinates),
|
||||
&EditorEvents::PopulateEditorGlobalContextMenu, contextMenu.m_menu.data(),
|
||||
AzFramework::Vector2FromScreenPoint(mouseInteraction.m_mouseInteraction.m_mousePick.m_screenCoordinates),
|
||||
contextMenuFlag);
|
||||
|
||||
if (!contextMenu.m_menu->isEmpty())
|
||||
@@ -70,4 +67,4 @@ namespace AzToolsFramework
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} // namespace AzToolsFramework
|
||||
|
||||
@@ -1,22 +1,22 @@
|
||||
/*
|
||||
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
|
||||
* its licensors.
|
||||
*
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this
|
||||
* distribution (the "License"). All use of this software is governed by the License,
|
||||
* or, if provided, by the license below or the license accompanying this file. Do not
|
||||
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
*
|
||||
*/
|
||||
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
|
||||
* its licensors.
|
||||
*
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this
|
||||
* distribution (the "License"). All use of this software is governed by the License,
|
||||
* or, if provided, by the license below or the license accompanying this file. Do not
|
||||
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <AzCore/std/smart_ptr/unique_ptr.h>
|
||||
|
||||
#include <QMenu>
|
||||
#include <QPoint>
|
||||
#include <QPointer>
|
||||
#include <QMenu>
|
||||
|
||||
namespace AzToolsFramework
|
||||
{
|
||||
@@ -25,7 +25,7 @@ namespace AzToolsFramework
|
||||
struct MouseInteractionEvent;
|
||||
}
|
||||
|
||||
/// State of when and where the right-click context menu should appear.
|
||||
//! State of when and where the right-click context menu should appear.
|
||||
struct EditorContextMenu final
|
||||
{
|
||||
bool m_shouldOpen = false;
|
||||
@@ -33,8 +33,6 @@ namespace AzToolsFramework
|
||||
QPointer<QMenu> m_menu;
|
||||
};
|
||||
|
||||
/// Update to run for context menu (when should it appear/disappear etc).
|
||||
void EditorContextMenuUpdate(
|
||||
EditorContextMenu& contextMenu,
|
||||
const ViewportInteraction::MouseInteractionEvent& mouseInteraction);
|
||||
//! Update to run for context menu (when should it appear/disappear etc).
|
||||
void EditorContextMenuUpdate(EditorContextMenu& contextMenu, const ViewportInteraction::MouseInteractionEvent& mouseInteraction);
|
||||
} // namespace AzToolsFramework
|
||||
|
||||
+21
-18
@@ -1,14 +1,14 @@
|
||||
/*
|
||||
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
|
||||
* its licensors.
|
||||
*
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this
|
||||
* distribution (the "License"). All use of this software is governed by the License,
|
||||
* or, if provided, by the license below or the license accompanying this file. Do not
|
||||
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
*
|
||||
*/
|
||||
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
|
||||
* its licensors.
|
||||
*
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this
|
||||
* distribution (the "License"). All use of this software is governed by the License,
|
||||
* or, if provided, by the license below or the license accompanying this file. Do not
|
||||
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "VertexContainerDisplay.h"
|
||||
|
||||
@@ -23,8 +23,7 @@ namespace AzToolsFramework
|
||||
const AZ::Vector3 DefaultVertexTextOffset = AZ::Vector3(0.0f, 0.0f, -0.1f);
|
||||
|
||||
void DisplayVertexContainerIndex(
|
||||
AzFramework::DebugDisplayRequests& debugDisplay,
|
||||
const AZ::Vector3& position, const size_t index, const float textSize)
|
||||
AzFramework::DebugDisplayRequests& debugDisplay, const AZ::Vector3& position, const size_t index, const float textSize)
|
||||
{
|
||||
AZStd::string indexFormat = AZStd::string::format("[%zu]", index);
|
||||
debugDisplay.DrawTextLabel(position, textSize, indexFormat.c_str(), true);
|
||||
@@ -36,7 +35,8 @@ namespace AzToolsFramework
|
||||
const AZ::FixedVertices<Vertex>& vertices,
|
||||
const AZ::Transform& transform,
|
||||
const AZ::Vector3& nonUniformScale,
|
||||
const bool selected, const float textSize,
|
||||
const bool selected,
|
||||
const float textSize,
|
||||
const AZ::Color& textColor,
|
||||
const AZ::Vector3& textOffset)
|
||||
{
|
||||
@@ -52,11 +52,12 @@ namespace AzToolsFramework
|
||||
if (vertices.GetVertex(vertIndex, vertex))
|
||||
{
|
||||
DisplayVertexContainerIndex(
|
||||
debugDisplay, transform.TransformPoint(nonUniformScale * (AdaptVertexOut(vertex) + textOffset)), vertIndex, textSize);
|
||||
debugDisplay, transform.TransformPoint(nonUniformScale * (AdaptVertexOut(vertex) + textOffset)), vertIndex,
|
||||
textSize);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} // namespace VertexContainerDisplay
|
||||
|
||||
// explicit template instantiations
|
||||
template void VertexContainerDisplay::DisplayVertexContainerIndices(
|
||||
@@ -64,7 +65,8 @@ namespace AzToolsFramework
|
||||
const AZ::FixedVertices<AZ::Vector2>& vertices,
|
||||
const AZ::Transform& transform,
|
||||
const AZ::Vector3& nonUniformScale,
|
||||
bool selected, float textSize,
|
||||
bool selected,
|
||||
float textSize,
|
||||
const AZ::Color& textColor,
|
||||
const AZ::Vector3& textOffset);
|
||||
template void VertexContainerDisplay::DisplayVertexContainerIndices(
|
||||
@@ -72,7 +74,8 @@ namespace AzToolsFramework
|
||||
const AZ::FixedVertices<AZ::Vector3>& vertices,
|
||||
const AZ::Transform& transform,
|
||||
const AZ::Vector3& nonUniformScale,
|
||||
bool selected, float textSize,
|
||||
bool selected,
|
||||
float textSize,
|
||||
const AZ::Color& textColor,
|
||||
const AZ::Vector3& textOffset);
|
||||
}
|
||||
} // namespace AzToolsFramework
|
||||
|
||||
+15
-14
@@ -1,14 +1,14 @@
|
||||
/*
|
||||
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
|
||||
* its licensors.
|
||||
*
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this
|
||||
* distribution (the "License"). All use of this software is governed by the License,
|
||||
* or, if provided, by the license below or the license accompanying this file. Do not
|
||||
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
*
|
||||
*/
|
||||
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
|
||||
* its licensors.
|
||||
*
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this
|
||||
* distribution (the "License"). All use of this software is governed by the License,
|
||||
* or, if provided, by the license below or the license accompanying this file. Do not
|
||||
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
@@ -22,22 +22,23 @@ namespace AzFramework
|
||||
|
||||
namespace AzToolsFramework
|
||||
{
|
||||
/// Utility functions for rendering vertex container indices.
|
||||
//! Utility functions for rendering vertex container indices.
|
||||
namespace VertexContainerDisplay
|
||||
{
|
||||
extern const float DefaultVertexTextSize;
|
||||
extern const AZ::Color DefaultVertexTextColor;
|
||||
extern const AZ::Vector3 DefaultVertexTextOffset;
|
||||
|
||||
/// Displays all vertex container indices as text at the position of each vertex when selected
|
||||
//! Displays all vertex container indices as text at the position of each vertex when selected
|
||||
template<typename Vertex>
|
||||
void DisplayVertexContainerIndices(
|
||||
AzFramework::DebugDisplayRequests& debugDisplay,
|
||||
const AZ::FixedVertices<Vertex>& vertices,
|
||||
const AZ::Transform& transform,
|
||||
const AZ::Vector3& nonUniformScale,
|
||||
bool selected, float textSize = DefaultVertexTextSize,
|
||||
bool selected,
|
||||
float textSize = DefaultVertexTextSize,
|
||||
const AZ::Color& textColor = DefaultVertexTextColor,
|
||||
const AZ::Vector3& textOffset = DefaultVertexTextOffset);
|
||||
}
|
||||
} // namespace VertexContainerDisplay
|
||||
} // namespace AzToolsFramework
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
/*
|
||||
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
|
||||
* its licensors.
|
||||
*
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this
|
||||
* distribution (the "License"). All use of this software is governed by the License,
|
||||
* or, if provided, by the license below or the license accompanying this file. Do not
|
||||
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
*
|
||||
*/
|
||||
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
|
||||
* its licensors.
|
||||
*
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this
|
||||
* distribution (the "License"). All use of this software is governed by the License,
|
||||
* or, if provided, by the license below or the license accompanying this file. Do not
|
||||
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
@@ -17,8 +17,8 @@
|
||||
#include <AzFramework/Entity/EntityContextBus.h>
|
||||
#include <AzFramework/Entity/EntityDebugDisplayBus.h>
|
||||
#include <AzFramework/Viewport/CameraState.h>
|
||||
#include <AzFramework/Viewport/ViewportId.h>
|
||||
#include <AzFramework/Viewport/ClickDetector.h>
|
||||
#include <AzFramework/Viewport/ViewportId.h>
|
||||
#include <AzToolsFramework/Entity/EditorEntityContextBus.h>
|
||||
#include <AzToolsFramework/Viewport/ViewportTypes.h>
|
||||
|
||||
@@ -31,45 +31,51 @@ namespace AzToolsFramework
|
||||
{
|
||||
namespace ViewportInteraction
|
||||
{
|
||||
/// Result of handling mouse interaction.
|
||||
//! Result of handling mouse interaction.
|
||||
enum class MouseInteractionResult
|
||||
{
|
||||
Manipulator, ///< The manipulator manager handled the interaction.
|
||||
Viewport, ///< The viewport handled the interaction.
|
||||
None ///< The interaction was not handled.
|
||||
Manipulator, //!< The manipulator manager handled the interaction.
|
||||
Viewport, //!< The viewport handled the interaction.
|
||||
None //!< The interaction was not handled.
|
||||
};
|
||||
|
||||
/// Interface for handling mouse viewport events.
|
||||
//! Interface for handling mouse viewport events.
|
||||
class MouseViewportRequests
|
||||
{
|
||||
public:
|
||||
/// @cond
|
||||
//! @cond
|
||||
virtual ~MouseViewportRequests() = default;
|
||||
/// @endcond
|
||||
//! @endcond
|
||||
|
||||
/// Implement this function to handle a particular mouse event.
|
||||
virtual bool HandleMouseInteraction(
|
||||
const MouseInteractionEvent& /*mouseInteraction*/) { return false; }
|
||||
//! Implement this function to handle a particular mouse event.
|
||||
virtual bool HandleMouseInteraction(const MouseInteractionEvent& /*mouseInteraction*/)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
/// Interface for internal handling mouse viewport events.
|
||||
|
||||
//! Interface for internal handling mouse viewport events.
|
||||
class InternalMouseViewportRequests
|
||||
{
|
||||
public:
|
||||
/// @cond
|
||||
//! @cond
|
||||
virtual ~InternalMouseViewportRequests() = default;
|
||||
/// @endcond
|
||||
//! @endcond
|
||||
|
||||
/// Implement this function to have the viewport handle this mouse event.
|
||||
virtual bool InternalHandleMouseViewportInteraction(
|
||||
const MouseInteractionEvent& /*mouseInteraction*/) { return false; }
|
||||
//! Implement this function to have the viewport handle this mouse event.
|
||||
virtual bool InternalHandleMouseViewportInteraction(const MouseInteractionEvent& /*mouseInteraction*/)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/// Implement this function to have manipulators handle this mouse event.
|
||||
virtual bool InternalHandleMouseManipulatorInteraction(
|
||||
const MouseInteractionEvent& /*mouseInteraction*/) { return false; }
|
||||
//! Implement this function to have manipulators handle this mouse event.
|
||||
virtual bool InternalHandleMouseManipulatorInteraction(const MouseInteractionEvent& /*mouseInteraction*/)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/// Helper to call both viewport and manipulator handle mouse events
|
||||
/// @note Manipulators always attempt to intercept the event first.
|
||||
//! Helper to call both viewport and manipulator handle mouse events
|
||||
//! @note Manipulators always attempt to intercept the event first.
|
||||
MouseInteractionResult InternalHandleAllMouseInteractions(const MouseInteractionEvent& mouseInteraction);
|
||||
};
|
||||
|
||||
@@ -90,117 +96,118 @@ namespace AzToolsFramework
|
||||
}
|
||||
}
|
||||
|
||||
/// Interface for viewport selection behaviors.
|
||||
//! Interface for viewport selection behaviors.
|
||||
class ViewportDisplayNotifications
|
||||
{
|
||||
public:
|
||||
/// @cond
|
||||
//! @cond
|
||||
virtual ~ViewportDisplayNotifications() = default;
|
||||
/// @endcond
|
||||
//! @endcond
|
||||
|
||||
/// Display drawing in world space.
|
||||
/// \ref DisplayViewportSelection is called from \ref EditorInteractionSystemComponent::DisplayViewport.
|
||||
/// DisplayViewport exists on the \ref AzFramework::ViewportDebugDisplayEventBus and is called from \ref CRenderViewport.
|
||||
/// \ref DisplayViewportSelection is called after \ref CalculateVisibleEntityDatas on the \ref EditorVisibleEntityDataCache,
|
||||
/// this ensures usage of the entity cache will be up to date (do not implement \ref AzFramework::ViewportDebugDisplayEventBus
|
||||
/// directly if wishing to use the \ref EditorVisibleEntityDataCache).
|
||||
//! Display drawing in world space.
|
||||
//! \ref DisplayViewportSelection is called from \ref EditorInteractionSystemComponent::DisplayViewport.
|
||||
//! DisplayViewport exists on the \ref AzFramework::ViewportDebugDisplayEventBus and is called from \ref CRenderViewport.
|
||||
//! \ref DisplayViewportSelection is called after \ref CalculateVisibleEntityDatas on the \ref EditorVisibleEntityDataCache,
|
||||
//! this ensures usage of the entity cache will be up to date (do not implement \ref AzFramework::ViewportDebugDisplayEventBus
|
||||
//! directly if wishing to use the \ref EditorVisibleEntityDataCache).
|
||||
virtual void DisplayViewportSelection(
|
||||
const AzFramework::ViewportInfo& /*viewportInfo*/,
|
||||
AzFramework::DebugDisplayRequests& /*debugDisplay*/) {}
|
||||
/// Display drawing in screen space.
|
||||
/// \ref DisplayViewportSelection2d is called after \ref DisplayViewportSelection when the viewport has been
|
||||
/// configured to be orthographic in \ref CRenderViewport. All screen space drawing can be performed here.
|
||||
const AzFramework::ViewportInfo& /*viewportInfo*/, AzFramework::DebugDisplayRequests& /*debugDisplay*/)
|
||||
{
|
||||
}
|
||||
//! Display drawing in screen space.
|
||||
//! \ref DisplayViewportSelection2d is called after \ref DisplayViewportSelection when the viewport has been
|
||||
//! configured to be orthographic in \ref CRenderViewport. All screen space drawing can be performed here.
|
||||
virtual void DisplayViewportSelection2d(
|
||||
const AzFramework::ViewportInfo& /*viewportInfo*/,
|
||||
AzFramework::DebugDisplayRequests& /*debugDisplay*/) {}
|
||||
const AzFramework::ViewportInfo& /*viewportInfo*/, AzFramework::DebugDisplayRequests& /*debugDisplay*/)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
/// Interface for internal handling mouse viewport events and display notifications.
|
||||
/// Implement this for types wishing to provide viewport functionality and
|
||||
/// set it by using \ref EditorInteractionSystemViewportSelectionRequestBus.
|
||||
//! Interface for internal handling mouse viewport events and display notifications.
|
||||
//! Implement this for types wishing to provide viewport functionality and
|
||||
//! set it by using \ref EditorInteractionSystemViewportSelectionRequestBus.
|
||||
class InternalViewportSelectionRequests
|
||||
: public ViewportDisplayNotifications
|
||||
, public InternalMouseViewportRequests
|
||||
{
|
||||
};
|
||||
|
||||
/// Interface for handling mouse viewport events and display notifications.
|
||||
/// Use this interface for composition types used by InternalViewportSelectionRequests.
|
||||
//! Interface for handling mouse viewport events and display notifications.
|
||||
//! Use this interface for composition types used by InternalViewportSelectionRequests.
|
||||
class ViewportSelectionRequests
|
||||
: public ViewportDisplayNotifications
|
||||
, public MouseViewportRequests
|
||||
{
|
||||
};
|
||||
|
||||
/// The EBusTraits for ViewportInteractionRequests.
|
||||
class ViewportEBusTraits
|
||||
: public AZ::EBusTraits
|
||||
//! The EBusTraits for ViewportInteractionRequests.
|
||||
class ViewportEBusTraits : public AZ::EBusTraits
|
||||
{
|
||||
public:
|
||||
using BusIdType = AzFramework::ViewportId; ///< ViewportId - used to address requests to this EBus.
|
||||
using BusIdType = AzFramework::ViewportId; //!< ViewportId - used to address requests to this EBus.
|
||||
static const AZ::EBusAddressPolicy AddressPolicy = AZ::EBusAddressPolicy::ById;
|
||||
static const AZ::EBusHandlerPolicy HandlerPolicy = AZ::EBusHandlerPolicy::Single;
|
||||
};
|
||||
|
||||
/// A ray projection, originating from a point and extending in a direction specified as a normal.
|
||||
//! A ray projection, originating from a point and extending in a direction specified as a normal.
|
||||
struct ProjectedViewportRay
|
||||
{
|
||||
AZ::Vector3 origin;
|
||||
AZ::Vector3 direction;
|
||||
};
|
||||
|
||||
/// Requests that can be made to the viewport to query and modify its state.
|
||||
//! Requests that can be made to the viewport to query and modify its state.
|
||||
class ViewportInteractionRequests
|
||||
{
|
||||
public:
|
||||
/// Return the current camera state for this viewport.
|
||||
//! Return the current camera state for this viewport.
|
||||
virtual AzFramework::CameraState GetCameraState() = 0;
|
||||
/// Return if grid snapping is enabled.
|
||||
//! Return if grid snapping is enabled.
|
||||
virtual bool GridSnappingEnabled() = 0;
|
||||
/// Return the grid snapping size.
|
||||
//! Return the grid snapping size.
|
||||
virtual float GridSize() = 0;
|
||||
/// Does the grid currently want to be displayed.
|
||||
//! Does the grid currently want to be displayed.
|
||||
virtual bool ShowGrid() = 0;
|
||||
/// Return if angle snapping is enabled.
|
||||
//! Return if angle snapping is enabled.
|
||||
virtual bool AngleSnappingEnabled() = 0;
|
||||
/// Return the angle snapping/step size.
|
||||
//! Return the angle snapping/step size.
|
||||
virtual float AngleStep() = 0;
|
||||
/// Transform a point in world space to screen space coordinates in Qt Widget space.
|
||||
/// Multiply by DeviceScalingFactor to get the position in viewport pixel space.
|
||||
//! Transform a point in world space to screen space coordinates in Qt Widget space.
|
||||
//! Multiply by DeviceScalingFactor to get the position in viewport pixel space.
|
||||
virtual AzFramework::ScreenPoint ViewportWorldToScreen(const AZ::Vector3& worldPosition) = 0;
|
||||
/// Transform a point from Qt widget screen space to world space based on the given clip space depth.
|
||||
/// Depth specifies a relative camera depth to project in the range of [0.f, 1.f].
|
||||
/// Returns the world space position if successful.
|
||||
//! Transform a point from Qt widget screen space to world space based on the given clip space depth.
|
||||
//! Depth specifies a relative camera depth to project in the range of [0.f, 1.f].
|
||||
//! Returns the world space position if successful.
|
||||
virtual AZStd::optional<AZ::Vector3> ViewportScreenToWorld(const AzFramework::ScreenPoint& screenPosition, float depth) = 0;
|
||||
/// Casts a point in screen space to a ray in world space originating from the viewport camera frustum's near plane.
|
||||
/// Returns a ray containing the ray's origin and a direction normal, if successful.
|
||||
//! Casts a point in screen space to a ray in world space originating from the viewport camera frustum's near plane.
|
||||
//! Returns a ray containing the ray's origin and a direction normal, if successful.
|
||||
virtual AZStd::optional<ProjectedViewportRay> ViewportScreenToWorldRay(const AzFramework::ScreenPoint& screenPosition) = 0;
|
||||
/// Gets the DPI scaling factor that translates Qt widget space into viewport pixel space.
|
||||
//! Gets the DPI scaling factor that translates Qt widget space into viewport pixel space.
|
||||
virtual float DeviceScalingFactor() = 0;
|
||||
|
||||
protected:
|
||||
~ViewportInteractionRequests() = default;
|
||||
};
|
||||
|
||||
/// Interface to return only viewport specific settings (e.g. snapping).
|
||||
//! Interface to return only viewport specific settings (e.g. snapping).
|
||||
class ViewportSettings
|
||||
{
|
||||
public:
|
||||
virtual ~ViewportSettings() = default;
|
||||
|
||||
/// Return if grid snapping is enabled.
|
||||
//! Return if grid snapping is enabled.
|
||||
virtual bool GridSnappingEnabled() const = 0;
|
||||
/// Return the grid snapping size.
|
||||
//! Return the grid snapping size.
|
||||
virtual float GridSize() const = 0;
|
||||
/// Does the grid currently want to be displayed.
|
||||
//! Does the grid currently want to be displayed.
|
||||
virtual bool ShowGrid() const = 0;
|
||||
/// Return if angle snapping is enabled.
|
||||
//! Return if angle snapping is enabled.
|
||||
virtual bool AngleSnappingEnabled() const = 0;
|
||||
/// Return the angle snapping/step size.
|
||||
//! Return the angle snapping/step size.
|
||||
virtual float AngleStep() const = 0;
|
||||
};
|
||||
|
||||
/// Type to inherit to implement ViewportInteractionRequests.
|
||||
//! Type to inherit to implement ViewportInteractionRequests.
|
||||
using ViewportInteractionRequestBus = AZ::EBus<ViewportInteractionRequests, ViewportEBusTraits>;
|
||||
|
||||
//! Requests to freeze the Viewport Input
|
||||
@@ -221,62 +228,62 @@ namespace AzToolsFramework
|
||||
//! Type to inherit to implement ViewportFreezeRequests.
|
||||
using ViewportFreezeRequestBus = AZ::EBus<ViewportFreezeRequests, ViewportEBusTraits>;
|
||||
|
||||
/// Viewport requests that are only guaranteed to be serviced by the Main Editor viewport.
|
||||
//! Viewport requests that are only guaranteed to be serviced by the Main Editor viewport.
|
||||
class MainEditorViewportInteractionRequests
|
||||
{
|
||||
public:
|
||||
/// Given a point in screen space, return the picked entity (if any).
|
||||
/// Picked EntityId will be returned, InvalidEntityId will be returned on failure.
|
||||
//! Given a point in screen space, return the picked entity (if any).
|
||||
//! Picked EntityId will be returned, InvalidEntityId will be returned on failure.
|
||||
virtual AZ::EntityId PickEntity(const AzFramework::ScreenPoint& point) = 0;
|
||||
/// Given a point in screen space, return the terrain position in world space.
|
||||
//! Given a point in screen space, return the terrain position in world space.
|
||||
virtual AZ::Vector3 PickTerrain(const AzFramework::ScreenPoint& point) = 0;
|
||||
/// Return the terrain height given a world position in 2d (xy plane).
|
||||
//! Return the terrain height given a world position in 2d (xy plane).
|
||||
virtual float TerrainHeight(const AZ::Vector2& position) = 0;
|
||||
/// Given the current view frustum (viewport) return all visible entities.
|
||||
//! Given the current view frustum (viewport) return all visible entities.
|
||||
virtual void FindVisibleEntities(AZStd::vector<AZ::EntityId>& visibleEntities) = 0;
|
||||
/// Is the user holding a modifier key to move the manipulator space from local to world.
|
||||
//! Is the user holding a modifier key to move the manipulator space from local to world.
|
||||
virtual bool ShowingWorldSpace() = 0;
|
||||
/// Return the widget to use as the parent for the viewport context menu.
|
||||
//! Return the widget to use as the parent for the viewport context menu.
|
||||
virtual QWidget* GetWidgetForViewportContextMenu() = 0;
|
||||
/// Set the render context for the viewport.
|
||||
//! Set the render context for the viewport.
|
||||
virtual void BeginWidgetContext() = 0;
|
||||
/// End the render context for the viewport.
|
||||
/// Return to previous context before Begin was called.
|
||||
//! End the render context for the viewport.
|
||||
//! Return to previous context before Begin was called.
|
||||
virtual void EndWidgetContext() = 0;
|
||||
|
||||
protected:
|
||||
~MainEditorViewportInteractionRequests() = default;
|
||||
};
|
||||
|
||||
/// Type to inherit to implement MainEditorViewportInteractionRequests.
|
||||
//! Type to inherit to implement MainEditorViewportInteractionRequests.
|
||||
using MainEditorViewportInteractionRequestBus = AZ::EBus<MainEditorViewportInteractionRequests, ViewportEBusTraits>;
|
||||
|
||||
/// Viewport requests for managing the viewport's cursor state.
|
||||
//! Viewport requests for managing the viewport's cursor state.
|
||||
class ViewportMouseCursorRequests
|
||||
{
|
||||
public:
|
||||
/// Begins hiding the cursor and locking it in place, to prevent the cursor from escaping the viewport window.
|
||||
//! Begins hiding the cursor and locking it in place, to prevent the cursor from escaping the viewport window.
|
||||
virtual void BeginCursorCapture() = 0;
|
||||
/// Restores the cursor and ends locking it in place, allowing it to be moved freely.
|
||||
//! Restores the cursor and ends locking it in place, allowing it to be moved freely.
|
||||
virtual void EndCursorCapture() = 0;
|
||||
/// Gets the most recent recorded cursor position in the viewport in screen space coordinates.
|
||||
//! Gets the most recent recorded cursor position in the viewport in screen space coordinates.
|
||||
virtual AzFramework::ScreenPoint ViewportCursorScreenPosition() = 0;
|
||||
/// Gets the cursor position recorded prior to the most recent cursor position.
|
||||
/// Note: The cursor may be captured by the viewport, in which case this may not correspond to the last result
|
||||
/// from ViewportCursorScreenPosition. This method will always return the correct position to generate a mouse
|
||||
/// position delta.
|
||||
//! Gets the cursor position recorded prior to the most recent cursor position.
|
||||
//! Note: The cursor may be captured by the viewport, in which case this may not correspond to the last result
|
||||
//! from ViewportCursorScreenPosition. This method will always return the correct position to generate a mouse
|
||||
//! position delta.
|
||||
virtual AZStd::optional<AzFramework::ScreenPoint> PreviousViewportCursorScreenPosition() = 0;
|
||||
/// Is mouse over viewport.
|
||||
//! Is mouse over viewport.
|
||||
virtual bool IsMouseOver() const = 0;
|
||||
|
||||
protected:
|
||||
~ViewportMouseCursorRequests() = default;
|
||||
};
|
||||
|
||||
/// Type to inherit to implement MainEditorViewportInteractionRequests.
|
||||
//! Type to inherit to implement MainEditorViewportInteractionRequests.
|
||||
using ViewportMouseCursorRequestBus = AZ::EBus<ViewportMouseCursorRequests, ViewportEBusTraits>;
|
||||
|
||||
/// A helper to wrap Begin/EndWidgetContext.
|
||||
//! A helper to wrap Begin/EndWidgetContext.
|
||||
class WidgetContextGuard
|
||||
{
|
||||
public:
|
||||
@@ -294,17 +301,16 @@ namespace AzToolsFramework
|
||||
}
|
||||
|
||||
private:
|
||||
int m_viewportId; ///< The viewport id the widget context is being set on.
|
||||
int m_viewportId; //!< The viewport id the widget context is being set on.
|
||||
};
|
||||
|
||||
} // namespace ViewportInteraction
|
||||
|
||||
/// Utility function to return EntityContextId.
|
||||
//! Utility function to return EntityContextId.
|
||||
inline AzFramework::EntityContextId GetEntityContextId()
|
||||
{
|
||||
AzFramework::EntityContextId entityContextId;
|
||||
EditorEntityContextRequestBus::BroadcastResult(
|
||||
entityContextId, &EditorEntityContextRequests::GetEditorEntityContextId);
|
||||
EditorEntityContextRequestBus::BroadcastResult(entityContextId, &EditorEntityContextRequests::GetEditorEntityContextId);
|
||||
|
||||
return entityContextId;
|
||||
}
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
/*
|
||||
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
|
||||
* its licensors.
|
||||
*
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this
|
||||
* distribution (the "License"). All use of this software is governed by the License,
|
||||
* or, if provided, by the license below or the license accompanying this file. Do not
|
||||
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
*
|
||||
*/
|
||||
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
|
||||
* its licensors.
|
||||
*
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this
|
||||
* distribution (the "License"). All use of this software is governed by the License,
|
||||
* or, if provided, by the license below or the license accompanying this file. Do not
|
||||
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "ViewportTypes.h"
|
||||
|
||||
@@ -23,26 +23,24 @@ namespace AzToolsFramework
|
||||
{
|
||||
if (auto serializeContext = azrtti_cast<AZ::SerializeContext*>(context))
|
||||
{
|
||||
serializeContext->Class<KeyboardModifiers>()->
|
||||
Field("KeyboardModifiers", &KeyboardModifiers::m_keyModifiers);
|
||||
serializeContext->Class<KeyboardModifiers>()->Field("KeyboardModifiers", &KeyboardModifiers::m_keyModifiers);
|
||||
|
||||
serializeContext->Class<MouseButtons>()->
|
||||
Field("MouseButtons", &MouseButtons::m_mouseButtons);
|
||||
serializeContext->Class<MouseButtons>()->Field("MouseButtons", &MouseButtons::m_mouseButtons);
|
||||
|
||||
serializeContext->Class<InteractionId>()->
|
||||
Field("CameraId", &InteractionId::m_cameraId)->
|
||||
Field("ViewportId", &InteractionId::m_viewportId);
|
||||
serializeContext->Class<InteractionId>()
|
||||
->Field("CameraId", &InteractionId::m_cameraId)
|
||||
->Field("ViewportId", &InteractionId::m_viewportId);
|
||||
|
||||
serializeContext->Class<MousePick>()->
|
||||
Field("RayOrigin", &MousePick::m_rayOrigin)->
|
||||
Field("RayDirection", &MousePick::m_rayDirection)->
|
||||
Field("ScreenCoordinates", &MousePick::m_screenCoordinates);
|
||||
serializeContext->Class<MousePick>()
|
||||
->Field("RayOrigin", &MousePick::m_rayOrigin)
|
||||
->Field("RayDirection", &MousePick::m_rayDirection)
|
||||
->Field("ScreenCoordinates", &MousePick::m_screenCoordinates);
|
||||
|
||||
serializeContext->Class<MouseInteraction>()->
|
||||
Field("MousePick", &MouseInteraction::m_mousePick)->
|
||||
Field("MouseButtons", &MouseInteraction::m_mouseButtons)->
|
||||
Field("InteractionId", &MouseInteraction::m_interactionId)->
|
||||
Field("KeyboardModifiers", &MouseInteraction::m_keyboardModifiers);
|
||||
serializeContext->Class<MouseInteraction>()
|
||||
->Field("MousePick", &MouseInteraction::m_mousePick)
|
||||
->Field("MouseButtons", &MouseInteraction::m_mouseButtons)
|
||||
->Field("InteractionId", &MouseInteraction::m_interactionId)
|
||||
->Field("KeyboardModifiers", &MouseInteraction::m_keyboardModifiers);
|
||||
|
||||
MouseInteractionEvent::Reflect(*serializeContext);
|
||||
}
|
||||
@@ -50,10 +48,10 @@ namespace AzToolsFramework
|
||||
|
||||
void MouseInteractionEvent::Reflect(AZ::SerializeContext& serializeContext)
|
||||
{
|
||||
serializeContext.Class<MouseInteractionEvent>()->
|
||||
Field("MouseInteraction", &MouseInteractionEvent::m_mouseInteraction)->
|
||||
Field("MouseEvent", &MouseInteractionEvent::m_mouseEvent)->
|
||||
Field("WheelDelta", &MouseInteractionEvent::m_wheelDelta);
|
||||
serializeContext.Class<MouseInteractionEvent>()
|
||||
->Field("MouseInteraction", &MouseInteractionEvent::m_mouseInteraction)
|
||||
->Field("MouseEvent", &MouseInteractionEvent::m_mouseEvent)
|
||||
->Field("WheelDelta", &MouseInteractionEvent::m_wheelDelta);
|
||||
}
|
||||
}
|
||||
}
|
||||
} // namespace ViewportInteraction
|
||||
} // namespace AzToolsFramework
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
/*
|
||||
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
|
||||
* its licensors.
|
||||
*
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this
|
||||
* distribution (the "License"). All use of this software is governed by the License,
|
||||
* or, if provided, by the license below or the license accompanying this file. Do not
|
||||
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
*
|
||||
*/
|
||||
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
|
||||
* its licensors.
|
||||
*
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this
|
||||
* distribution (the "License"). All use of this software is governed by the License,
|
||||
* or, if provided, by the license below or the license accompanying this file. Do not
|
||||
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
@@ -27,57 +27,75 @@ namespace AZ
|
||||
|
||||
namespace AzToolsFramework
|
||||
{
|
||||
/// Viewport related types that are used when interacting with the viewport.
|
||||
//! Viewport related types that are used when interacting with the viewport.
|
||||
namespace ViewportInteraction
|
||||
{
|
||||
/// Flags to represent each modifier key.
|
||||
//! Flags to represent each modifier key.
|
||||
enum class KeyboardModifier : AZ::u32
|
||||
{
|
||||
None = 0, ///< No keyboard modifier.
|
||||
Alt = 0x01, ///< Alt keyboard modifier.
|
||||
Shift = 0x02, ///< Shift keyboard modifier.
|
||||
Ctrl = 0x04, ///< Ctrl keyboard modifier.
|
||||
Control = Ctrl ///< Alias for Ctrl modifier.
|
||||
None = 0, //!< No keyboard modifier.
|
||||
Alt = 0x01, //!< Alt keyboard modifier.
|
||||
Shift = 0x02, //!< Shift keyboard modifier.
|
||||
Ctrl = 0x04, //!< Ctrl keyboard modifier.
|
||||
Control = Ctrl //!< Alias for Ctrl modifier.
|
||||
};
|
||||
|
||||
/// Flags to represent each mouse button.
|
||||
//! Flags to represent each mouse button.
|
||||
enum class MouseButton : AZ::u32
|
||||
{
|
||||
None = 0, ///< No mouse buttons.
|
||||
Left = 0x01, ///< Left mouse button.
|
||||
Middle = 0x02, ///< Middle mouse button.
|
||||
Right = 0x04 ///< Right mouse button.
|
||||
None = 0, //!< No mouse buttons.
|
||||
Left = 0x01, //!< Left mouse button.
|
||||
Middle = 0x02, //!< Middle mouse button.
|
||||
Right = 0x04 //!< Right mouse button.
|
||||
};
|
||||
|
||||
/// The type of mouse event that occurred.
|
||||
//! The type of mouse event that occurred.
|
||||
enum class MouseEvent
|
||||
{
|
||||
Up, ///< Mouse up event,
|
||||
Down, ///< Mouse down event.
|
||||
DoubleClick, ///< Mouse double click event.
|
||||
Wheel, ///< Mouse wheel event.
|
||||
Move, ///< Mouse move event.
|
||||
Up, //!< Mouse up event,
|
||||
Down, //!< Mouse down event.
|
||||
DoubleClick, //!< Mouse double click event.
|
||||
Wheel, //!< Mouse wheel event.
|
||||
Move, //!< Mouse move event.
|
||||
};
|
||||
|
||||
/// Interface over keyboard modifier to query which key is pressed.
|
||||
//! Interface over keyboard modifier to query which key is pressed.
|
||||
struct KeyboardModifiers
|
||||
{
|
||||
/// @cond
|
||||
//! @cond
|
||||
AZ_TYPE_INFO(KeyboardModifiers, "{2635F4DF-E7DC-4919-A97B-9AE35FE086D8}");
|
||||
KeyboardModifiers() = default;
|
||||
/// @endcond
|
||||
//! @endcond
|
||||
|
||||
/// Explicit constructor to create a KeyboardModifier struct.
|
||||
explicit KeyboardModifiers(const AZ::u32 keyModifiers) : m_keyModifiers(keyModifiers) {}
|
||||
//! Explicit constructor to create a KeyboardModifier struct.
|
||||
explicit KeyboardModifiers(const AZ::u32 keyModifiers)
|
||||
: m_keyModifiers(keyModifiers)
|
||||
{
|
||||
}
|
||||
|
||||
/// Given the current keyboard modifiers, is the Alt key held.
|
||||
bool Alt() const { return (m_keyModifiers & static_cast<AZ::u32>(KeyboardModifier::Alt)) != 0; }
|
||||
/// Given the current keyboard modifiers, is the Shift key held.
|
||||
bool Shift() const { return (m_keyModifiers & static_cast<AZ::u32>(KeyboardModifier::Shift)) != 0; }
|
||||
/// Given the current keyboard modifiers, is the Ctrl key held.
|
||||
bool Ctrl() const { return (m_keyModifiers & static_cast<AZ::u32>(KeyboardModifier::Ctrl)) != 0; }
|
||||
/// Given the current keyboard modifiers, are none being held.
|
||||
bool None() const { return m_keyModifiers == static_cast<AZ::u32>(KeyboardModifier::None); }
|
||||
//! Given the current keyboard modifiers, is the Alt key held.
|
||||
bool Alt() const
|
||||
{
|
||||
return (m_keyModifiers & static_cast<AZ::u32>(KeyboardModifier::Alt)) != 0;
|
||||
}
|
||||
|
||||
//! Given the current keyboard modifiers, is the Shift key held.
|
||||
bool Shift() const
|
||||
{
|
||||
return (m_keyModifiers & static_cast<AZ::u32>(KeyboardModifier::Shift)) != 0;
|
||||
}
|
||||
|
||||
//! Given the current keyboard modifiers, is the Ctrl key held.
|
||||
bool Ctrl() const
|
||||
{
|
||||
return (m_keyModifiers & static_cast<AZ::u32>(KeyboardModifier::Ctrl)) != 0;
|
||||
}
|
||||
|
||||
//! Given the current keyboard modifiers, are none being held.
|
||||
bool None() const
|
||||
{
|
||||
return m_keyModifiers == static_cast<AZ::u32>(KeyboardModifier::None);
|
||||
}
|
||||
|
||||
bool operator==(const KeyboardModifiers& keyboardModifiers) const
|
||||
{
|
||||
@@ -89,132 +107,162 @@ namespace AzToolsFramework
|
||||
return m_keyModifiers != keyboardModifiers.m_keyModifiers;
|
||||
}
|
||||
|
||||
AZ::u32 m_keyModifiers = 0; ///< Raw keyboard modifier state.
|
||||
AZ::u32 m_keyModifiers = 0; //!< Raw keyboard modifier state.
|
||||
};
|
||||
|
||||
/// Interface over mouse buttons to query which button is pressed.
|
||||
//! Interface over mouse buttons to query which button is pressed.
|
||||
struct MouseButtons
|
||||
{
|
||||
/// @cond
|
||||
//! @cond
|
||||
AZ_TYPE_INFO(MouseButtons, "{1D137B5D-73BF-4FD9-BECA-85E6DC3786CB}");
|
||||
MouseButtons() = default;
|
||||
/// @endcond
|
||||
//! @endcond
|
||||
|
||||
/// Explicit constructor to create a MouseButton struct.
|
||||
explicit MouseButtons(const AZ::u32 mouseButtons) : m_mouseButtons(mouseButtons) {}
|
||||
//! Explicit constructor to create a MouseButton struct.
|
||||
explicit MouseButtons(const AZ::u32 mouseButtons)
|
||||
: m_mouseButtons(mouseButtons)
|
||||
{
|
||||
}
|
||||
|
||||
/// Given the current mouse state, is the left mouse button held.
|
||||
bool Left() const { return (m_mouseButtons & static_cast<AZ::u32>(MouseButton::Left)) != 0; }
|
||||
/// Given the current mouse state, is the middle mouse button held.
|
||||
bool Middle() const { return (m_mouseButtons & static_cast<AZ::u32>(MouseButton::Middle)) != 0; }
|
||||
/// Given the current mouse state, is the right mouse button held.
|
||||
bool Right() const { return (m_mouseButtons & static_cast<AZ::u32>(MouseButton::Right)) != 0; }
|
||||
/// Given the current mouse state, are no mouse buttons held.
|
||||
bool None() const { return m_mouseButtons == static_cast<AZ::u32>(MouseButton::None); }
|
||||
/// Given the current mouse state, are any mouse buttons held.
|
||||
bool Any() const { return m_mouseButtons != static_cast<AZ::u32>(MouseButton::None); }
|
||||
//! Given the current mouse state, is the left mouse button held.
|
||||
bool Left() const
|
||||
{
|
||||
return (m_mouseButtons & static_cast<AZ::u32>(MouseButton::Left)) != 0;
|
||||
}
|
||||
|
||||
AZ::u32 m_mouseButtons = 0; ///< Current mouse button state (flags).
|
||||
//! Given the current mouse state, is the middle mouse button held.
|
||||
bool Middle() const
|
||||
{
|
||||
return (m_mouseButtons & static_cast<AZ::u32>(MouseButton::Middle)) != 0;
|
||||
}
|
||||
|
||||
//! Given the current mouse state, is the right mouse button held.
|
||||
bool Right() const
|
||||
{
|
||||
return (m_mouseButtons & static_cast<AZ::u32>(MouseButton::Right)) != 0;
|
||||
}
|
||||
|
||||
//! Given the current mouse state, are no mouse buttons held.
|
||||
bool None() const
|
||||
{
|
||||
return m_mouseButtons == static_cast<AZ::u32>(MouseButton::None);
|
||||
}
|
||||
|
||||
//! Given the current mouse state, are any mouse buttons held.
|
||||
bool Any() const
|
||||
{
|
||||
return m_mouseButtons != static_cast<AZ::u32>(MouseButton::None);
|
||||
}
|
||||
|
||||
AZ::u32 m_mouseButtons = 0; //!< Current mouse button state (flags).
|
||||
};
|
||||
|
||||
/// Information relevant when interacting with a particular viewport.
|
||||
//! Information relevant when interacting with a particular viewport.
|
||||
struct InteractionId
|
||||
{
|
||||
/// @cond
|
||||
//! @cond
|
||||
AZ_TYPE_INFO(InteractionId, "{35593FC2-846F-4AAD-8044-4CD84EC84F9A}");
|
||||
InteractionId() = default;
|
||||
/// @endcond
|
||||
//! @endcond
|
||||
|
||||
InteractionId(AZ::EntityId cameraId, int viewportId)
|
||||
: m_cameraId(cameraId), m_viewportId(viewportId) {}
|
||||
: m_cameraId(cameraId)
|
||||
, m_viewportId(viewportId)
|
||||
{
|
||||
}
|
||||
|
||||
AZ::EntityId m_cameraId; ///< The entity id of the viewport camera.
|
||||
int m_viewportId = 0; ///< The id of the viewport being interacted with.
|
||||
AZ::EntityId m_cameraId; //!< The entity id of the viewport camera.
|
||||
int m_viewportId = 0; //!< The id of the viewport being interacted with.
|
||||
};
|
||||
|
||||
/// Data representing a mouse pick ray.
|
||||
//! Data representing a mouse pick ray.
|
||||
struct MousePick
|
||||
{
|
||||
/// @cond
|
||||
//! @cond
|
||||
AZ_TYPE_INFO(MousePick, "{A69B9562-FC8C-4DE7-9137-0FF867B1513D}");
|
||||
MousePick() = default;
|
||||
/// @endcond
|
||||
//! @endcond
|
||||
|
||||
AZ::Vector3 m_rayOrigin = AZ::Vector3::CreateZero(); ///< World space.
|
||||
AZ::Vector3 m_rayDirection = AZ::Vector3::CreateZero(); ///< World space - normalized.
|
||||
AzFramework::ScreenPoint m_screenCoordinates = {}; ///< Screen space.
|
||||
AZ::Vector3 m_rayOrigin = AZ::Vector3::CreateZero(); //!< World space.
|
||||
AZ::Vector3 m_rayDirection = AZ::Vector3::CreateZero(); //!< World space - normalized.
|
||||
AzFramework::ScreenPoint m_screenCoordinates = {}; //!< Screen space.
|
||||
};
|
||||
|
||||
/// State relating to an individual mouse interaction.
|
||||
//! State relating to an individual mouse interaction.
|
||||
struct MouseInteraction
|
||||
{
|
||||
/// @cond
|
||||
//! @cond
|
||||
AZ_TYPE_INFO(MouseInteraction, "{E67357C3-DFE1-40DF-921F-9CBCFE63A68C}");
|
||||
MouseInteraction() = default;
|
||||
/// @endcond
|
||||
//! @endcond
|
||||
|
||||
MousePick m_mousePick; ///< The mouse pick ray in world space and screen coordinates in screen space.
|
||||
MouseButtons m_mouseButtons; ///< The current state of the mouse buttons.
|
||||
MousePick m_mousePick; //!< The mouse pick ray in world space and screen coordinates in screen space.
|
||||
MouseButtons m_mouseButtons; //!< The current state of the mouse buttons.
|
||||
InteractionId m_interactionId; /**< The EntityId of the camera this click came from
|
||||
* and the id of the viewport it originated from. */
|
||||
KeyboardModifiers m_keyboardModifiers; ///< The state of the keyboard modifiers (Alt/Ctrl/Shift).
|
||||
* and the id of the viewport it originated from. */
|
||||
KeyboardModifiers m_keyboardModifiers; //!< The state of the keyboard modifiers (Alt/Ctrl/Shift).
|
||||
};
|
||||
|
||||
/// Structure to compose MouseInteraction (mouse state) and
|
||||
/// MouseEvent (MouseEvent::MouseUp/MouseEvent::DownMove etc.)
|
||||
//! Structure to compose MouseInteraction (mouse state) and
|
||||
//! MouseEvent (MouseEvent::MouseUp/MouseEvent::DownMove etc.)
|
||||
struct MouseInteractionEvent
|
||||
{
|
||||
/// @cond
|
||||
//! @cond
|
||||
AZ_TYPE_INFO(MouseInteractionEvent, "{67FE0826-DD59-4B5B-BEFE-421E83EA7F31}");
|
||||
MouseInteractionEvent() = default;
|
||||
/// @endcond
|
||||
//! @endcond
|
||||
|
||||
static void Reflect(AZ::SerializeContext& context);
|
||||
|
||||
/// Constructor to create a default MouseInteractionEvent
|
||||
//! Constructor to create a default MouseInteractionEvent
|
||||
MouseInteractionEvent(MouseInteraction mouseInteraction, const MouseEvent mouseEvent)
|
||||
: m_mouseInteraction(std::move(mouseInteraction))
|
||||
, m_mouseEvent(mouseEvent) {}
|
||||
, m_mouseEvent(mouseEvent)
|
||||
{
|
||||
}
|
||||
|
||||
/// Special constructor for mouse wheel event.
|
||||
//! Special constructor for mouse wheel event.
|
||||
MouseInteractionEvent(MouseInteraction mouseInteraction, const float wheelDelta)
|
||||
: m_mouseInteraction(std::move(mouseInteraction))
|
||||
, m_mouseEvent(MouseEvent::Wheel)
|
||||
, m_wheelDelta(wheelDelta) {}
|
||||
, m_wheelDelta(wheelDelta)
|
||||
{
|
||||
}
|
||||
|
||||
MouseInteraction m_mouseInteraction; ///< Mouse state.
|
||||
MouseEvent m_mouseEvent; ///< Mouse event.
|
||||
MouseInteraction m_mouseInteraction; //!< Mouse state.
|
||||
MouseEvent m_mouseEvent; //!< Mouse event.
|
||||
|
||||
/// Special friend function to return the mouse wheel delta (scroll amount)
|
||||
/// if the event was of type MouseEvent::Wheel.
|
||||
//! Special friend function to return the mouse wheel delta (scroll amount)
|
||||
//! if the event was of type MouseEvent::Wheel.
|
||||
friend float MouseWheelDelta(const MouseInteractionEvent& mouseInteractionEvent);
|
||||
|
||||
private:
|
||||
float m_wheelDelta = 0.0f; ///< The amount the mouse wheel moved during a mouse wheel event.
|
||||
float m_wheelDelta = 0.0f; //!< The amount the mouse wheel moved during a mouse wheel event.
|
||||
};
|
||||
|
||||
/// Checked access to mouse wheel delta - ensure event originated from the mouse wheel.
|
||||
//! Checked access to mouse wheel delta - ensure event originated from the mouse wheel.
|
||||
inline float MouseWheelDelta(const MouseInteractionEvent& mouseInteractionEvent)
|
||||
{
|
||||
AZ_Assert(mouseInteractionEvent.m_mouseEvent == MouseEvent::Wheel,
|
||||
AZ_Assert(
|
||||
mouseInteractionEvent.m_mouseEvent == MouseEvent::Wheel,
|
||||
"Attempting to access mouse wheel delta when mouse interaction event was not mouse wheel");
|
||||
|
||||
return mouseInteractionEvent.m_wheelDelta;
|
||||
}
|
||||
|
||||
/// Return QPoint from AzFramework::ScreenPoint.
|
||||
//! Return QPoint from AzFramework::ScreenPoint.
|
||||
inline QPoint QPointFromScreenPoint(const AzFramework::ScreenPoint& screenPoint)
|
||||
{
|
||||
return {screenPoint.m_x, screenPoint.m_y};
|
||||
return { screenPoint.m_x, screenPoint.m_y };
|
||||
}
|
||||
|
||||
/// Return AzFramework::ScreenPoint from QPoint.
|
||||
//! Return AzFramework::ScreenPoint from QPoint.
|
||||
inline AzFramework::ScreenPoint ScreenPointFromQPoint(const QPoint& qpoint)
|
||||
{
|
||||
return AzFramework::ScreenPoint{qpoint.x(), qpoint.y()};
|
||||
return AzFramework::ScreenPoint{ qpoint.x(), qpoint.y() };
|
||||
}
|
||||
|
||||
/// Map from Qt -> Open 3D Engine buttons.>>>>>>> main
|
||||
//! Map from Qt -> Open 3D Engine buttons.>>>>>>> main
|
||||
inline AZ::u32 TranslateMouseButtons(const Qt::MouseButtons buttons)
|
||||
{
|
||||
AZ::u32 result = 0;
|
||||
@@ -224,7 +272,7 @@ namespace AzToolsFramework
|
||||
return result;
|
||||
}
|
||||
|
||||
/// Map from Qt -> Open 3D Engine modifiers.
|
||||
//! Map from Qt -> Open 3D Engine modifiers.
|
||||
inline AZ::u32 TranslateKeyboardModifiers(const Qt::KeyboardModifiers modifiers)
|
||||
{
|
||||
AZ::u32 result = 0;
|
||||
@@ -234,19 +282,19 @@ namespace AzToolsFramework
|
||||
return result;
|
||||
}
|
||||
|
||||
/// Interface to translate Qt modifiers to Open 3D Engine modifiers.
|
||||
//! Interface to translate Qt modifiers to Open 3D Engine modifiers.
|
||||
inline KeyboardModifiers BuildKeyboardModifiers(const Qt::KeyboardModifiers modifiers)
|
||||
{
|
||||
return KeyboardModifiers(TranslateKeyboardModifiers(modifiers));
|
||||
}
|
||||
|
||||
/// Interface to translate Qt buttons to Open 3D Engine buttons.
|
||||
//! Interface to translate Qt buttons to Open 3D Engine buttons.
|
||||
inline MouseButtons BuildMouseButtons(const Qt::MouseButtons buttons)
|
||||
{
|
||||
return MouseButtons(TranslateMouseButtons(buttons));
|
||||
}
|
||||
|
||||
/// Generate mouse buttons from single button enum.
|
||||
//! Generate mouse buttons from single button enum.
|
||||
inline MouseButtons MouseButtonsFromButton(MouseButton button)
|
||||
{
|
||||
MouseButtons mouseButtons;
|
||||
@@ -254,7 +302,7 @@ namespace AzToolsFramework
|
||||
return mouseButtons;
|
||||
}
|
||||
|
||||
/// Reflect all viewport related types.
|
||||
//! Reflect all viewport related types.
|
||||
void ViewportInteractionReflect(AZ::ReflectContext* context);
|
||||
} // namespace ViewportInteraction
|
||||
} // namespace AzToolsFramework
|
||||
|
||||
Reference in New Issue
Block a user