Expose setting to adjust angular manipulator circle bound (#3932)
* add debug drawing for angular manipulator bounds Signed-off-by: hultonha <hultonha@amazon.co.uk> * remove editor viewport settings from RenderViewport Signed-off-by: hultonha <hultonha@amazon.co.uk> * add setting for angular manipulator circle bound Signed-off-by: hultonha <hultonha@amazon.co.uk> * update minimum value allowed for some camera settings Signed-off-by: hultonha <hultonha@amazon.co.uk> * updates following review feedback, some small tidy-up Signed-off-by: hultonha <hultonha@amazon.co.uk> * update comment Signed-off-by: hultonha <hultonha@amazon.co.uk>
This commit is contained in:
+1
-2
@@ -226,8 +226,7 @@ namespace AzToolsFramework
|
||||
m_translationManipulator = AZStd::make_shared<IndexedTranslationManipulator<Vertex>>(
|
||||
Dimensions(), vertexIndex, vertex, WorldFromLocalWithUniformScale(entityComponentIdPair.GetEntityId()),
|
||||
GetNonUniformScale(entityComponentIdPair.GetEntityId()));
|
||||
m_translationManipulator->m_manipulator.SetLineBoundWidth(
|
||||
AzToolsFramework::ManipulatorLineBoundWidth(AzFramework::InvalidViewportId));
|
||||
m_translationManipulator->m_manipulator.SetLineBoundWidth(AzToolsFramework::ManipulatorLineBoundWidth());
|
||||
|
||||
// setup how the manipulator should look
|
||||
m_manipulatorConfiguratorFn(&m_translationManipulator->m_manipulator);
|
||||
|
||||
+10
-10
@@ -137,8 +137,8 @@ namespace AzToolsFramework
|
||||
bool GridSnapping(const int viewportId)
|
||||
{
|
||||
bool snapping = false;
|
||||
ViewportInteraction::ViewportInteractionRequestBus::EventResult(
|
||||
snapping, viewportId, &ViewportInteraction::ViewportInteractionRequestBus::Events::GridSnappingEnabled);
|
||||
ViewportInteraction::ViewportSettingsRequestBus::EventResult(
|
||||
snapping, viewportId, &ViewportInteraction::ViewportSettingsRequestBus::Events::GridSnappingEnabled);
|
||||
|
||||
return snapping;
|
||||
}
|
||||
@@ -146,8 +146,8 @@ namespace AzToolsFramework
|
||||
float GridSize(const int viewportId)
|
||||
{
|
||||
float gridSize = 0.0f;
|
||||
ViewportInteraction::ViewportInteractionRequestBus::EventResult(
|
||||
gridSize, viewportId, &ViewportInteraction::ViewportInteractionRequestBus::Events::GridSize);
|
||||
ViewportInteraction::ViewportSettingsRequestBus::EventResult(
|
||||
gridSize, viewportId, &ViewportInteraction::ViewportSettingsRequestBus::Events::GridSize);
|
||||
|
||||
return gridSize;
|
||||
}
|
||||
@@ -168,8 +168,8 @@ namespace AzToolsFramework
|
||||
bool AngleSnapping(const int viewportId)
|
||||
{
|
||||
bool snapping = false;
|
||||
ViewportInteraction::ViewportInteractionRequestBus::EventResult(
|
||||
snapping, viewportId, &ViewportInteraction::ViewportInteractionRequestBus::Events::AngleSnappingEnabled);
|
||||
ViewportInteraction::ViewportSettingsRequestBus::EventResult(
|
||||
snapping, viewportId, &ViewportInteraction::ViewportSettingsRequestBus::Events::AngleSnappingEnabled);
|
||||
|
||||
return snapping;
|
||||
}
|
||||
@@ -177,8 +177,8 @@ namespace AzToolsFramework
|
||||
float AngleStep(const int viewportId)
|
||||
{
|
||||
float angle = 0.0f;
|
||||
ViewportInteraction::ViewportInteractionRequestBus::EventResult(
|
||||
angle, viewportId, &ViewportInteraction::ViewportInteractionRequestBus::Events::AngleStep);
|
||||
ViewportInteraction::ViewportSettingsRequestBus::EventResult(
|
||||
angle, viewportId, &ViewportInteraction::ViewportSettingsRequestBus::Events::AngleStep);
|
||||
|
||||
return angle;
|
||||
}
|
||||
@@ -186,8 +186,8 @@ namespace AzToolsFramework
|
||||
bool ShowingGrid(const int viewportId)
|
||||
{
|
||||
bool show = false;
|
||||
ViewportInteraction::ViewportInteractionRequestBus::EventResult(
|
||||
show, viewportId, &ViewportInteraction::ViewportInteractionRequestBus::Events::ShowGrid);
|
||||
ViewportInteraction::ViewportSettingsRequestBus::EventResult(
|
||||
show, viewportId, &ViewportInteraction::ViewportSettingsRequestBus::Events::ShowGrid);
|
||||
|
||||
return show;
|
||||
}
|
||||
|
||||
@@ -8,9 +8,9 @@
|
||||
|
||||
#include "ManipulatorView.h"
|
||||
|
||||
#include <AzCore/Console/IConsole.h>
|
||||
#include <AzCore/Component/NonUniformScaleBus.h>
|
||||
#include <AzCore/Component/TransformBus.h>
|
||||
#include <AzCore/Console/IConsole.h>
|
||||
#include <AzCore/Math/VectorConversions.h>
|
||||
#include <AzCore/std/containers/array.h>
|
||||
#include <AzFramework/Entity/EntityDebugDisplayBus.h>
|
||||
@@ -413,8 +413,8 @@ namespace AzToolsFramework
|
||||
m_axis, m_cameraCorrectedAxis, managerState, mouseInteraction, manipulatorState.m_worldFromLocal,
|
||||
manipulatorState.m_localPosition, cameraState);
|
||||
|
||||
const auto worldLine = CalculateLine(
|
||||
manipulatorState.m_localPosition, manipulatorState.m_worldFromLocal, m_cameraCorrectedAxis, m_length * viewScale);
|
||||
const auto worldLine =
|
||||
CalculateLine(manipulatorState.m_localPosition, manipulatorState.m_worldFromLocal, m_cameraCorrectedAxis, m_length * viewScale);
|
||||
|
||||
debugDisplay.SetColor(ViewColor(manipulatorState.m_mouseOver, m_color, m_mouseOverColor).GetAsVector4());
|
||||
debugDisplay.SetLineWidth(defaultLineWidth(manipulatorState.m_mouseOver));
|
||||
@@ -612,13 +612,30 @@ namespace AzToolsFramework
|
||||
const Picking::BoundShapeTorus torusBound = CalculateTorusBound(
|
||||
manipulatorState.m_localPosition, manipulatorState.m_worldFromLocal, m_axis, m_radius * viewScale, m_width * viewScale);
|
||||
|
||||
// transform circle based on delta between default z up axis and other axes
|
||||
const AZ::Transform worldFromLocalWithOrientation =
|
||||
AZ::Transform::CreateTranslation(manipulatorState.m_worldFromLocal.GetTranslation()) *
|
||||
const AZ::Transform orientation =
|
||||
AZ::Transform::CreateFromQuaternion((QuaternionFromTransformNoScaling(manipulatorState.m_worldFromLocal) *
|
||||
AZ::Quaternion::CreateShortestArc(AZ::Vector3::CreateAxisZ(), m_axis))
|
||||
.GetNormalized());
|
||||
|
||||
// transform circle based on delta between default z up axis and other axes
|
||||
const AZ::Transform worldFromLocalWithOrientation =
|
||||
AZ::Transform::CreateTranslation(manipulatorState.m_worldFromLocal.GetTranslation()) * orientation;
|
||||
|
||||
if (ed_manipulatorDisplayBoundDebug)
|
||||
{
|
||||
debugDisplay.SetColor(AZ::Colors::BlanchedAlmond);
|
||||
debugDisplay.PushMatrix(orientation);
|
||||
debugDisplay.DrawCircle(torusBound.m_center + AZ::Vector3::CreateAxisZ() * torusBound.m_minorRadius, torusBound.m_majorRadius);
|
||||
debugDisplay.DrawCircle(
|
||||
torusBound.m_center + AZ::Vector3::CreateAxisZ() * torusBound.m_minorRadius,
|
||||
torusBound.m_majorRadius + torusBound.m_minorRadius);
|
||||
debugDisplay.DrawCircle(torusBound.m_center - AZ::Vector3::CreateAxisZ() * torusBound.m_minorRadius, torusBound.m_majorRadius);
|
||||
debugDisplay.DrawCircle(
|
||||
torusBound.m_center - AZ::Vector3::CreateAxisZ() * torusBound.m_minorRadius,
|
||||
torusBound.m_majorRadius + torusBound.m_minorRadius);
|
||||
debugDisplay.PopMatrix();
|
||||
}
|
||||
|
||||
debugDisplay.CullOn();
|
||||
debugDisplay.PushMatrix(worldFromLocalWithOrientation);
|
||||
debugDisplay.SetColor(ViewColor(manipulatorState.m_mouseOver, m_color, m_mouseOverColor).GetAsVector4());
|
||||
@@ -638,7 +655,10 @@ namespace AzToolsFramework
|
||||
}
|
||||
|
||||
void DrawFullCircle(
|
||||
AzFramework::DebugDisplayRequests& debugDisplay, const AZ::Vector3& position, const float radius, const AZ::Vector3& /*viewPos*/)
|
||||
AzFramework::DebugDisplayRequests& debugDisplay,
|
||||
const AZ::Vector3& position,
|
||||
const float radius,
|
||||
[[maybe_unused]] const AZ::Vector3& viewPos)
|
||||
{
|
||||
debugDisplay.DrawCircle(position, radius);
|
||||
}
|
||||
|
||||
+9
-2
@@ -130,11 +130,13 @@ namespace AzToolsFramework
|
||||
for (size_t manipulatorIndex = 0; manipulatorIndex < m_localAngularManipulators.size(); ++manipulatorIndex)
|
||||
{
|
||||
m_localAngularManipulators[manipulatorIndex]->SetView(CreateManipulatorViewCircle(
|
||||
*m_localAngularManipulators[manipulatorIndex], colors[manipulatorIndex], radius, 0.05f, DrawHalfDottedCircle));
|
||||
*m_localAngularManipulators[manipulatorIndex], colors[manipulatorIndex], radius, m_circleBoundWidth, DrawHalfDottedCircle));
|
||||
}
|
||||
|
||||
const float viewAlignedScale = 1.12f;
|
||||
m_viewAngularManipulator->SetView(CreateManipulatorViewCircle(
|
||||
*m_viewAngularManipulator, AZ::Color(1.0f, 1.0f, 1.0f, 1.0f), radius + (radius * 0.12f), 0.05f, DrawFullCircle));
|
||||
*m_viewAngularManipulator, AZ::Color(1.0f, 1.0f, 1.0f, 1.0f), radius * viewAlignedScale, m_circleBoundWidth,
|
||||
DrawFullCircle));
|
||||
}
|
||||
|
||||
bool RotationManipulators::PerformingActionViewAxis() const
|
||||
@@ -151,4 +153,9 @@ namespace AzToolsFramework
|
||||
|
||||
manipulatorFn(m_viewAngularManipulator.get());
|
||||
}
|
||||
|
||||
void RotationManipulators::SetCircleBoundWidth(const float circleBoundWidth)
|
||||
{
|
||||
m_circleBoundWidth = circleBoundWidth;
|
||||
}
|
||||
} // namespace AzToolsFramework
|
||||
|
||||
@@ -42,6 +42,9 @@ namespace AzToolsFramework
|
||||
|
||||
bool PerformingActionViewAxis() const;
|
||||
|
||||
//! Sets the bound width to use for the circle (torus) of an angular manipulator.
|
||||
void SetCircleBoundWidth(float circleBoundWidth);
|
||||
|
||||
private:
|
||||
AZ_DISABLE_COPY_MOVE(RotationManipulators)
|
||||
|
||||
@@ -49,5 +52,6 @@ namespace AzToolsFramework
|
||||
|
||||
AZStd::array<AZStd::shared_ptr<AngularManipulator>, 3> m_localAngularManipulators;
|
||||
AZStd::shared_ptr<AngularManipulator> m_viewAngularManipulator;
|
||||
float m_circleBoundWidth = 0.1f; //!< The default circle bound width for the angular manipulator torus.
|
||||
};
|
||||
} // namespace AzToolsFramework
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
/*
|
||||
* Copyright (c) Contributors to the Open 3D Engine Project.
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include <AzToolsFramework/Viewport/ViewportMessages.h>
|
||||
|
||||
namespace AzToolsFramework
|
||||
{
|
||||
float ManipulatorLineBoundWidth(const AzFramework::ViewportId viewportId /*= AzFramework::InvalidViewportId*/)
|
||||
{
|
||||
float lineBoundWidth = 0.0f;
|
||||
if (viewportId != AzFramework::InvalidViewportId)
|
||||
{
|
||||
ViewportInteraction::ViewportSettingsRequestBus::EventResult(
|
||||
lineBoundWidth, viewportId, &ViewportInteraction::ViewportSettingsRequestBus::Events::ManipulatorLineBoundWidth);
|
||||
}
|
||||
else
|
||||
{
|
||||
ViewportInteraction::ViewportSettingsRequestBus::BroadcastResult(
|
||||
lineBoundWidth, &ViewportInteraction::ViewportSettingsRequestBus::Events::ManipulatorLineBoundWidth);
|
||||
}
|
||||
|
||||
return lineBoundWidth;
|
||||
}
|
||||
|
||||
float ManipulatorCicleBoundWidth(const AzFramework::ViewportId viewportId /*= AzFramework::InvalidViewportId*/)
|
||||
{
|
||||
float circleBoundWidth = 0.0f;
|
||||
if (viewportId != AzFramework::InvalidViewportId)
|
||||
{
|
||||
ViewportInteraction::ViewportSettingsRequestBus::EventResult(
|
||||
circleBoundWidth, viewportId, &ViewportInteraction::ViewportSettingsRequestBus::Events::ManipulatorCircleBoundWidth);
|
||||
}
|
||||
else
|
||||
{
|
||||
ViewportInteraction::ViewportSettingsRequestBus::BroadcastResult(
|
||||
circleBoundWidth, &ViewportInteraction::ViewportSettingsRequestBus::Events::ManipulatorCircleBoundWidth);
|
||||
}
|
||||
|
||||
return circleBoundWidth;
|
||||
}
|
||||
} // namespace AzToolsFramework
|
||||
@@ -158,18 +158,6 @@ namespace AzToolsFramework
|
||||
public:
|
||||
//! Returns the current camera state for this viewport.
|
||||
virtual AzFramework::CameraState GetCameraState() = 0;
|
||||
//! Returns if grid snapping is enabled.
|
||||
virtual bool GridSnappingEnabled() = 0;
|
||||
//! Returns the grid snapping size.
|
||||
virtual float GridSize() = 0;
|
||||
//! Does the grid currently want to be displayed.
|
||||
virtual bool ShowGrid() = 0;
|
||||
//! Returns if angle snapping is enabled.
|
||||
virtual bool AngleSnappingEnabled() = 0;
|
||||
//! Returns the angle snapping/step size.
|
||||
virtual float AngleStep() = 0;
|
||||
//! Returns the current line bound width for manipulators.
|
||||
virtual float ManipulatorLineBoundWidth() = 0;
|
||||
//! Transforms 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;
|
||||
@@ -187,12 +175,13 @@ namespace AzToolsFramework
|
||||
~ViewportInteractionRequests() = default;
|
||||
};
|
||||
|
||||
//! Type to inherit to implement ViewportInteractionRequests.
|
||||
using ViewportInteractionRequestBus = AZ::EBus<ViewportInteractionRequests, ViewportEBusTraits>;
|
||||
|
||||
//! Interface to return only viewport specific settings (e.g. snapping).
|
||||
class ViewportSettings
|
||||
class ViewportSettingsRequests
|
||||
{
|
||||
public:
|
||||
virtual ~ViewportSettings() = default;
|
||||
|
||||
//! Return if grid snapping is enabled.
|
||||
virtual bool GridSnappingEnabled() const = 0;
|
||||
//! Return the grid snapping size.
|
||||
@@ -205,10 +194,15 @@ namespace AzToolsFramework
|
||||
virtual float AngleStep() const = 0;
|
||||
//! Returns the current line bound width for manipulators.
|
||||
virtual float ManipulatorLineBoundWidth() const = 0;
|
||||
//! Returns the current circle (torus) bound width for manipulators.
|
||||
virtual float ManipulatorCircleBoundWidth() const = 0;
|
||||
|
||||
protected:
|
||||
~ViewportSettingsRequests() = default;
|
||||
};
|
||||
|
||||
//! Type to inherit to implement ViewportInteractionRequests.
|
||||
using ViewportInteractionRequestBus = AZ::EBus<ViewportInteractionRequests, ViewportEBusTraits>;
|
||||
//! Type to inherit to implement ViewportSettingsRequests.
|
||||
using ViewportSettingsRequestBus = AZ::EBus<ViewportSettingsRequests, ViewportEBusTraits>;
|
||||
|
||||
//! An interface to notify when changes to viewport settings have happened.
|
||||
class ViewportSettingNotifications
|
||||
@@ -346,21 +340,10 @@ namespace AzToolsFramework
|
||||
}
|
||||
|
||||
//! Wrap EBus call to retrieve manipulator line bound width.
|
||||
//! @note It is possible to pass AzFramework::InvalidViewportId to perform a Broadcast as opposed to a targeted Event.
|
||||
inline float ManipulatorLineBoundWidth(AzFramework::ViewportId viewportId)
|
||||
{
|
||||
float lineBoundWidth = 0.0f;
|
||||
if (viewportId != AzFramework::InvalidViewportId)
|
||||
{
|
||||
ViewportInteraction::ViewportInteractionRequestBus::EventResult(
|
||||
lineBoundWidth, viewportId, &ViewportInteraction::ViewportInteractionRequestBus::Events::ManipulatorLineBoundWidth);
|
||||
}
|
||||
else
|
||||
{
|
||||
ViewportInteraction::ViewportInteractionRequestBus::BroadcastResult(
|
||||
lineBoundWidth, &ViewportInteraction::ViewportInteractionRequestBus::Events::ManipulatorLineBoundWidth);
|
||||
}
|
||||
//! @note It is possible to pass AzFramework::InvalidViewportId (the default) to perform a Broadcast as opposed to a targeted Event.
|
||||
float ManipulatorLineBoundWidth(AzFramework::ViewportId viewportId = AzFramework::InvalidViewportId);
|
||||
|
||||
return lineBoundWidth;
|
||||
}
|
||||
//! Wrap EBus call to retrieve manipulator circle bound width.
|
||||
//! @note It is possible to pass AzFramework::InvalidViewportId (the default) to perform a Broadcast as opposed to a targeted Event.
|
||||
float ManipulatorCicleBoundWidth(AzFramework::ViewportId viewportId = AzFramework::InvalidViewportId);
|
||||
} // namespace AzToolsFramework
|
||||
|
||||
+5
-4
@@ -488,8 +488,8 @@ namespace AzToolsFramework
|
||||
void SnappingCluster::TrySetVisible(const bool visible)
|
||||
{
|
||||
bool snapping = false;
|
||||
ViewportInteraction::ViewportInteractionRequestBus::EventResult(
|
||||
snapping, ViewportUi::DefaultViewportId, &ViewportInteraction::ViewportInteractionRequestBus::Events::GridSnappingEnabled);
|
||||
ViewportInteraction::ViewportSettingsRequestBus::EventResult(
|
||||
snapping, ViewportUi::DefaultViewportId, &ViewportInteraction::ViewportSettingsRequestBus::Events::GridSnappingEnabled);
|
||||
|
||||
// show snapping viewport ui only if there are entities selected and snapping is enabled
|
||||
SetViewportUiClusterVisible(m_clusterId, visible && snapping);
|
||||
@@ -1377,6 +1377,7 @@ namespace AzToolsFramework
|
||||
|
||||
AZStd::unique_ptr<RotationManipulators> rotationManipulators =
|
||||
AZStd::make_unique<RotationManipulators>(AZ::Transform::CreateIdentity());
|
||||
rotationManipulators->SetCircleBoundWidth(ManipulatorCicleBoundWidth(ViewportUi::DefaultViewportId));
|
||||
|
||||
InitializeManipulators(*rotationManipulators);
|
||||
|
||||
@@ -2546,8 +2547,8 @@ namespace AzToolsFramework
|
||||
if (buttonId == m_snappingCluster.m_snapToWorldButtonId)
|
||||
{
|
||||
float gridSize = 1.0f;
|
||||
ViewportInteraction::ViewportInteractionRequestBus::EventResult(
|
||||
gridSize, ViewportUi::DefaultViewportId, &ViewportInteraction::ViewportInteractionRequestBus::Events::GridSize);
|
||||
ViewportInteraction::ViewportSettingsRequestBus::EventResult(
|
||||
gridSize, ViewportUi::DefaultViewportId, &ViewportInteraction::ViewportSettingsRequestBus::Events::GridSize);
|
||||
|
||||
SnapSelectedEntitiesToWorldGrid(gridSize);
|
||||
}
|
||||
|
||||
@@ -481,6 +481,7 @@ set(FILES
|
||||
Viewport/VertexContainerDisplay.h
|
||||
Viewport/VertexContainerDisplay.cpp
|
||||
Viewport/ViewportMessages.h
|
||||
Viewport/ViewportMessages.cpp
|
||||
Viewport/ViewportTypes.h
|
||||
Viewport/ViewportTypes.cpp
|
||||
ViewportUi/Button.h
|
||||
|
||||
Reference in New Issue
Block a user