From 29894e9c1a8ea420e48d5ce2f9c8a7b5be34bdec Mon Sep 17 00:00:00 2001 From: Raul Santos Date: Thu, 4 Aug 2022 02:44:31 +0200 Subject: [PATCH] Remove copy constructors in C# structs --- .../GodotSharp/GodotSharp/Core/Projection.cs | 12 ------- .../GodotSharp/GodotSharp/Core/Quaternion.cs | 9 ------ .../GodotSharp/GodotSharp/Core/Vector2.cs | 10 ------ .../GodotSharp/GodotSharp/Core/Vector2i.cs | 26 +++------------ .../GodotSharp/GodotSharp/Core/Vector3.cs | 11 ------- .../GodotSharp/GodotSharp/Core/Vector3i.cs | 29 +++-------------- .../GodotSharp/GodotSharp/Core/Vector4.cs | 12 ------- .../GodotSharp/GodotSharp/Core/Vector4i.cs | 32 ++++--------------- 8 files changed, 15 insertions(+), 126 deletions(-) diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/Projection.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/Projection.cs index df16fe57181..e9cc0164d42 100644 --- a/modules/mono/glue/GodotSharp/GodotSharp/Core/Projection.cs +++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/Projection.cs @@ -73,18 +73,6 @@ namespace Godot this.w = w; } - /// - /// Constructs a new from an existing . - /// - /// The existing . - public Projection(Projection proj) - { - x = proj.x; - y = proj.y; - z = proj.z; - w = proj.w; - } - /// /// Constructs a new from a . /// diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/Quaternion.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/Quaternion.cs index 90e4e3b41e4..74c2525a308 100644 --- a/modules/mono/glue/GodotSharp/GodotSharp/Core/Quaternion.cs +++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/Quaternion.cs @@ -357,15 +357,6 @@ namespace Godot this.w = w; } - /// - /// Constructs a from the given . - /// - /// The existing quaternion. - public Quaternion(Quaternion q) - { - this = q; - } - /// /// Constructs a from the given . /// diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector2.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector2.cs index e47efacf697..04c2ea7eb97 100644 --- a/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector2.cs +++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector2.cs @@ -638,16 +638,6 @@ namespace Godot this.y = y; } - /// - /// Constructs a new from an existing . - /// - /// The existing . - public Vector2(Vector2 v) - { - x = v.x; - y = v.y; - } - /// /// Creates a unit Vector2 rotated to the given angle. This is equivalent to doing /// Vector2(Mathf.Cos(angle), Mathf.Sin(angle)) or Vector2.Right.Rotated(angle). diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector2i.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector2i.cs index 84790404d75..a8f42972d7f 100644 --- a/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector2i.cs +++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector2i.cs @@ -349,27 +349,6 @@ namespace Godot this.y = y; } - /// - /// Constructs a new from an existing . - /// - /// The existing . - public Vector2i(Vector2i vi) - { - this.x = vi.x; - this.y = vi.y; - } - - /// - /// Constructs a new from an existing - /// by rounding the components via . - /// - /// The to convert. - public Vector2i(Vector2 v) - { - this.x = Mathf.RoundToInt(v.x); - this.y = Mathf.RoundToInt(v.y); - } - /// /// Adds each component of the /// with the components of the given . @@ -674,7 +653,10 @@ namespace Godot /// The vector to convert. public static explicit operator Vector2i(Vector2 value) { - return new Vector2i(value); + return new Vector2i( + Mathf.RoundToInt(value.x), + Mathf.RoundToInt(value.y) + ); } /// diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector3.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector3.cs index e796d2f20fd..5804c172b15 100644 --- a/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector3.cs +++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector3.cs @@ -691,17 +691,6 @@ namespace Godot this.z = z; } - /// - /// Constructs a new from an existing . - /// - /// The existing . - public Vector3(Vector3 v) - { - x = v.x; - y = v.y; - z = v.z; - } - /// /// Adds each component of the /// with the components of the given . diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector3i.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector3i.cs index 897e14ae886..eb46f36e7c7 100644 --- a/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector3i.cs +++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector3i.cs @@ -329,29 +329,6 @@ namespace Godot this.z = z; } - /// - /// Constructs a new from an existing . - /// - /// The existing . - public Vector3i(Vector3i vi) - { - this.x = vi.x; - this.y = vi.y; - this.z = vi.z; - } - - /// - /// Constructs a new from an existing - /// by rounding the components via . - /// - /// The to convert. - public Vector3i(Vector3 v) - { - this.x = Mathf.RoundToInt(v.x); - this.y = Mathf.RoundToInt(v.y); - this.z = Mathf.RoundToInt(v.z); - } - /// /// Adds each component of the /// with the components of the given . @@ -684,7 +661,11 @@ namespace Godot /// The vector to convert. public static explicit operator Vector3i(Vector3 value) { - return new Vector3i(value); + return new Vector3i( + Mathf.RoundToInt(value.x), + Mathf.RoundToInt(value.y), + Mathf.RoundToInt(value.z) + ); } /// diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector4.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector4.cs index f60033078c4..20a24616ce3 100644 --- a/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector4.cs +++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector4.cs @@ -476,18 +476,6 @@ namespace Godot this.w = w; } - /// - /// Constructs a new from an existing . - /// - /// The existing . - public Vector4(Vector4 v) - { - x = v.x; - y = v.y; - z = v.z; - w = v.w; - } - /// /// Adds each component of the /// with the components of the given . diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector4i.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector4i.cs index 2802c1bb06b..11c2b7234b6 100644 --- a/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector4i.cs +++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector4i.cs @@ -257,31 +257,6 @@ namespace Godot this.w = w; } - /// - /// Constructs a new from an existing . - /// - /// The existing . - public Vector4i(Vector4i vi) - { - this.x = vi.x; - this.y = vi.y; - this.z = vi.z; - this.w = vi.w; - } - - /// - /// Constructs a new from an existing - /// by rounding the components via . - /// - /// The to convert. - public Vector4i(Vector4 v) - { - this.x = Mathf.RoundToInt(v.x); - this.y = Mathf.RoundToInt(v.y); - this.z = Mathf.RoundToInt(v.z); - this.w = Mathf.RoundToInt(v.w); - } - /// /// Adds each component of the /// with the components of the given . @@ -638,7 +613,12 @@ namespace Godot /// The vector to convert. public static explicit operator Vector4i(Vector4 value) { - return new Vector4i(value); + return new Vector4i( + Mathf.RoundToInt(value.x), + Mathf.RoundToInt(value.y), + Mathf.RoundToInt(value.z), + Mathf.RoundToInt(value.w) + ); } ///