Expose the ability to control manipulator line bounds (#3890)
Signed-off-by: hultonha <hultonha@amazon.co.uk>
This commit is contained in:
@@ -65,7 +65,7 @@ EditorPreferencesDialog::EditorPreferencesDialog(QWidget* pParent)
|
||||
CEditorPreferencesPage_General::Reflect(*serializeContext);
|
||||
CEditorPreferencesPage_Files::Reflect(*serializeContext);
|
||||
CEditorPreferencesPage_ViewportGeneral::Reflect(*serializeContext);
|
||||
CEditorPreferencesPage_ViewportGizmo::Reflect(*serializeContext);
|
||||
CEditorPreferencesPage_ViewportManipulator::Reflect(*serializeContext);
|
||||
CEditorPreferencesPage_ViewportMovement::Reflect(*serializeContext);
|
||||
CEditorPreferencesPage_ViewportDebug::Reflect(*serializeContext);
|
||||
CEditorPreferencesPage_ExperimentalLighting::Reflect(*serializeContext);
|
||||
|
||||
@@ -5,96 +5,57 @@
|
||||
* SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "EditorDefs.h"
|
||||
|
||||
#include "EditorPreferencesPageViewportGizmo.h"
|
||||
|
||||
// Editor
|
||||
#include "EditorViewportSettings.h"
|
||||
#include "Settings.h"
|
||||
|
||||
|
||||
void CEditorPreferencesPage_ViewportGizmo::Reflect(AZ::SerializeContext& serialize)
|
||||
void CEditorPreferencesPage_ViewportManipulator::Reflect(AZ::SerializeContext& serialize)
|
||||
{
|
||||
serialize.Class<AxisGizmo>()
|
||||
->Version(1)
|
||||
->Field("Size", &AxisGizmo::m_size)
|
||||
->Field("Text", &AxisGizmo::m_text)
|
||||
->Field("MaxCount", &AxisGizmo::m_maxCount);
|
||||
serialize.Class<Manipulators>()->Version(1)->Field("LineBoundWidth", &Manipulators::m_manipulatorLineBoundWidth);
|
||||
|
||||
serialize.Class<Helpers>()
|
||||
->Version(1)
|
||||
->Field("LabelsOn", &Helpers::m_helpersGlobalScale)
|
||||
->Field("LabelsOn", &Helpers::m_tagpointScaleMulti)
|
||||
->Field("LabelsOn", &Helpers::m_rulerSphereScale)
|
||||
->Field("LabelsDistance", &Helpers::m_rulerSphereTrans);
|
||||
serialize.Class<CEditorPreferencesPage_ViewportManipulator>()->Version(2)->Field(
|
||||
"Manipulators", &CEditorPreferencesPage_ViewportManipulator::m_manipulators);
|
||||
|
||||
serialize.Class<CEditorPreferencesPage_ViewportGizmo>()
|
||||
->Version(1)
|
||||
->Field("Axis Gizmo", &CEditorPreferencesPage_ViewportGizmo::m_axisGizmo)
|
||||
->Field("Helpers", &CEditorPreferencesPage_ViewportGizmo::m_helpers);
|
||||
|
||||
AZ::EditContext* editContext = serialize.GetEditContext();
|
||||
if (editContext)
|
||||
if (AZ::EditContext* editContext = serialize.GetEditContext())
|
||||
{
|
||||
editContext->Class<AxisGizmo>("Axis Gizmo", "")
|
||||
->DataElement(AZ::Edit::UIHandlers::SpinBox, &AxisGizmo::m_size, "Size", "Axis Gizmo Size")
|
||||
->DataElement(AZ::Edit::UIHandlers::CheckBox, &AxisGizmo::m_text, "Text Labels", "Text Labels on Axis Gizmo")
|
||||
->DataElement(AZ::Edit::UIHandlers::SpinBox, &AxisGizmo::m_maxCount, "Max Count", "Max Count of Axis Gizmos");
|
||||
editContext->Class<Manipulators>("Manipulators", "")
|
||||
->DataElement(
|
||||
AZ::Edit::UIHandlers::SpinBox, &Manipulators::m_manipulatorLineBoundWidth, "Line Bound Width",
|
||||
"Manipulator Line Bound Width")
|
||||
->Attribute(AZ::Edit::Attributes::Min, 0.001f)
|
||||
->Attribute(AZ::Edit::Attributes::Max, 2.0f);
|
||||
|
||||
editContext->Class<Helpers>("Helpers", "")
|
||||
->DataElement(AZ::Edit::UIHandlers::SpinBox, &Helpers::m_helpersGlobalScale, "Helpers Scale", "Helpers Scale")
|
||||
->Attribute(AZ::Edit::Attributes::Min, 0.01f)
|
||||
->Attribute(AZ::Edit::Attributes::Max, 100.0f)
|
||||
->DataElement(AZ::Edit::UIHandlers::SpinBox, &Helpers::m_tagpointScaleMulti, "Tagpoint Scale Multiplier", "Tagpoint Scale Multiplier")
|
||||
->Attribute(AZ::Edit::Attributes::Min, 0.01f)
|
||||
->Attribute(AZ::Edit::Attributes::Max, 100.0f)
|
||||
->DataElement(AZ::Edit::UIHandlers::SpinBox, &Helpers::m_rulerSphereScale, "Ruler Sphere Scale", "Ruler Sphere Scale")
|
||||
->Attribute(AZ::Edit::Attributes::Min, 0.1f)
|
||||
->Attribute(AZ::Edit::Attributes::Max, 100.0f)
|
||||
->Attribute(AZ::Edit::Attributes::Step, 0.1f)
|
||||
->DataElement(AZ::Edit::UIHandlers::SpinBox, &Helpers::m_rulerSphereTrans, "Ruler Sphere Transparency", "Ruler Sphere Transparency")
|
||||
->Attribute(AZ::Edit::Attributes::Min, 0.01f)
|
||||
->Attribute(AZ::Edit::Attributes::Max, 100.0f);
|
||||
|
||||
editContext->Class<CEditorPreferencesPage_ViewportGizmo>("Gizmo Viewport Preferences", "Gizmo Viewport Preferences")
|
||||
editContext
|
||||
->Class<CEditorPreferencesPage_ViewportManipulator>("Manipulator Viewport Preferences", "Manipulator Viewport Preferences")
|
||||
->ClassElement(AZ::Edit::ClassElements::EditorData, "")
|
||||
->Attribute(AZ::Edit::Attributes::Visibility, AZ_CRC("PropertyVisibility_ShowChildrenOnly", 0xef428f20))
|
||||
->DataElement(AZ::Edit::UIHandlers::Default, &CEditorPreferencesPage_ViewportGizmo::m_axisGizmo, "Axis Gizmo", "Axis Gizmo")
|
||||
->DataElement(AZ::Edit::UIHandlers::Default, &CEditorPreferencesPage_ViewportGizmo::m_helpers, "Helpers", "Helpers");
|
||||
->DataElement(
|
||||
AZ::Edit::UIHandlers::Default, &CEditorPreferencesPage_ViewportManipulator::m_manipulators, "Manipulators", "Manipulators");
|
||||
}
|
||||
}
|
||||
|
||||
CEditorPreferencesPage_ViewportGizmo::CEditorPreferencesPage_ViewportGizmo()
|
||||
CEditorPreferencesPage_ViewportManipulator::CEditorPreferencesPage_ViewportManipulator()
|
||||
{
|
||||
InitializeSettings();
|
||||
m_icon = QIcon(":/res/Gizmos.svg");
|
||||
}
|
||||
|
||||
QIcon& CEditorPreferencesPage_ViewportGizmo::GetIcon()
|
||||
QIcon& CEditorPreferencesPage_ViewportManipulator::GetIcon()
|
||||
{
|
||||
return m_icon;
|
||||
}
|
||||
|
||||
void CEditorPreferencesPage_ViewportGizmo::OnApply()
|
||||
void CEditorPreferencesPage_ViewportManipulator::OnApply()
|
||||
{
|
||||
gSettings.gizmo.axisGizmoSize = m_axisGizmo.m_size;
|
||||
gSettings.gizmo.axisGizmoText = m_axisGizmo.m_text;
|
||||
gSettings.gizmo.axisGizmoMaxCount = m_axisGizmo.m_maxCount;
|
||||
|
||||
gSettings.gizmo.helpersScale = m_helpers.m_helpersGlobalScale;
|
||||
gSettings.gizmo.tagpointScaleMulti = m_helpers.m_tagpointScaleMulti;
|
||||
gSettings.gizmo.rulerSphereScale = m_helpers.m_rulerSphereScale;
|
||||
gSettings.gizmo.rulerSphereTrans = m_helpers.m_rulerSphereTrans;
|
||||
SandboxEditor::SetManipulatorLineBoundWidth(m_manipulators.m_manipulatorLineBoundWidth);
|
||||
}
|
||||
|
||||
void CEditorPreferencesPage_ViewportGizmo::InitializeSettings()
|
||||
void CEditorPreferencesPage_ViewportManipulator::InitializeSettings()
|
||||
{
|
||||
m_axisGizmo.m_size = gSettings.gizmo.axisGizmoSize;
|
||||
m_axisGizmo.m_text = gSettings.gizmo.axisGizmoText;
|
||||
m_axisGizmo.m_maxCount = gSettings.gizmo.axisGizmoMaxCount;
|
||||
|
||||
m_helpers.m_helpersGlobalScale = gSettings.gizmo.helpersScale;
|
||||
m_helpers.m_tagpointScaleMulti = gSettings.gizmo.tagpointScaleMulti;
|
||||
m_helpers.m_rulerSphereScale = gSettings.gizmo.rulerSphereScale;
|
||||
m_helpers.m_rulerSphereTrans = gSettings.gizmo.rulerSphereTrans;
|
||||
m_manipulators.m_manipulatorLineBoundWidth = SandboxEditor::ManipulatorLineBoundWidth();
|
||||
}
|
||||
|
||||
@@ -5,59 +5,57 @@
|
||||
* SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "Include/IPreferencesPage.h"
|
||||
#include <AzCore/Serialization/SerializeContext.h>
|
||||
#include <AzCore/Serialization/EditContext.h>
|
||||
#include <AzCore/RTTI/RTTI.h>
|
||||
#include <AzCore/Math/Vector3.h>
|
||||
#include <AzCore/RTTI/RTTI.h>
|
||||
#include <AzCore/Serialization/EditContext.h>
|
||||
#include <AzCore/Serialization/SerializeContext.h>
|
||||
#include <QIcon>
|
||||
|
||||
|
||||
class CEditorPreferencesPage_ViewportGizmo
|
||||
: public IPreferencesPage
|
||||
class CEditorPreferencesPage_ViewportManipulator : public IPreferencesPage
|
||||
{
|
||||
public:
|
||||
AZ_RTTI(CEditorPreferencesPage_ViewportGizmo, "{14433511-8175-4348-954E-82D903475B06}", IPreferencesPage)
|
||||
AZ_RTTI(CEditorPreferencesPage_ViewportManipulator, "{14433511-8175-4348-954E-82D903475B06}", IPreferencesPage)
|
||||
|
||||
static void Reflect(AZ::SerializeContext& serialize);
|
||||
|
||||
CEditorPreferencesPage_ViewportGizmo();
|
||||
virtual ~CEditorPreferencesPage_ViewportGizmo() = default;
|
||||
CEditorPreferencesPage_ViewportManipulator();
|
||||
virtual ~CEditorPreferencesPage_ViewportManipulator() = default;
|
||||
|
||||
virtual const char* GetCategory() override
|
||||
{
|
||||
return "Viewports";
|
||||
}
|
||||
|
||||
virtual const char* GetTitle() override
|
||||
{
|
||||
return "Manipulators";
|
||||
}
|
||||
|
||||
virtual const char* GetCategory() override { return "Viewports"; }
|
||||
virtual const char* GetTitle() override { return "Gizmos"; }
|
||||
virtual QIcon& GetIcon() override;
|
||||
virtual void OnApply() override;
|
||||
virtual void OnCancel() override {}
|
||||
virtual bool OnQueryCancel() override { return true; }
|
||||
virtual void OnCancel() override
|
||||
{
|
||||
}
|
||||
|
||||
virtual bool OnQueryCancel() override
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
private:
|
||||
void InitializeSettings();
|
||||
|
||||
struct AxisGizmo
|
||||
struct Manipulators
|
||||
{
|
||||
AZ_TYPE_INFO(AxisGizmo, "{7D90D60E-996B-4F54-8748-B26EFA781EE2}")
|
||||
AZ_TYPE_INFO(Manipulators, "{2974439C-4839-41F6-B526-F317999B9DB9}")
|
||||
|
||||
float m_size;
|
||||
bool m_text;
|
||||
int m_maxCount;
|
||||
float m_manipulatorLineBoundWidth;
|
||||
};
|
||||
|
||||
struct Helpers
|
||||
{
|
||||
AZ_TYPE_INFO(Helpers, "{EC99922E-F61C-4AA0-9A51-630E09AB55AA}")
|
||||
|
||||
float m_helpersGlobalScale;
|
||||
float m_tagpointScaleMulti;
|
||||
float m_rulerSphereScale;
|
||||
float m_rulerSphereTrans;
|
||||
};
|
||||
|
||||
AxisGizmo m_axisGizmo;
|
||||
Helpers m_helpers;
|
||||
Manipulators m_manipulators;
|
||||
QIcon m_icon;
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -20,6 +20,7 @@ namespace SandboxEditor
|
||||
constexpr AZStd::string_view AngleSnappingSetting = "/Amazon/Preferences/Editor/AngleSnapping";
|
||||
constexpr AZStd::string_view AngleSizeSetting = "/Amazon/Preferences/Editor/AngleSize";
|
||||
constexpr AZStd::string_view ShowGridSetting = "/Amazon/Preferences/Editor/ShowGrid";
|
||||
constexpr AZStd::string_view ManipulatorLineBoundWidthSetting = "/Amazon/Preferences/Editor/Manipulator/LineBoundWidth";
|
||||
constexpr AZStd::string_view CameraTranslateSpeedSetting = "/Amazon/Preferences/Editor/Camera/TranslateSpeed";
|
||||
constexpr AZStd::string_view CameraBoostMultiplierSetting = "/Amazon/Preferences/Editor/Camera/BoostMultiplier";
|
||||
constexpr AZStd::string_view CameraRotateSpeedSetting = "/Amazon/Preferences/Editor/Camera/RotateSpeed";
|
||||
@@ -156,6 +157,16 @@ namespace SandboxEditor
|
||||
SetRegistry(ShowGridSetting, showing);
|
||||
}
|
||||
|
||||
float ManipulatorLineBoundWidth()
|
||||
{
|
||||
return aznumeric_cast<float>(GetRegistry(ManipulatorLineBoundWidthSetting, 0.1));
|
||||
}
|
||||
|
||||
void SetManipulatorLineBoundWidth(const float lineBoundWidth)
|
||||
{
|
||||
SetRegistry(ManipulatorLineBoundWidthSetting, lineBoundWidth);
|
||||
}
|
||||
|
||||
float CameraTranslateSpeed()
|
||||
{
|
||||
return aznumeric_cast<float>(GetRegistry(CameraTranslateSpeedSetting, 10.0));
|
||||
|
||||
@@ -47,6 +47,9 @@ namespace SandboxEditor
|
||||
SANDBOX_API bool ShowingGrid();
|
||||
SANDBOX_API void SetShowingGrid(bool showing);
|
||||
|
||||
SANDBOX_API float ManipulatorLineBoundWidth();
|
||||
SANDBOX_API void SetManipulatorLineBoundWidth(float lineBoundWidth);
|
||||
|
||||
SANDBOX_API float CameraTranslateSpeed();
|
||||
SANDBOX_API void SetCameraTranslateSpeed(float speed);
|
||||
|
||||
|
||||
@@ -121,6 +121,7 @@ struct EditorViewportSettings : public AzToolsFramework::ViewportInteraction::Vi
|
||||
bool ShowGrid() const override;
|
||||
bool AngleSnappingEnabled() const override;
|
||||
float AngleStep() const override;
|
||||
float ManipulatorLineBoundWidth() const override;
|
||||
};
|
||||
|
||||
static const EditorViewportSettings g_EditorViewportSettings;
|
||||
@@ -2559,6 +2560,11 @@ float EditorViewportSettings::AngleStep() const
|
||||
return SandboxEditor::AngleSnappingSize();
|
||||
}
|
||||
|
||||
float EditorViewportSettings::ManipulatorLineBoundWidth() const
|
||||
{
|
||||
return SandboxEditor::ManipulatorLineBoundWidth();
|
||||
}
|
||||
|
||||
AZ_CVAR_EXTERNED(bool, ed_previewGameInFullscreen_once);
|
||||
|
||||
bool EditorViewportWidget::ShouldPreviewFullscreen() const
|
||||
|
||||
@@ -680,8 +680,8 @@ const SGizmoParameters& CEditorImpl::GetGlobalGizmoParameters()
|
||||
|
||||
m_pGizmoParameters->axisConstraint = m_selectedAxis;
|
||||
m_pGizmoParameters->referenceCoordSys = m_refCoordsSys;
|
||||
m_pGizmoParameters->axisGizmoScale = gSettings.gizmo.axisGizmoSize;
|
||||
m_pGizmoParameters->axisGizmoText = gSettings.gizmo.axisGizmoText;
|
||||
m_pGizmoParameters->axisGizmoScale = 1.0f;
|
||||
m_pGizmoParameters->axisGizmoText = false;
|
||||
|
||||
return *m_pGizmoParameters;
|
||||
}
|
||||
|
||||
@@ -2378,7 +2378,7 @@ void CObjectManager::SetObjectSelected(CBaseObject* pObject, bool bSelect)
|
||||
|
||||
if (bSelect && !GetIEditor()->GetTransformManipulator())
|
||||
{
|
||||
if (CAxisGizmo::GetGlobalAxisGizmoCount() < gSettings.gizmo.axisGizmoMaxCount)
|
||||
if (CAxisGizmo::GetGlobalAxisGizmoCount() < 1 /*legacy axisGizmoMaxCount*/)
|
||||
{
|
||||
// Create axis gizmo for this object.
|
||||
m_gizmoManager->AddGizmo(new CAxisGizmo(pObject));
|
||||
|
||||
@@ -36,7 +36,7 @@ CStdPreferencesClassDesc::CStdPreferencesClassDesc()
|
||||
[](){ return new CEditorPreferencesPage_Files(); },
|
||||
[](){ return new CEditorPreferencesPage_ViewportGeneral(); },
|
||||
[](){ return new CEditorPreferencesPage_ViewportMovement(); },
|
||||
[](){ return new CEditorPreferencesPage_ViewportGizmo(); },
|
||||
[](){ return new CEditorPreferencesPage_ViewportManipulator(); },
|
||||
[](){ return new CEditorPreferencesPage_ViewportDebug(); }
|
||||
};
|
||||
|
||||
|
||||
@@ -82,7 +82,6 @@ private:
|
||||
|
||||
namespace
|
||||
{
|
||||
|
||||
class QtApplicationListener
|
||||
: public AzToolsFramework::EditorEvents::Bus::Handler
|
||||
{
|
||||
@@ -99,20 +98,8 @@ namespace
|
||||
delete this;
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
SGizmoSettings::SGizmoSettings()
|
||||
{
|
||||
axisGizmoSize = 0.2f;
|
||||
axisGizmoText = true;
|
||||
axisGizmoMaxCount = 50;
|
||||
helpersScale = 1.f;
|
||||
tagpointScaleMulti = 0.5f;
|
||||
rulerSphereScale = 0.5f;
|
||||
rulerSphereTrans = 0.5f;
|
||||
}
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
SEditorSettings::SEditorSettings()
|
||||
{
|
||||
@@ -564,18 +551,6 @@ void SEditorSettings::Save()
|
||||
SaveValue("Settings", "ShowScaleWarnings", viewports.bShowScaleWarnings);
|
||||
SaveValue("Settings", "ShowRotationWarnings", viewports.bShowRotationWarnings);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// Gizmos.
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
SaveValue("Settings", "AxisGizmoSize", gizmo.axisGizmoSize);
|
||||
SaveValue("Settings", "AxisGizmoText", gizmo.axisGizmoText);
|
||||
SaveValue("Settings", "AxisGizmoMaxCount", gizmo.axisGizmoMaxCount);
|
||||
SaveValue("Settings", "HelpersScale", gizmo.helpersScale);
|
||||
SaveValue("Settings", "TagPointScaleMulti", gizmo.tagpointScaleMulti);
|
||||
SaveValue("Settings", "RulerSphereScale", gizmo.rulerSphereScale);
|
||||
SaveValue("Settings", "RulerSphereTrans", gizmo.rulerSphereTrans);
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
SaveValue("Settings", "TextEditorScript", textEditorForScript);
|
||||
SaveValue("Settings", "TextEditorShaders", textEditorForShaders);
|
||||
SaveValue("Settings", "TextEditorBSpaces", textEditorForBspaces);
|
||||
@@ -769,18 +744,6 @@ void SEditorSettings::Load()
|
||||
LoadValue("Settings", "ShowScaleWarnings", viewports.bShowScaleWarnings);
|
||||
LoadValue("Settings", "ShowRotationWarnings", viewports.bShowRotationWarnings);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// Gizmos.
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
LoadValue("Settings", "AxisGizmoSize", gizmo.axisGizmoSize);
|
||||
LoadValue("Settings", "AxisGizmoText", gizmo.axisGizmoText);
|
||||
LoadValue("Settings", "AxisGizmoMaxCount", gizmo.axisGizmoMaxCount);
|
||||
LoadValue("Settings", "HelpersScale", gizmo.helpersScale);
|
||||
LoadValue("Settings", "TagPointScaleMulti", gizmo.tagpointScaleMulti);
|
||||
LoadValue("Settings", "RulerSphereScale", gizmo.rulerSphereScale);
|
||||
LoadValue("Settings", "RulerSphereTrans", gizmo.rulerSphereTrans);
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
LoadValue("Settings", "TextEditorScript", textEditorForScript);
|
||||
LoadValue("Settings", "TextEditorShaders", textEditorForShaders);
|
||||
LoadValue("Settings", "TextEditorBSpaces", textEditorForBspaces);
|
||||
|
||||
@@ -22,22 +22,6 @@
|
||||
|
||||
#include <AzQtComponents/Components/Widgets/ToolBar.h>
|
||||
|
||||
struct SGizmoSettings
|
||||
{
|
||||
float axisGizmoSize;
|
||||
bool axisGizmoText;
|
||||
int axisGizmoMaxCount;
|
||||
|
||||
float helpersScale;
|
||||
float tagpointScaleMulti;
|
||||
|
||||
// Scale size and transparency for debug spheres when using Ruler tool
|
||||
float rulerSphereScale;
|
||||
float rulerSphereTrans;
|
||||
|
||||
SGizmoSettings();
|
||||
};
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// Settings for snapping in the viewports.
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
@@ -381,8 +365,6 @@ AZ_POP_DISABLE_DLL_EXPORT_BASECLASS_WARNING
|
||||
//! Keeps the editor active even if no focus is set
|
||||
int keepEditorActive;
|
||||
|
||||
SGizmoSettings gizmo;
|
||||
|
||||
// Settings of the snapping.
|
||||
SSnapSettings snap;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user