summaryrefslogtreecommitdiffstats
path: root/core/math/math_2d.h
diff options
context:
space:
mode:
authorHein-Pieter van Braam <hp@tmm.cx>2017-02-14 04:10:02 +0100
committerHein-Pieter van Braam <hp@tmm.cx>2017-02-14 13:32:23 +0100
commitadcc211feb7827127b2548c791f2de0b6efda3d3 (patch)
tree8bb33b592e3d3982ca5faf5e041c37644d5b525d /core/math/math_2d.h
parent81edda18f39efc4f783bc6fa2b381c01cfc0ef2d (diff)
downloadredot-engine-adcc211feb7827127b2548c791f2de0b6efda3d3.tar.gz
Make nan==nan true for GDScript
After discussing this with Reduz this seemed like the best way to fix #7354. This will make composite values that contain NaN in the same places as well as the same other values compare as the same. Additionally non-composite values now also compare equal if they are both NaN. This breaks IEEE specifications but this is probably what most users expect. There is a GDScript function check for NaN if the user needs this information. This fixes #7354 and probably also fixes #6947
Diffstat (limited to 'core/math/math_2d.h')
-rw-r--r--core/math/math_2d.h3
1 files changed, 3 insertions, 0 deletions
diff --git a/core/math/math_2d.h b/core/math/math_2d.h
index a24c4266ee..6dd8799ba2 100644
--- a/core/math/math_2d.h
+++ b/core/math/math_2d.h
@@ -133,6 +133,7 @@ struct Vector2 {
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 nan_equals(const Vector2& p_vec2) const;
real_t angle() const;
void set_rotation(real_t p_radians) {
@@ -319,6 +320,8 @@ struct Rect2 {
bool operator==(const Rect2& p_rect) const { return pos==p_rect.pos && size==p_rect.size; }
bool operator!=(const Rect2& p_rect) const { return pos!=p_rect.pos || size!=p_rect.size; }
+ bool nan_equals(const Rect2& p_rect) const { return pos.nan_equals(p_rect.pos) && size == p_rect.size; }
+
inline Rect2 grow(real_t p_by) const {
Rect2 g=*this;