Created
September 29, 2019 11:59
-
-
Save john-h-k/8636bf2ec7f3fa77c38af0bc488dd13a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public struct Vector2S | |
| { | |
| public Vector2S(float xy) | |
| { | |
| X = xy; | |
| Y = xy; | |
| } | |
| public Vector2S(float x, float y) | |
| { | |
| X = x; | |
| Y = y; | |
| } | |
| public float X, Y; | |
| } | |
| public struct Vector3S | |
| { | |
| public Vector3S(float xyz) | |
| { | |
| X = xyz; | |
| Y = xyz; | |
| Z = xyz; | |
| } | |
| public Vector3S(float x, float y, float z) | |
| { | |
| X = x; | |
| Y = y; | |
| Z = z; | |
| } | |
| public Vector3S(Vector2S xy, float z) | |
| { | |
| X = xy.X; | |
| Y = xy.Y; | |
| Z = z; | |
| } | |
| public float X, Y, Z; | |
| } | |
| public struct Vector4S | |
| { | |
| public Vector4S(float xyzw) | |
| { | |
| X = xyzw; | |
| Y = xyzw; | |
| Z = xyzw; | |
| W = xyzw; | |
| } | |
| public Vector4S(Vector2S xy, float z, float w) | |
| { | |
| X = xy.X; | |
| Y = xy.Y; | |
| Z = z; | |
| W = w; | |
| } | |
| public Vector4S(Vector3S xyz, float w) | |
| { | |
| X = xyz.X; | |
| Y = xyz.Y; | |
| Z = xyz.Z; | |
| W = w; | |
| } | |
| public Vector4S(float x, float y, float z, float w) | |
| { | |
| X = x; | |
| Y = y; | |
| Z = z; | |
| W = w; | |
| } | |
| public float X, Y, Z, W; | |
| } | |
| public static unsafe class VectorTypeExtensions | |
| { | |
| public static HwVector2S Load(this Vector2S vector) => MathSharp.Vector.Load2D(&vector.X); | |
| public static HwVector3S Load(this Vector3S vector) => MathSharp.Vector.Load3D(&vector.X); | |
| public static HwVector4S Load(this Vector4S vector) => MathSharp.Vector.Load4D(&vector.X); | |
| public static void Store(this HwVector2S vector, out Vector2S destination) | |
| { | |
| fixed (void* p = &destination) | |
| { | |
| vector.Store2D((float*)p); | |
| } | |
| } | |
| public static void Store(this HwVector3S vector, out Vector3S destination) | |
| { | |
| fixed (void* p = &destination) | |
| { | |
| vector.Store3D((float*)p); | |
| } | |
| } | |
| public static void Store(this HwVector4S vector, out Vector4S destination) | |
| { | |
| fixed (void* p = &destination) | |
| { | |
| vector.Store4D((float*)p); | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment