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
@@ -11,17 +11,18 @@
|
||||
*/
|
||||
|
||||
#include "AzManipulatorTestFrameworkTestFixtures.h"
|
||||
#include <AzToolsFramework/ViewportSelection/EditorInteractionSystemViewportSelectionRequestBus.h>
|
||||
#include <AzToolsFramework/ViewportSelection/EditorDefaultSelection.h>
|
||||
#include <AzToolsFramework/ViewportSelection/EditorInteractionSystemViewportSelectionRequestBus.h>
|
||||
|
||||
namespace UnitTest
|
||||
{
|
||||
class AzManipulatorTestFrameworkBusCallTestFixture
|
||||
: public LinearManipulatorTestFixture
|
||||
class AzManipulatorTestFrameworkBusCallTestFixture : public LinearManipulatorTestFixture
|
||||
{
|
||||
protected:
|
||||
AzManipulatorTestFrameworkBusCallTestFixture()
|
||||
: LinearManipulatorTestFixture(AzToolsFramework::g_mainManipulatorManagerId) {}
|
||||
: LinearManipulatorTestFixture(AzToolsFramework::g_mainManipulatorManagerId)
|
||||
{
|
||||
}
|
||||
|
||||
bool IsManipulatorInteractingBusCall() const
|
||||
{
|
||||
@@ -37,8 +38,8 @@ namespace UnitTest
|
||||
TEST_F(AzManipulatorTestFrameworkBusCallTestFixture, ConsumeViewportLeftMouseClick)
|
||||
{
|
||||
// given a left mouse down ray in world space
|
||||
auto event = AzManipulatorTestFramework::CreateMouseInteractionEvent(
|
||||
m_interaction, AzToolsFramework::ViewportInteraction::MouseEvent::Down);
|
||||
auto event =
|
||||
AzManipulatorTestFramework::CreateMouseInteractionEvent(m_interaction, AzToolsFramework::ViewportInteraction::MouseEvent::Down);
|
||||
|
||||
// consume the mouse down and up events
|
||||
AzManipulatorTestFramework::DispatchMouseInteractionEvent(event);
|
||||
@@ -56,8 +57,8 @@ namespace UnitTest
|
||||
TEST_F(AzManipulatorTestFrameworkBusCallTestFixture, ConsumeViewportMouseMoveHover)
|
||||
{
|
||||
// given a left mouse down ray in world space
|
||||
const auto event = AzManipulatorTestFramework::CreateMouseInteractionEvent(
|
||||
m_interaction, AzToolsFramework::ViewportInteraction::MouseEvent::Move);
|
||||
const auto event =
|
||||
AzManipulatorTestFramework::CreateMouseInteractionEvent(m_interaction, AzToolsFramework::ViewportInteraction::MouseEvent::Move);
|
||||
|
||||
// consume the mouse move event
|
||||
AzManipulatorTestFramework::DispatchMouseInteractionEvent(event);
|
||||
@@ -75,8 +76,8 @@ namespace UnitTest
|
||||
TEST_F(AzManipulatorTestFrameworkBusCallTestFixture, ConsumeViewportMouseMoveActive)
|
||||
{
|
||||
// given a left mouse down ray in world space
|
||||
auto event = AzManipulatorTestFramework::CreateMouseInteractionEvent(
|
||||
m_interaction, AzToolsFramework::ViewportInteraction::MouseEvent::Down);
|
||||
auto event =
|
||||
AzManipulatorTestFramework::CreateMouseInteractionEvent(m_interaction, AzToolsFramework::ViewportInteraction::MouseEvent::Down);
|
||||
|
||||
// consume the mouse down event
|
||||
AzManipulatorTestFramework::DispatchMouseInteractionEvent(event);
|
||||
@@ -110,14 +111,14 @@ namespace UnitTest
|
||||
const AZ::Vector3 initialManipulatorPosition = m_linearManipulator->GetLocalPosition();
|
||||
m_linearManipulator->InstallMouseMoveCallback(
|
||||
[&movementAlongAxis, this](const AzToolsFramework::LinearManipulator::Action& action)
|
||||
{
|
||||
movementAlongAxis = action.LocalPositionOffset();
|
||||
m_linearManipulator->SetLocalPosition(action.LocalPosition());
|
||||
});
|
||||
{
|
||||
movementAlongAxis = action.LocalPositionOffset();
|
||||
m_linearManipulator->SetLocalPosition(action.LocalPosition());
|
||||
});
|
||||
|
||||
// given a left mouse down ray in world space
|
||||
auto event = AzManipulatorTestFramework::CreateMouseInteractionEvent(
|
||||
m_interaction, AzToolsFramework::ViewportInteraction::MouseEvent::Down);
|
||||
auto event =
|
||||
AzManipulatorTestFramework::CreateMouseInteractionEvent(m_interaction, AzToolsFramework::ViewportInteraction::MouseEvent::Down);
|
||||
|
||||
// consume the mouse down event
|
||||
AzManipulatorTestFramework::DispatchMouseInteractionEvent(event);
|
||||
@@ -134,7 +135,7 @@ namespace UnitTest
|
||||
// consume the mouse up event
|
||||
event.m_mouseEvent = AzToolsFramework::ViewportInteraction::MouseEvent::Up;
|
||||
AzManipulatorTestFramework::DispatchMouseInteractionEvent(event);
|
||||
|
||||
|
||||
// expect the left mouse down/up sanity flags to be set
|
||||
EXPECT_TRUE(m_receivedLeftMouseDown);
|
||||
EXPECT_TRUE(m_receivedLeftMouseUp);
|
||||
|
||||
@@ -14,10 +14,10 @@
|
||||
|
||||
namespace UnitTest
|
||||
{
|
||||
class CustomManipulatorManager
|
||||
: public AzToolsFramework::ManipulatorManager
|
||||
class CustomManipulatorManager : public AzToolsFramework::ManipulatorManager
|
||||
{
|
||||
using ManagerBase = AzToolsFramework::ManipulatorManager;
|
||||
|
||||
public:
|
||||
using ManagerBase::ManagerBase;
|
||||
|
||||
@@ -27,17 +27,17 @@ namespace UnitTest
|
||||
}
|
||||
};
|
||||
|
||||
class AzManipulatorTestFrameworkCustomManagerTestFixture
|
||||
: public LinearManipulatorTestFixture
|
||||
class AzManipulatorTestFrameworkCustomManagerTestFixture : public LinearManipulatorTestFixture
|
||||
{
|
||||
protected:
|
||||
AzManipulatorTestFrameworkCustomManagerTestFixture()
|
||||
: LinearManipulatorTestFixture(AzToolsFramework::ManipulatorManagerId(AZ::Crc32("TestManipulatorManagerId"))) {}
|
||||
: LinearManipulatorTestFixture(AzToolsFramework::ManipulatorManagerId(AZ::Crc32("TestManipulatorManagerId")))
|
||||
{
|
||||
}
|
||||
|
||||
void SetUpEditorFixtureImpl() override
|
||||
{
|
||||
m_manipulatorManager =
|
||||
AZStd::make_shared<CustomManipulatorManager>(m_manipulatorManagerId);
|
||||
m_manipulatorManager = AZStd::make_shared<CustomManipulatorManager>(m_manipulatorManagerId);
|
||||
|
||||
LinearManipulatorTestFixture::SetUpEditorFixtureImpl();
|
||||
}
|
||||
@@ -115,9 +115,9 @@ namespace UnitTest
|
||||
|
||||
m_linearManipulator->InstallMouseMoveCallback(
|
||||
[&movementAlongAxis](const AzToolsFramework::LinearManipulator::Action& action)
|
||||
{
|
||||
movementAlongAxis = action.m_current.m_localPositionOffset;
|
||||
});
|
||||
{
|
||||
movementAlongAxis = action.m_current.m_localPositionOffset;
|
||||
});
|
||||
|
||||
// consume the mouse down event
|
||||
m_manipulatorManager->ConsumeViewportMousePress(m_interaction);
|
||||
@@ -141,4 +141,3 @@ namespace UnitTest
|
||||
EXPECT_EQ(movementAlongAxis, expectedPositionAfterMovementAlongAxis);
|
||||
}
|
||||
} // namespace UnitTest
|
||||
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
|
||||
#include "AzManipulatorTestFrameworkTestFixtures.h"
|
||||
|
||||
#include <AZTestShared/Math/MathTestHelpers.h>
|
||||
#include <AzCore/std/smart_ptr/unique_ptr.h>
|
||||
#include <AzFramework/Viewport/ViewportScreen.h>
|
||||
#include <AzManipulatorTestFramework/AzManipulatorTestFramework.h>
|
||||
@@ -22,7 +23,6 @@
|
||||
#include <AzToolsFramework/Manipulators/LinearManipulator.h>
|
||||
#include <AzToolsFramework/Manipulators/PlanarManipulator.h>
|
||||
#include <AzToolsFramework/ViewportSelection/EditorSelectionUtil.h>
|
||||
#include <AZTestShared/Math/MathTestHelpers.h>
|
||||
|
||||
namespace UnitTest
|
||||
{
|
||||
@@ -94,7 +94,8 @@ namespace UnitTest
|
||||
|
||||
template<typename Manipulator>
|
||||
void ValidateManipulatorSnappingBehavior(
|
||||
AZStd::shared_ptr<Manipulator> manipulator, AzManipulatorTestFramework::ImmediateModeActionDispatcher* actionDispatcher,
|
||||
AZStd::shared_ptr<Manipulator> manipulator,
|
||||
AzManipulatorTestFramework::ImmediateModeActionDispatcher* actionDispatcher,
|
||||
const AzFramework::CameraState& cameraState)
|
||||
{
|
||||
manipulator->SetLocalOrientation(AZ::Quaternion::CreateFromEulerAnglesDegrees(AZ::Vector3(180.0f, 0.0f, 135.0f)));
|
||||
|
||||
@@ -15,8 +15,7 @@
|
||||
|
||||
namespace UnitTest
|
||||
{
|
||||
class AValidViewportInteraction
|
||||
: public ToolsApplicationFixture
|
||||
class AValidViewportInteraction : public ToolsApplicationFixture
|
||||
{
|
||||
public:
|
||||
AValidViewportInteraction()
|
||||
@@ -27,8 +26,7 @@ namespace UnitTest
|
||||
protected:
|
||||
void SetUpEditorFixtureImpl() override
|
||||
{
|
||||
m_cameraState =
|
||||
AzFramework::CreateIdentityDefaultCamera(AZ::Vector3::CreateZero(), AZ::Vector2(800.0f, 600.0f));
|
||||
m_cameraState = AzFramework::CreateIdentityDefaultCamera(AZ::Vector3::CreateZero(), AZ::Vector2(800.0f, 600.0f));
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
@@ -11,49 +11,48 @@
|
||||
*/
|
||||
|
||||
#include <AzFramework/Viewport/ViewportScreen.h>
|
||||
#include <AzManipulatorTestFramework/AzManipulatorTestFrameworkUtils.h>
|
||||
#include <AzManipulatorTestFramework/AzManipulatorTestFramework.h>
|
||||
#include <AzManipulatorTestFramework/AzManipulatorTestFrameworkUtils.h>
|
||||
#include <AzManipulatorTestFramework/DirectManipulatorViewportInteraction.h>
|
||||
#include <AzManipulatorTestFramework/IndirectManipulatorViewportInteraction.h>
|
||||
#include <AzManipulatorTestFramework/ImmediateModeActionDispatcher.h>
|
||||
#include <AzToolsFramework/ViewportSelection/EditorSelectionUtil.h>
|
||||
#include <AzManipulatorTestFramework/IndirectManipulatorViewportInteraction.h>
|
||||
#include <AzToolsFramework/UnitTest/AzToolsFrameworkTestHelpers.h>
|
||||
#include <AzToolsFramework/ViewportSelection/EditorSelectionUtil.h>
|
||||
|
||||
namespace UnitTest
|
||||
{
|
||||
class AzManipulatorTestFrameworkWorldSpaceBuilderTestFixture
|
||||
: public ToolsApplicationFixture
|
||||
class AzManipulatorTestFrameworkWorldSpaceBuilderTestFixture : public ToolsApplicationFixture
|
||||
{
|
||||
protected:
|
||||
struct State
|
||||
{
|
||||
State(AZStd::unique_ptr<AzManipulatorTestFramework::ManipulatorViewportInteraction> viewportManipulatorInteraction)
|
||||
: m_viewportManipulatorInteraction(viewportManipulatorInteraction.release())
|
||||
, m_actionDispatcher(AZStd::make_unique<AzManipulatorTestFramework::ImmediateModeActionDispatcher>(*m_viewportManipulatorInteraction))
|
||||
, m_linearManipulator(
|
||||
AzManipulatorTestFramework::CreateLinearManipulator(
|
||||
m_viewportManipulatorInteraction->GetManipulatorManager().GetId(),
|
||||
/*position=*/AZ::Vector3(0.0f, 50.0f, 0.0f),
|
||||
/*radius=*/m_boundsRadius))
|
||||
, m_actionDispatcher(
|
||||
AZStd::make_unique<AzManipulatorTestFramework::ImmediateModeActionDispatcher>(*m_viewportManipulatorInteraction))
|
||||
, m_linearManipulator(AzManipulatorTestFramework::CreateLinearManipulator(
|
||||
m_viewportManipulatorInteraction->GetManipulatorManager().GetId(),
|
||||
/*position=*/AZ::Vector3(0.0f, 50.0f, 0.0f),
|
||||
/*radius=*/m_boundsRadius))
|
||||
{
|
||||
// default sanity check call backs
|
||||
m_linearManipulator->InstallLeftMouseDownCallback(
|
||||
[this]([[maybe_unused]] const AzToolsFramework::LinearManipulator::Action& action)
|
||||
{
|
||||
m_receivedLeftMouseDown = true;
|
||||
});
|
||||
{
|
||||
m_receivedLeftMouseDown = true;
|
||||
});
|
||||
|
||||
m_linearManipulator->InstallMouseMoveCallback(
|
||||
[this]([[maybe_unused]] const AzToolsFramework::LinearManipulator::Action& action)
|
||||
{
|
||||
m_receivedMouseMove = true;
|
||||
});
|
||||
{
|
||||
m_receivedMouseMove = true;
|
||||
});
|
||||
|
||||
m_linearManipulator->InstallLeftMouseUpCallback(
|
||||
[this]([[maybe_unused]] const AzToolsFramework::LinearManipulator::Action& action)
|
||||
{
|
||||
m_receivedLeftMouseUp = true;
|
||||
});
|
||||
{
|
||||
m_receivedLeftMouseUp = true;
|
||||
});
|
||||
}
|
||||
|
||||
~State() = default;
|
||||
@@ -79,13 +78,12 @@ namespace UnitTest
|
||||
protected:
|
||||
void SetUpEditorFixtureImpl() override
|
||||
{
|
||||
m_directState = AZStd::make_unique<State>(
|
||||
AZStd::make_unique<AzManipulatorTestFramework::DirectCallManipulatorViewportInteraction>());
|
||||
m_busState = AZStd::make_unique<State>(
|
||||
AZStd::make_unique<AzManipulatorTestFramework::IndirectCallManipulatorViewportInteraction>());
|
||||
m_directState =
|
||||
AZStd::make_unique<State>(AZStd::make_unique<AzManipulatorTestFramework::DirectCallManipulatorViewportInteraction>());
|
||||
m_busState =
|
||||
AZStd::make_unique<State>(AZStd::make_unique<AzManipulatorTestFramework::IndirectCallManipulatorViewportInteraction>());
|
||||
m_cameraState =
|
||||
AzFramework::CreateIdentityDefaultCamera(
|
||||
AZ::Vector3::CreateZero(), AzManipulatorTestFramework::DefaultViewportSize);
|
||||
AzFramework::CreateIdentityDefaultCamera(AZ::Vector3::CreateZero(), AzManipulatorTestFramework::DefaultViewportSize);
|
||||
}
|
||||
|
||||
void TearDownEditorFixtureImpl() override
|
||||
@@ -105,8 +103,7 @@ namespace UnitTest
|
||||
{
|
||||
// given a left mouse down ray in world space
|
||||
// consume the mouse down and up events
|
||||
state.m_actionDispatcher
|
||||
->CameraState(m_cameraState)
|
||||
state.m_actionDispatcher->CameraState(m_cameraState)
|
||||
->MousePosition(AzManipulatorTestFramework::GetCameraStateViewportCenter(m_cameraState))
|
||||
->MouseLButtonDown()
|
||||
->Trace("Expecting left mouse button down")
|
||||
@@ -126,31 +123,27 @@ namespace UnitTest
|
||||
->ExpectTrue(state.m_receivedLeftMouseUp)
|
||||
->ExpectTrue(state.m_receivedMouseMove)
|
||||
->ExpectFalse(state.m_linearManipulator->PerformingAction())
|
||||
->ExpectManipulatorNotBeingInteracted()
|
||||
;
|
||||
->ExpectManipulatorNotBeingInteracted();
|
||||
}
|
||||
|
||||
void AzManipulatorTestFrameworkWorldSpaceBuilderTestFixture::ConsumeViewportMouseMoveHover(State& state)
|
||||
{
|
||||
// given a left mouse down ray in world space
|
||||
// consume the mouse move event
|
||||
state.m_actionDispatcher
|
||||
->CameraState(m_cameraState)
|
||||
state.m_actionDispatcher->CameraState(m_cameraState)
|
||||
->MousePosition(AzManipulatorTestFramework::GetCameraStateViewportCenter(m_cameraState))
|
||||
->ExpectFalse(state.m_linearManipulator->PerformingAction())
|
||||
->ExpectManipulatorNotBeingInteracted()
|
||||
->ExpectFalse(state.m_receivedLeftMouseDown)
|
||||
->ExpectFalse(state.m_receivedMouseMove)
|
||||
->ExpectFalse(state.m_receivedLeftMouseUp)
|
||||
;
|
||||
->ExpectFalse(state.m_receivedLeftMouseUp);
|
||||
}
|
||||
|
||||
void AzManipulatorTestFrameworkWorldSpaceBuilderTestFixture::ConsumeViewportMouseMoveActive(State& state)
|
||||
{
|
||||
// given a left mouse down ray in world space
|
||||
// consume the mouse move event
|
||||
state.m_actionDispatcher
|
||||
->CameraState(m_cameraState)
|
||||
state.m_actionDispatcher->CameraState(m_cameraState)
|
||||
->MouseLButtonDown()
|
||||
->MousePosition(AzManipulatorTestFramework::GetCameraStateViewportCenter(m_cameraState))
|
||||
->ExpectTrue(state.m_linearManipulator->PerformingAction())
|
||||
@@ -158,8 +151,7 @@ namespace UnitTest
|
||||
->MouseLButtonUp()
|
||||
->ExpectTrue(state.m_receivedLeftMouseDown)
|
||||
->ExpectTrue(state.m_receivedMouseMove)
|
||||
->ExpectTrue(state.m_receivedLeftMouseUp)
|
||||
;
|
||||
->ExpectTrue(state.m_receivedLeftMouseUp);
|
||||
}
|
||||
|
||||
void AzManipulatorTestFrameworkWorldSpaceBuilderTestFixture::MoveManipulatorAlongAxis(State& state)
|
||||
@@ -176,8 +168,7 @@ namespace UnitTest
|
||||
// adjusted final world position taking into account the manipulator position relative to the camera
|
||||
const auto finalPositionWorldAdjusted = finalPositionWorld - (vectorToInitialPositionWorld * scaledRadiusBound);
|
||||
// calculate the position in screen space of the initial position of the manipulator
|
||||
const auto initialPositionScreen =
|
||||
AzFramework::WorldToScreen(initialPositionWorld, m_cameraState);
|
||||
const auto initialPositionScreen = AzFramework::WorldToScreen(initialPositionWorld, m_cameraState);
|
||||
// calculate the position in screen space of the final position of the manipulator
|
||||
const auto finalPositionScreen = AzFramework::WorldToScreen(finalPositionWorldAdjusted, m_cameraState);
|
||||
|
||||
@@ -185,12 +176,11 @@ namespace UnitTest
|
||||
|
||||
state.m_linearManipulator->InstallMouseMoveCallback(
|
||||
[&movementAlongAxis](const AzToolsFramework::LinearManipulator::Action& action)
|
||||
{
|
||||
movementAlongAxis = action.LocalPosition();
|
||||
});
|
||||
{
|
||||
movementAlongAxis = action.LocalPosition();
|
||||
});
|
||||
|
||||
state.m_actionDispatcher
|
||||
->CameraState(m_cameraState)
|
||||
state.m_actionDispatcher->CameraState(m_cameraState)
|
||||
->MousePosition(initialPositionScreen)
|
||||
->MouseLButtonDown()
|
||||
->ExpectTrue(state.m_linearManipulator->PerformingAction())
|
||||
@@ -199,8 +189,7 @@ namespace UnitTest
|
||||
->MouseLButtonUp()
|
||||
->ExpectTrue(state.m_receivedLeftMouseDown)
|
||||
->ExpectTrue(state.m_receivedLeftMouseUp)
|
||||
->ExpectTrue(movementAlongAxis.IsClose(finalPositionWorld, 0.01f))
|
||||
;
|
||||
->ExpectTrue(movementAlongAxis.IsClose(finalPositionWorld, 0.01f));
|
||||
}
|
||||
|
||||
TEST_F(AzManipulatorTestFrameworkWorldSpaceBuilderTestFixture, ConsumeViewportLeftMouseClick)
|
||||
|
||||
Reference in New Issue
Block a user