From a5572ba5a39cdb74c022464466a1141d1f878572 Mon Sep 17 00:00:00 2001
From: kleonc <9283098+kleonc@users.noreply.github.com>
Date: Fri, 7 Apr 2023 17:44:36 +0200
Subject: C# Truncate instead of round in Vector2/3/4 to Vector2I/3I/4I
conversion
(cherry picked from commit f53d3382af3ce04c924e6f92bb4c81ba349cfd8f)
---
modules/mono/glue/GodotSharp/GodotSharp/Core/Vector2I.cs | 10 +++++-----
modules/mono/glue/GodotSharp/GodotSharp/Core/Vector3I.cs | 11 +++++------
modules/mono/glue/GodotSharp/GodotSharp/Core/Vector4I.cs | 12 +++++-------
3 files changed, 15 insertions(+), 18 deletions(-)
(limited to 'modules/mono')
diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector2I.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector2I.cs
index e849939ebb..0dac8205b6 100644
--- a/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector2I.cs
+++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector2I.cs
@@ -504,15 +504,15 @@ namespace Godot
}
///
- /// Converts a to a .
+ /// Converts a to a by truncating
+ /// components' fractional parts (rounding towards zero). For a different
+ /// behavior consider passing the result of ,
+ /// or to this conversion operator instead.
///
/// The vector to convert.
public static explicit operator Vector2I(Vector2 value)
{
- return new Vector2I(
- Mathf.RoundToInt(value.X),
- Mathf.RoundToInt(value.Y)
- );
+ return new Vector2I((int)value.X, (int)value.Y);
}
///
diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector3I.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector3I.cs
index fe899527ef..a2927533f8 100644
--- a/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector3I.cs
+++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector3I.cs
@@ -559,16 +559,15 @@ namespace Godot
}
///
- /// Converts a to a .
+ /// Converts a to a by truncating
+ /// components' fractional parts (rounding towards zero). For a different
+ /// behavior consider passing the result of ,
+ /// or to this conversion operator instead.
///
/// The vector to convert.
public static explicit operator Vector3I(Vector3 value)
{
- return new Vector3I(
- Mathf.RoundToInt(value.X),
- Mathf.RoundToInt(value.Y),
- Mathf.RoundToInt(value.Z)
- );
+ return new Vector3I((int)value.X, (int)value.Y, (int)value.Z);
}
///
diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector4I.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector4I.cs
index f065327066..bb552b939d 100644
--- a/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector4I.cs
+++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector4I.cs
@@ -580,17 +580,15 @@ namespace Godot
}
///
- /// Converts a to a .
+ /// Converts a to a by truncating
+ /// components' fractional parts (rounding towards zero). For a different
+ /// behavior consider passing the result of ,
+ /// or to this conversion operator instead.
///
/// The vector to convert.
public static explicit operator Vector4I(Vector4 value)
{
- return new Vector4I(
- Mathf.RoundToInt(value.X),
- Mathf.RoundToInt(value.Y),
- Mathf.RoundToInt(value.Z),
- Mathf.RoundToInt(value.W)
- );
+ return new Vector4I((int)value.X, (int)value.Y, (int)value.Z, (int)value.W);
}
///
--
cgit v1.2.3