Advertisement
Guest User

Untitled

a guest
Oct 17th, 2019
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.99 KB | None | 0 0
  1. public struct Vector2S
  2. {
  3. public Vector2S(float xy)
  4. {
  5. X = xy;
  6. Y = xy;
  7. }
  8.  
  9. public Vector2S(float x, float y)
  10. {
  11. X = x;
  12. Y = y;
  13. }
  14.  
  15. public float X, Y;
  16. }
  17.  
  18. public struct Vector3S
  19. {
  20. public Vector3S(float xyz)
  21. {
  22. X = xyz;
  23. Y = xyz;
  24. Z = xyz;
  25. }
  26.  
  27. public Vector3S(float x, float y, float z)
  28. {
  29. X = x;
  30. Y = y;
  31. Z = z;
  32. }
  33.  
  34. public Vector3S(Vector2S xy, float z)
  35. {
  36. X = xy.X;
  37. Y = xy.Y;
  38. Z = z;
  39. }
  40.  
  41. public float X, Y, Z;
  42. }
  43.  
  44. public struct Vector4S
  45. {
  46. public Vector4S(float xyzw)
  47. {
  48. X = xyzw;
  49. Y = xyzw;
  50. Z = xyzw;
  51. W = xyzw;
  52. }
  53.  
  54. public Vector4S(Vector2S xy, float z, float w)
  55. {
  56. X = xy.X;
  57. Y = xy.Y;
  58. Z = z;
  59. W = w;
  60. }
  61.  
  62. public Vector4S(Vector3S xyz, float w)
  63. {
  64. X = xyz.X;
  65. Y = xyz.Y;
  66. Z = xyz.Z;
  67. W = w;
  68. }
  69.  
  70. public Vector4S(float x, float y, float z, float w)
  71. {
  72. X = x;
  73. Y = y;
  74. Z = z;
  75. W = w;
  76. }
  77.  
  78. public float X, Y, Z, W;
  79. }
  80.  
  81. public static unsafe class VectorTypeExtensions
  82. {
  83. public static HwVector2S Load(this Vector2S vector) => MathSharp.Vector.Load2D(&vector.X);
  84. public static HwVector3S Load(this Vector3S vector) => MathSharp.Vector.Load3D(&vector.X);
  85. public static HwVector4S Load(this Vector4S vector) => MathSharp.Vector.Load4D(&vector.X);
  86.  
  87. public static void Store(this HwVector2S vector, out Vector2S destination)
  88. {
  89. fixed (void* p = &destination)
  90. {
  91. vector.Store2D((float*)p);
  92. }
  93. }
  94.  
  95. public static void Store(this HwVector3S vector, out Vector3S destination)
  96. {
  97. fixed (void* p = &destination)
  98. {
  99. vector.Store3D((float*)p);
  100. }
  101. }
  102.  
  103. public static void Store(this HwVector4S vector, out Vector4S destination)
  104. {
  105. fixed (void* p = &destination)
  106. {
  107. vector.Store4D((float*)p);
  108. }
  109. }
  110. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement