diff --git a/core/aabb.cpp b/core/aabb.cpp index 8c40692..7f57824 100644 --- a/core/aabb.cpp +++ b/core/aabb.cpp @@ -346,7 +346,7 @@ bool AABB::intersects_ray(const Vector3 &p_from, const Vector3 &p_dir, Vector3 * c2[i] = (end[i] - p_from[i]) / p_dir[i]; if (c1[i] > c2[i]) { - std::swap(c1, c2); + SWAP(c1, c2); } if (c1[i] > near) { near = c1[i]; diff --git a/core/basis.cpp b/core/basis.cpp index 3b7c61d..95936f8 100644 --- a/core/basis.cpp +++ b/core/basis.cpp @@ -106,9 +106,9 @@ bool Basis::is_rotation() const { } void Basis::transpose() { - std::swap(elements[0][1], elements[1][0]); - std::swap(elements[0][2], elements[2][0]); - std::swap(elements[1][2], elements[2][1]); + SWAP(elements[0][1], elements[1][0]); + SWAP(elements[0][2], elements[2][0]); + SWAP(elements[1][2], elements[2][1]); } Basis Basis::inverse() const { diff --git a/core/math_funcs.h b/core/math_funcs.h index bf5fc61..31f5198 100644 --- a/core/math_funcs.h +++ b/core/math_funcs.h @@ -195,11 +195,11 @@ inline bool is_equal_approx(real_t a, real_t b) { return true; } // Then check for approximate equality. - real_t tolerance = CMP_EPSILON * std::abs(a); + real_t tolerance = CMP_EPSILON * ABS(a); if (tolerance < CMP_EPSILON) { tolerance = CMP_EPSILON; } - return std::abs(a - b) < tolerance; + return ABS(a - b) < tolerance; } inline bool is_equal_approx(real_t a, real_t b, real_t tolerance) { @@ -208,11 +208,11 @@ inline bool is_equal_approx(real_t a, real_t b, real_t tolerance) { return true; } // Then check for approximate equality. - return std::abs(a - b) < tolerance; + return ABS(a - b) < tolerance; } inline bool is_zero_approx(real_t s) { - return std::abs(s) < CMP_EPSILON; + return ABS(s) < CMP_EPSILON; } inline double smoothstep(double p_from, double p_to, double p_weight) { @@ -231,11 +231,11 @@ inline float smoothstep(float p_from, float p_to, float p_weight) { } inline double move_toward(double p_from, double p_to, double p_delta) { - return std::abs(p_to - p_from) <= p_delta ? p_to : p_from + sign(p_to - p_from) * p_delta; + return ABS(p_to - p_from) <= p_delta ? p_to : p_from + sign(p_to - p_from) * p_delta; } inline float move_toward(float p_from, float p_to, float p_delta) { - return std::abs(p_to - p_from) <= p_delta ? p_to : p_from + sign(p_to - p_from) * p_delta; + return ABS(p_to - p_from) <= p_delta ? p_to : p_from + sign(p_to - p_from) * p_delta; } inline double linear2db(double p_linear) { diff --git a/core/projection.cpp b/core/projection.cpp index 7b9711c..7b2e452 100644 --- a/core/projection.cpp +++ b/core/projection.cpp @@ -561,7 +561,7 @@ real_t Projection::get_fov() const { right_plane.normalize(); if ((matrix[8] == 0) && (matrix[9] == 0)) { - return Mathp::rad2deg(acos(std::abs(right_plane.normal.x))) * 2.0; + return Mathp::rad2deg(acos(ABS(right_plane.normal.x))) * 2.0; } else { // our frustum is asymmetrical need to calculate the left planes angle separately.. Plane left_plane = Plane(matrix[3] + matrix[0], @@ -570,7 +570,7 @@ real_t Projection::get_fov() const { matrix[15] + matrix[12]); left_plane.normalize(); - return Mathp::rad2deg(acos(std::abs(left_plane.normal.x))) + Mathp::rad2deg(acos(std::abs(right_plane.normal.x))); + return Mathp::rad2deg(acos(ABS(left_plane.normal.x))) + Mathp::rad2deg(acos(ABS(right_plane.normal.x))); } } diff --git a/core/projection.h b/core/projection.h index 9cca7ee..7f5edfe 100644 --- a/core/projection.h +++ b/core/projection.h @@ -39,10 +39,6 @@ #include -namespace { - -} // namespace - struct Projection { enum Planes { PLANE_NEAR, diff --git a/core/quaternion.cpp b/core/quaternion.cpp index d69cf57..9f60d6d 100644 --- a/core/quaternion.cpp +++ b/core/quaternion.cpp @@ -122,7 +122,7 @@ Quaternion Quaternion::normalized() const { } bool Quaternion::is_normalized() const { - return std::abs(length_squared() - 1.0) < 0.00001; + return ABS(length_squared() - 1.0) < 0.00001; } Quaternion Quaternion::inverse() const { diff --git a/core/quaternion.h b/core/quaternion.h index f5c8bc1..0c9215f 100644 --- a/core/quaternion.h +++ b/core/quaternion.h @@ -35,10 +35,6 @@ #include "vector3.h" -// #include "basis.h" - - - class Quaternion { public: static const Quaternion IDENTITY; @@ -120,6 +116,4 @@ public: } }; - - #endif // QUAT_H diff --git a/core/transform_2d.cpp b/core/transform_2d.cpp index 8c6591e..820b38f 100644 --- a/core/transform_2d.cpp +++ b/core/transform_2d.cpp @@ -115,7 +115,7 @@ Rect2 Transform2D::xform_inv(const Rect2 &p_rect) const { void Transform2D::invert() { // FIXME: this function assumes the basis is a rotation matrix, with no scaling. // Transform2D::affine_inverse can handle matrices with scaling, so GDScript should eventually use that. - std::swap(elements[0][1], elements[1][0]); + SWAP(elements[0][1], elements[1][0]); elements[2] = basis_xform(-elements[2]); } @@ -130,7 +130,7 @@ void Transform2D::affine_invert() { ERR_FAIL_COND(det == 0); real_t idet = 1.0 / det; - std::swap(elements[0][0], elements[1][1]); + SWAP(elements[0][0], elements[1][1]); elements[0] *= Vector2(idet, -idet); elements[1] *= Vector2(-idet, idet); diff --git a/core/vector3.h b/core/vector3.h index a475535..0f05595 100644 --- a/core/vector3.h +++ b/core/vector3.h @@ -37,8 +37,6 @@ #include - - class Basis; class String; @@ -257,7 +255,7 @@ struct Vector3 { } inline real_t angle_to(const Vector3 &b) const { - return std::atan2(cross(b).length(), dot(b)); + return Mathp::atan2(cross(b).length(), dot(b)); } inline Vector3 direction_to(const Vector3 &p_b) const { @@ -275,7 +273,7 @@ struct Vector3 { } inline bool is_normalized() const { - return std::abs(length_squared() - 1.f) < 0.00001f; + return ABS(length_squared() - 1.f) < 0.00001f; } Basis outer(const Vector3 &b) const; @@ -336,6 +334,4 @@ inline Vector3 vec3_cross(const Vector3 &p_a, const Vector3 &p_b) { return p_a.cross(p_b); } - - #endif // VECTOR3_H