From 4baa38c0ccd849573293f2e9fb3577e21673ff1d Mon Sep 17 00:00:00 2001 From: Wojtek Figat Date: Tue, 11 Feb 2025 00:32:20 +0100 Subject: [PATCH] Add explicit cast to in vector in C# api --- Source/Engine/Core/Math/Vector2.cs | 10 ++++++++++ Source/Engine/Core/Math/Vector3.cs | 14 ++++++++++++-- Source/Engine/Core/Math/Vector4.cs | 14 ++++++++++++-- 3 files changed, 34 insertions(+), 4 deletions(-) diff --git a/Source/Engine/Core/Math/Vector2.cs b/Source/Engine/Core/Math/Vector2.cs index 4570ad2e9..b9d31fcad 100644 --- a/Source/Engine/Core/Math/Vector2.cs +++ b/Source/Engine/Core/Math/Vector2.cs @@ -1689,6 +1689,16 @@ namespace FlaxEngine return new Double2(value.X, value.Y); } + /// + /// Performs an explicit conversion from to . + /// + /// The value. + /// The result of the conversion. + public static explicit operator Int2(Vector2 value) + { + return new Int2((int)value.X, (int)value.Y); + } + /// /// Performs an explicit conversion from to . /// diff --git a/Source/Engine/Core/Math/Vector3.cs b/Source/Engine/Core/Math/Vector3.cs index 5505c5053..61d0e51f0 100644 --- a/Source/Engine/Core/Math/Vector3.cs +++ b/Source/Engine/Core/Math/Vector3.cs @@ -2011,7 +2011,7 @@ namespace FlaxEngine } /// - /// Performs an explicit conversion from to . + /// Performs an implicit conversion from to . /// /// The value. /// The result of the conversion. @@ -2021,7 +2021,7 @@ namespace FlaxEngine } /// - /// Performs an explicit conversion from to . + /// Performs an implicit conversion from to . /// /// The value. /// The result of the conversion. @@ -2030,6 +2030,16 @@ namespace FlaxEngine return new Double3(value.X, value.Y, value.Z); } + /// + /// Performs an explicit conversion from to . + /// + /// The value. + /// The result of the conversion. + public static explicit operator Int3(Vector3 value) + { + return new Int3((int)value.X, (int)value.Y, (int)value.Z); + } + /// /// Performs an explicit conversion from to . /// diff --git a/Source/Engine/Core/Math/Vector4.cs b/Source/Engine/Core/Math/Vector4.cs index e859938bf..11a171680 100644 --- a/Source/Engine/Core/Math/Vector4.cs +++ b/Source/Engine/Core/Math/Vector4.cs @@ -1378,7 +1378,7 @@ namespace FlaxEngine } /// - /// Performs an explicit conversion from to . + /// Performs an implicit conversion from to . /// /// The value. /// The result of the conversion. @@ -1388,7 +1388,7 @@ namespace FlaxEngine } /// - /// Performs an explicit conversion from to . + /// Performs an implicit conversion from to . /// /// The value. /// The result of the conversion. @@ -1397,6 +1397,16 @@ namespace FlaxEngine return new Double4(value.X, value.Y, value.Z, value.W); } + /// + /// Performs an explicit conversion from to . + /// + /// The value. + /// The result of the conversion. + public static explicit operator Int4(Vector4 value) + { + return new Int4((int)value.X, (int)value.Y, (int)value.Z, (int)value.W); + } + /// /// Performs an explicit conversion from to . ///