You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-12-06 17:25:19 +00: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:
@@ -176,6 +176,17 @@ Vector3 Vector3::cubic_interpolate(const Vector3& p_b,const Vector3& p_pre_a, co
|
||||
return out;
|
||||
}
|
||||
# endif
|
||||
bool Vector3::nan_equals(const Vector3& p_v) const {
|
||||
return (x == p_v.x && y == p_v.y && z == p_v.z) ||
|
||||
(x == p_v.x && y == p_v.y && isnan(z) && isnan(p_v.z)) ||
|
||||
(x == p_v.x && isnan(y) && isnan(p_v.y) && z == p_v.z) ||
|
||||
(isnan(x) && isnan(p_v.x) && y == p_v.y && z == p_v.z) ||
|
||||
(x == p_v.x && isnan(y) && isnan(p_v.y) && isnan(z) && isnan(p_v.z)) ||
|
||||
(isnan(x) && isnan(p_v.x) && y == p_v.y && isnan(z) && isnan(p_v.z)) ||
|
||||
(isnan(x) && isnan(p_v.x) && isnan(y) && isnan(p_v.y) && z == p_v.z) ||
|
||||
(isnan(x) && isnan(p_v.x) && isnan(y) && isnan(p_v.y) && isnan(z) && isnan(p_v.z));
|
||||
}
|
||||
|
||||
Vector3::operator String() const {
|
||||
|
||||
return (rtos(x)+", "+rtos(y)+", "+rtos(z));
|
||||
|
||||
Reference in New Issue
Block a user