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:
+58
-41
@@ -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());
|
||||
|
||||
+8
-5
@@ -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()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user