diff options
-rw-r--r-- | doc/classes/@GlobalScope.xml | 2 | ||||
-rw-r--r-- | modules/mono/glue/GodotSharp/GodotSharp/Core/Mathf.cs | 5 | ||||
-rw-r--r-- | modules/mono/glue/GodotSharp/GodotSharp/Core/Vector2.cs | 12 | ||||
-rw-r--r-- | modules/mono/glue/GodotSharp/GodotSharp/Core/Vector3.cs | 12 | ||||
-rw-r--r-- | modules/mono/glue/GodotSharp/GodotSharp/Core/Vector4.cs | 12 |
5 files changed, 40 insertions, 3 deletions
diff --git a/doc/classes/@GlobalScope.xml b/doc/classes/@GlobalScope.xml index 41836650cd..61bc8f666a 100644 --- a/doc/classes/@GlobalScope.xml +++ b/doc/classes/@GlobalScope.xml @@ -529,7 +529,7 @@ <return type="bool" /> <param index="0" name="x" type="float" /> <description> - Returns [code]true[/code] if [param x] is zero or almost zero. + Returns [code]true[/code] if [param x] is zero or almost zero. The comparison is done using a tolerance calculation with a small internal epsilon. This function is faster than using [method is_equal_approx] with one value as zero. </description> </method> diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/Mathf.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/Mathf.cs index 3f9e986f62..cef31a7679 100644 --- a/modules/mono/glue/GodotSharp/GodotSharp/Core/Mathf.cs +++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/Mathf.cs @@ -460,10 +460,11 @@ namespace Godot } /// <summary> - /// Returns <see langword="true"/> if <paramref name="s"/> is approximately zero. + /// Returns <see langword="true"/> if <paramref name="s"/> is zero or almost zero. /// The comparison is done using a tolerance calculation with <see cref="Epsilon"/>. /// - /// This method is faster than using <see cref="IsEqualApprox(real_t, real_t)"/> with one value as zero. + /// This method is faster than using <see cref="IsEqualApprox(real_t, real_t)"/> with + /// one value as zero. /// </summary> /// <param name="s">The value to check.</param> /// <returns>A <see langword="bool"/> for whether or not the value is nearly zero.</returns> diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector2.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector2.cs index 4c60080ee9..0760f1668f 100644 --- a/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector2.cs +++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector2.cs @@ -989,6 +989,18 @@ namespace Godot } /// <summary> + /// Returns <see langword="true"/> if this vector's values are approximately zero, + /// by running <see cref="Mathf.IsZeroApprox(real_t)"/> on each component. + /// This method is faster than using <see cref="IsEqualApprox"/> with one value + /// as a zero vector. + /// </summary> + /// <returns>Whether or not the vector is approximately zero.</returns> + public readonly bool IsZeroApprox() + { + return Mathf.IsZeroApprox(x) && Mathf.IsZeroApprox(y); + } + + /// <summary> /// Serves as the hash function for <see cref="Vector2"/>. /// </summary> /// <returns>A hash code for this vector.</returns> diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector3.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector3.cs index fefdee33a5..e000e3994d 100644 --- a/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector3.cs +++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector3.cs @@ -1060,6 +1060,18 @@ namespace Godot } /// <summary> + /// Returns <see langword="true"/> if this vector's values are approximately zero, + /// by running <see cref="Mathf.IsZeroApprox(real_t)"/> on each component. + /// This method is faster than using <see cref="IsEqualApprox"/> with one value + /// as a zero vector. + /// </summary> + /// <returns>Whether or not the vector is approximately zero.</returns> + public readonly bool IsZeroApprox() + { + return Mathf.IsZeroApprox(x) && Mathf.IsZeroApprox(y) && Mathf.IsZeroApprox(z); + } + + /// <summary> /// Serves as the hash function for <see cref="Vector3"/>. /// </summary> /// <returns>A hash code for this vector.</returns> diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector4.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector4.cs index 3191e8adc0..dc2380c083 100644 --- a/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector4.cs +++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector4.cs @@ -857,6 +857,18 @@ namespace Godot } /// <summary> + /// Returns <see langword="true"/> if this vector's values are approximately zero, + /// by running <see cref="Mathf.IsZeroApprox(real_t)"/> on each component. + /// This method is faster than using <see cref="IsEqualApprox"/> with one value + /// as a zero vector. + /// </summary> + /// <returns>Whether or not the vector is approximately zero.</returns> + public readonly bool IsZeroApprox() + { + return Mathf.IsZeroApprox(x) && Mathf.IsZeroApprox(y) && Mathf.IsZeroApprox(z) && Mathf.IsZeroApprox(w); + } + + /// <summary> /// Serves as the hash function for <see cref="Vector4"/>. /// </summary> /// <returns>A hash code for this vector.</returns> |