From 4bdcfe144333e5cb7725ddbb97ba8d769b47958e Mon Sep 17 00:00:00 2001 From: Raul Santos Date: Sat, 14 Jan 2023 03:14:20 +0100 Subject: [PATCH] Sync C# vectors with Core - Remove `Vector2.Lerp` overload that takes a weight parameter of type `Vector2`. - Remove `Vector3.Lerp` overload that takes a weight parameter of type `Vector3`. - Remove `Color.Lerp` overload that takes a weight parameter of type `Color`. - Remove `Angle` method from `Vector2i`. - Remove `AngleTo` method from `Vector2i`. - Remove `AngleToPoint` method from `Vector2i`. - Remove `Cross` method from `Vector2i`. - Remove `DistanceSquaredTo` method from `Vector2i` and `Vector3i`. - Remove `DistanceTo` method from `Vector2i` and `Vector3i`. - Remove `Dot` method from `Vector2i` and `Vector3i`. - Remove `PosMod` method from `Vector2i` and `Vector3i`. - Remove `Orthogonal` method from `Vector2i`. - Remove `&` operator from `Vector2i` and `Vector3i`. --- .../glue/GodotSharp/GodotSharp/Core/Color.cs | 18 --- .../GodotSharp/GodotSharp/Core/Vector2.cs | 18 --- .../GodotSharp/GodotSharp/Core/Vector2i.cs | 148 +----------------- .../GodotSharp/GodotSharp/Core/Vector3.cs | 17 -- .../GodotSharp/GodotSharp/Core/Vector3i.cs | 101 +----------- .../GodotSharp/GodotSharp/Core/Vector4i.cs | 32 ---- 6 files changed, 4 insertions(+), 330 deletions(-) diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/Color.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/Color.cs index 4075a878d2c..2effdecf40b 100644 --- a/modules/mono/glue/GodotSharp/GodotSharp/Core/Color.cs +++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/Color.cs @@ -358,24 +358,6 @@ namespace Godot ); } - /// - /// Returns the result of the linear interpolation between - /// this color and by color amount . - /// - /// The destination color for interpolation. - /// A color with components on the range of 0.0 to 1.0, representing the amount of interpolation. - /// The resulting color of the interpolation. - public readonly Color Lerp(Color to, Color weight) - { - return new Color - ( - (float)Mathf.Lerp(r, to.r, weight.r), - (float)Mathf.Lerp(g, to.g, weight.g), - (float)Mathf.Lerp(b, to.b, weight.b), - (float)Mathf.Lerp(a, to.a, weight.a) - ); - } - /// /// Returns the color converted to the sRGB color space. /// This method assumes the original color is in the linear color space. diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector2.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector2.cs index 1e88e18b3df..07cb34cadde 100644 --- a/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector2.cs +++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector2.cs @@ -389,24 +389,6 @@ namespace Godot ); } - /// - /// Returns the result of the linear interpolation between - /// this vector and by the vector amount . - /// - /// The destination vector for interpolation. - /// - /// A vector with components on the range of 0.0 to 1.0, representing the amount of interpolation. - /// - /// The resulting vector of the interpolation. - public readonly Vector2 Lerp(Vector2 to, Vector2 weight) - { - return new Vector2 - ( - Mathf.Lerp(x, to.x, weight.x), - Mathf.Lerp(y, to.y, weight.y) - ); - } - /// /// Returns the vector with a maximum length by limiting its length to . /// diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector2i.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector2i.cs index 91be548a214..740fedec668 100644 --- a/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector2i.cs +++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector2i.cs @@ -94,38 +94,6 @@ namespace Godot return new Vector2i(Mathf.Abs(x), Mathf.Abs(y)); } - /// - /// Returns this vector's angle with respect to the X axis, or (1, 0) vector, in radians. - /// - /// Equivalent to the result of when - /// called with the vector's and as parameters: Mathf.Atan2(v.y, v.x). - /// - /// The angle of this vector, in radians. - public readonly real_t Angle() - { - return Mathf.Atan2(y, x); - } - - /// - /// Returns the angle to the given vector, in radians. - /// - /// The other vector to compare this vector to. - /// The angle between the two vectors, in radians. - public readonly real_t AngleTo(Vector2i to) - { - return Mathf.Atan2(Cross(to), Dot(to)); - } - - /// - /// Returns the angle between the line connecting the two points and the X axis, in radians. - /// - /// The other vector to compare this vector to. - /// The angle between the two vectors, in radians. - public readonly real_t AngleToPoint(Vector2i to) - { - return Mathf.Atan2(to.y - y, to.x - x); - } - /// /// Returns the aspect ratio of this vector, the ratio of to . /// @@ -152,48 +120,6 @@ namespace Godot ); } - /// - /// Returns the cross product of this vector and . - /// - /// The other vector. - /// The cross product vector. - public readonly int Cross(Vector2i with) - { - return x * with.y - y * with.x; - } - - /// - /// Returns the squared distance between this vector and . - /// This method runs faster than , so prefer it if - /// you need to compare vectors or need the squared distance for some formula. - /// - /// The other vector to use. - /// The squared distance between the two vectors. - public readonly int DistanceSquaredTo(Vector2i to) - { - return (to - this).LengthSquared(); - } - - /// - /// Returns the distance between this vector and . - /// - /// The other vector to use. - /// The distance between the two vectors. - public readonly real_t DistanceTo(Vector2i to) - { - return (to - this).Length(); - } - - /// - /// Returns the dot product of this vector and . - /// - /// The other vector to use. - /// The dot product of the two vectors. - public readonly int Dot(Vector2i with) - { - return x * with.x + y * with.y; - } - /// /// Returns the length (magnitude) of this vector. /// @@ -241,38 +167,6 @@ namespace Godot return x < y ? Axis.X : Axis.Y; } - /// - /// Returns a vector composed of the of this vector's components - /// and . - /// - /// A value representing the divisor of the operation. - /// - /// A vector with each component by . - /// - public readonly Vector2i PosMod(int mod) - { - Vector2i v = this; - v.x = Mathf.PosMod(v.x, mod); - v.y = Mathf.PosMod(v.y, mod); - return v; - } - - /// - /// Returns a vector composed of the of this vector's components - /// and 's components. - /// - /// A vector representing the divisors of the operation. - /// - /// A vector with each component by 's components. - /// - public readonly Vector2i PosMod(Vector2i modv) - { - Vector2i v = this; - v.x = Mathf.PosMod(v.x, modv.x); - v.y = Mathf.PosMod(v.y, modv.y); - return v; - } - /// /// Returns a vector with each component set to one or negative one, depending /// on the signs of this vector's components, or zero if the component is zero, @@ -287,16 +181,6 @@ namespace Godot return v; } - /// - /// Returns a perpendicular vector rotated 90 degrees counter-clockwise - /// compared to the original, with the same length. - /// - /// The perpendicular vector. - public readonly Vector2i Orthogonal() - { - return new Vector2i(y, -x); - } - // Constants private static readonly Vector2i _zero = new Vector2i(0, 0); private static readonly Vector2i _one = new Vector2i(1, 1); @@ -467,7 +351,7 @@ namespace Godot /// 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 + /// Consider using instead /// if you want to handle negative numbers. /// /// @@ -490,7 +374,7 @@ namespace Godot /// 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 + /// Consider using instead /// if you want to handle negative numbers. /// /// @@ -508,34 +392,6 @@ 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; - vec.y &= and; - 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; - vec.y &= andv.y; - return vec; - } - /// /// Returns if the vectors are equal. /// diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector3.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector3.cs index 031464dcc6c..b017ba5853c 100644 --- a/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector3.cs +++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector3.cs @@ -395,23 +395,6 @@ namespace Godot ); } - /// - /// Returns the result of the linear interpolation between - /// this vector and by the vector amount . - /// - /// The destination vector for interpolation. - /// A vector with components on the range of 0.0 to 1.0, representing the amount of interpolation. - /// The resulting vector of the interpolation. - public readonly Vector3 Lerp(Vector3 to, Vector3 weight) - { - return new Vector3 - ( - Mathf.Lerp(x, to.x, weight.x), - Mathf.Lerp(y, to.y, weight.y), - Mathf.Lerp(z, to.z, weight.z) - ); - } - /// /// Returns the vector with a maximum length by limiting its length to . /// diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector3i.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector3i.cs index e631a9f443b..de0c6d27e73 100644 --- a/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector3i.cs +++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector3i.cs @@ -128,39 +128,6 @@ namespace Godot ); } - /// - /// Returns the squared distance between this vector and . - /// This method runs faster than , so prefer it if - /// you need to compare vectors or need the squared distance for some formula. - /// - /// The other vector to use. - /// The squared distance between the two vectors. - public readonly int DistanceSquaredTo(Vector3i to) - { - return (to - this).LengthSquared(); - } - - /// - /// Returns the distance between this vector and . - /// - /// - /// The other vector to use. - /// The distance between the two vectors. - public readonly real_t DistanceTo(Vector3i to) - { - return (to - this).Length(); - } - - /// - /// Returns the dot product of this vector and . - /// - /// The other vector to use. - /// The dot product of the two vectors. - public readonly int Dot(Vector3i with) - { - return x * with.x + y * with.y + z * with.z; - } - /// /// Returns the length (magnitude) of this vector. /// @@ -210,40 +177,6 @@ namespace Godot return x < y ? (x < z ? Axis.X : Axis.Z) : (y < z ? Axis.Y : Axis.Z); } - /// - /// Returns a vector composed of the of this vector's components - /// and . - /// - /// A value representing the divisor of the operation. - /// - /// A vector with each component by . - /// - public readonly Vector3i PosMod(int mod) - { - Vector3i v = this; - v.x = Mathf.PosMod(v.x, mod); - v.y = Mathf.PosMod(v.y, mod); - v.z = Mathf.PosMod(v.z, mod); - return v; - } - - /// - /// Returns a vector composed of the of this vector's components - /// and 's components. - /// - /// A vector representing the divisors of the operation. - /// - /// A vector with each component by 's components. - /// - public readonly Vector3i PosMod(Vector3i modv) - { - Vector3i v = this; - v.x = Mathf.PosMod(v.x, modv.x); - v.y = Mathf.PosMod(v.y, modv.y); - v.z = Mathf.PosMod(v.z, modv.z); - return v; - } - /// /// Returns a vector with each component set to one or negative one, depending /// on the signs of this vector's components, or zero if the component is zero, @@ -455,7 +388,7 @@ namespace Godot /// 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 + /// Consider using instead /// if you want to handle negative numbers. /// /// @@ -479,7 +412,7 @@ namespace Godot /// 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 + /// Consider using instead /// if you want to handle negative numbers. /// /// @@ -498,36 +431,6 @@ 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; - vec.y &= and; - vec.z &= and; - 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; - vec.y &= andv.y; - vec.z &= andv.z; - return vec; - } - /// /// Returns if the vectors are equal. /// diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector4i.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector4i.cs index 8146991fd7e..00ecc64856e 100644 --- a/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector4i.cs +++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector4i.cs @@ -432,38 +432,6 @@ 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 Vector4i operator &(Vector4i vec, int and) - { - vec.x &= and; - vec.y &= and; - vec.z &= and; - vec.w &= and; - 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 Vector4i operator &(Vector4i vec, Vector4i andv) - { - vec.x &= andv.x; - vec.y &= andv.y; - vec.z &= andv.z; - vec.w &= andv.w; - return vec; - } - /// /// Returns if the vectors are equal. ///