mirror of
https://github.com/Relintai/gdnative_cpp.git
synced 2024-11-12 10:25:31 +01:00
Use the built in macros.
This commit is contained in:
parent
3e2e07a056
commit
e1f7662027
@ -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];
|
||||
|
@ -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 {
|
||||
|
@ -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) {
|
||||
|
@ -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)));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -39,10 +39,6 @@
|
||||
|
||||
#include <vector>
|
||||
|
||||
namespace {
|
||||
|
||||
} // namespace
|
||||
|
||||
struct Projection {
|
||||
enum Planes {
|
||||
PLANE_NEAR,
|
||||
|
@ -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 {
|
||||
|
@ -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
|
||||
|
@ -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);
|
||||
|
||||
|
@ -37,8 +37,6 @@
|
||||
|
||||
#include <math_funcs.h>
|
||||
|
||||
|
||||
|
||||
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
|
||||
|
Loading…
Reference in New Issue
Block a user