Merge branch 'development' into cmake/warn_virtual

Signed-off-by: Esteban Papp <81431996+amznestebanpapp@users.noreply.github.com>

# Conflicts:
#	Code/Editor/Viewport.h
This commit is contained in:
Esteban Papp
2021-09-13 08:59:24 -07:00
189 changed files with 325 additions and 358 deletions
@@ -8,15 +8,15 @@
#pragma once
#include <AzToolsFramework/Viewport/ViewportMessages.h>
#include <AzCore/Debug/Trace.h>
#include <AzCore/Math/ToString.h>
#include <AzCore/std/string/string.h>
#include <AzCore/Debug/Trace.h>
#include <AzToolsFramework/Viewport/ViewportMessages.h>
namespace AzManipulatorTestFramework
{
//! Base class for derived immediate and retained action dispatchers.
template <typename DerivedDispatcherT>
template<typename DerivedDispatcherT>
class ActionDispatcher
{
public:
@@ -31,7 +31,7 @@ namespace AzManipulatorTestFramework
//! Enable/disable action logging.
DerivedDispatcherT* LogActions(bool logging);
//! Output a trace debug message.
template <typename... Args>
template<typename... Args>
DerivedDispatcherT* Trace(const char* format, const Args&... args);
//! Set the camera state.
DerivedDispatcherT* CameraState(const AzFramework::CameraState& cameraState);
@@ -60,8 +60,9 @@ namespace AzManipulatorTestFramework
//! Break out to the debugger mid action sequence (note: do not leave uses in production code).
DerivedDispatcherT* DebugBreak();
//! Enter component mode for the specified component type.
template <typename ComponentT>
template<typename ComponentT>
DerivedDispatcherT* EnterComponentMode();
protected:
// Actions to be implemented by derived immediate and retained action dispatchers.
virtual void EnableSnapToGridImpl() = 0;
@@ -79,32 +80,50 @@ namespace AzManipulatorTestFramework
virtual void SetSelectedEntityImpl(AZ::EntityId entity) = 0;
virtual void SetSelectedEntitiesImpl(const AzToolsFramework::EntityIdList& entities) = 0;
virtual void EnterComponentModeImpl(const AZ::Uuid& uuid) = 0;
template <typename... Args>
template<typename... Args>
void Log(const char* format, const Args&... args);
bool m_logging = false;
private:
const char* KeyboardModifierString(const AzToolsFramework::ViewportInteraction::KeyboardModifier& keyModifier);
static void DebugPrint(const char* format, ...);
};
template <typename DerivedDispatcherT>
template<typename DerivedDispatcherT>
void ActionDispatcher<DerivedDispatcherT>::DebugPrint(const char* format, ...)
{
va_list args;
va_start(args, format);
vprintf(format, args);
printf("\n");
va_end(args);
}
template<typename DerivedDispatcherT>
template <typename... Args>
void ActionDispatcher<DerivedDispatcherT>::Log(const char* format, const Args&... args)
{
if (m_logging)
{
AZ_Printf("ActionDispatcher", format, args...);
DebugPrint(format, args...);
}
}
template <typename DerivedDispatcherT>
template<typename DerivedDispatcherT>
template <typename... Args>
DerivedDispatcherT* ActionDispatcher<DerivedDispatcherT>::Trace(const char* format, const Args&... args)
{
Log(format, args...);
if (m_logging)
{
DebugPrint(format, args...);
}
return static_cast<DerivedDispatcherT*>(this);
}
template <typename DerivedDispatcherT>
template<typename DerivedDispatcherT>
DerivedDispatcherT* ActionDispatcher<DerivedDispatcherT>::EnableSnapToGrid()
{
Log("Enabling SnapToGrid");
@@ -112,7 +131,7 @@ namespace AzManipulatorTestFramework
return static_cast<DerivedDispatcherT*>(this);
}
template <typename DerivedDispatcherT>
template<typename DerivedDispatcherT>
DerivedDispatcherT* ActionDispatcher<DerivedDispatcherT>::DisableSnapToGrid()
{
Log("Disabling SnapToGrid");
@@ -120,15 +139,15 @@ namespace AzManipulatorTestFramework
return static_cast<DerivedDispatcherT*>(this);
}
template <typename DerivedDispatcherT>
template<typename DerivedDispatcherT>
DerivedDispatcherT* ActionDispatcher<DerivedDispatcherT>::GridSize(float size)
{
Log("GridSize: %f", size);
Log("GridSize: %.3f", size);
GridSizeImpl(size);
return static_cast<DerivedDispatcherT*>(this);
}
template <typename DerivedDispatcherT>
template<typename DerivedDispatcherT>
DerivedDispatcherT* ActionDispatcher<DerivedDispatcherT>::LogActions(bool logging)
{
m_logging = logging;
@@ -136,17 +155,16 @@ namespace AzManipulatorTestFramework
return static_cast<DerivedDispatcherT*>(this);
}
template <typename DerivedDispatcherT>
template<typename DerivedDispatcherT>
DerivedDispatcherT* ActionDispatcher<DerivedDispatcherT>::CameraState(const AzFramework::CameraState& cameraState)
{
Log("Camera state: p(%f, %f, %f) d(%f, %f, %f)",
float(cameraState.m_position.GetX()), float(cameraState.m_position.GetY()), float(cameraState.m_position.GetZ()),
float(cameraState.m_forward.GetX()), float(cameraState.m_forward.GetY()), float(cameraState.m_forward.GetZ()));
Log("Camera state: p(%.3f, %.3f, %.3f) d(%.3f, %.3f, %.3f)", cameraState.m_position.GetX(), cameraState.m_position.GetY(),
cameraState.m_position.GetZ(), cameraState.m_forward.GetX(), cameraState.m_forward.GetY(), cameraState.m_forward.GetZ());
CameraStateImpl(cameraState);
return static_cast<DerivedDispatcherT*>(this);
}
template <typename DerivedDispatcherT>
template<typename DerivedDispatcherT>
DerivedDispatcherT* ActionDispatcher<DerivedDispatcherT>::MouseLButtonDown()
{
Log("%s", "Mouse left button down");
@@ -154,14 +172,15 @@ namespace AzManipulatorTestFramework
return static_cast<DerivedDispatcherT*>(this);
}
template <typename DerivedDispatcherT>
template<typename DerivedDispatcherT>
DerivedDispatcherT* ActionDispatcher<DerivedDispatcherT>::MouseLButtonUp()
{
Log("%s", "Mouse left button up");
MouseLButtonUpImpl();
return static_cast<DerivedDispatcherT*>(this);
}
template <typename DerivedDispatcherT>
template<typename DerivedDispatcherT>
const char* ActionDispatcher<DerivedDispatcherT>::KeyboardModifierString(
const AzToolsFramework::ViewportInteraction::KeyboardModifier& keyModifier)
{
@@ -176,11 +195,12 @@ namespace AzManipulatorTestFramework
return "Shift";
case KeyboardModifier::None:
return "None";
default: return "Unknown modifier";
default:
return "Unknown modifier";
}
}
template <typename DerivedDispatcherT>
template<typename DerivedDispatcherT>
DerivedDispatcherT* ActionDispatcher<DerivedDispatcherT>::KeyboardModifierDown(
const AzToolsFramework::ViewportInteraction::KeyboardModifier& keyModifier)
{
@@ -189,7 +209,7 @@ namespace AzManipulatorTestFramework
return static_cast<DerivedDispatcherT*>(this);
}
template <typename DerivedDispatcherT>
template<typename DerivedDispatcherT>
DerivedDispatcherT* ActionDispatcher<DerivedDispatcherT>::KeyboardModifierUp(
const AzToolsFramework::ViewportInteraction::KeyboardModifier& keyModifier)
{
@@ -198,7 +218,7 @@ namespace AzManipulatorTestFramework
return static_cast<DerivedDispatcherT*>(this);
}
template <typename DerivedDispatcherT>
template<typename DerivedDispatcherT>
DerivedDispatcherT* ActionDispatcher<DerivedDispatcherT>::MousePosition(const AzFramework::ScreenPoint& position)
{
Log("Mouse position: (%i, %i)", position.m_x, position.m_y);
@@ -206,7 +226,7 @@ namespace AzManipulatorTestFramework
return static_cast<DerivedDispatcherT*>(this);
}
template <typename DerivedDispatcherT>
template<typename DerivedDispatcherT>
DerivedDispatcherT* ActionDispatcher<DerivedDispatcherT>::ExpectManipulatorBeingInteracted()
{
Log("Expecting manipulator interacting");
@@ -214,7 +234,7 @@ namespace AzManipulatorTestFramework
return static_cast<DerivedDispatcherT*>(this);
}
template <typename DerivedDispatcherT>
template<typename DerivedDispatcherT>
DerivedDispatcherT* ActionDispatcher<DerivedDispatcherT>::ExpectManipulatorNotBeingInteracted()
{
Log("Not expecting manipulator interacting");
@@ -222,27 +242,24 @@ namespace AzManipulatorTestFramework
return static_cast<DerivedDispatcherT*>(this);
}
template <typename DerivedDispatcherT>
DerivedDispatcherT* ActionDispatcher<DerivedDispatcherT>::SetEntityWorldTransform(
AZ::EntityId entityId, const AZ::Transform& transform)
template<typename DerivedDispatcherT>
DerivedDispatcherT* ActionDispatcher<DerivedDispatcherT>::SetEntityWorldTransform(AZ::EntityId entityId, const AZ::Transform& transform)
{
Log("Setting entity world transform: %s", AZ::ToString(transform).c_str());
SetEntityWorldTransformImpl(entityId, transform);
return static_cast<DerivedDispatcherT*>(this);
}
template <typename DerivedDispatcherT>
DerivedDispatcherT* ActionDispatcher<DerivedDispatcherT>::SetSelectedEntity(
AZ::EntityId entity)
template<typename DerivedDispatcherT>
DerivedDispatcherT* ActionDispatcher<DerivedDispatcherT>::SetSelectedEntity(AZ::EntityId entity)
{
Log("Selecting entity: %u", static_cast<AZ::u64>(entity));
SetSelectedEntityImpl(entity);
return static_cast<DerivedDispatcherT*>(this);
}
template <typename DerivedDispatcherT>
DerivedDispatcherT* ActionDispatcher<DerivedDispatcherT>::SetSelectedEntities(
const AzToolsFramework::EntityIdList& entities)
template<typename DerivedDispatcherT>
DerivedDispatcherT* ActionDispatcher<DerivedDispatcherT>::SetSelectedEntities(const AzToolsFramework::EntityIdList& entities)
{
for (const auto& entity : entities)
{
@@ -252,7 +269,7 @@ namespace AzManipulatorTestFramework
return static_cast<DerivedDispatcherT*>(this);
}
template <typename DerivedDispatcherT>
template<typename DerivedDispatcherT>
DerivedDispatcherT* ActionDispatcher<DerivedDispatcherT>::EnterComponentMode(const AZ::Uuid& uuid)
{
Log("Entering component mode: %s", uuid.ToString<AZStd::string>().c_str());
@@ -260,7 +277,7 @@ namespace AzManipulatorTestFramework
return static_cast<DerivedDispatcherT*>(this);
}
template <typename DerivedDispatcherT>
template<typename DerivedDispatcherT>
DerivedDispatcherT* ActionDispatcher<DerivedDispatcherT>::DebugBreak()
{
Log("Breaking to debugger");
@@ -268,8 +285,8 @@ namespace AzManipulatorTestFramework
return static_cast<DerivedDispatcherT*>(this);
}
template <typename DerivedDispatcherT>
template <typename ComponentT>
template<typename DerivedDispatcherT>
template<typename ComponentT>
DerivedDispatcherT* ActionDispatcher<DerivedDispatcherT>::EnterComponentMode()
{
EnterComponentMode(AZ::AzTypeInfo<ComponentT>::Uuid());
@@ -10,11 +10,14 @@
#include <AzManipulatorTestFramework/ActionDispatcher.h>
#include <AzManipulatorTestFramework/AzManipulatorTestFramework.h>
#include <AzToolsFramework/Viewport/ViewportMessages.h>
namespace AzManipulatorTestFramework
{
//! Dispatches actions immediately to the manipulators.
class ImmediateModeActionDispatcher : public ActionDispatcher<ImmediateModeActionDispatcher>
class ImmediateModeActionDispatcher
: public ActionDispatcher<ImmediateModeActionDispatcher>
, public AzToolsFramework::ViewportInteraction::EditorModifierKeyRequestBus::Handler
{
using KeyboardModifier = AzToolsFramework::ViewportInteraction::KeyboardModifier;
using KeyboardModifiers = AzToolsFramework::ViewportInteraction::KeyboardModifiers;
@@ -44,8 +47,8 @@ namespace AzManipulatorTestFramework
//! Execute an arbitrary section of code inline in the action dispatcher.
ImmediateModeActionDispatcher* ExecuteBlock(const AZStd::function<void()>& blockFn);
//! Get the current state of the keyboard modifiers.
KeyboardModifiers GetKeyboardModifiers() const;
// EditorModifierKeyRequestBus overrides ...
KeyboardModifiers QueryKeyboardModifiers() override;
protected:
// ActionDispatcher ...
@@ -94,11 +97,11 @@ namespace AzManipulatorTestFramework
inline ImmediateModeActionDispatcher* ImmediateModeActionDispatcher::GetKeyboardModifiers(KeyboardModifiers& keyboardModifiers)
{
keyboardModifiers = GetKeyboardModifiers();
keyboardModifiers = QueryKeyboardModifiers();
return this;
}
inline AzToolsFramework::ViewportInteraction::KeyboardModifiers ImmediateModeActionDispatcher::GetKeyboardModifiers() const
inline AzToolsFramework::ViewportInteraction::KeyboardModifiers ImmediateModeActionDispatcher::QueryKeyboardModifiers()
{
return GetMouseInteractionEvent()->m_mouseInteraction.m_keyboardModifiers;
}
@@ -32,9 +32,13 @@ namespace AzManipulatorTestFramework
ImmediateModeActionDispatcher::ImmediateModeActionDispatcher(ManipulatorViewportInteraction& viewportManipulatorInteraction)
: m_viewportManipulatorInteraction(viewportManipulatorInteraction)
{
AzToolsFramework::ViewportInteraction::EditorModifierKeyRequestBus::Handler::BusConnect();
}
ImmediateModeActionDispatcher::~ImmediateModeActionDispatcher() = default;
ImmediateModeActionDispatcher::~ImmediateModeActionDispatcher()
{
AzToolsFramework::ViewportInteraction::EditorModifierKeyRequestBus::Handler::BusDisconnect();
}
void ImmediateModeActionDispatcher::MouseMoveAfterButton()
{
@@ -414,6 +414,9 @@ namespace AzToolsFramework
//! Gets an existing entity id from a known id.
virtual AZ::EntityId GetExistingEntity(AZ::u64 id) = 0;
//! Returns if an entity with the given id exists
virtual bool EntityExists(AZ::EntityId id) = 0;
/*!
* Delete all currently-selected entities.
*/
@@ -378,6 +378,7 @@ namespace AzToolsFramework
->Event("CreateNewEntityAtPosition", &ToolsApplicationRequests::CreateNewEntityAtPosition)
->Event("GetCurrentLevelEntityId", &ToolsApplicationRequests::GetCurrentLevelEntityId)
->Event("GetExistingEntity", &ToolsApplicationRequests::GetExistingEntity)
->Event("EntityExists", &ToolsApplicationRequests::EntityExists)
->Event("DeleteEntityById", &ToolsApplicationRequests::DeleteEntityById)
->Event("DeleteEntities", &ToolsApplicationRequests::DeleteEntities)
->Event("DeleteEntityAndAllDescendants", &ToolsApplicationRequests::DeleteEntityAndAllDescendants)
@@ -783,6 +784,11 @@ namespace AzToolsFramework
return AZ::EntityId{id};
}
bool ToolsApplication::EntityExists(AZ::EntityId id)
{
return FindEntity(id) != nullptr;
}
void ToolsApplication::DeleteSelected()
{
if (IsPrefabSystemEnabled())
@@ -115,6 +115,7 @@ namespace AzToolsFramework
AZ::EntityId CreateNewEntity(AZ::EntityId parentId = AZ::EntityId()) override;
AZ::EntityId CreateNewEntityAtPosition(const AZ::Vector3& pos, AZ::EntityId parentId = AZ::EntityId()) override;
AZ::EntityId GetExistingEntity(AZ::u64 id) override;
bool EntityExists(AZ::EntityId id) override;
void DeleteSelected() override;
void DeleteEntityById(AZ::EntityId entityId) override;
void DeleteEntities(const EntityIdList& entities) override;
@@ -11,6 +11,7 @@
#include <AzCore/Component/TransformBus.h>
#include <AzCore/Math/VertexContainerInterface.h>
#include <AzCore/std/sort.h>
#include <AzFramework/Viewport/ViewportScreen.h>
#include <AzToolsFramework/ComponentMode/EditorComponentModeBus.h>
#include <AzToolsFramework/Manipulators/LinearManipulator.h>
#include <AzToolsFramework/Manipulators/ManipulatorSnapping.h>
@@ -363,9 +364,7 @@ namespace AzToolsFramework
boxSelectData.m_activeSelection = boxSelectData.m_startSelection;
}
// set the widget context before calls to ViewportWorldToScreen so we are not
// going to constantly be pushing/popping the widget context
ViewportInteraction::WidgetContextGuard widgetContextGuard(viewportId);
const AzFramework::CameraState cameraState = GetCameraState(viewportId);
// box select active (clicking and dragging)
if (editorBoxSelect.BoxRegion())
@@ -385,7 +384,7 @@ namespace AzToolsFramework
found, fixedVertices, &AZ::FixedVerticesRequestBus<Vertex>::Handler::GetVertex, vertexIndex, localVertex);
const AZ::Vector3 worldVertex = worldFromLocal.TransformPoint(AZ::AdaptVertexOut<Vertex>(localVertex));
const AzFramework::ScreenPoint screenPosition = GetScreenPosition(viewportId, worldVertex);
const AzFramework::ScreenPoint screenPosition = AzFramework::WorldToScreen(worldVertex, cameraState);
// check if a vertex is inside the box select region
if (editorBoxSelect.BoxRegion()->contains(ViewportInteraction::QPointFromScreenPoint(screenPosition)))
@@ -658,8 +657,7 @@ namespace AzToolsFramework
m_editorBoxSelect.InstallDisplayScene(
[this, vertexBoxSelectData](const AzFramework::ViewportInfo& viewportInfo, AzFramework::DebugDisplayRequests& /*debugDisplay*/)
{
const auto keyboardModifiers = ViewportInteraction::KeyboardModifiers(
ViewportInteraction::TranslateKeyboardModifiers(QApplication::queryKeyboardModifiers()));
const auto keyboardModifiers = AzToolsFramework::ViewportInteraction::QueryKeyboardModifiers();
// when modifiers change ensure we refresh box selection for immediate update
if (keyboardModifiers != m_editorBoxSelect.PreviousModifiers())
@@ -254,11 +254,6 @@ namespace AzToolsFramework
virtual bool ShowingWorldSpace() = 0;
//! Return the widget to use as the parent for the viewport context menu.
virtual QWidget* GetWidgetForViewportContextMenu() = 0;
//! 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.
virtual void EndWidgetContext() = 0;
protected:
~MainEditorViewportInteractionRequests() = default;
@@ -280,6 +275,29 @@ namespace AzToolsFramework
using EditorEntityViewportInteractionRequestBus = AZ::EBus<EditorEntityViewportInteractionRequests, ViewportEBusTraits>;
//! An interface to query editor modifier keys.
class EditorModifierKeyRequests : public AZ::EBusTraits
{
public:
static const AZ::EBusAddressPolicy AddressPolicy = AZ::EBusAddressPolicy::Single;
static const AZ::EBusHandlerPolicy HandlerPolicy = AZ::EBusHandlerPolicy::Single;
//! Returns the current state of the keyboard modifier keys.
virtual KeyboardModifiers QueryKeyboardModifiers() = 0;
protected:
~EditorModifierKeyRequests() = default;
};
using EditorModifierKeyRequestBus = AZ::EBus<EditorModifierKeyRequests>;
inline KeyboardModifiers QueryKeyboardModifiers()
{
KeyboardModifiers keyboardModifiers;
EditorModifierKeyRequestBus::BroadcastResult(keyboardModifiers, &EditorModifierKeyRequestBus::Events::QueryKeyboardModifiers);
return keyboardModifiers;
}
//! Viewport requests for managing the viewport cursor state.
class ViewportMouseCursorRequests
{
@@ -297,28 +315,6 @@ namespace AzToolsFramework
//! Type to inherit to implement MainEditorViewportInteractionRequests.
using ViewportMouseCursorRequestBus = AZ::EBus<ViewportMouseCursorRequests, ViewportEBusTraits>;
//! A helper to wrap Begin/EndWidgetContext.
class WidgetContextGuard
{
public:
explicit WidgetContextGuard(const int viewportId)
: m_viewportId(viewportId)
{
MainEditorViewportInteractionRequestBus::Event(
viewportId, &MainEditorViewportInteractionRequestBus::Events::BeginWidgetContext);
}
~WidgetContextGuard()
{
MainEditorViewportInteractionRequestBus::Event(
m_viewportId, &MainEditorViewportInteractionRequestBus::Events::EndWidgetContext);
}
private:
int m_viewportId; //!< The viewport id the widget context is being set on.
};
} // namespace ViewportInteraction
//! Utility function to return EntityContextId.
@@ -19,6 +19,13 @@ namespace AzToolsFramework
static const AZ::Color s_boxSelectColor = AZ::Color(1.0f, 1.0f, 1.0f, 0.4f);
static const float s_boxSelectLineWidth = 2.0f;
EditorBoxSelect::EditorBoxSelect()
{
// discard double click interval as box select is only interested in 'move' detection
// note: this also simplifies integration tests that do not have delays between presses
m_clickDetector.SetDoubleClickInterval(0.0f);
}
void EditorBoxSelect::HandleMouseInteraction(const ViewportInteraction::MouseInteractionEvent& mouseInteraction)
{
AZ_PROFILE_FUNCTION(AzToolsFramework);
@@ -95,8 +102,7 @@ namespace AzToolsFramework
debugDisplay.DepthTestOn();
m_previousModifiers = ViewportInteraction::KeyboardModifiers(
ViewportInteraction::TranslateKeyboardModifiers(QApplication::queryKeyboardModifiers()));
m_previousModifiers = AzToolsFramework::ViewportInteraction::QueryKeyboardModifiers();
}
}
@@ -29,7 +29,7 @@ namespace AzToolsFramework
class EditorBoxSelect
{
public:
EditorBoxSelect() = default;
EditorBoxSelect();
//! Return if a box select action is currently taking place.
bool Active() const { return m_boxSelectRegion.has_value(); }
@@ -293,8 +293,8 @@ namespace AzToolsFramework
}
// poll and set the keyboard modifiers to ensure the mouse interaction is up to date
m_currentInteraction.m_keyboardModifiers =
AzToolsFramework::ViewportInteraction::BuildKeyboardModifiers(QGuiApplication::queryKeyboardModifiers());
m_currentInteraction.m_keyboardModifiers = AzToolsFramework::ViewportInteraction::QueryKeyboardModifiers();
// draw the manipulators
const AzFramework::CameraState cameraState = GetCameraState(viewportInfo.m_viewportId);
debugDisplay.DepthTestOff();
@@ -11,6 +11,7 @@
#include <AzCore/Console/Console.h>
#include <AzFramework/Entity/EntityDebugDisplayBus.h>
#include <AzFramework/Viewport/CameraState.h>
#include <AzFramework/Viewport/ViewportScreen.h>
#include <AzFramework/Visibility/BoundsBus.h>
#include <AzToolsFramework/API/EditorViewportIconDisplayInterface.h>
#include <AzToolsFramework/ToolsComponents/EditorEntityIconComponentBus.h>
@@ -118,10 +119,6 @@ namespace AzToolsFramework
const int viewportId = mouseInteraction.m_mouseInteraction.m_interactionId.m_viewportId;
// set the widget context before calls to ViewportWorldToScreen so we are not
// going to constantly be pushing/popping the widget context
ViewportInteraction::WidgetContextGuard widgetContextGuard(viewportId);
const bool helpersVisible = HelpersVisible();
// selecting new entities
@@ -145,7 +142,7 @@ namespace AzToolsFramework
const AZ::Vector3& entityPosition = m_entityDataCache->GetVisibleEntityPosition(entityCacheIndex);
// selecting based on 2d icon - should only do it when visible and not selected
const AzFramework::ScreenPoint screenPosition = GetScreenPosition(viewportId, entityPosition);
const AzFramework::ScreenPoint screenPosition = AzFramework::WorldToScreen(entityPosition, cameraState);
const float distSqFromCamera = cameraState.m_position.GetDistanceSq(entityPosition);
const auto iconRange = static_cast<float>(GetIconScale(distSqFromCamera) * s_iconSize * 0.5f);
@@ -48,18 +48,6 @@ namespace AzToolsFramework
return AZ::GetMax(projectedCameraDistance, cameraState.m_nearClip) / apparentDistance;
}
AzFramework::ScreenPoint GetScreenPosition(const int viewportId, const AZ::Vector3& worldTranslation)
{
AZ_PROFILE_FUNCTION(AzToolsFramework);
auto screenPosition = AzFramework::ScreenPoint(0, 0);
ViewportInteraction::ViewportInteractionRequestBus::EventResult(
screenPosition, viewportId, &ViewportInteraction::ViewportInteractionRequestBus::Events::ViewportWorldToScreen,
worldTranslation);
return screenPosition;
}
bool AabbIntersectRay(const AZ::Vector3& origin, const AZ::Vector3& direction, const AZ::Aabb& aabb, float& distance)
{
AZ_PROFILE_FUNCTION(AzToolsFramework);
@@ -39,9 +39,6 @@ namespace AzToolsFramework
//! Calculate scale factor based on distance from camera
float CalculateScreenToWorldMultiplier(const AZ::Vector3& worldPosition, const AzFramework::CameraState& cameraState);
//! Map from world space to screen space.
AzFramework::ScreenPoint GetScreenPosition(int viewportId, const AZ::Vector3& worldTranslation);
//! Given a mouse interaction, determine if the pick ray from its position
//! in screen space intersected an aabb in world space.
bool AabbIntersectMouseRay(const ViewportInteraction::MouseInteraction& mouseInteraction, const AZ::Aabb& aabb);
@@ -399,23 +399,22 @@ namespace AzToolsFramework
// modifier has changed - swapped from additive to subtractive box select (or vice versa)
if (previousKeyboardModifiers != currentKeyboardModifiers)
{
for (AZ::EntityId entityId : potentialDeselectedEntityIds)
for (const AZ::EntityId& entityId : potentialDeselectedEntityIds)
{
editorTransformComponentSelection.AddEntityToSelection(entityId);
}
potentialDeselectedEntityIds.clear();
for (AZ::EntityId entityId : potentialSelectedEntityIds)
for (const AZ::EntityId& entityId : potentialSelectedEntityIds)
{
editorTransformComponentSelection.RemoveEntityFromSelection(entityId);
}
potentialSelectedEntityIds.clear();
}
// set the widget context before calls to ViewportWorldToScreen so we are not
// going to constantly be pushing/popping the widget context
ViewportInteraction::WidgetContextGuard widgetContextGuard(viewportId);
const AzFramework::CameraState cameraState = GetCameraState(viewportId);
for (size_t entityCacheIndex = 0; entityCacheIndex < entityDataCache.VisibleEntityDataCount(); ++entityCacheIndex)
{
if (entityDataCache.IsVisibleEntityLocked(entityCacheIndex) || !entityDataCache.IsVisibleEntityVisible(entityCacheIndex))
@@ -426,7 +425,7 @@ namespace AzToolsFramework
const AZ::EntityId entityId = entityDataCache.GetVisibleEntityId(entityCacheIndex);
const AZ::Vector3& entityPosition = entityDataCache.GetVisibleEntityPosition(entityCacheIndex);
const AzFramework::ScreenPoint screenPosition = GetScreenPosition(viewportId, entityPosition);
const AzFramework::ScreenPoint screenPosition = AzFramework::WorldToScreen(entityPosition, cameraState);
if (currentKeyboardModifiers.Ctrl())
{
@@ -1165,15 +1164,13 @@ namespace AzToolsFramework
m_boxSelect.InstallDisplayScene(
[this, entityBoxSelectData](const AzFramework::ViewportInfo& viewportInfo, AzFramework::DebugDisplayRequests& debugDisplay)
{
const auto modifiers = ViewportInteraction::KeyboardModifiers(
ViewportInteraction::TranslateKeyboardModifiers(QApplication::queryKeyboardModifiers()));
if (m_boxSelect.PreviousModifiers() != modifiers)
if (const auto keyboardModifiers = AzToolsFramework::ViewportInteraction::QueryKeyboardModifiers();
m_boxSelect.PreviousModifiers() != keyboardModifiers)
{
EntityBoxSelectUpdateGeneral(
m_boxSelect.BoxRegion(), *this, m_selectedEntityIds, entityBoxSelectData->m_selectedEntityIdsBeforeBoxSelect,
entityBoxSelectData->m_potentialSelectedEntityIds, entityBoxSelectData->m_potentialDeselectedEntityIds,
*m_entityDataCache, viewportInfo.m_viewportId, modifiers, m_boxSelect.PreviousModifiers());
*m_entityDataCache, viewportInfo.m_viewportId, keyboardModifiers, m_boxSelect.PreviousModifiers());
}
debugDisplay.DepthTestOff();
@@ -1779,13 +1776,7 @@ namespace AzToolsFramework
CheckDirtyEntityIds();
const int viewportId = mouseInteraction.m_mouseInteraction.m_interactionId.m_viewportId;
const AzFramework::CameraState cameraState = GetCameraState(viewportId);
// set the widget context before calls to ViewportWorldToScreen so we are not
// going to constantly be pushing/popping the widget context
ViewportInteraction::WidgetContextGuard widgetContextGuard(viewportId);
const AzFramework::CameraState cameraState = GetCameraState(mouseInteraction.m_mouseInteraction.m_interactionId.m_viewportId);
m_cachedEntityIdUnderCursor = m_editorHelpers->HandleMouseInteraction(cameraState, mouseInteraction);
@@ -3333,16 +3324,15 @@ namespace AzToolsFramework
CheckDirtyEntityIds();
const auto modifiers =
ViewportInteraction::KeyboardModifiers(ViewportInteraction::TranslateKeyboardModifiers(QApplication::queryKeyboardModifiers()));
const auto keyboardModifiers = AzToolsFramework::ViewportInteraction::QueryKeyboardModifiers();
m_cursorState.Update();
HandleAccents(
!m_selectedEntityIds.empty(), m_cachedEntityIdUnderCursor, modifiers.Ctrl(), m_hoveredEntityId,
!m_selectedEntityIds.empty(), m_cachedEntityIdUnderCursor, keyboardModifiers.Ctrl(), m_hoveredEntityId,
ViewportInteraction::BuildMouseButtons(QGuiApplication::mouseButtons()), m_boxSelect.Active());
const ReferenceFrame referenceFrame = m_spaceCluster.m_spaceLock.value_or(ReferenceFrameFromModifiers(modifiers));
const ReferenceFrame referenceFrame = m_spaceCluster.m_spaceLock.value_or(ReferenceFrameFromModifiers(keyboardModifiers));
UpdateSpaceCluster(referenceFrame);
@@ -235,7 +235,7 @@ namespace AzToolsFramework
// can be returned to its previous state after an undo/redo operation
void CreateEntityManipulatorDeselectCommand(ScopedUndoBatch& undoBatch);
// EditorTransformComponentSelectionRequestBus ...
// EditorTransformComponentSelectionRequestBus overrides ...
Mode GetTransformMode() override;
void SetTransformMode(Mode mode) override;
void RefreshManipulators(RefreshType refreshType) override;
@@ -252,34 +252,34 @@ namespace AzToolsFramework
void CopyScaleToSelectedEntitiesIndividualWorld(float scale) override;
void SnapSelectedEntitiesToWorldGrid(float gridSize) override;
// EditorManipulatorCommandUndoRedoRequestBus ...
// EditorManipulatorCommandUndoRedoRequestBus overrides ...
void UndoRedoEntityManipulatorCommand(AZ::u8 pivotOverride, const AZ::Transform& transform, AZ::EntityId entityId) override;
// EditorContextMenuBus...
// EditorContextMenuBus overrides ...
void PopulateEditorGlobalContextMenu(QMenu* menu, const AZ::Vector2& point, int flags) override;
int GetMenuPosition() const override;
AZStd::string GetMenuIdentifier() const override;
// EditorEventsBus ...
// EditorEventsBus overrides ...
void OnEscape() override;
// ToolsApplicationNotificationBus ...
// ToolsApplicationNotificationBus overrides ...
void BeforeEntitySelectionChanged() override;
void AfterEntitySelectionChanged(const EntityIdList& newlySelectedEntities, const EntityIdList& newlyDeselectedEntities) override;
// TransformNotificationBus ...
// TransformNotificationBus overrides ...
void OnTransformChanged(const AZ::Transform& localTM, const AZ::Transform& worldTM) override;
// Camera::EditorCameraNotificationBus ...
// Camera::EditorCameraNotificationBus overrides ...
void OnViewportViewEntityChanged(const AZ::EntityId& newViewId) override;
// EditorContextVisibilityNotificationBus ...
// EditorContextVisibilityNotificationBus overrides ...
void OnEntityVisibilityChanged(bool visibility) override;
// EditorContextLockComponentNotificationBus ...
// EditorContextLockComponentNotificationBus overrides ...
void OnEntityLockChanged(bool locked) override;
// EditorComponentModeNotificationBus ...
// EditorComponentModeNotificationBus overrides ...
void EnteredComponentMode(const AZStd::vector<AZ::Uuid>& componentModeTypes) override;
void LeftComponentMode(const AZStd::vector<AZ::Uuid>& componentModeTypes) override;
@@ -301,7 +301,7 @@ namespace AzToolsFramework
//! Responsible for keeping the space cluster in sync with the current reference frame.
void UpdateSpaceCluster(ReferenceFrame referenceFrame);
//! Hides/Shows all viewportUi toolbars.
//! Hides/Shows all viewportUi tool bars.
void SetAllViewportUiVisible(bool visible);
AZ::EntityId m_hoveredEntityId; //!< What EntityId is the mouse currently hovering over (if any).
@@ -238,10 +238,32 @@ namespace UnitTest
m_entityId3 = createEntityWithBoundsFn("Entity3");
}
public:
void PositionEntities()
{
// the initial starting position of the entities
AZ::TransformBus::Event(
m_entityId1, &AZ::TransformBus::Events::SetWorldTM, AZ::Transform::CreateTranslation(m_entity1WorldTranslation));
AZ::TransformBus::Event(
m_entityId2, &AZ::TransformBus::Events::SetWorldTM, AZ::Transform::CreateTranslation(m_entity2WorldTranslation));
AZ::TransformBus::Event(
m_entityId3, &AZ::TransformBus::Events::SetWorldTM, AZ::Transform::CreateTranslation(m_entity3WorldTranslation));
}
static void PositionCamera(AzFramework::CameraState& cameraState)
{
// initial camera position (looking down the negative x-axis)
AzFramework::SetCameraTransform(
cameraState,
AZ::Transform::CreateFromQuaternionAndTranslation(
AZ::Quaternion::CreateFromEulerAnglesDegrees(AZ::Vector3(0.0f, 0.0f, 90.0f)), AZ::Vector3(10.0f, 15.0f, 10.0f)));
}
AZ::EntityId m_entityId1;
AZ::EntityId m_entityId2;
AZ::EntityId m_entityId3;
AZ::Vector3 m_entity1WorldTranslation = AZ::Vector3(5.0f, 15.0f, 10.0f);
AZ::Vector3 m_entity2WorldTranslation = AZ::Vector3(5.0f, 14.0f, 10.0f);
AZ::Vector3 m_entity3WorldTranslation = AZ::Vector3(5.0f, 16.0f, 10.0f);
};
void ArrangeIndividualRotatedEntitySelection(const AzToolsFramework::EntityIdList& entityIds, const AZ::Quaternion& orientation)
@@ -596,25 +618,18 @@ namespace UnitTest
{
AzToolsFramework::ed_viewportStickySelect = true;
// the initial starting position of the entity
const auto initialTransformWorld = AZ::Transform::CreateTranslation(AZ::Vector3(5.0f, 15.0f, 10.0f));
AZ::TransformBus::Event(m_entityId1, &AZ::TransformBus::Events::SetWorldTM, initialTransformWorld);
// initial camera position (looking down the negative x-axis)
AzFramework::SetCameraTransform(
m_cameraState,
AZ::Transform::CreateFromQuaternionAndTranslation(
AZ::Quaternion::CreateFromEulerAnglesDegrees(AZ::Vector3(0.0f, 0.0f, 90.0f)), AZ::Vector3(10.0f, 15.0f, 10.0f)));
PositionEntities();
PositionCamera(m_cameraState);
using ::testing::Eq;
auto selectedEntitiesBefore = SelectedEntities();
EXPECT_TRUE(selectedEntitiesBefore.empty());
// calculate the position in screen space of the initial entity position
const auto initialPositionScreen = AzFramework::WorldToScreen(initialTransformWorld.GetTranslation(), m_cameraState);
const auto entity1ScreenPosition = AzFramework::WorldToScreen(m_entity1WorldTranslation, m_cameraState);
// click the entity in the viewport
m_actionDispatcher->CameraState(m_cameraState)->MousePosition(initialPositionScreen)->MouseLButtonDown()->MouseLButtonUp();
m_actionDispatcher->CameraState(m_cameraState)->MousePosition(entity1ScreenPosition)->MouseLButtonDown()->MouseLButtonUp();
// entity is selected
auto selectedEntitiesAfter = SelectedEntities();
@@ -626,19 +641,12 @@ namespace UnitTest
{
AzToolsFramework::ed_viewportStickySelect = true;
// the initial starting position of the entity
AZ::TransformBus::Event(
m_entityId1, &AZ::TransformBus::Events::SetWorldTM, AZ::Transform::CreateTranslation(AZ::Vector3(5.0f, 15.0f, 10.0f)));
PositionEntities();
PositionCamera(m_cameraState);
// position in space above the entity
const auto clickOffPositionWorld = AZ::Vector3(5.0f, 15.0f, 12.0f);
// initial camera position (looking down the negative x-axis)
AzFramework::SetCameraTransform(
m_cameraState,
AZ::Transform::CreateFromQuaternionAndTranslation(
AZ::Quaternion::CreateFromEulerAnglesDegrees(AZ::Vector3(0.0f, 0.0f, 90.0f)), AZ::Vector3(10.0f, 15.0f, 10.0f)));
AzToolsFramework::SelectEntity(m_entityId1);
// calculate the position in screen space of the initial position of the entity
@@ -660,30 +668,16 @@ namespace UnitTest
{
AzToolsFramework::ed_viewportStickySelect = true;
// the initial starting position of the entity
AZ::TransformBus::Event(
m_entityId1, &AZ::TransformBus::Events::SetWorldTM, AZ::Transform::CreateTranslation(AZ::Vector3(5.0f, 15.0f, 10.0f)));
const auto initialTransformWorldSecondEntity = AZ::Transform::CreateTranslation(AZ::Vector3(5.0f, 10.0f, 10.0f));
AZ::TransformBus::Event(m_entityId2, &AZ::TransformBus::Events::SetWorldTM, initialTransformWorldSecondEntity);
// initial camera position (looking down the negative x-axis)
AzFramework::SetCameraTransform(
m_cameraState,
AZ::Transform::CreateFromQuaternionAndTranslation(
AZ::Quaternion::CreateFromEulerAnglesDegrees(AZ::Vector3(0.0f, 0.0f, 90.0f)), AZ::Vector3(10.0f, 15.0f, 10.0f)));
PositionEntities();
PositionCamera(m_cameraState);
AzToolsFramework::SelectEntity(m_entityId1);
// calculate the position in screen space of the second entity
const auto initialPositionScreenSecondEntity =
AzFramework::WorldToScreen(initialTransformWorldSecondEntity.GetTranslation(), m_cameraState);
const auto entity2ScreenPosition = AzFramework::WorldToScreen(m_entity2WorldTranslation, m_cameraState);
// click the entity in the viewport
m_actionDispatcher->CameraState(m_cameraState)
->MousePosition(initialPositionScreenSecondEntity)
->MouseLButtonDown()
->MouseLButtonUp();
m_actionDispatcher->CameraState(m_cameraState)->MousePosition(entity2ScreenPosition)->MouseLButtonDown()->MouseLButtonUp();
// entity selection was not changed
using ::testing::Eq;
@@ -698,28 +692,17 @@ namespace UnitTest
{
AzToolsFramework::ed_viewportStickySelect = true;
// the initial starting position of the entity
AZ::TransformBus::Event(
m_entityId1, &AZ::TransformBus::Events::SetWorldTM, AZ::Transform::CreateTranslation(AZ::Vector3(5.0f, 15.0f, 10.0f)));
const auto initialTransformWorldSecondEntity = AZ::Transform::CreateTranslation(AZ::Vector3(5.0f, 10.0f, 10.0f));
AZ::TransformBus::Event(m_entityId2, &AZ::TransformBus::Events::SetWorldTM, initialTransformWorldSecondEntity);
// initial camera position (looking down the negative x-axis)
AzFramework::SetCameraTransform(
m_cameraState,
AZ::Transform::CreateFromQuaternionAndTranslation(
AZ::Quaternion::CreateFromEulerAnglesDegrees(AZ::Vector3(0.0f, 0.0f, 90.0f)), AZ::Vector3(10.0f, 15.0f, 10.0f)));
PositionEntities();
PositionCamera(m_cameraState);
AzToolsFramework::SelectEntity(m_entityId1);
// calculate the position in screen space of the second entity
const auto initialPositionScreenSecondEntity =
AzFramework::WorldToScreen(initialTransformWorldSecondEntity.GetTranslation(), m_cameraState);
const auto entity2ScreenPosition = AzFramework::WorldToScreen(m_entity2WorldTranslation, m_cameraState);
// click the entity in the viewport
m_actionDispatcher->CameraState(m_cameraState)
->MousePosition(initialPositionScreenSecondEntity)
->MousePosition(entity2ScreenPosition)
->KeyboardModifierDown(AzToolsFramework::ViewportInteraction::KeyboardModifier::Control)
->MouseLButtonDown()
->MouseLButtonUp();
@@ -736,28 +719,17 @@ namespace UnitTest
{
AzToolsFramework::ed_viewportStickySelect = true;
// the initial starting position of the entity
AZ::TransformBus::Event(
m_entityId1, &AZ::TransformBus::Events::SetWorldTM, AZ::Transform::CreateTranslation(AZ::Vector3(5.0f, 15.0f, 10.0f)));
const auto initialTransformWorldSecondEntity = AZ::Transform::CreateTranslation(AZ::Vector3(5.0f, 10.0f, 10.0f));
AZ::TransformBus::Event(m_entityId2, &AZ::TransformBus::Events::SetWorldTM, initialTransformWorldSecondEntity);
// initial camera position (looking down the negative x-axis)
AzFramework::SetCameraTransform(
m_cameraState,
AZ::Transform::CreateFromQuaternionAndTranslation(
AZ::Quaternion::CreateFromEulerAnglesDegrees(AZ::Vector3(0.0f, 0.0f, 90.0f)), AZ::Vector3(10.0f, 15.0f, 10.0f)));
PositionEntities();
PositionCamera(m_cameraState);
AzToolsFramework::SelectEntities({ m_entityId1, m_entityId2 });
// calculate the position in screen space of the second entity
const auto initialPositionScreenSecondEntity =
AzFramework::WorldToScreen(initialTransformWorldSecondEntity.GetTranslation(), m_cameraState);
const auto entity2ScreenPosition = AzFramework::WorldToScreen(m_entity2WorldTranslation, m_cameraState);
// click the entity in the viewport
m_actionDispatcher->CameraState(m_cameraState)
->MousePosition(initialPositionScreenSecondEntity)
->MousePosition(entity2ScreenPosition)
->KeyboardModifierDown(AzToolsFramework::ViewportInteraction::KeyboardModifier::Control)
->MouseLButtonDown()
->MouseLButtonUp();
@@ -768,39 +740,26 @@ namespace UnitTest
EXPECT_THAT(selectedEntitiesAfter, UnorderedElementsAre(m_entityId1));
}
TEST_F(EditorTransformComponentSelectionViewportPickingManipulatorTestFixture, DISABLED_BoxSelectWithNoInitialSelectionAddsEntitiesToSelection)
TEST_F(EditorTransformComponentSelectionViewportPickingManipulatorTestFixture, BoxSelectWithNoInitialSelectionAddsEntitiesToSelection)
{
AzToolsFramework::ed_viewportStickySelect = true;
// the initial starting position of the entities
AZ::TransformBus::Event(
m_entityId1, &AZ::TransformBus::Events::SetWorldTM, AZ::Transform::CreateTranslation(AZ::Vector3(5.0f, 15.0f, 10.0f)));
AZ::TransformBus::Event(
m_entityId2, &AZ::TransformBus::Events::SetWorldTM, AZ::Transform::CreateTranslation(AZ::Vector3(5.0f, 14.0f, 10.0f)));
AZ::TransformBus::Event(
m_entityId3, &AZ::TransformBus::Events::SetWorldTM, AZ::Transform::CreateTranslation(AZ::Vector3(5.0f, 16.0f, 10.0f)));
// initial camera position (looking down the negative x-axis)
AzFramework::SetCameraTransform(
m_cameraState,
AZ::Transform::CreateFromQuaternionAndTranslation(
AZ::Quaternion::CreateFromEulerAnglesDegrees(AZ::Vector3(0.0f, 0.0f, 90.0f)), AZ::Vector3(10.0f, 15.0f, 10.0f)));
PositionEntities();
PositionCamera(m_cameraState);
using ::testing::Eq;
auto selectedEntitiesBefore = SelectedEntities();
EXPECT_THAT(selectedEntitiesBefore.size(), Eq(0));
// calculate the position in screen space of where to begin and end the box select action
const auto beginningPositionWorldBoxSelectStart = AzFramework::WorldToScreen(AZ::Vector3(5.0f, 13.5f, 10.5f), m_cameraState);
const auto middlePositionWorldBoxSelectStart = AzFramework::WorldToScreen(AZ::Vector3(5.0f, 15.0f, 10.0f), m_cameraState);
const auto endingPositionWorldBoxSelectStart = AzFramework::WorldToScreen(AZ::Vector3(5.0f, 16.5f, 9.5f), m_cameraState);
const auto beginningPositionWorldBoxSelect = AzFramework::WorldToScreen(AZ::Vector3(5.0f, 13.5f, 10.5f), m_cameraState);
const auto endingPositionWorldBoxSelect = AzFramework::WorldToScreen(AZ::Vector3(5.0f, 16.5f, 9.5f), m_cameraState);
// perform a box select in the viewport
m_actionDispatcher->CameraState(m_cameraState)
->MousePosition(beginningPositionWorldBoxSelectStart)
->MousePosition(beginningPositionWorldBoxSelect)
->MouseLButtonDown()
->MousePosition(middlePositionWorldBoxSelectStart)
->MousePosition(endingPositionWorldBoxSelectStart)
->MousePosition(endingPositionWorldBoxSelect)
->MouseLButtonUp();
// entities are selected
@@ -809,6 +768,73 @@ namespace UnitTest
EXPECT_THAT(selectedEntitiesAfter, UnorderedElementsAre(m_entityId1, m_entityId2, m_entityId3));
}
TEST_F(EditorTransformComponentSelectionViewportPickingManipulatorTestFixture, BoxSelectWithSelectionAppendsEntitiesToSelection)
{
AzToolsFramework::ed_viewportStickySelect = true;
PositionEntities();
PositionCamera(m_cameraState);
AzToolsFramework::SelectEntity(m_entityId1);
using ::testing::UnorderedElementsAre;
auto selectedEntitiesBefore = SelectedEntities();
EXPECT_THAT(selectedEntitiesBefore, UnorderedElementsAre(m_entityId1));
// calculate the position in screen space of where to begin and end the box select action
const auto beginningPositionWorldBoxSelect1 = AzFramework::WorldToScreen(AZ::Vector3(5.0f, 14.5f, 10.5f), m_cameraState);
const auto endingPositionWorldBoxSelect1 = AzFramework::WorldToScreen(AZ::Vector3(5.0f, 13.5f, 9.5f), m_cameraState);
const auto beginningPositionWorldBoxSelect2 = AzFramework::WorldToScreen(AZ::Vector3(5.0f, 15.5f, 10.5f), m_cameraState);
const auto endingPositionWorldBoxSelect2 = AzFramework::WorldToScreen(AZ::Vector3(5.0f, 16.5f, 9.5f), m_cameraState);
// perform a box select in the viewport (going left and right)
m_actionDispatcher->CameraState(m_cameraState)
->MousePosition(beginningPositionWorldBoxSelect1)
->MouseLButtonDown()
->MousePosition(endingPositionWorldBoxSelect1)
->MouseLButtonUp()
->MousePosition(beginningPositionWorldBoxSelect2)
->MouseLButtonDown()
->MousePosition(endingPositionWorldBoxSelect2)
->MouseLButtonUp();
// entities are selected
auto selectedEntitiesAfter = SelectedEntities();
EXPECT_THAT(selectedEntitiesAfter, UnorderedElementsAre(m_entityId1, m_entityId2, m_entityId3));
}
TEST_F(
EditorTransformComponentSelectionViewportPickingManipulatorTestFixture,
BoxSelectHoldingCtrlWithSelectionRemovesEntitiesFromSelection)
{
AzToolsFramework::ed_viewportStickySelect = true;
PositionEntities();
PositionCamera(m_cameraState);
AzToolsFramework::SelectEntities({ m_entityId1, m_entityId2, m_entityId3 });
using ::testing::UnorderedElementsAre;
auto selectedEntitiesBefore = SelectedEntities();
EXPECT_THAT(selectedEntitiesBefore, UnorderedElementsAre(m_entityId1, m_entityId2, m_entityId3));
// calculate the position in screen space of where to begin and end the box select action
const auto beginningPositionWorldBoxSelect = AzFramework::WorldToScreen(AZ::Vector3(5.0f, 13.5f, 10.5f), m_cameraState);
const auto endingPositionWorldBoxSelect = AzFramework::WorldToScreen(AZ::Vector3(5.0f, 16.5f, 9.5f), m_cameraState);
// perform a box select in the viewport
m_actionDispatcher->CameraState(m_cameraState)
->MousePosition(beginningPositionWorldBoxSelect)
->KeyboardModifierDown(AzToolsFramework::ViewportInteraction::KeyboardModifier::Control)
->MouseLButtonDown()
->MousePosition(endingPositionWorldBoxSelect)
->MouseLButtonUp();
// entities are selected
auto selectedEntitiesAfter = SelectedEntities();
EXPECT_TRUE(selectedEntitiesAfter.empty());
}
using EditorTransformComponentSelectionManipulatorTestFixture =
IndirectCallManipulatorViewportInteractionFixtureMixin<EditorTransformComponentSelectionFixture>;