diff options
author | Aaron Franke <arnfranke@yahoo.com> | 2020-09-08 18:10:58 -0400 |
---|---|---|
committer | Aaron Franke <arnfranke@yahoo.com> | 2020-09-08 18:10:58 -0400 |
commit | d0a1399a1b7ef6b76f6e6094fb6dd6bd9b43d2c8 (patch) | |
tree | 1cec418ba6bd8dd6eee9a17757381d45c34d1e46 /core/math | |
parent | 2410016638a1fbf4c5e11ffe76dc2cd2d50d3771 (diff) |
Change inequality comparison operators to use exact equality
Diffstat (limited to 'core/math')
-rw-r--r-- | core/math/vector2.h | 8 | ||||
-rw-r--r-- | core/math/vector3.h | 16 |
2 files changed, 12 insertions, 12 deletions
diff --git a/core/math/vector2.h b/core/math/vector2.h index 8a08d3bf64..0966d3392f 100644 --- a/core/math/vector2.h +++ b/core/math/vector2.h @@ -114,10 +114,10 @@ struct Vector2 { bool operator==(const Vector2 &p_vec2) const; bool operator!=(const Vector2 &p_vec2) const; - bool operator<(const Vector2 &p_vec2) const { return Math::is_equal_approx(x, p_vec2.x) ? (y < p_vec2.y) : (x < p_vec2.x); } - bool operator>(const Vector2 &p_vec2) const { return Math::is_equal_approx(x, p_vec2.x) ? (y > p_vec2.y) : (x > p_vec2.x); } - bool operator<=(const Vector2 &p_vec2) const { return Math::is_equal_approx(x, p_vec2.x) ? (y <= p_vec2.y) : (x < p_vec2.x); } - bool operator>=(const Vector2 &p_vec2) const { return Math::is_equal_approx(x, p_vec2.x) ? (y >= p_vec2.y) : (x > p_vec2.x); } + bool operator<(const Vector2 &p_vec2) const { return x == p_vec2.x ? (y < p_vec2.y) : (x < p_vec2.x); } + bool operator>(const Vector2 &p_vec2) const { return x == p_vec2.x ? (y > p_vec2.y) : (x > p_vec2.x); } + bool operator<=(const Vector2 &p_vec2) const { return x == p_vec2.x ? (y <= p_vec2.y) : (x < p_vec2.x); } + bool operator>=(const Vector2 &p_vec2) const { return x == p_vec2.x ? (y >= p_vec2.y) : (x > p_vec2.x); } real_t angle() const; diff --git a/core/math/vector3.h b/core/math/vector3.h index 0bc1a467f2..5370b297f1 100644 --- a/core/math/vector3.h +++ b/core/math/vector3.h @@ -322,8 +322,8 @@ bool Vector3::operator!=(const Vector3 &p_v) const { } bool Vector3::operator<(const Vector3 &p_v) const { - if (Math::is_equal_approx(x, p_v.x)) { - if (Math::is_equal_approx(y, p_v.y)) { + if (x == p_v.x) { + if (y == p_v.y) { return z < p_v.z; } else { return y < p_v.y; @@ -334,8 +334,8 @@ bool Vector3::operator<(const Vector3 &p_v) const { } bool Vector3::operator>(const Vector3 &p_v) const { - if (Math::is_equal_approx(x, p_v.x)) { - if (Math::is_equal_approx(y, p_v.y)) { + if (x == p_v.x) { + if (y == p_v.y) { return z > p_v.z; } else { return y > p_v.y; @@ -346,8 +346,8 @@ bool Vector3::operator>(const Vector3 &p_v) const { } bool Vector3::operator<=(const Vector3 &p_v) const { - if (Math::is_equal_approx(x, p_v.x)) { - if (Math::is_equal_approx(y, p_v.y)) { + if (x == p_v.x) { + if (y == p_v.y) { return z <= p_v.z; } else { return y < p_v.y; @@ -358,8 +358,8 @@ bool Vector3::operator<=(const Vector3 &p_v) const { } bool Vector3::operator>=(const Vector3 &p_v) const { - if (Math::is_equal_approx(x, p_v.x)) { - if (Math::is_equal_approx(y, p_v.y)) { + if (x == p_v.x) { + if (y == p_v.y) { return z >= p_v.z; } else { return y > p_v.y; |