From 22845118450d05778a7cd4352854dea1ea6b1c85 Mon Sep 17 00:00:00 2001 From: Shawdooow Date: Fri, 19 Nov 2021 15:37:59 -0500 Subject: [PATCH] Use Unsafe since its faster --- vke/src/Utils.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/vke/src/Utils.cs b/vke/src/Utils.cs index 3324d7a..853067e 100644 --- a/vke/src/Utils.cs +++ b/vke/src/Utils.cs @@ -6,6 +6,7 @@ using System.IO; using System.Linq; using System.Numerics; using System.Reflection; +using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Xml.Serialization; @@ -68,7 +69,7 @@ namespace Vulkan { /// Populate a Vector3 with values from a float array /// public static void FromFloatArray (ref Vector3 v, float[] floats) { - v = MemoryMarshal.Cast(floats)[0]; + v = Unsafe.As(ref floats)[0]; } /// /// Populate a Vector4 with values from a float array @@ -132,7 +133,7 @@ namespace Vulkan { #region Extensions methods public static void ImportFloatArray (this ref Vector3 v, float[] floats) { - v = MemoryMarshal.Cast(floats)[0]; + v = Unsafe.As(ref floats)[0]; } public static Vector3 Transform (this Vector3 v, ref Matrix4x4 mat, bool translate = false) { Vector4 v4 = Vector4.Transform (new Vector4 (v, translate ? 1f : 0f), mat); -- 2.47.3