From 09f7dfce9019271b15f34f32ef31775e9d73fcc8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20L=C3=BCbe=C3=9F?= Date: Tue, 30 Jan 2024 23:36:35 +0100 Subject: [PATCH] FloatX to Numerics.VectorX converision operators --- ScriptCore/Math/FloatVectors.cs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/ScriptCore/Math/FloatVectors.cs b/ScriptCore/Math/FloatVectors.cs index 29e2a0a..2dd8c9d 100644 --- a/ScriptCore/Math/FloatVectors.cs +++ b/ScriptCore/Math/FloatVectors.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Numerics; using System.Runtime.InteropServices; using System.Text; using GlitchyEngine.Math; @@ -19,6 +20,9 @@ public partial struct float2 public static readonly float2 UnitX = new(1.0f, 0.0f); public static readonly float2 UnitY = new(0.0f, 1.0f); public static readonly float2 One = new(0.0f, 0.0f); + + public static explicit operator Vector2(float2 self) => new(self.X, self.Y); + public static explicit operator float2(Vector2 self) => new(self.X, self.Y); } [Vector(typeof(float), 3, "float")] @@ -41,6 +45,9 @@ public partial struct float3 public static readonly float3 Right = new(1.0f, 0.0f, 0.0f); public static readonly float3 Up = new(0.0f, 1.0f, 0.0f); public static readonly float3 Down = new(0.0f, -1.0f, 0.0f); + + public static explicit operator Vector3(float3 self) => new(self.X, self.Y, self.Z); + public static explicit operator float3(Vector3 self) => new(self.X, self.Y, self.Z); } [Vector(typeof(float), 4, "float")] @@ -57,4 +64,7 @@ public partial struct float4 public static readonly float4 UnitZ = new(0f, 0f, 1f, 0f); public static readonly float4 UnitW = new(0f, 0f, 0f, 1f); public static readonly float4 One = new(1f, 1f, 1f, 1f); + + public static explicit operator Vector4(float4 self) => new(self.X, self.Y, self.Z, self.W); + public static explicit operator float4(Vector4 self) => new(self.X, self.Y, self.Z, self.W); }