mirror of
https://github.com/godotengine/godot.git
synced 2026-01-03 18:11:19 +03:00
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
This commit is contained in:
@@ -157,6 +157,13 @@ bool Vector2::operator!=(const Vector2& p_vec2) const {
|
||||
|
||||
return x!=p_vec2.x || y!=p_vec2.y;
|
||||
}
|
||||
bool Vector2::nan_equals(const Vector2& p_vec2) const {
|
||||
|
||||
return (x==p_vec2.x && y==p_vec2.y) ||
|
||||
(x==p_vec2.x && isnan(y) && isnan(p_vec2.y)) ||
|
||||
(isnan(x) && isnan(p_vec2.x) && y == p_vec2.y);
|
||||
}
|
||||
|
||||
Vector2 Vector2::floor() const {
|
||||
|
||||
return Vector2( Math::floor(x), Math::floor(y) );
|
||||
|
||||
Reference in New Issue
Block a user