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:
Tom Hulton-Harrop
2021-05-10 18:40:32 +01:00
committed by GitHub
parent bdaa7eb3c1
commit b2523217c3
15 changed files with 242 additions and 81 deletions
+10 -9
View File
@@ -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
+20
View File
@@ -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;
}
@@ -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;