From 813466b3c893ce2d47098268475818d1e4e485b4 Mon Sep 17 00:00:00 2001 From: Aaron Franke Date: Thu, 4 Nov 2021 10:58:20 -0500 Subject: Add documentation to operators for math types Co-authored-by: Raul Santos --- .../mono/glue/GodotSharp/GodotSharp/Core/AABB.cs | 33 +++- .../mono/glue/GodotSharp/GodotSharp/Core/Basis.cs | 41 ++++- .../mono/glue/GodotSharp/GodotSharp/Core/Color.cs | 172 +++++++++++++++++- .../mono/glue/GodotSharp/GodotSharp/Core/Colors.cs | 2 + .../glue/GodotSharp/GodotSharp/Core/Dictionary.cs | 6 +- .../mono/glue/GodotSharp/GodotSharp/Core/Plane.cs | 31 +++- .../glue/GodotSharp/GodotSharp/Core/Quaternion.cs | 100 ++++++++++- .../mono/glue/GodotSharp/GodotSharp/Core/Rect2.cs | 22 ++- .../mono/glue/GodotSharp/GodotSharp/Core/Rect2i.cs | 14 ++ .../GodotSharp/GodotSharp/Core/StringExtensions.cs | 2 +- .../glue/GodotSharp/GodotSharp/Core/Transform2D.cs | 39 ++++- .../glue/GodotSharp/GodotSharp/Core/Transform3D.cs | 39 ++++- .../glue/GodotSharp/GodotSharp/Core/Vector2.cs | 171 +++++++++++++++++- .../glue/GodotSharp/GodotSharp/Core/Vector2i.cs | 182 +++++++++++++++++-- .../glue/GodotSharp/GodotSharp/Core/Vector3.cs | 167 +++++++++++++++++- .../glue/GodotSharp/GodotSharp/Core/Vector3i.cs | 194 +++++++++++++++++++-- 16 files changed, 1131 insertions(+), 84 deletions(-) (limited to 'modules') diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/AABB.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/AABB.cs index 70a2cf5695..850ae7fc3b 100644 --- a/modules/mono/glue/GodotSharp/GodotSharp/Core/AABB.cs +++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/AABB.cs @@ -666,21 +666,40 @@ namespace Godot _size = new Vector3(width, height, depth); } + /// + /// Returns if the AABBs are exactly equal. + /// Note: Due to floating-point precision errors, consider using + /// instead, which is more reliable. + /// + /// The left AABB. + /// The right AABB. + /// Whether or not the AABBs are exactly equal. public static bool operator ==(AABB left, AABB right) { return left.Equals(right); } + /// + /// Returns if the AABBs are not equal. + /// Note: Due to floating-point precision errors, consider using + /// instead, which is more reliable. + /// + /// The left AABB. + /// The right AABB. + /// Whether or not the AABBs are not equal. public static bool operator !=(AABB left, AABB right) { return !left.Equals(right); } /// - /// Returns if this AABB and are equal. + /// Returns if the AABB is exactly equal + /// to the given object (). + /// Note: Due to floating-point precision errors, consider using + /// instead, which is more reliable. /// - /// The other object to compare. - /// Whether or not the AABB structure and the other object are equal. + /// The object to compare with. + /// Whether or not the AABB and the object are equal. public override bool Equals(object obj) { if (obj is AABB) @@ -692,10 +711,12 @@ namespace Godot } /// - /// Returns if this AABB and are equal + /// Returns if the AABBs are exactly equal. + /// Note: Due to floating-point precision errors, consider using + /// instead, which is more reliable. /// - /// The other AABB to compare. - /// Whether or not the AABBs are equal. + /// The other AABB. + /// Whether or not the AABBs are exactly equal. public bool Equals(AABB other) { return _position == other._position && _size == other._size; diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/Basis.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/Basis.cs index 0fb1df6c2f..bfbf1a097e 100644 --- a/modules/mono/glue/GodotSharp/GodotSharp/Core/Basis.cs +++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/Basis.cs @@ -827,6 +827,14 @@ namespace Godot Row2 = new Vector3(xz, yz, zz); } + /// + /// Composes these two basis matrices by multiplying them + /// together. This has the effect of transforming the second basis + /// (the child) by the first basis (the parent). + /// + /// The parent basis. + /// The child basis. + /// The composed basis. public static Basis operator *(Basis left, Basis right) { return new Basis @@ -837,21 +845,40 @@ namespace Godot ); } + /// + /// Returns if the basis matrices are exactly + /// equal. Note: Due to floating-point precision errors, consider using + /// instead, which is more reliable. + /// + /// The left basis. + /// The right basis. + /// Whether or not the basis matrices are exactly equal. public static bool operator ==(Basis left, Basis right) { return left.Equals(right); } + /// + /// Returns if the basis matrices are not equal. + /// Note: Due to floating-point precision errors, consider using + /// instead, which is more reliable. + /// + /// The left basis. + /// The right basis. + /// Whether or not the basis matrices are not equal. public static bool operator !=(Basis left, Basis right) { return !left.Equals(right); } /// - /// Returns if this basis and are equal. + /// Returns if the is + /// exactly equal to the given object (). + /// Note: Due to floating-point precision errors, consider using + /// instead, which is more reliable. /// - /// The other object to compare. - /// Whether or not the basis and the other object are equal. + /// The object to compare with. + /// Whether or not the basis matrix and the object are exactly equal. public override bool Equals(object obj) { if (obj is Basis) @@ -863,10 +890,12 @@ namespace Godot } /// - /// Returns if this basis and are equal + /// Returns if the basis matrices are exactly + /// equal. Note: Due to floating-point precision errors, consider using + /// instead, which is more reliable. /// - /// The other basis to compare. - /// Whether or not the bases are equal. + /// The other basis. + /// Whether or not the basis matrices are exactly equal. public bool Equals(Basis other) { return Row0.Equals(other.Row0) && Row1.Equals(other.Row1) && Row2.Equals(other.Row2); diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/Color.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/Color.cs index 2a869bc335..fc9d40ca48 100644 --- a/modules/mono/glue/GodotSharp/GodotSharp/Core/Color.cs +++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/Color.cs @@ -878,6 +878,13 @@ namespace Godot return true; } + /// + /// Adds each component of the + /// with the components of the given . + /// + /// The left color. + /// The right color. + /// The added color. public static Color operator +(Color left, Color right) { left.r += right.r; @@ -887,6 +894,13 @@ namespace Godot return left; } + /// + /// Subtracts each component of the + /// by the components of the given . + /// + /// The left color. + /// The right color. + /// The subtracted color. public static Color operator -(Color left, Color right) { left.r -= right.r; @@ -896,11 +910,25 @@ namespace Godot return left; } + /// + /// Inverts the given color. This is equivalent to + /// Colors.White - c or + /// new Color(1 - c.r, 1 - c.g, 1 - c.b, 1 - c.a). + /// + /// The color to invert. + /// The inverted color public static Color operator -(Color color) { return Colors.White - color; } + /// + /// Multiplies each component of the + /// by the given . + /// + /// The color to multiply. + /// The value to multiply by. + /// The multiplied color. public static Color operator *(Color color, float scale) { color.r *= scale; @@ -910,6 +938,13 @@ namespace Godot return color; } + /// + /// Multiplies each component of the + /// by the given . + /// + /// The value to multiply by. + /// The color to multiply. + /// The multiplied color. public static Color operator *(float scale, Color color) { color.r *= scale; @@ -919,6 +954,13 @@ namespace Godot return color; } + /// + /// Multiplies each component of the + /// by the components of the given . + /// + /// The left color. + /// The right color. + /// The multiplied color. public static Color operator *(Color left, Color right) { left.r *= right.r; @@ -928,6 +970,13 @@ namespace Godot return left; } + /// + /// Divides each component of the + /// by the given . + /// + /// The dividend vector. + /// The divisor value. + /// The divided color. public static Color operator /(Color color, float scale) { color.r /= scale; @@ -937,6 +986,13 @@ namespace Godot return color; } + /// + /// Divides each component of the + /// by the components of the given . + /// + /// The dividend color. + /// The divisor color. + /// The divided color. public static Color operator /(Color left, Color right) { left.r /= right.r; @@ -946,23 +1002,51 @@ namespace Godot return left; } + /// + /// Returns if the colors are exactly equal. + /// Note: Due to floating-point precision errors, consider using + /// instead, which is more reliable. + /// + /// The left color. + /// The right color. + /// Whether or not the colors are equal. public static bool operator ==(Color left, Color right) { return left.Equals(right); } + /// + /// Returns if the colors are not equal. + /// Note: Due to floating-point precision errors, consider using + /// instead, which is more reliable. + /// + /// The left color. + /// The right color. + /// Whether or not the colors are equal. public static bool operator !=(Color left, Color right) { return !left.Equals(right); } + /// + /// Compares two s by first checking if + /// the red value of the color is less than + /// the red value of the color. + /// If the red values are exactly equal, then it repeats this check + /// with the green values of the two colors, then with the blue values, + /// and then with the alpha value. + /// This operator is useful for sorting colors. + /// + /// The left color. + /// The right color. + /// Whether or not the left is less than the right. public static bool operator <(Color left, Color right) { - if (Mathf.IsEqualApprox(left.r, right.r)) + if (left.r == right.r) { - if (Mathf.IsEqualApprox(left.g, right.g)) + if (left.g == right.g) { - if (Mathf.IsEqualApprox(left.b, right.b)) + if (left.b == right.b) { return left.a < right.a; } @@ -973,13 +1057,25 @@ namespace Godot return left.r < right.r; } + /// + /// Compares two s by first checking if + /// the red value of the color is greater than + /// the red value of the color. + /// If the red values are exactly equal, then it repeats this check + /// with the green values of the two colors, then with the blue values, + /// and then with the alpha value. + /// This operator is useful for sorting colors. + /// + /// The left color. + /// The right color. + /// Whether or not the left is greater than the right. public static bool operator >(Color left, Color right) { - if (Mathf.IsEqualApprox(left.r, right.r)) + if (left.r == right.r) { - if (Mathf.IsEqualApprox(left.g, right.g)) + if (left.g == right.g) { - if (Mathf.IsEqualApprox(left.b, right.b)) + if (left.b == right.b) { return left.a > right.a; } @@ -990,6 +1086,64 @@ namespace Godot return left.r > right.r; } + /// + /// Compares two s by first checking if + /// the red value of the color is less than + /// or equal to the red value of the color. + /// If the red values are exactly equal, then it repeats this check + /// with the green values of the two colors, then with the blue values, + /// and then with the alpha value. + /// This operator is useful for sorting colors. + /// + /// The left color. + /// The right color. + /// Whether or not the left is less than or equal to the right. + public static bool operator <=(Color left, Color right) + { + if (left.r == right.r) + { + if (left.g == right.g) + { + if (left.b == right.b) + { + return left.a <= right.a; + } + return left.b < right.b; + } + return left.g < right.g; + } + return left.r < right.r; + } + + /// + /// Compares two s by first checking if + /// the red value of the color is greater than + /// or equal to the red value of the color. + /// If the red values are exactly equal, then it repeats this check + /// with the green values of the two colors, then with the blue values, + /// and then with the alpha value. + /// This operator is useful for sorting colors. + /// + /// The left color. + /// The right color. + /// Whether or not the left is greater than or equal to the right. + public static bool operator >=(Color left, Color right) + { + if (left.r == right.r) + { + if (left.g == right.g) + { + if (left.b == right.b) + { + return left.a >= right.a; + } + return left.b > right.b; + } + return left.g > right.g; + } + return left.r > right.r; + } + /// /// Returns if this color and are equal. /// @@ -1006,9 +1160,11 @@ namespace Godot } /// - /// Returns if this color and are equal + /// Returns if the colors are exactly equal. + /// Note: Due to floating-point precision errors, consider using + /// instead, which is more reliable. /// - /// The other color to compare. + /// The other color. /// Whether or not the colors are equal. public bool Equals(Color other) { diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/Colors.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/Colors.cs index d64c8b563e..68c821b447 100644 --- a/modules/mono/glue/GodotSharp/GodotSharp/Core/Colors.cs +++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/Colors.cs @@ -158,6 +158,7 @@ namespace Godot {"YELLOWGREEN", new Color(0.60f, 0.80f, 0.20f)}, }; +#pragma warning disable CS1591 // Disable warning: "Missing XML comment for publicly visible type or member" public static Color AliceBlue { get { return namedColors["ALICEBLUE"]; } } public static Color AntiqueWhite { get { return namedColors["ANTIQUEWHITE"]; } } public static Color Aqua { get { return namedColors["AQUA"]; } } @@ -304,5 +305,6 @@ namespace Godot public static Color WhiteSmoke { get { return namedColors["WHITESMOKE"]; } } public static Color Yellow { get { return namedColors["YELLOW"]; } } public static Color YellowGreen { get { return namedColors["YELLOWGREEN"]; } } +#pragma warning restore CS1591 } } diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/Dictionary.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/Dictionary.cs index 2dfe304aaa..75240b0c09 100644 --- a/modules/mono/glue/GodotSharp/GodotSharp/Core/Dictionary.cs +++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/Dictionary.cs @@ -314,13 +314,13 @@ namespace Godot.Collections internal static extern int godot_icall_Dictionary_Count(IntPtr ptr); [MethodImpl(MethodImplOptions.InternalCall)] - internal extern static int godot_icall_Dictionary_KeyValuePairs(IntPtr ptr, out IntPtr keys, out IntPtr values); + internal static extern int godot_icall_Dictionary_KeyValuePairs(IntPtr ptr, out IntPtr keys, out IntPtr values); [MethodImpl(MethodImplOptions.InternalCall)] - internal extern static void godot_icall_Dictionary_KeyValuePairAt(IntPtr ptr, int index, out object key, out object value); + internal static extern void godot_icall_Dictionary_KeyValuePairAt(IntPtr ptr, int index, out object key, out object value); [MethodImpl(MethodImplOptions.InternalCall)] - internal extern static void godot_icall_Dictionary_Add(IntPtr ptr, object key, object value); + internal static extern void godot_icall_Dictionary_Add(IntPtr ptr, object key, object value); [MethodImpl(MethodImplOptions.InternalCall)] internal static extern void godot_icall_Dictionary_Clear(IntPtr ptr); diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/Plane.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/Plane.cs index 66f7b745f7..63af1c5892 100644 --- a/modules/mono/glue/GodotSharp/GodotSharp/Core/Plane.cs +++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/Plane.cs @@ -309,16 +309,43 @@ namespace Godot D = _normal.Dot(v1); } + /// + /// Returns the negative value of the . + /// This is the same as writing new Plane(-p.Normal, -p.D). + /// This operation flips the direction of the normal vector and + /// also flips the distance value, resulting in a Plane that is + /// in the same place, but facing the opposite direction. + /// + /// The plane to negate/flip. + /// The negated/flipped plane. public static Plane operator -(Plane plane) { return new Plane(-plane._normal, -plane.D); } + /// + /// Returns if the + /// s are exactly equal. + /// Note: Due to floating-point precision errors, consider using + /// instead, which is more reliable. + /// + /// The left rect. + /// The right rect. + /// Whether or not the planes are exactly equal. public static bool operator ==(Plane left, Plane right) { return left.Equals(right); } + /// + /// Returns if the + /// s are not equal. + /// Note: Due to floating-point precision errors, consider using + /// instead, which is more reliable. + /// + /// The left rect. + /// The right rect. + /// Whether or not the planes are not equal. public static bool operator !=(Plane left, Plane right) { return !left.Equals(right); @@ -328,7 +355,7 @@ namespace Godot /// Returns if this plane and are equal. /// /// The other object to compare. - /// Whether or not the plane and the other object are equal. + /// Whether or not the plane and the other object are exactly equal. public override bool Equals(object obj) { if (obj is Plane) @@ -343,7 +370,7 @@ namespace Godot /// Returns if this plane and are equal. /// /// The other plane to compare. - /// Whether or not the planes are equal. + /// Whether or not the planes are exactly equal. public bool Equals(Plane other) { return _normal == other._normal && D == other.D; diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/Quaternion.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/Quaternion.cs index c18f818ed2..dfb8e87bce 100644 --- a/modules/mono/glue/GodotSharp/GodotSharp/Core/Quaternion.cs +++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/Quaternion.cs @@ -446,6 +446,14 @@ namespace Godot } } + /// + /// Composes these two quaternions by multiplying them together. + /// This has the effect of rotating the second quaternion + /// (the child) by the first quaternion (the parent). + /// + /// The parent quaternion. + /// The child quaternion. + /// The composed quaternion. public static Quaternion operator *(Quaternion left, Quaternion right) { return new Quaternion @@ -457,21 +465,55 @@ namespace Godot ); } + /// + /// Adds each component of the left + /// to the right . This operation is not + /// meaningful on its own, but it can be used as a part of a + /// larger expression, such as approximating an intermediate + /// rotation between two nearby rotations. + /// + /// The left quaternion to add. + /// The right quaternion to add. + /// The added quaternion. public static Quaternion operator +(Quaternion left, Quaternion right) { return new Quaternion(left.x + right.x, left.y + right.y, left.z + right.z, left.w + right.w); } + /// + /// Subtracts each component of the left + /// by the right . This operation is not + /// meaningful on its own, but it can be used as a part of a + /// larger expression. + /// + /// The left quaternion to subtract. + /// The right quaternion to subtract. + /// The subtracted quaternion. public static Quaternion operator -(Quaternion left, Quaternion right) { return new Quaternion(left.x - right.x, left.y - right.y, left.z - right.z, left.w - right.w); } - public static Quaternion operator -(Quaternion left) + /// + /// Returns the negative value of the . + /// This is the same as writing + /// new Quaternion(-q.x, -q.y, -q.z, -q.w). This operation + /// results in a quaternion that represents the same rotation. + /// + /// The quaternion to negate. + /// The negated quaternion. + public static Quaternion operator -(Quaternion quat) { - return new Quaternion(-left.x, -left.y, -left.z, -left.w); + return new Quaternion(-quat.x, -quat.y, -quat.z, -quat.w); } + /// + /// Rotates (multiplies) the + /// by the given . + /// + /// The quaternion to rotate by. + /// The vector to rotate. + /// The rotated vector. public static Vector3 operator *(Quaternion quat, Vector3 vec) { #if DEBUG @@ -485,31 +527,81 @@ namespace Godot return vec + (((uv * quat.w) + u.Cross(uv)) * 2); } + /// + /// Inversely rotates (multiplies) the + /// by the given . + /// + /// The vector to rotate. + /// The quaternion to rotate by. + /// The inversely rotated vector. public static Vector3 operator *(Vector3 vec, Quaternion quat) { return quat.Inverse() * vec; } + /// + /// Multiplies each component of the + /// by the given . This operation is not + /// meaningful on its own, but it can be used as a part of a + /// larger expression. + /// + /// The quaternion to multiply. + /// The value to multiply by. + /// The multiplied quaternion. public static Quaternion operator *(Quaternion left, real_t right) { return new Quaternion(left.x * right, left.y * right, left.z * right, left.w * right); } + /// + /// Multiplies each component of the + /// by the given . This operation is not + /// meaningful on its own, but it can be used as a part of a + /// larger expression. + /// + /// The value to multiply by. + /// The quaternion to multiply. + /// The multiplied quaternion. public static Quaternion operator *(real_t left, Quaternion right) { return new Quaternion(right.x * left, right.y * left, right.z * left, right.w * left); } + /// + /// Divides each component of the + /// by the given . This operation is not + /// meaningful on its own, but it can be used as a part of a + /// larger expression. + /// + /// The quaternion to divide. + /// The value to divide by. + /// The divided quaternion. public static Quaternion operator /(Quaternion left, real_t right) { return left * (1.0f / right); } + /// + /// Returns if the quaternions are exactly equal. + /// Note: Due to floating-point precision errors, consider using + /// instead, which is more reliable. + /// + /// The left quaternion. + /// The right quaternion. + /// Whether or not the quaternions are exactly equal. public static bool operator ==(Quaternion left, Quaternion right) { return left.Equals(right); } + /// + /// Returns if the quaternions are not equal. + /// Note: Due to floating-point precision errors, consider using + /// instead, which is more reliable. + /// + /// The left quaternion. + /// The right quaternion. + /// Whether or not the quaternions are not equal. public static bool operator !=(Quaternion left, Quaternion right) { return !left.Equals(right); @@ -519,7 +611,7 @@ namespace Godot /// Returns if this quaternion and are equal. /// /// The other object to compare. - /// Whether or not the quaternion and the other object are equal. + /// Whether or not the quaternion and the other object are exactly equal. public override bool Equals(object obj) { if (obj is Quaternion) @@ -534,7 +626,7 @@ namespace Godot /// Returns if this quaternion and are equal. /// /// The other quaternion to compare. - /// Whether or not the quaternions are equal. + /// Whether or not the quaternions are exactly equal. public bool Equals(Quaternion other) { return x == other.x && y == other.y && z == other.z && w == other.w; diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/Rect2.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/Rect2.cs index af94484577..ec16920fed 100644 --- a/modules/mono/glue/GodotSharp/GodotSharp/Core/Rect2.cs +++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/Rect2.cs @@ -396,11 +396,29 @@ namespace Godot _size = new Vector2(width, height); } + /// + /// Returns if the + /// s are exactly equal. + /// Note: Due to floating-point precision errors, consider using + /// instead, which is more reliable. + /// + /// The left rect. + /// The right rect. + /// Whether or not the rects are exactly equal. public static bool operator ==(Rect2 left, Rect2 right) { return left.Equals(right); } + /// + /// Returns if the + /// s are not equal. + /// Note: Due to floating-point precision errors, consider using + /// instead, which is more reliable. + /// + /// The left rect. + /// The right rect. + /// Whether or not the rects are not equal. public static bool operator !=(Rect2 left, Rect2 right) { return !left.Equals(right); @@ -410,7 +428,7 @@ namespace Godot /// Returns if this rect and are equal. /// /// The other object to compare. - /// Whether or not the rect and the other object are equal. + /// Whether or not the rect and the other object are exactly equal. public override bool Equals(object obj) { if (obj is Rect2) @@ -425,7 +443,7 @@ namespace Godot /// Returns if this rect and are equal. /// /// The other rect to compare. - /// Whether or not the rects are equal. + /// Whether or not the rects are exactly equal. public bool Equals(Rect2 other) { return _position.Equals(other._position) && _size.Equals(other._size); diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/Rect2i.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/Rect2i.cs index 03f406a910..5d53b8330e 100644 --- a/modules/mono/glue/GodotSharp/GodotSharp/Core/Rect2i.cs +++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/Rect2i.cs @@ -377,11 +377,25 @@ namespace Godot _size = new Vector2i(width, height); } + /// + /// Returns if the + /// s are exactly equal. + /// + /// The left rect. + /// The right rect. + /// Whether or not the rects are equal. public static bool operator ==(Rect2i left, Rect2i right) { return left.Equals(right); } + /// + /// Returns if the + /// s are not equal. + /// + /// The left rect. + /// The right rect. + /// Whether or not the rects are not equal. public static bool operator !=(Rect2i left, Rect2i right) { return !left.Equals(right); diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/StringExtensions.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/StringExtensions.cs index 6b3eb09581..d9ee684c5b 100644 --- a/modules/mono/glue/GodotSharp/GodotSharp/Core/StringExtensions.cs +++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/StringExtensions.cs @@ -1345,7 +1345,7 @@ namespace Godot } [MethodImpl(MethodImplOptions.InternalCall)] - internal extern static string godot_icall_String_simplify_path(string str); + internal static extern string godot_icall_String_simplify_path(string str); /// /// Split the string by a divisor string, return an array of the substrings. diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/Transform2D.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/Transform2D.cs index c82c5f4588..6f1d9574a8 100644 --- a/modules/mono/glue/GodotSharp/GodotSharp/Core/Transform2D.cs +++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/Transform2D.cs @@ -447,6 +447,14 @@ namespace Godot this.origin = origin; } + /// + /// Composes these two transformation matrices by multiplying them + /// together. This has the effect of transforming the second transform + /// (the child) by the first transform (the parent). + /// + /// The parent transform. + /// The child transform. + /// The composed transform. public static Transform2D operator *(Transform2D left, Transform2D right) { left.origin = left * right.origin; @@ -554,31 +562,52 @@ namespace Godot return newArray; } + /// + /// Returns if the transforms are exactly equal. + /// Note: Due to floating-point precision errors, consider using + /// instead, which is more reliable. + /// + /// The left transform. + /// The right transform. + /// Whether or not the transforms are exactly equal. public static bool operator ==(Transform2D left, Transform2D right) { return left.Equals(right); } + /// + /// Returns if the transforms are not equal. + /// Note: Due to floating-point precision errors, consider using + /// instead, which is more reliable. + /// + /// The left transform. + /// The right transform. + /// Whether or not the transforms are not equal. public static bool operator !=(Transform2D left, Transform2D right) { return !left.Equals(right); } /// - /// Returns if this transform and are equal. + /// Returns if the transform is exactly equal + /// to the given object (). + /// Note: Due to floating-point precision errors, consider using + /// instead, which is more reliable. /// - /// The other object to compare. - /// Whether or not the transform and the other object are equal. + /// The object to compare with. + /// Whether or not the transform and the object are exactly equal. public override bool Equals(object obj) { return obj is Transform2D transform2D && Equals(transform2D); } /// - /// Returns if this transform and are equal. + /// Returns if the transforms are exactly equal. + /// Note: Due to floating-point precision errors, consider using + /// instead, which is more reliable. /// /// The other transform to compare. - /// Whether or not the matrices are equal. + /// Whether or not the matrices are exactly equal. public bool Equals(Transform2D other) { return x.Equals(other.x) && y.Equals(other.y) && origin.Equals(other.origin); diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/Transform3D.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/Transform3D.cs index 7176cd60dc..4bb8308c12 100644 --- a/modules/mono/glue/GodotSharp/GodotSharp/Core/Transform3D.cs +++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/Transform3D.cs @@ -352,6 +352,14 @@ namespace Godot this.origin = origin; } + /// + /// Composes these two transformation matrices by multiplying them + /// together. This has the effect of transforming the second transform + /// (the child) by the first transform (the parent). + /// + /// The parent transform. + /// The child transform. + /// The composed transform. public static Transform3D operator *(Transform3D left, Transform3D right) { left.origin = left.Xform(right.origin); @@ -359,21 +367,40 @@ namespace Godot return left; } + /// + /// Returns if the transforms are exactly equal. + /// Note: Due to floating-point precision errors, consider using + /// instead, which is more reliable. + /// + /// The left transform. + /// The right transform. + /// Whether or not the transforms are exactly equal. public static bool operator ==(Transform3D left, Transform3D right) { return left.Equals(right); } + /// + /// Returns if the transforms are not equal. + /// Note: Due to floating-point precision errors, consider using + /// instead, which is more reliable. + /// + /// The left transform. + /// The right transform. + /// Whether or not the transforms are not equal. public static bool operator !=(Transform3D left, Transform3D right) { return !left.Equals(right); } /// - /// Returns if this transform and are equal. + /// Returns if the transform is exactly equal + /// to the given object (). + /// Note: Due to floating-point precision errors, consider using + /// instead, which is more reliable. /// - /// The other object to compare. - /// Whether or not the transform and the other object are equal. + /// The object to compare with. + /// Whether or not the transform and the object are exactly equal. public override bool Equals(object obj) { if (obj is Transform3D) @@ -385,10 +412,12 @@ namespace Godot } /// - /// Returns if this transform and are equal. + /// Returns if the transforms are exactly equal. + /// Note: Due to floating-point precision errors, consider using + /// instead, which is more reliable. /// /// The other transform to compare. - /// Whether or not the matrices are equal. + /// Whether or not the matrices are exactly equal. public bool Equals(Transform3D other) { return basis.Equals(other.basis) && origin.Equals(other.origin); diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector2.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector2.cs index fe70d71cce..0c3331900a 100644 --- a/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector2.cs +++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector2.cs @@ -642,6 +642,13 @@ namespace Godot return new Vector2(Mathf.Cos(angle), Mathf.Sin(angle)); } + /// + /// Adds each component of the + /// with the components of the given . + /// + /// The left vector. + /// The right vector. + /// The added vector. public static Vector2 operator +(Vector2 left, Vector2 right) { left.x += right.x; @@ -649,6 +656,13 @@ namespace Godot return left; } + /// + /// Subtracts each component of the + /// by the components of the given . + /// + /// The left vector. + /// The right vector. + /// The subtracted vector. public static Vector2 operator -(Vector2 left, Vector2 right) { left.x -= right.x; @@ -656,6 +670,15 @@ namespace Godot return left; } + /// + /// Returns the negative value of the . + /// This is the same as writing new Vector2(-v.x, -v.y). + /// This operation flips the direction of the vector while + /// keeping the same magnitude. + /// With floats, the number zero can be either positive or negative. + /// + /// The vector to negate/flip. + /// The negated/flipped vector. public static Vector2 operator -(Vector2 vec) { vec.x = -vec.x; @@ -663,6 +686,13 @@ namespace Godot return vec; } + /// + /// Multiplies each component of the + /// by the given . + /// + /// The vector to multiply. + /// The scale to multiply by. + /// The multiplied vector. public static Vector2 operator *(Vector2 vec, real_t scale) { vec.x *= scale; @@ -670,6 +700,13 @@ namespace Godot return vec; } + /// + /// Multiplies each component of the + /// by the given . + /// + /// The scale to multiply by. + /// The vector to multiply. + /// The multiplied vector. public static Vector2 operator *(real_t scale, Vector2 vec) { vec.x *= scale; @@ -677,6 +714,13 @@ namespace Godot return vec; } + /// + /// Multiplies each component of the + /// by the components of the given . + /// + /// The left vector. + /// The right vector. + /// The multiplied vector. public static Vector2 operator *(Vector2 left, Vector2 right) { left.x *= right.x; @@ -684,6 +728,13 @@ namespace Godot return left; } + /// + /// Multiplies each component of the + /// by the given . + /// + /// The dividend vector. + /// The divisor value. + /// The divided vector. public static Vector2 operator /(Vector2 vec, real_t divisor) { vec.x /= divisor; @@ -691,6 +742,13 @@ namespace Godot return vec; } + /// + /// Divides each component of the + /// by the components of the given . + /// + /// The dividend vector. + /// The divisor vector. + /// The divided vector. public static Vector2 operator /(Vector2 vec, Vector2 divisorv) { vec.x /= divisorv.x; @@ -698,6 +756,22 @@ namespace Godot return vec; } + /// + /// Gets the remainder of each component of the + /// with the components of the given . + /// This operation uses truncated division, which is often not desired + /// as it does not work well with negative numbers. + /// Consider using instead + /// if you want to handle negative numbers. + /// + /// + /// + /// GD.Print(new Vector2(10, -20) % 7); // Prints "(3, -6)" + /// + /// + /// The dividend vector. + /// The divisor value. + /// The remainder vector. public static Vector2 operator %(Vector2 vec, real_t divisor) { vec.x %= divisor; @@ -705,6 +779,22 @@ namespace Godot return vec; } + /// + /// Gets the remainder of each component of the + /// with the components of the given . + /// This operation uses truncated division, which is often not desired + /// as it does not work well with negative numbers. + /// Consider using instead + /// if you want to handle negative numbers. + /// + /// + /// + /// GD.Print(new Vector2(10, -20) % new Vector2(7, 8)); // Prints "(3, -4)" + /// + /// + /// The dividend vector. + /// The divisor vector. + /// The remainder vector. public static Vector2 operator %(Vector2 vec, Vector2 divisorv) { vec.x %= divisorv.x; @@ -712,16 +802,43 @@ namespace Godot return vec; } + /// + /// Returns if the vectors are exactly equal. + /// Note: Due to floating-point precision errors, consider using + /// instead, which is more reliable. + /// + /// The left vector. + /// The right vector. + /// Whether or not the vectors are exactly equal. public static bool operator ==(Vector2 left, Vector2 right) { return left.Equals(right); } + /// + /// Returns if the vectors are not equal. + /// Note: Due to floating-point precision errors, consider using + /// instead, which is more reliable. + /// + /// The left vector. + /// The right vector. + /// Whether or not the vectors are not equal. public static bool operator !=(Vector2 left, Vector2 right) { return !left.Equals(right); } + /// + /// Compares two vectors by first checking if + /// the X value of the vector is less than + /// the X value of the vector. + /// If the X values are exactly equal, then it repeats this check + /// with the Y values of the two vectors. + /// This operator is useful for sorting vectors. + /// + /// The left vector. + /// The right vector. + /// Whether or not the left is less than the right. public static bool operator <(Vector2 left, Vector2 right) { if (left.x == right.x) @@ -731,6 +848,17 @@ namespace Godot return left.x < right.x; } + /// + /// Compares two vectors by first checking if + /// the X value of the vector is greater than + /// the X value of the vector. + /// If the X values are exactly equal, then it repeats this check + /// with the Y values of the two vectors. + /// This operator is useful for sorting vectors. + /// + /// The left vector. + /// The right vector. + /// Whether or not the left is greater than the right. public static bool operator >(Vector2 left, Vector2 right) { if (left.x == right.x) @@ -740,29 +868,54 @@ namespace Godot return left.x > right.x; } + /// + /// Compares two vectors by first checking if + /// the X value of the vector is less than + /// or equal to the X value of the vector. + /// If the X values are exactly equal, then it repeats this check + /// with the Y values of the two vectors. + /// This operator is useful for sorting vectors. + /// + /// The left vector. + /// The right vector. + /// Whether or not the left is less than or equal to the right. public static bool operator <=(Vector2 left, Vector2 right) { if (left.x == right.x) { return left.y <= right.y; } - return left.x <= right.x; + return left.x < right.x; } + /// + /// Compares two vectors by first checking if + /// the X value of the vector is greater than + /// or equal to the X value of the vector. + /// If the X values are exactly equal, then it repeats this check + /// with the Y values of the two vectors. + /// This operator is useful for sorting vectors. + /// + /// The left vector. + /// The right vector. + /// Whether or not the left is greater than or equal to the right. public static bool operator >=(Vector2 left, Vector2 right) { if (left.x == right.x) { return left.y >= right.y; } - return left.x >= right.x; + return left.x > right.x; } /// - /// Returns if this vector and are equal. + /// Returns if the vector is exactly equal + /// to the given object (). + /// Note: Due to floating-point precision errors, consider using + /// instead, which is more reliable. /// - /// The other object to compare. - /// Whether or not the vector and the other object are equal. + /// The object to compare with. + /// Whether or not the vector and the object are equal. public override bool Equals(object obj) { if (obj is Vector2) @@ -773,10 +926,12 @@ namespace Godot } /// - /// Returns if this vector and are equal. + /// Returns if the vectors are exactly equal. + /// Note: Due to floating-point precision errors, consider using + /// instead, which is more reliable. /// - /// The other vector to compare. - /// Whether or not the vectors are equal. + /// The other vector. + /// Whether or not the vectors are exactly equal. public bool Equals(Vector2 other) { return x == other.x && y == other.y; diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector2i.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector2i.cs index ca4531d885..6cac16d53b 100644 --- a/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector2i.cs +++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector2i.cs @@ -366,6 +366,13 @@ namespace Godot this.y = Mathf.RoundToInt(v.y); } + /// + /// Adds each component of the + /// with the components of the given . + /// + /// The left vector. + /// The right vector. + /// The added vector. public static Vector2i operator +(Vector2i left, Vector2i right) { left.x += right.x; @@ -373,6 +380,13 @@ namespace Godot return left; } + /// + /// Subtracts each component of the + /// by the components of the given . + /// + /// The left vector. + /// The right vector. + /// The subtracted vector. public static Vector2i operator -(Vector2i left, Vector2i right) { left.x -= right.x; @@ -380,6 +394,14 @@ namespace Godot return left; } + /// + /// Returns the negative value of the . + /// This is the same as writing new Vector2i(-v.x, -v.y). + /// This operation flips the direction of the vector while + /// keeping the same magnitude. + /// + /// The vector to negate/flip. + /// The negated/flipped vector. public static Vector2i operator -(Vector2i vec) { vec.x = -vec.x; @@ -387,6 +409,13 @@ namespace Godot return vec; } + /// + /// Multiplies each component of the + /// by the given . + /// + /// The vector to multiply. + /// The scale to multiply by. + /// The multiplied vector. public static Vector2i operator *(Vector2i vec, int scale) { vec.x *= scale; @@ -394,6 +423,13 @@ namespace Godot return vec; } + /// + /// Multiplies each component of the + /// by the given . + /// + /// The scale to multiply by. + /// The vector to multiply. + /// The multiplied vector. public static Vector2i operator *(int scale, Vector2i vec) { vec.x *= scale; @@ -401,6 +437,13 @@ namespace Godot return vec; } + /// + /// Multiplies each component of the + /// by the components of the given . + /// + /// The left vector. + /// The right vector. + /// The multiplied vector. public static Vector2i operator *(Vector2i left, Vector2i right) { left.x *= right.x; @@ -408,6 +451,13 @@ namespace Godot return left; } + /// + /// Multiplies each component of the + /// by the given . + /// + /// The dividend vector. + /// The divisor value. + /// The divided vector. public static Vector2i operator /(Vector2i vec, int divisor) { vec.x /= divisor; @@ -415,6 +465,13 @@ namespace Godot return vec; } + /// + /// Divides each component of the + /// by the components of the given . + /// + /// The dividend vector. + /// The divisor vector. + /// The divided vector. public static Vector2i operator /(Vector2i vec, Vector2i divisorv) { vec.x /= divisorv.x; @@ -422,6 +479,22 @@ namespace Godot return vec; } + /// + /// Gets the remainder of each component of the + /// with the components of the given . + /// This operation uses truncated division, which is often not desired + /// as it does not work well with negative numbers. + /// Consider using instead + /// if you want to handle negative numbers. + /// + /// + /// + /// GD.Print(new Vector2i(10, -20) % 7); // Prints "(3, -6)" + /// + /// + /// The dividend vector. + /// The divisor value. + /// The remainder vector. public static Vector2i operator %(Vector2i vec, int divisor) { vec.x %= divisor; @@ -429,6 +502,22 @@ namespace Godot return vec; } + /// + /// Gets the remainder of each component of the + /// with the components of the given . + /// This operation uses truncated division, which is often not desired + /// as it does not work well with negative numbers. + /// Consider using instead + /// if you want to handle negative numbers. + /// + /// + /// + /// GD.Print(new Vector2i(10, -20) % new Vector2i(7, 8)); // Prints "(3, -4)" + /// + /// + /// The dividend vector. + /// The divisor vector. + /// The remainder vector. public static Vector2i operator %(Vector2i vec, Vector2i divisorv) { vec.x %= divisorv.x; @@ -436,6 +525,13 @@ namespace Godot return vec; } + /// + /// Performs a bitwise AND operation with this + /// and the given . + /// + /// The vector to AND with. + /// The integer to AND with. + /// The result of the bitwise AND. public static Vector2i operator &(Vector2i vec, int and) { vec.x &= and; @@ -443,6 +539,13 @@ namespace Godot return vec; } + /// + /// Performs a bitwise AND operation with this + /// and the given . + /// + /// The left vector to AND with. + /// The right vector to AND with. + /// The result of the bitwise AND. public static Vector2i operator &(Vector2i vec, Vector2i andv) { vec.x &= andv.x; @@ -450,50 +553,106 @@ namespace Godot return vec; } + /// + /// Returns if the vectors are equal. + /// + /// The left vector. + /// The right vector. + /// Whether or not the vectors are equal. public static bool operator ==(Vector2i left, Vector2i right) { return left.Equals(right); } + /// + /// Returns if the vectors are not equal. + /// + /// The left vector. + /// The right vector. + /// Whether or not the vectors are not equal. public static bool operator !=(Vector2i left, Vector2i right) { return !left.Equals(right); } + /// + /// Compares two vectors by first checking if + /// the X value of the vector is less than + /// the X value of the vector. + /// If the X values are exactly equal, then it repeats this check + /// with the Y values of the two vectors. + /// This operator is useful for sorting vectors. + /// + /// The left vector. + /// The right vector. + /// Whether or not the left is less than the right. public static bool operator <(Vector2i left, Vector2i right) { - if (left.x.Equals(right.x)) + if (left.x == right.x) { return left.y < right.y; } return left.x < right.x; } + /// + /// Compares two vectors by first checking if + /// the X value of the vector is greater than + /// the X value of the vector. + /// If the X values are exactly equal, then it repeats this check + /// with the Y values of the two vectors. + /// This operator is useful for sorting vectors. + /// + /// The left vector. + /// The right vector. + /// Whether or not the left is greater than the right. public static bool operator >(Vector2i left, Vector2i right) { - if (left.x.Equals(right.x)) + if (left.x == right.x) { return left.y > right.y; } return left.x > right.x; } + /// + /// Compares two vectors by first checking if + /// the X value of the vector is less than + /// or equal to the X value of the vector. + /// If the X values are exactly equal, then it repeats this check + /// with the Y values of the two vectors. + /// This operator is useful for sorting vectors. + /// + /// The left vector. + /// The right vector. + /// Whether or not the left is less than or equal to the right. public static bool operator <=(Vector2i left, Vector2i right) { - if (left.x.Equals(right.x)) + if (left.x == right.x) { return left.y <= right.y; } - return left.x <= right.x; + return left.x < right.x; } + /// + /// Compares two vectors by first checking if + /// the X value of the vector is greater than + /// or equal to the X value of the vector. + /// If the X values are exactly equal, then it repeats this check + /// with the Y values of the two vectors. + /// This operator is useful for sorting vectors. + /// + /// The left vector. + /// The right vector. + /// Whether or not the left is greater than or equal to the right. public static bool operator >=(Vector2i left, Vector2i right) { - if (left.x.Equals(right.x)) + if (left.x == right.x) { return left.y >= right.y; } - return left.x >= right.x; + return left.x > right.x; } /// @@ -515,10 +674,11 @@ namespace Godot } /// - /// Returns if this vector and are equal. + /// Returns if the vector is equal + /// to the given object (). /// - /// The other object to compare. - /// Whether or not the vector and the other object are equal. + /// The object to compare with. + /// Whether or not the vector and the object are equal. public override bool Equals(object obj) { if (obj is Vector2i) @@ -530,9 +690,9 @@ namespace Godot } /// - /// Returns if this vector and are equal. + /// Returns if the vectors are equal. /// - /// The other vector to compare. + /// The other vector. /// Whether or not the vectors are equal. public bool Equals(Vector2i other) { diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector3.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector3.cs index 01e3a71bcb..63d9be0a6d 100644 --- a/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector3.cs +++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector3.cs @@ -699,6 +699,13 @@ namespace Godot z = v.z; } + /// + /// Adds each component of the + /// with the components of the given . + /// + /// The left vector. + /// The right vector. + /// The added vector. public static Vector3 operator +(Vector3 left, Vector3 right) { left.x += right.x; @@ -707,6 +714,13 @@ namespace Godot return left; } + /// + /// Subtracts each component of the + /// by the components of the given . + /// + /// The left vector. + /// The right vector. + /// The subtracted vector. public static Vector3 operator -(Vector3 left, Vector3 right) { left.x -= right.x; @@ -715,6 +729,15 @@ namespace Godot return left; } + /// + /// Returns the negative value of the . + /// This is the same as writing new Vector3(-v.x, -v.y, -v.z). + /// This operation flips the direction of the vector while + /// keeping the same magnitude. + /// With floats, the number zero can be either positive or negative. + /// + /// The vector to negate/flip. + /// The negated/flipped vector. public static Vector3 operator -(Vector3 vec) { vec.x = -vec.x; @@ -723,6 +746,13 @@ namespace Godot return vec; } + /// + /// Multiplies each component of the + /// by the given . + /// + /// The vector to multiply. + /// The scale to multiply by. + /// The multiplied vector. public static Vector3 operator *(Vector3 vec, real_t scale) { vec.x *= scale; @@ -731,6 +761,13 @@ namespace Godot return vec; } + /// + /// Multiplies each component of the + /// by the given . + /// + /// The scale to multiply by. + /// The vector to multiply. + /// The multiplied vector. public static Vector3 operator *(real_t scale, Vector3 vec) { vec.x *= scale; @@ -739,6 +776,13 @@ namespace Godot return vec; } + /// + /// Multiplies each component of the + /// by the components of the given . + /// + /// The left vector. + /// The right vector. + /// The multiplied vector. public static Vector3 operator *(Vector3 left, Vector3 right) { left.x *= right.x; @@ -747,6 +791,13 @@ namespace Godot return left; } + /// + /// Divides each component of the + /// by the given . + /// + /// The dividend vector. + /// The divisor value. + /// The divided vector. public static Vector3 operator /(Vector3 vec, real_t divisor) { vec.x /= divisor; @@ -755,6 +806,13 @@ namespace Godot return vec; } + /// + /// Divides each component of the + /// by the components of the given . + /// + /// The dividend vector. + /// The divisor vector. + /// The divided vector. public static Vector3 operator /(Vector3 vec, Vector3 divisorv) { vec.x /= divisorv.x; @@ -763,6 +821,22 @@ namespace Godot return vec; } + /// + /// Gets the remainder of each component of the + /// with the components of the given . + /// This operation uses truncated division, which is often not desired + /// as it does not work well with negative numbers. + /// Consider using instead + /// if you want to handle negative numbers. + /// + /// + /// + /// GD.Print(new Vector3(10, -20, 30) % 7); // Prints "(3, -6, 2)" + /// + /// + /// The dividend vector. + /// The divisor value. + /// The remainder vector. public static Vector3 operator %(Vector3 vec, real_t divisor) { vec.x %= divisor; @@ -771,6 +845,22 @@ namespace Godot return vec; } + /// + /// Gets the remainder of each component of the + /// with the components of the given . + /// This operation uses truncated division, which is often not desired + /// as it does not work well with negative numbers. + /// Consider using instead + /// if you want to handle negative numbers. + /// + /// + /// + /// GD.Print(new Vector3(10, -20, 30) % new Vector3(7, 8, 9)); // Prints "(3, -4, 3)" + /// + /// + /// The dividend vector. + /// The divisor vector. + /// The remainder vector. public static Vector3 operator %(Vector3 vec, Vector3 divisorv) { vec.x %= divisorv.x; @@ -779,16 +869,43 @@ namespace Godot return vec; } + /// + /// Returns if the vectors are exactly equal. + /// Note: Due to floating-point precision errors, consider using + /// instead, which is more reliable. + /// + /// The left vector. + /// The right vector. + /// Whether or not the vectors are exactly equal. public static bool operator ==(Vector3 left, Vector3 right) { return left.Equals(right); } + /// + /// Returns if the vectors are not equal. + /// Note: Due to floating-point precision errors, consider using + /// instead, which is more reliable. + /// + /// The left vector. + /// The right vector. + /// Whether or not the vectors are not equal. public static bool operator !=(Vector3 left, Vector3 right) { return !left.Equals(right); } + /// + /// Compares two vectors by first checking if + /// the X value of the vector is less than + /// the X value of the vector. + /// If the X values are exactly equal, then it repeats this check + /// with the Y values of the two vectors, and then with the Z values. + /// This operator is useful for sorting vectors. + /// + /// The left vector. + /// The right vector. + /// Whether or not the left is less than the right. public static bool operator <(Vector3 left, Vector3 right) { if (left.x == right.x) @@ -802,6 +919,17 @@ namespace Godot return left.x < right.x; } + /// + /// Compares two vectors by first checking if + /// the X value of the vector is greater than + /// the X value of the vector. + /// If the X values are exactly equal, then it repeats this check + /// with the Y values of the two vectors, and then with the Z values. + /// This operator is useful for sorting vectors. + /// + /// The left vector. + /// The right vector. + /// Whether or not the left is greater than the right. public static bool operator >(Vector3 left, Vector3 right) { if (left.x == right.x) @@ -815,6 +943,17 @@ namespace Godot return left.x > right.x; } + /// + /// Compares two vectors by first checking if + /// the X value of the vector is less than + /// or equal to the X value of the vector. + /// If the X values are exactly equal, then it repeats this check + /// with the Y values of the two vectors, and then with the Z values. + /// This operator is useful for sorting vectors. + /// + /// The left vector. + /// The right vector. + /// Whether or not the left is less than or equal to the right. public static bool operator <=(Vector3 left, Vector3 right) { if (left.x == right.x) @@ -828,6 +967,17 @@ namespace Godot return left.x < right.x; } + /// + /// Compares two vectors by first checking if + /// the X value of the vector is greater than + /// or equal to the X value of the vector. + /// If the X values are exactly equal, then it repeats this check + /// with the Y values of the two vectors, and then with the Z values. + /// This operator is useful for sorting vectors. + /// + /// The left vector. + /// The right vector. + /// Whether or not the left is greater than or equal to the right. public static bool operator >=(Vector3 left, Vector3 right) { if (left.x == right.x) @@ -842,10 +992,13 @@ namespace Godot } /// - /// Returns if this vector and are equal. + /// Returns if the vector is exactly equal + /// to the given object (). + /// Note: Due to floating-point precision errors, consider using + /// instead, which is more reliable. /// - /// The other object to compare. - /// Whether or not the vector and the other object are equal. + /// The object to compare with. + /// Whether or not the vector and the object are equal. public override bool Equals(object obj) { if (obj is Vector3) @@ -857,10 +1010,12 @@ namespace Godot } /// - /// Returns if this vector and are equal + /// Returns if the vectors are exactly equal. + /// Note: Due to floating-point precision errors, consider using + /// instead, which is more reliable. /// - /// The other vector to compare. - /// Whether or not the vectors are equal. + /// The other vector. + /// Whether or not the vectors are exactly equal. public bool Equals(Vector3 other) { return x == other.x && y == other.y && z == other.z; diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector3i.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector3i.cs index 2a7771cdfc..474876fc91 100644 --- a/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector3i.cs +++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector3i.cs @@ -347,6 +347,13 @@ namespace Godot this.z = Mathf.RoundToInt(v.z); } + /// + /// Adds each component of the + /// with the components of the given . + /// + /// The left vector. + /// The right vector. + /// The added vector. public static Vector3i operator +(Vector3i left, Vector3i right) { left.x += right.x; @@ -355,6 +362,13 @@ namespace Godot return left; } + /// + /// Subtracts each component of the + /// by the components of the given . + /// + /// The left vector. + /// The right vector. + /// The subtracted vector. public static Vector3i operator -(Vector3i left, Vector3i right) { left.x -= right.x; @@ -363,6 +377,14 @@ namespace Godot return left; } + /// + /// Returns the negative value of the . + /// This is the same as writing new Vector3i(-v.x, -v.y, -v.z). + /// This operation flips the direction of the vector while + /// keeping the same magnitude. + /// + /// The vector to negate/flip. + /// The negated/flipped vector. public static Vector3i operator -(Vector3i vec) { vec.x = -vec.x; @@ -371,6 +393,13 @@ namespace Godot return vec; } + /// + /// Multiplies each component of the + /// by the given . + /// + /// The vector to multiply. + /// The scale to multiply by. + /// The multiplied vector. public static Vector3i operator *(Vector3i vec, int scale) { vec.x *= scale; @@ -379,6 +408,13 @@ namespace Godot return vec; } + /// + /// Multiplies each component of the + /// by the given . + /// + /// The scale to multiply by. + /// The vector to multiply. + /// The multiplied vector. public static Vector3i operator *(int scale, Vector3i vec) { vec.x *= scale; @@ -387,6 +423,13 @@ namespace Godot return vec; } + /// + /// Multiplies each component of the + /// by the components of the given . + /// + /// The left vector. + /// The right vector. + /// The multiplied vector. public static Vector3i operator *(Vector3i left, Vector3i right) { left.x *= right.x; @@ -395,6 +438,13 @@ namespace Godot return left; } + /// + /// Multiplies each component of the + /// by the given . + /// + /// The dividend vector. + /// The divisor value. + /// The divided vector. public static Vector3i operator /(Vector3i vec, int divisor) { vec.x /= divisor; @@ -403,6 +453,13 @@ namespace Godot return vec; } + /// + /// Divides each component of the + /// by the components of the given . + /// + /// The dividend vector. + /// The divisor vector. + /// The divided vector. public static Vector3i operator /(Vector3i vec, Vector3i divisorv) { vec.x /= divisorv.x; @@ -411,6 +468,22 @@ namespace Godot return vec; } + /// + /// Gets the remainder of each component of the + /// with the components of the given . + /// This operation uses truncated division, which is often not desired + /// as it does not work well with negative numbers. + /// Consider using instead + /// if you want to handle negative numbers. + /// + /// + /// + /// GD.Print(new Vector3i(10, -20, 30) % 7); // Prints "(3, -6, 2)" + /// + /// + /// The dividend vector. + /// The divisor value. + /// The remainder vector. public static Vector3i operator %(Vector3i vec, int divisor) { vec.x %= divisor; @@ -419,6 +492,22 @@ namespace Godot return vec; } + /// + /// Gets the remainder of each component of the + /// with the components of the given . + /// This operation uses truncated division, which is often not desired + /// as it does not work well with negative numbers. + /// Consider using instead + /// if you want to handle negative numbers. + /// + /// + /// + /// GD.Print(new Vector3i(10, -20, 30) % new Vector3i(7, 8, 9)); // Prints "(3, -4, 3)" + /// + /// + /// The dividend vector. + /// The divisor vector. + /// The remainder vector. public static Vector3i operator %(Vector3i vec, Vector3i divisorv) { vec.x %= divisorv.x; @@ -427,6 +516,13 @@ namespace Godot return vec; } + /// + /// Performs a bitwise AND operation with this + /// and the given . + /// + /// The vector to AND with. + /// The integer to AND with. + /// The result of the bitwise AND. public static Vector3i operator &(Vector3i vec, int and) { vec.x &= and; @@ -435,6 +531,13 @@ namespace Godot return vec; } + /// + /// Performs a bitwise AND operation with this + /// and the given . + /// + /// The left vector to AND with. + /// The right vector to AND with. + /// The result of the bitwise AND. public static Vector3i operator &(Vector3i vec, Vector3i andv) { vec.x &= andv.x; @@ -443,65 +546,121 @@ namespace Godot return vec; } + /// + /// Returns if the vectors are equal. + /// + /// The left vector. + /// The right vector. + /// Whether or not the vectors are equal. public static bool operator ==(Vector3i left, Vector3i right) { return left.Equals(right); } + /// + /// Returns if the vectors are not equal. + /// + /// The left vector. + /// The right vector. + /// Whether or not the vectors are not equal. public static bool operator !=(Vector3i left, Vector3i right) { return !left.Equals(right); } + /// + /// Compares two vectors by first checking if + /// the X value of the vector is less than + /// the X value of the vector. + /// If the X values are exactly equal, then it repeats this check + /// with the Y values of the two vectors, and then with the Z values. + /// This operator is useful for sorting vectors. + /// + /// The left vector. + /// The right vector. + /// Whether or not the left is less than the right. public static bool operator <(Vector3i left, Vector3i right) { if (left.x == right.x) { if (left.y == right.y) + { return left.z < right.z; - else - return left.y < right.y; + } + return left.y < right.y; } - return left.x < right.x; } + /// + /// Compares two vectors by first checking if + /// the X value of the vector is greater than + /// the X value of the vector. + /// If the X values are exactly equal, then it repeats this check + /// with the Y values of the two vectors, and then with the Z values. + /// This operator is useful for sorting vectors. + /// + /// The left vector. + /// The right vector. + /// Whether or not the left is greater than the right. public static bool operator >(Vector3i left, Vector3i right) { if (left.x == right.x) { if (left.y == right.y) + { return left.z > right.z; - else - return left.y > right.y; + } + return left.y > right.y; } - return left.x > right.x; } + /// + /// Compares two vectors by first checking if + /// the X value of the vector is less than + /// or equal to the X value of the vector. + /// If the X values are exactly equal, then it repeats this check + /// with the Y values of the two vectors, and then with the Z values. + /// This operator is useful for sorting vectors. + /// + /// The left vector. + /// The right vector. + /// Whether or not the left is less than or equal to the right. public static bool operator <=(Vector3i left, Vector3i right) { if (left.x == right.x) { if (left.y == right.y) + { return left.z <= right.z; - else - return left.y < right.y; + } + return left.y < right.y; } - return left.x < right.x; } + /// + /// Compares two vectors by first checking if + /// the X value of the vector is greater than + /// or equal to the X value of the vector. + /// If the X values are exactly equal, then it repeats this check + /// with the Y values of the two vectors, and then with the Z values. + /// This operator is useful for sorting vectors. + /// + /// The left vector. + /// The right vector. + /// Whether or not the left is greater than or equal to the right. public static bool operator >=(Vector3i left, Vector3i right) { if (left.x == right.x) { if (left.y == right.y) + { return left.z >= right.z; - else - return left.y > right.y; + } + return left.y > right.y; } - return left.x > right.x; } @@ -524,10 +683,11 @@ namespace Godot } /// - /// Returns if this vector and are equal. + /// Returns if the vector is equal + /// to the given object (). /// - /// The other object to compare. - /// Whether or not the vector and the other object are equal. + /// The object to compare with. + /// Whether or not the vector and the object are equal. public override bool Equals(object obj) { if (obj is Vector3i) @@ -539,9 +699,9 @@ namespace Godot } /// - /// Returns if this vector and are equal + /// Returns if the vectors are equal. /// - /// The other vector to compare. + /// The other vector. /// Whether or not the vectors are equal. public bool Equals(Vector3i other) { -- cgit v1.2.3