summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
authorHugo Locurcio <hugo.locurcio@hugo.pro>2021-10-16 01:22:57 +0200
committerHugo Locurcio <hugo.locurcio@hugo.pro>2021-11-16 20:40:49 +0100
commit8fb7e622a6a4d6651442764e4e22e000f455f77b (patch)
treec0a47367d1778fb3903be27067ad0c3731e76668 /core
parent5045f46a5c384d83504be3d0cf101e403700b1e3 (diff)
Rename built-in `SGN()` macro to `SIGN()`
This matches the name of the GDScript function (except it's uppercase here).
Diffstat (limited to 'core')
-rw-r--r--core/input/input.cpp6
-rw-r--r--core/math/basis.cpp4
-rw-r--r--core/math/math_funcs.h4
-rw-r--r--core/math/transform_2d.cpp6
-rw-r--r--core/math/vector2.cpp2
-rw-r--r--core/math/vector2.h2
-rw-r--r--core/math/vector3.h2
-rw-r--r--core/math/vector3i.h2
-rw-r--r--core/typedefs.h4
-rw-r--r--core/variant/variant_utility.cpp8
10 files changed, 20 insertions, 20 deletions
diff --git a/core/input/input.cpp b/core/input/input.cpp
index 4b5a84f401..6fd8aca01b 100644
--- a/core/input/input.cpp
+++ b/core/input/input.cpp
@@ -714,11 +714,11 @@ Point2i Input::warp_mouse_motion(const Ref<InputEventMouseMotion> &p_motion, con
// detect the warp: if the relative distance is greater than the half of the size of the relevant rect
// (checked per each axis), it will be considered as the consequence of a former pointer warp.
- const Point2i rel_sgn(p_motion->get_relative().x >= 0.0f ? 1 : -1, p_motion->get_relative().y >= 0.0 ? 1 : -1);
+ const Point2i rel_sign(p_motion->get_relative().x >= 0.0f ? 1 : -1, p_motion->get_relative().y >= 0.0 ? 1 : -1);
const Size2i warp_margin = p_rect.size * 0.5f;
const Point2i rel_warped(
- Math::fmod(p_motion->get_relative().x + rel_sgn.x * warp_margin.x, p_rect.size.x) - rel_sgn.x * warp_margin.x,
- Math::fmod(p_motion->get_relative().y + rel_sgn.y * warp_margin.y, p_rect.size.y) - rel_sgn.y * warp_margin.y);
+ Math::fmod(p_motion->get_relative().x + rel_sign.x * warp_margin.x, p_rect.size.x) - rel_sign.x * warp_margin.x,
+ Math::fmod(p_motion->get_relative().y + rel_sign.y * warp_margin.y, p_rect.size.y) - rel_sign.y * warp_margin.y);
const Point2i pos_local = p_motion->get_global_position() - p_rect.position;
const Point2i pos_warped(Math::fposmod(pos_local.x, p_rect.size.x), Math::fposmod(pos_local.y, p_rect.size.y));
diff --git a/core/math/basis.cpp b/core/math/basis.cpp
index 3d893afb4d..566300c716 100644
--- a/core/math/basis.cpp
+++ b/core/math/basis.cpp
@@ -261,7 +261,7 @@ Vector3 Basis::get_scale_abs() const {
}
Vector3 Basis::get_scale_local() const {
- real_t det_sign = SGN(determinant());
+ real_t det_sign = SIGN(determinant());
return det_sign * Vector3(elements[0].length(), elements[1].length(), elements[2].length());
}
@@ -287,7 +287,7 @@ Vector3 Basis::get_scale() const {
// matrix elements.
//
// The rotation part of this decomposition is returned by get_rotation* functions.
- real_t det_sign = SGN(determinant());
+ real_t det_sign = SIGN(determinant());
return det_sign * get_scale_abs();
}
diff --git a/core/math/math_funcs.h b/core/math/math_funcs.h
index b3eabd3e7a..e3b990d48f 100644
--- a/core/math/math_funcs.h
+++ b/core/math/math_funcs.h
@@ -266,8 +266,8 @@ public:
float s = CLAMP((p_s - p_from) / (p_to - p_from), 0.0f, 1.0f);
return s * s * (3.0f - 2.0f * s);
}
- static _ALWAYS_INLINE_ double move_toward(double p_from, double p_to, double p_delta) { return abs(p_to - p_from) <= p_delta ? p_to : p_from + SGN(p_to - p_from) * p_delta; }
- static _ALWAYS_INLINE_ float move_toward(float p_from, float p_to, float p_delta) { return abs(p_to - p_from) <= p_delta ? p_to : p_from + SGN(p_to - p_from) * p_delta; }
+ static _ALWAYS_INLINE_ double move_toward(double p_from, double p_to, double p_delta) { return abs(p_to - p_from) <= p_delta ? p_to : p_from + SIGN(p_to - p_from) * p_delta; }
+ static _ALWAYS_INLINE_ float move_toward(float p_from, float p_to, float p_delta) { return abs(p_to - p_from) <= p_delta ? p_to : p_from + SIGN(p_to - p_from) * p_delta; }
static _ALWAYS_INLINE_ double linear2db(double p_linear) { return Math::log(p_linear) * 8.6858896380650365530225783783321; }
static _ALWAYS_INLINE_ float linear2db(float p_linear) { return Math::log(p_linear) * 8.6858896380650365530225783783321; }
diff --git a/core/math/transform_2d.cpp b/core/math/transform_2d.cpp
index df43c605f9..4bdeaa2a58 100644
--- a/core/math/transform_2d.cpp
+++ b/core/math/transform_2d.cpp
@@ -69,12 +69,12 @@ void Transform2D::rotate(const real_t p_phi) {
real_t Transform2D::get_skew() const {
real_t det = basis_determinant();
- return Math::acos(elements[0].normalized().dot(SGN(det) * elements[1].normalized())) - Math_PI * 0.5;
+ return Math::acos(elements[0].normalized().dot(SIGN(det) * elements[1].normalized())) - Math_PI * 0.5;
}
void Transform2D::set_skew(const real_t p_angle) {
real_t det = basis_determinant();
- elements[1] = SGN(det) * elements[0].rotated((Math_PI * 0.5 + p_angle)).normalized() * elements[1].length();
+ elements[1] = SIGN(det) * elements[0].rotated((Math_PI * 0.5 + p_angle)).normalized() * elements[1].length();
}
real_t Transform2D::get_rotation() const {
@@ -111,7 +111,7 @@ Transform2D::Transform2D(const real_t p_rot, const Size2 &p_scale, const real_t
}
Size2 Transform2D::get_scale() const {
- real_t det_sign = SGN(basis_determinant());
+ real_t det_sign = SIGN(basis_determinant());
return Size2(elements[0].length(), det_sign * elements[1].length());
}
diff --git a/core/math/vector2.cpp b/core/math/vector2.cpp
index 1d3f93848e..718e94eee4 100644
--- a/core/math/vector2.cpp
+++ b/core/math/vector2.cpp
@@ -91,7 +91,7 @@ real_t Vector2::cross(const Vector2 &p_other) const {
}
Vector2 Vector2::sign() const {
- return Vector2(SGN(x), SGN(y));
+ return Vector2(SIGN(x), SIGN(y));
}
Vector2 Vector2::floor() const {
diff --git a/core/math/vector2.h b/core/math/vector2.h
index 332c0475fa..0a7b9d3faf 100644
--- a/core/math/vector2.h
+++ b/core/math/vector2.h
@@ -345,7 +345,7 @@ struct Vector2i {
bool operator!=(const Vector2i &p_vec2) const;
real_t aspect() const { return width / (real_t)height; }
- Vector2i sign() const { return Vector2i(SGN(x), SGN(y)); }
+ Vector2i sign() const { return Vector2i(SIGN(x), SIGN(y)); }
Vector2i abs() const { return Vector2i(ABS(x), ABS(y)); }
Vector2i clamp(const Vector2i &p_min, const Vector2i &p_max) const;
diff --git a/core/math/vector3.h b/core/math/vector3.h
index dc9aa60458..02a56f684e 100644
--- a/core/math/vector3.h
+++ b/core/math/vector3.h
@@ -217,7 +217,7 @@ Vector3 Vector3::abs() const {
}
Vector3 Vector3::sign() const {
- return Vector3(SGN(x), SGN(y), SGN(z));
+ return Vector3(SIGN(x), SIGN(y), SIGN(z));
}
Vector3 Vector3::floor() const {
diff --git a/core/math/vector3i.h b/core/math/vector3i.h
index 9308d09045..10c28a5bb9 100644
--- a/core/math/vector3i.h
+++ b/core/math/vector3i.h
@@ -115,7 +115,7 @@ Vector3i Vector3i::abs() const {
}
Vector3i Vector3i::sign() const {
- return Vector3i(SGN(x), SGN(y), SGN(z));
+ return Vector3i(SIGN(x), SIGN(y), SIGN(z));
}
/* Operators */
diff --git a/core/typedefs.h b/core/typedefs.h
index 9ab874b2f0..95bd423817 100644
--- a/core/typedefs.h
+++ b/core/typedefs.h
@@ -91,8 +91,8 @@
#define ABS(m_v) (((m_v) < 0) ? (-(m_v)) : (m_v))
#endif
-#ifndef SGN
-#define SGN(m_v) (((m_v) == 0) ? (0.0) : (((m_v) < 0) ? (-1.0) : (+1.0)))
+#ifndef SIGN
+#define SIGN(m_v) (((m_v) == 0) ? (0.0) : (((m_v) < 0) ? (-1.0) : (+1.0)))
#endif
#ifndef MIN
diff --git a/core/variant/variant_utility.cpp b/core/variant/variant_utility.cpp
index e89bdd4faa..83fa4bde69 100644
--- a/core/variant/variant_utility.cpp
+++ b/core/variant/variant_utility.cpp
@@ -151,10 +151,10 @@ struct VariantUtilityFunctions {
r_error.error = Callable::CallError::CALL_OK;
switch (x.get_type()) {
case Variant::INT: {
- return SGN(VariantInternalAccessor<int64_t>::get(&x));
+ return SIGN(VariantInternalAccessor<int64_t>::get(&x));
} break;
case Variant::FLOAT: {
- return SGN(VariantInternalAccessor<double>::get(&x));
+ return SIGN(VariantInternalAccessor<double>::get(&x));
} break;
case Variant::VECTOR2: {
return VariantInternalAccessor<Vector2>::get(&x).sign();
@@ -176,11 +176,11 @@ struct VariantUtilityFunctions {
}
static inline double signf(double x) {
- return SGN(x);
+ return SIGN(x);
}
static inline int64_t signi(int64_t x) {
- return SGN(x);
+ return SIGN(x);
}
static inline double pow(double x, double y) {