diff options
author | Aaron Franke <arnfranke@yahoo.com> | 2019-04-25 13:19:14 -0400 |
---|---|---|
committer | Aaron Franke <arnfranke@yahoo.com> | 2019-04-25 13:20:29 -0400 |
commit | b2e1c9c276cd833b642dfbaea3dde36d490b014e (patch) | |
tree | 1e5a46ea7be22d211525d1994f16d0240706961c /core/math/vector2.h | |
parent | cce2e4b07c1c4b6f2f9d72cac340d9f9ecbb790e (diff) | |
download | redot-engine-b2e1c9c276cd833b642dfbaea3dde36d490b014e.tar.gz |
[Core] Approximate equality
Diffstat (limited to 'core/math/vector2.h')
-rw-r--r-- | core/math/vector2.h | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/core/math/vector2.h b/core/math/vector2.h index 9a214ef9b5..a0c6024c9f 100644 --- a/core/math/vector2.h +++ b/core/math/vector2.h @@ -106,8 +106,8 @@ struct Vector2 { bool operator==(const Vector2 &p_vec2) const; bool operator!=(const Vector2 &p_vec2) const; - 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 (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); } real_t angle() const; @@ -213,11 +213,11 @@ _FORCE_INLINE_ Vector2 Vector2::operator-() const { _FORCE_INLINE_ bool Vector2::operator==(const Vector2 &p_vec2) const { - return x == p_vec2.x && y == p_vec2.y; + return Math::is_equal_approx(x, p_vec2.x) && Math::is_equal_approx(y, p_vec2.y); } _FORCE_INLINE_ bool Vector2::operator!=(const Vector2 &p_vec2) const { - return x != p_vec2.x || y != p_vec2.y; + return !Math::is_equal_approx(x, p_vec2.x) || !Math::is_equal_approx(y, p_vec2.y); } Vector2 Vector2::linear_interpolate(const Vector2 &p_b, real_t p_t) const { |