Update snapping settings to be stored in the Settings Registry (#646)
* add overload to ActionManager to support capturing an AZStd::function * move snapping settings to new settings registry * remove unneeded reference in ViewportSettings * move viewport setting function implementations to .cpp file * add more sensible default values for snapping * fix variable name for angle snapping * remove const from function prototype value parameters * add import/export api for free functions * change from std::bind to a lambda * remove redundant const for constexpr string_view * add AZStd alias for std::abs
This commit is contained in:
committed by
GitHub
parent
bdaa7eb3c1
commit
b2523217c3
@@ -13,16 +13,17 @@
|
||||
#pragma once
|
||||
|
||||
#include <AzCore/base.h>
|
||||
#include <AzCore/std/math.h>
|
||||
#include <AzCore/std/typetraits/conditional.h>
|
||||
#include <AzCore/std/typetraits/is_integral.h>
|
||||
#include <AzCore/std/typetraits/is_signed.h>
|
||||
#include <AzCore/std/typetraits/is_unsigned.h>
|
||||
#include <AzCore/std/utils.h>
|
||||
#include <math.h>
|
||||
|
||||
#include <float.h>
|
||||
#include <limits>
|
||||
#include <cmath>
|
||||
#include <math.h>
|
||||
#include <utility>
|
||||
#include <AzCore/std/typetraits/conditional.h>
|
||||
#include <AzCore/std/typetraits/is_integral.h>
|
||||
|
||||
// We have a separate inline define for math functions.
|
||||
// The performance of these functions is very sensitive to inlining, and some compilers don't deal well with this.
|
||||
@@ -308,12 +309,12 @@ namespace AZ
|
||||
|
||||
AZ_MATH_INLINE bool IsClose(float a, float b, float tolerance = Constants::Tolerance)
|
||||
{
|
||||
return (fabsf(a - b) <= tolerance);
|
||||
return (AZStd::abs(a - b) <= tolerance);
|
||||
}
|
||||
|
||||
AZ_MATH_INLINE bool IsClose(double a, double b, double tolerance = Constants::Tolerance)
|
||||
{
|
||||
return (fabs(a - b) <= tolerance);
|
||||
return (AZStd::abs(a - b) <= tolerance);
|
||||
}
|
||||
|
||||
//! Returns x >= 0.0f ? 1.0f : -1.0f.
|
||||
@@ -402,12 +403,12 @@ namespace AZ
|
||||
|
||||
AZ_MATH_INLINE float GetAbs(float a)
|
||||
{
|
||||
return fabsf(a);
|
||||
return AZStd::abs(a);
|
||||
}
|
||||
|
||||
AZ_MATH_INLINE double GetAbs(double a)
|
||||
{
|
||||
return std::abs(a);
|
||||
return AZStd::abs(a);
|
||||
}
|
||||
|
||||
AZ_MATH_INLINE float GetMod(float a, float b)
|
||||
@@ -441,7 +442,7 @@ namespace AZ
|
||||
template<typename T>
|
||||
AZ_MATH_INLINE bool IsCloseMag(T x, T y, T epsilonValue = std::numeric_limits<T>::epsilon())
|
||||
{
|
||||
return (std::fabs(x - y) <= epsilonValue * GetMax<T>(GetMax<T>(T(1.0), std::fabs(x)), std::fabs(y)));
|
||||
return (AZStd::abs(x - y) <= epsilonValue * GetMax<T>(GetMax<T>(T(1.0), AZStd::abs(x)), AZStd::abs(y)));
|
||||
}
|
||||
|
||||
//! ClampIfCloseMag(x, y, epsilon) returns y when x and y are within epsilon of each other (taking magnitude into account). Otherwise returns x.
|
||||
|
||||
@@ -31,6 +31,7 @@ set(FILES
|
||||
iterator.h
|
||||
limits.h
|
||||
numeric.h
|
||||
math.h
|
||||
optional.h
|
||||
ratio.h
|
||||
reference_wrapper.h
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
/*
|
||||
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
|
||||
* its licensors.
|
||||
*
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this
|
||||
* distribution (the "License"). All use of this software is governed by the License,
|
||||
* or, if provided, by the license below or the license accompanying this file. Do not
|
||||
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <cmath>
|
||||
|
||||
namespace AZStd
|
||||
{
|
||||
using std::abs;
|
||||
}
|
||||
+2
-2
@@ -85,14 +85,14 @@ namespace AzToolsFramework
|
||||
|
||||
// if we're snapping, only increment current radians when we know
|
||||
// preSnapRadians is greater than the angleStep
|
||||
if (snapping)
|
||||
if (snapping && AZStd::abs(angleStepDegrees) > 0.0f)
|
||||
{
|
||||
actionInternal.m_current.m_preSnapRadians += rotationAngleRad * rotateSign;
|
||||
|
||||
const float angleStepRad = AZ::DegToRad(angleStepDegrees);
|
||||
const float preSnapRotateSign = Sign(actionInternal.m_current.m_preSnapRadians);
|
||||
// if we move more than angleStep in a frame, make sure we catch up
|
||||
while (fabsf(actionInternal.m_current.m_preSnapRadians) >= angleStepRad)
|
||||
while (AZStd::abs(actionInternal.m_current.m_preSnapRadians) >= angleStepRad)
|
||||
{
|
||||
actionInternal.m_current.m_radians += angleStepRad * preSnapRotateSign;
|
||||
actionInternal.m_current.m_preSnapRadians -= angleStepRad * preSnapRotateSign;
|
||||
|
||||
@@ -169,6 +169,13 @@ public:
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<typename Fn>
|
||||
ActionWrapper& RegisterUpdateCallback(Fn&& fn)
|
||||
{
|
||||
m_actionManager->RegisterUpdateCallback(m_action->data().toInt(), AZStd::forward<Fn>(fn));
|
||||
return *this;
|
||||
}
|
||||
|
||||
private:
|
||||
friend ActionManager;
|
||||
friend DynamicMenu;
|
||||
@@ -315,11 +322,17 @@ public:
|
||||
void DetachOverride() override;
|
||||
|
||||
template<typename T>
|
||||
void RegisterUpdateCallback(int id, T* object, void (T::* method)(QAction*))
|
||||
void RegisterUpdateCallback(int id, T* object, void (T::*method)(QAction*))
|
||||
{
|
||||
Q_ASSERT(m_actions.contains(id));
|
||||
auto f = std::bind(method, object, m_actions.value(id));
|
||||
m_updateCallbacks[id] = f;
|
||||
m_updateCallbacks[id] = [action = m_actions.value(id), object, method] { AZStd::invoke(method, object, action); };
|
||||
}
|
||||
|
||||
template<typename Fn>
|
||||
void RegisterUpdateCallback(int id, Fn&& fn)
|
||||
{
|
||||
Q_ASSERT(m_actions.contains(id));
|
||||
m_updateCallbacks[id] = [action = m_actions.value(id), fn] { fn(action); };
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
|
||||
@@ -398,8 +398,6 @@ void CCryEditApp::RegisterActionHandlers()
|
||||
ON_COMMAND(ID_GAME_SYNCPLAYER, OnSyncPlayer)
|
||||
ON_COMMAND(ID_RESOURCES_REDUCEWORKINGSET, OnResourcesReduceworkingset)
|
||||
|
||||
ON_COMMAND(ID_SNAP_TO_GRID, OnSnap)
|
||||
|
||||
ON_COMMAND(ID_WIREFRAME, OnWireframe)
|
||||
|
||||
ON_COMMAND(ID_VIEW_GRIDSETTINGS, OnViewGridsettings)
|
||||
@@ -442,7 +440,6 @@ void CCryEditApp::RegisterActionHandlers()
|
||||
ON_COMMAND(ID_VIEW_CYCLE2DVIEWPORT, OnViewCycle2dviewport)
|
||||
#endif
|
||||
ON_COMMAND(ID_DISPLAY_GOTOPOSITION, OnDisplayGotoPosition)
|
||||
ON_COMMAND(ID_SNAPANGLE, OnSnapangle)
|
||||
ON_COMMAND(ID_CHANGEMOVESPEED_INCREASE, OnChangemovespeedIncrease)
|
||||
ON_COMMAND(ID_CHANGEMOVESPEED_DECREASE, OnChangemovespeedDecrease)
|
||||
ON_COMMAND(ID_CHANGEMOVESPEED_CHANGESTEP, OnChangemovespeedChangestep)
|
||||
@@ -3423,14 +3420,6 @@ void CCryEditApp::OnResourcesReduceworkingset()
|
||||
#endif
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void CCryEditApp::OnSnap()
|
||||
{
|
||||
// Switch current snap to grid state.
|
||||
bool bGridEnabled = gSettings.pGrid->IsEnabled();
|
||||
gSettings.pGrid->Enable(!bGridEnabled);
|
||||
}
|
||||
|
||||
void CCryEditApp::OnWireframe()
|
||||
{
|
||||
int nWireframe(R_SOLID_MODE);
|
||||
@@ -3679,19 +3668,6 @@ void CCryEditApp::OnDisplayGotoPosition()
|
||||
dlg.exec();
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void CCryEditApp::OnSnapangle()
|
||||
{
|
||||
gSettings.pGrid->EnableAngleSnap(!gSettings.pGrid->IsAngleSnapEnabled());
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void CCryEditApp::OnUpdateSnapangle(QAction* action)
|
||||
{
|
||||
Q_ASSERT(action->isCheckable());
|
||||
action->setChecked(gSettings.pGrid->IsAngleSnapEnabled());
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void CCryEditApp::OnChangemovespeedIncrease()
|
||||
{
|
||||
|
||||
@@ -364,7 +364,6 @@ private:
|
||||
AZ_POP_DISABLE_DLL_EXPORT_MEMBER_WARNING
|
||||
friend struct PythonTestOutputHandler;
|
||||
|
||||
void OnSnap();
|
||||
void OnWireframe();
|
||||
void OnUpdateWireframe(QAction* action);
|
||||
void OnViewGridsettings();
|
||||
@@ -402,8 +401,6 @@ private:
|
||||
void OnToolsScriptHelp();
|
||||
void OnViewCycle2dviewport();
|
||||
void OnDisplayGotoPosition();
|
||||
void OnSnapangle();
|
||||
void OnUpdateSnapangle(QAction* action);
|
||||
void OnChangemovespeedIncrease();
|
||||
void OnChangemovespeedDecrease();
|
||||
void OnChangemovespeedChangestep();
|
||||
|
||||
@@ -0,0 +1,116 @@
|
||||
/*
|
||||
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
|
||||
* its licensors.
|
||||
*
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this
|
||||
* distribution (the "License"). All use of this software is governed by the License,
|
||||
* or, if provided, by the license below or the license accompanying this file. Do not
|
||||
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <EditorViewportSettings.h>
|
||||
|
||||
#include <AzCore/Casting/numeric_cast.h>
|
||||
#include <AzCore/Settings/SettingsRegistry.h>
|
||||
#include <AzCore/std/string/string_view.h>
|
||||
|
||||
namespace Editor
|
||||
{
|
||||
constexpr AZStd::string_view GridSnappingSetting = "/Amazon/Preferences/Editor/GridSnapping";
|
||||
constexpr AZStd::string_view GridSizeSetting = "/Amazon/Preferences/Editor/GridSize";
|
||||
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";
|
||||
|
||||
bool GridSnappingEnabled()
|
||||
{
|
||||
bool enabled = false;
|
||||
if (auto* registry = AZ::SettingsRegistry::Get())
|
||||
{
|
||||
registry->Get(enabled, GridSnappingSetting);
|
||||
}
|
||||
return enabled;
|
||||
}
|
||||
|
||||
float GridSnappingSize()
|
||||
{
|
||||
double gridSize = 0.1;
|
||||
if (auto* registry = AZ::SettingsRegistry::Get())
|
||||
{
|
||||
registry->Get(gridSize, GridSizeSetting);
|
||||
}
|
||||
return aznumeric_cast<float>(gridSize);
|
||||
}
|
||||
|
||||
bool AngleSnappingEnabled()
|
||||
{
|
||||
bool enabled = false;
|
||||
if (auto* registry = AZ::SettingsRegistry::Get())
|
||||
{
|
||||
registry->Get(enabled, AngleSnappingSetting);
|
||||
}
|
||||
return enabled;
|
||||
}
|
||||
|
||||
float AngleSnappingSize()
|
||||
{
|
||||
double angleSize = 5.0;
|
||||
if (auto* registry = AZ::SettingsRegistry::Get())
|
||||
{
|
||||
registry->Get(angleSize, AngleSizeSetting);
|
||||
}
|
||||
return aznumeric_cast<float>(angleSize);
|
||||
}
|
||||
|
||||
bool ShowingGrid()
|
||||
{
|
||||
bool enabled = false;
|
||||
if (auto* registry = AZ::SettingsRegistry::Get())
|
||||
{
|
||||
registry->Get(enabled, ShowGridSetting);
|
||||
}
|
||||
return enabled;
|
||||
}
|
||||
|
||||
void SetGridSnapping(const bool enabled)
|
||||
{
|
||||
if (auto* registry = AZ::SettingsRegistry::Get())
|
||||
{
|
||||
registry->Set(GridSnappingSetting, enabled);
|
||||
}
|
||||
}
|
||||
|
||||
void SetGridSnappingSize(const float size)
|
||||
{
|
||||
if (auto* registry = AZ::SettingsRegistry::Get())
|
||||
{
|
||||
registry->Set(GridSizeSetting, size);
|
||||
}
|
||||
}
|
||||
|
||||
void SetAngleSnapping(const bool enabled)
|
||||
{
|
||||
if (auto* registry = AZ::SettingsRegistry::Get())
|
||||
{
|
||||
registry->Set(AngleSnappingSetting, enabled);
|
||||
}
|
||||
}
|
||||
|
||||
void SetAngleSnappingSize(const float size)
|
||||
{
|
||||
if (auto* registry = AZ::SettingsRegistry::Get())
|
||||
{
|
||||
registry->Set(AngleSizeSetting, size);
|
||||
}
|
||||
}
|
||||
|
||||
void SetShowingGrid(const bool showing)
|
||||
{
|
||||
if (auto* registry = AZ::SettingsRegistry::Get())
|
||||
{
|
||||
registry->Set(ShowGridSetting, showing);
|
||||
}
|
||||
}
|
||||
} // namespace Editor
|
||||
@@ -0,0 +1,38 @@
|
||||
/*
|
||||
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
|
||||
* its licensors.
|
||||
*
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this
|
||||
* distribution (the "License"). All use of this software is governed by the License,
|
||||
* or, if provided, by the license below or the license accompanying this file. Do not
|
||||
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <EditorCoreAPI.h>
|
||||
|
||||
namespace Editor
|
||||
{
|
||||
EDITOR_CORE_API bool GridSnappingEnabled();
|
||||
|
||||
EDITOR_CORE_API float GridSnappingSize();
|
||||
|
||||
EDITOR_CORE_API bool AngleSnappingEnabled();
|
||||
|
||||
EDITOR_CORE_API float AngleSnappingSize();
|
||||
|
||||
EDITOR_CORE_API bool ShowingGrid();
|
||||
|
||||
EDITOR_CORE_API void SetGridSnapping(bool enabled);
|
||||
|
||||
EDITOR_CORE_API void SetGridSnappingSize(float size);
|
||||
|
||||
EDITOR_CORE_API void SetAngleSnapping(bool enabled);
|
||||
|
||||
EDITOR_CORE_API void SetAngleSnappingSize(float size);
|
||||
|
||||
EDITOR_CORE_API void SetShowingGrid(bool showing);
|
||||
} // namespace Editor
|
||||
@@ -75,6 +75,7 @@
|
||||
#include "ViewportManipulatorController.h"
|
||||
#include "LegacyViewportCameraController.h"
|
||||
#include "ModernViewportCameraController.h"
|
||||
#include "EditorViewportSettings.h"
|
||||
|
||||
#include "ViewPane.h"
|
||||
#include "CustomResolutionDlg.h"
|
||||
@@ -127,6 +128,18 @@ AZ_CVAR(
|
||||
bool, ed_useNewCameraSystem, false, nullptr, AZ::ConsoleFunctorFlags::Null,
|
||||
"Use the new Editor camera system (the Atom-native Editor viewport (experimental) must also be enabled)");
|
||||
|
||||
//! Viewport settings for the EditorViewportWidget
|
||||
struct EditorViewportSettings : public AzToolsFramework::ViewportInteraction::ViewportSettings
|
||||
{
|
||||
bool GridSnappingEnabled() const override;
|
||||
float GridSize() const override;
|
||||
bool ShowGrid() const override;
|
||||
bool AngleSnappingEnabled() const override;
|
||||
float AngleStep() const override;
|
||||
};
|
||||
|
||||
static const EditorViewportSettings g_EditorViewportSettings;
|
||||
|
||||
namespace AZ::ViewportHelpers
|
||||
{
|
||||
static const char TextCantCreateCameraNoLevel[] = "Cannot create camera when no level is loaded.";
|
||||
@@ -170,7 +183,6 @@ EditorViewportWidget::EditorViewportWidget(const QString& name, QWidget* parent)
|
||||
, m_camFOV(gSettings.viewports.fDefaultFov)
|
||||
, m_defaultViewName(name)
|
||||
, m_renderViewport(nullptr) //m_renderViewport is initialized later, in SetViewportId
|
||||
, m_editorViewportSettings(this)
|
||||
{
|
||||
// need this to be set in order to allow for language switching on Windows
|
||||
setAttribute(Qt::WA_InputMethodEnabled);
|
||||
@@ -1246,7 +1258,7 @@ void EditorViewportWidget::SetViewportId(int id)
|
||||
m_renderViewport->GetControllerList()->Add(AZStd::make_shared<SandboxEditor::LegacyViewportCameraController>());
|
||||
}
|
||||
|
||||
m_renderViewport->SetViewportSettings(&m_editorViewportSettings);
|
||||
m_renderViewport->SetViewportSettings(&g_EditorViewportSettings);
|
||||
|
||||
UpdateScene();
|
||||
|
||||
@@ -2867,35 +2879,29 @@ void EditorViewportWidget::SetAsActiveViewport()
|
||||
}
|
||||
}
|
||||
|
||||
EditorViewportSettings::EditorViewportSettings(const EditorViewportWidget* editorViewportWidget)
|
||||
: m_editorViewportWidget(editorViewportWidget)
|
||||
{
|
||||
}
|
||||
|
||||
bool EditorViewportSettings::GridSnappingEnabled() const
|
||||
{
|
||||
return m_editorViewportWidget->GetViewManager()->GetGrid()->IsEnabled();
|
||||
return Editor::GridSnappingEnabled();
|
||||
}
|
||||
|
||||
float EditorViewportSettings::GridSize() const
|
||||
{
|
||||
const CGrid* grid = m_editorViewportWidget->GetViewManager()->GetGrid();
|
||||
return grid->scale * grid->size;
|
||||
return Editor::GridSnappingSize();
|
||||
}
|
||||
|
||||
bool EditorViewportSettings::ShowGrid() const
|
||||
{
|
||||
return gSettings.viewports.bShowGridGuide;
|
||||
return Editor::ShowingGrid();
|
||||
}
|
||||
|
||||
bool EditorViewportSettings::AngleSnappingEnabled() const
|
||||
{
|
||||
return m_editorViewportWidget->GetViewManager()->GetGrid()->IsAngleSnapEnabled();
|
||||
return Editor::AngleSnappingEnabled();
|
||||
}
|
||||
|
||||
float EditorViewportSettings::AngleStep() const
|
||||
{
|
||||
return m_editorViewportWidget->GetViewManager()->GetGrid()->GetAngleSnap();
|
||||
return Editor::AngleSnappingSize();
|
||||
}
|
||||
|
||||
#include <moc_EditorViewportWidget.cpp>
|
||||
|
||||
@@ -65,23 +65,6 @@ namespace AzToolsFramework
|
||||
class ManipulatorManager;
|
||||
}
|
||||
|
||||
class EditorViewportWidget;
|
||||
|
||||
//! Viewport settings for the EditorViewportWidget
|
||||
struct EditorViewportSettings : public AzToolsFramework::ViewportInteraction::ViewportSettings
|
||||
{
|
||||
explicit EditorViewportSettings(const EditorViewportWidget* editorViewportWidget);
|
||||
|
||||
bool GridSnappingEnabled() const override;
|
||||
float GridSize() const override;
|
||||
bool ShowGrid() const override;
|
||||
bool AngleSnappingEnabled() const override;
|
||||
float AngleStep() const override;
|
||||
|
||||
private:
|
||||
const EditorViewportWidget* m_editorViewportWidget = nullptr;
|
||||
};
|
||||
|
||||
// EditorViewportWidget window
|
||||
AZ_PUSH_DISABLE_DLL_EXPORT_BASECLASS_WARNING
|
||||
AZ_PUSH_DISABLE_DLL_EXPORT_MEMBER_WARNING
|
||||
@@ -607,7 +590,5 @@ private:
|
||||
|
||||
AZ::Name m_defaultViewportContextName;
|
||||
|
||||
EditorViewportSettings m_editorViewportSettings;
|
||||
|
||||
AZ_POP_DISABLE_DLL_EXPORT_MEMBER_WARNING
|
||||
};
|
||||
|
||||
@@ -78,6 +78,7 @@ AZ_POP_DISABLE_WARNING
|
||||
#include "Core/QtEditorApplication.h"
|
||||
#include "UndoDropDown.h"
|
||||
#include "CVarMenu.h"
|
||||
#include "EditorViewportSettings.h"
|
||||
|
||||
#include "KeyboardCustomizationSettings.h"
|
||||
#include "CustomizeKeyboardDialog.h"
|
||||
@@ -915,13 +916,22 @@ void MainWindow::InitActions()
|
||||
.SetToolTip(tr("Snap to grid (G)"))
|
||||
.SetStatusTip(tr("Toggles snap to grid"))
|
||||
.SetCheckable(true)
|
||||
.RegisterUpdateCallback(this, &MainWindow::OnUpdateSnapToGrid);
|
||||
.RegisterUpdateCallback([](QAction* action) {
|
||||
Q_ASSERT(action->isCheckable());
|
||||
action->setChecked(Editor::GridSnappingEnabled());
|
||||
})
|
||||
.Connect(&QAction::triggered, []() { Editor::SetGridSnapping(!Editor::GridSnappingEnabled()); });
|
||||
|
||||
am->AddAction(ID_SNAPANGLE, tr("Snap angle"))
|
||||
.SetIcon(Style::icon("Angle"))
|
||||
.SetApplyHoverEffect()
|
||||
.SetStatusTip(tr("Snap angle"))
|
||||
.SetCheckable(true)
|
||||
.RegisterUpdateCallback(cryEdit, &CCryEditApp::OnUpdateSnapangle);
|
||||
.RegisterUpdateCallback([](QAction* action) {
|
||||
Q_ASSERT(action->isCheckable());
|
||||
action->setChecked(Editor::AngleSnappingEnabled());
|
||||
})
|
||||
.Connect(&QAction::triggered, []() { Editor::SetAngleSnapping(!Editor::AngleSnappingEnabled()); });
|
||||
|
||||
// Display actions
|
||||
am->AddAction(ID_WIREFRAME, tr("&Wireframe"))
|
||||
@@ -1432,12 +1442,12 @@ QWidget* MainWindow::CreateSnapToGridWidget()
|
||||
{
|
||||
SnapToWidget::SetValueCallback setCallback = [](double snapStep)
|
||||
{
|
||||
GetIEditor()->GetViewManager()->GetGrid()->size = snapStep;
|
||||
Editor::SetGridSnappingSize(snapStep);
|
||||
};
|
||||
|
||||
SnapToWidget::GetValueCallback getCallback = []()
|
||||
{
|
||||
return GetIEditor()->GetViewManager()->GetGrid()->size;
|
||||
return Editor::GridSnappingSize();
|
||||
};
|
||||
|
||||
return new SnapToWidget(m_actionManager->GetAction(ID_SNAP_TO_GRID), setCallback, getCallback);
|
||||
@@ -1447,12 +1457,12 @@ QWidget* MainWindow::CreateSnapToAngleWidget()
|
||||
{
|
||||
SnapToWidget::SetValueCallback setCallback = [](double snapAngle)
|
||||
{
|
||||
GetIEditor()->GetViewManager()->GetGrid()->angleSnap = snapAngle;
|
||||
Editor::SetAngleSnappingSize(snapAngle);
|
||||
};
|
||||
|
||||
SnapToWidget::GetValueCallback getCallback = []()
|
||||
{
|
||||
return GetIEditor()->GetViewManager()->GetGrid()->angleSnap;
|
||||
return Editor::AngleSnappingSize();
|
||||
};
|
||||
|
||||
return new SnapToWidget(m_actionManager->GetAction(ID_SNAPANGLE), setCallback, getCallback);
|
||||
|
||||
@@ -22,6 +22,8 @@ set(FILES
|
||||
Include/IEditorMaterial.h
|
||||
Include/IEditorMaterialManager.h
|
||||
Include/IImageUtil.h
|
||||
EditorViewportSettings.cpp
|
||||
EditorViewportSettings.h
|
||||
Controls/ReflectedPropertyControl/ReflectedPropertyCtrl.qrc
|
||||
Controls/ReflectedPropertyControl/ReflectedPropertyCtrl.cpp
|
||||
Controls/ReflectedPropertyControl/ReflectedPropertyCtrl.h
|
||||
|
||||
+1
-1
@@ -100,7 +100,7 @@ namespace AtomToolsFramework
|
||||
const AzFramework::ScreenPoint& screenPosition) override;
|
||||
|
||||
//! Set interface for providing viewport specific settings (e.g. snapping properties).
|
||||
void SetViewportSettings(AzToolsFramework::ViewportInteraction::ViewportSettings* viewportSettings);
|
||||
void SetViewportSettings(const AzToolsFramework::ViewportInteraction::ViewportSettings* viewportSettings);
|
||||
|
||||
// AzToolsFramework::ViewportInteraction::ViewportMouseCursorRequestBus::Handler ...
|
||||
void BeginCursorCapture() override;
|
||||
|
||||
@@ -407,7 +407,7 @@ namespace AtomToolsFramework
|
||||
return m_viewportSettings ? m_viewportSettings->AngleStep() : 0.0f;
|
||||
}
|
||||
|
||||
void RenderViewportWidget::SetViewportSettings(AzToolsFramework::ViewportInteraction::ViewportSettings* viewportSettings)
|
||||
void RenderViewportWidget::SetViewportSettings(const AzToolsFramework::ViewportInteraction::ViewportSettings* viewportSettings)
|
||||
{
|
||||
m_viewportSettings = viewportSettings;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user