Add `IsFinite` to C# Variants

This commit is contained in:
Raul Santos 2023-01-13 17:57:52 +01:00
parent 3c9bf4bc21
commit f852004cf5
No known key found for this signature in database
GPG Key ID: B532473AE3A803E4
12 changed files with 112 additions and 1 deletions

View File

@ -494,7 +494,7 @@
<return type="bool" />
<param index="0" name="x" type="float" />
<description>
Returns whether [code]x[/code] is a finite value, i.e. it is not [constant @GDScript.NAN], positive infinity, or negative infinity.
Returns whether [param x] is a finite value, i.e. it is not [constant @GDScript.NAN], positive infinity, or negative infinity.
</description>
</method>
<method name="is_inf">

View File

@ -585,6 +585,16 @@ namespace Godot
return true;
}
/// <summary>
/// Returns <see langword="true"/> if this <see cref="AABB"/> is finite, by calling
/// <see cref="Mathf.IsFinite"/> on each component.
/// </summary>
/// <returns>Whether this vector is finite or not.</returns>
public readonly bool IsFinite()
{
return _position.IsFinite() && _size.IsFinite();
}
/// <summary>
/// Returns a larger <see cref="AABB"/> that contains this <see cref="AABB"/> and <paramref name="with"/>.
/// </summary>

View File

@ -709,6 +709,16 @@ namespace Godot
);
}
/// <summary>
/// Returns <see langword="true"/> if this basis is finite, by calling
/// <see cref="Mathf.IsFinite"/> on each component.
/// </summary>
/// <returns>Whether this vector is finite or not.</returns>
public readonly bool IsFinite()
{
return Row0.IsFinite() && Row1.IsFinite() && Row2.IsFinite();
}
internal readonly Basis Lerp(Basis to, real_t weight)
{
Basis b = this;

View File

@ -439,6 +439,17 @@ namespace Godot
return Abs(a - b) < tolerance;
}
/// <summary>
/// Returns whether <paramref name="s"/> is a finite value, i.e. it is not
/// <see cref="NaN"/>, positive infinite, or negative infinity.
/// </summary>
/// <param name="s">The value to check.</param>
/// <returns>A <see langword="bool"/> for whether or not the value is a finite value.</returns>
public static bool IsFinite(real_t s)
{
return real_t.IsFinite(s);
}
/// <summary>
/// Returns whether <paramref name="s"/> is an infinity value (either positive infinity or negative infinity).
/// </summary>

View File

@ -204,6 +204,16 @@ namespace Godot
return begin - (segment * dist);
}
/// <summary>
/// Returns <see langword="true"/> if this plane is finite, by calling
/// <see cref="Mathf.IsFinite"/> on each component.
/// </summary>
/// <returns>Whether this vector is finite or not.</returns>
public readonly bool IsFinite()
{
return _normal.IsFinite() && Mathf.IsFinite(D);
}
/// <summary>
/// Returns <see langword="true"/> if <paramref name="point"/> is located above the plane.
/// </summary>

View File

@ -339,6 +339,16 @@ namespace Godot
return new Quaternion(-x, -y, -z, w);
}
/// <summary>
/// Returns <see langword="true"/> if this quaternion is finite, by calling
/// <see cref="Mathf.IsFinite"/> on each component.
/// </summary>
/// <returns>Whether this vector is finite or not.</returns>
public readonly bool IsFinite()
{
return Mathf.IsFinite(x) && Mathf.IsFinite(y) && Mathf.IsFinite(z) && Mathf.IsFinite(w);
}
/// <summary>
/// Returns whether the quaternion is normalized or not.
/// </summary>

View File

@ -100,6 +100,16 @@ namespace Godot
return newRect;
}
/// <summary>
/// Returns <see langword="true"/> if this <see cref="Rect2"/> is finite, by calling
/// <see cref="Mathf.IsFinite"/> on each component.
/// </summary>
/// <returns>Whether this vector is finite or not.</returns>
public bool IsFinite()
{
return _position.IsFinite() && _size.IsFinite();
}
/// <summary>
/// Returns <see langword="true"/> if this <see cref="Rect2"/> completely encloses another one.
/// </summary>

View File

@ -270,6 +270,16 @@ namespace Godot
return inv;
}
/// <summary>
/// Returns <see langword="true"/> if this transform is finite, by calling
/// <see cref="Mathf.IsFinite"/> on each component.
/// </summary>
/// <returns>Whether this vector is finite or not.</returns>
public readonly bool IsFinite()
{
return x.IsFinite() && y.IsFinite() && origin.IsFinite();
}
/// <summary>
/// Returns the transform with the basis orthogonal (90 degrees),
/// and normalized axis vectors (scale of 1 or -1).

View File

@ -139,6 +139,16 @@ namespace Godot
return new Transform3D(basisTr, basisTr * -origin);
}
/// <summary>
/// Returns <see langword="true"/> if this transform is finite, by calling
/// <see cref="Mathf.IsFinite"/> on each component.
/// </summary>
/// <returns>Whether this vector is finite or not.</returns>
public readonly bool IsFinite()
{
return basis.IsFinite() && origin.IsFinite();
}
/// <summary>
/// Returns a copy of the transform rotated such that its
/// -Z axis (forward) points towards the <paramref name="target"/> position.

View File

@ -333,6 +333,16 @@ namespace Godot
return new Vector2(1 / x, 1 / y);
}
/// <summary>
/// Returns <see langword="true"/> if this vector is finite, by calling
/// <see cref="Mathf.IsFinite"/> on each component.
/// </summary>
/// <returns>Whether this vector is finite or not.</returns>
public readonly bool IsFinite()
{
return Mathf.IsFinite(x) && Mathf.IsFinite(y);
}
/// <summary>
/// Returns <see langword="true"/> if the vector is normalized, and <see langword="false"/> otherwise.
/// </summary>

View File

@ -330,6 +330,16 @@ namespace Godot
return new Vector3(1 / x, 1 / y, 1 / z);
}
/// <summary>
/// Returns <see langword="true"/> if this vector is finite, by calling
/// <see cref="Mathf.IsFinite"/> on each component.
/// </summary>
/// <returns>Whether this vector is finite or not.</returns>
public readonly bool IsFinite()
{
return Mathf.IsFinite(x) && Mathf.IsFinite(y) && Mathf.IsFinite(z);
}
/// <summary>
/// Returns <see langword="true"/> if the vector is normalized, and <see langword="false"/> otherwise.
/// </summary>

View File

@ -279,6 +279,16 @@ namespace Godot
return new Vector4(1 / x, 1 / y, 1 / z, 1 / w);
}
/// <summary>
/// Returns <see langword="true"/> if this vector is finite, by calling
/// <see cref="Mathf.IsFinite"/> on each component.
/// </summary>
/// <returns>Whether this vector is finite or not.</returns>
public readonly bool IsFinite()
{
return Mathf.IsFinite(x) && Mathf.IsFinite(y) && Mathf.IsFinite(z) && Mathf.IsFinite(w);
}
/// <summary>
/// Returns <see langword="true"/> if the vector is normalized, and <see langword="false"/> otherwise.
/// </summary>