From 247300c09cdc99b99c80a0479727c6a971c603ca Mon Sep 17 00:00:00 2001 From: ronnie Date: Wed, 10 Jun 2026 14:34:33 -0400 Subject: [PATCH] Bumped SJKScript Vesion and added vector Lerp --- GodotHelper/GodotHelper.csproj | 1 + GodotHelper/src/Math/LerpVectors.cs | 4 ++-- GodotHelper/src/Math/RoundVectors.cs | 33 ++++++++++++++++++++++++++++ 3 files changed, 36 insertions(+), 2 deletions(-) create mode 100644 GodotHelper/src/Math/RoundVectors.cs diff --git a/GodotHelper/GodotHelper.csproj b/GodotHelper/GodotHelper.csproj index 5bcb511..76fb553 100644 --- a/GodotHelper/GodotHelper.csproj +++ b/GodotHelper/GodotHelper.csproj @@ -49,5 +49,6 @@ + diff --git a/GodotHelper/src/Math/LerpVectors.cs b/GodotHelper/src/Math/LerpVectors.cs index a05c006..c26e93c 100644 --- a/GodotHelper/src/Math/LerpVectors.cs +++ b/GodotHelper/src/Math/LerpVectors.cs @@ -8,7 +8,7 @@ public static partial class SJKMath // Mathf.Lerp(from.Y, to.Y, weight), // Mathf.Lerp(from.Z, to.Z, weight) // ); - public static Vector3 Lerp(Vector3 from, Vector3 to, float weight) => new Vector3( + public static Vector3 Lerp(this Vector3 from, Vector3 to, float weight) => new Vector3( Mathf.Lerp(from.X, to.X, weight), Mathf.Lerp(from.Y, to.Y, weight), Mathf.Lerp(from.Z, to.Z, weight) @@ -17,7 +17,7 @@ public static partial class SJKMath // Mathf.Lerp(from.X, to.X, weight), // Mathf.Lerp(from.Y, to.Y, weight) // ); - public static Vector2 Lerp(Vector2 from, Vector2 to, float weight) => new Vector2( + public static Vector2 Lerp(this Vector2 from, Vector2 to, float weight) => new Vector2( Mathf.Lerp(from.X, to.X, weight), Mathf.Lerp(from.Y, to.Y, weight) ); diff --git a/GodotHelper/src/Math/RoundVectors.cs b/GodotHelper/src/Math/RoundVectors.cs new file mode 100644 index 0000000..eca5870 --- /dev/null +++ b/GodotHelper/src/Math/RoundVectors.cs @@ -0,0 +1,33 @@ +namespace GodotHelpers; + +using Godot; +public static partial class SJKMath +{ + public static Vector3I RoundToIntVector(this Vector3 vector) => new Vector3I( + Mathf.RoundToInt(vector.X), + Mathf.RoundToInt(vector.Y), + Mathf.RoundToInt(vector.Z) + ); + public static Vector3I FloorToIntVector(this Vector3 vector) => new Vector3I( + Mathf.FloorToInt(vector.X), + Mathf.FloorToInt(vector.Y), + Mathf.FloorToInt(vector.Z) + ); + public static Vector3I CeilToIntVector(this Vector3 vector) => new Vector3I( + Mathf.CeilToInt(vector.X), + Mathf.CeilToInt(vector.Y), + Mathf.CeilToInt(vector.Z) + ); + public static Vector2I RoundToIntVector(this Vector2 vector) => new Vector2I( + Mathf.RoundToInt(vector.X), + Mathf.RoundToInt(vector.Y) + ); + public static Vector2I FloorToIntVector(this Vector2 vector) => new Vector2I( + Mathf.FloorToInt(vector.X), + Mathf.FloorToInt(vector.Y) + ); + public static Vector2I CeilToIntVector(this Vector2 vector) => new Vector2I( + Mathf.CeilToInt(vector.X), + Mathf.CeilToInt(vector.Y) + ); +}