[1166] | 1 | /**
|
---|
| 2 | * This file has no copyright assigned and is placed in the Public Domain.
|
---|
| 3 | * This file is part of the mingw-w64 runtime package.
|
---|
| 4 | * No warranty is given; refer to the file DISCLAIMER.PD within this package.
|
---|
| 5 | */
|
---|
| 6 |
|
---|
| 7 | #ifndef DIRECTXMATH_H
|
---|
| 8 | #define DIRECTXMATH_H
|
---|
| 9 |
|
---|
| 10 | #ifndef __cplusplus
|
---|
| 11 | #error DirectX Math requires C++
|
---|
| 12 | #endif
|
---|
| 13 |
|
---|
| 14 | #include <stdint.h>
|
---|
| 15 |
|
---|
| 16 | #define DIRECTX_MATH_VERSION 314
|
---|
| 17 |
|
---|
| 18 | #define XM_CONST const
|
---|
| 19 | #if __cplusplus >= 201103L
|
---|
| 20 | #define XM_CONSTEXPR constexpr
|
---|
| 21 | #else
|
---|
| 22 | #define XM_CONSTEXPR
|
---|
| 23 | #endif
|
---|
| 24 |
|
---|
| 25 | namespace DirectX {
|
---|
| 26 |
|
---|
| 27 | struct XMFLOAT2 {
|
---|
| 28 | float x, y;
|
---|
| 29 | XMFLOAT2() = default;
|
---|
| 30 | XMFLOAT2(const XMFLOAT2&) = default;
|
---|
| 31 | XMFLOAT2& operator=(const XMFLOAT2&) = default;
|
---|
| 32 | XMFLOAT2(XMFLOAT2&&) = default;
|
---|
| 33 | XMFLOAT2& operator=(XMFLOAT2&&) = default;
|
---|
| 34 | XM_CONSTEXPR XMFLOAT2(float _x, float _y) : x(_x), y(_y) {}
|
---|
| 35 | explicit XMFLOAT2(const float *pArray) : x(pArray[0]), y(pArray[1]) {}
|
---|
| 36 | };
|
---|
| 37 |
|
---|
| 38 | struct __attribute__ ((__aligned__ (16))) XMFLOAT2A : public XMFLOAT2 {
|
---|
| 39 | XMFLOAT2A() = default;
|
---|
| 40 | XMFLOAT2A(const XMFLOAT2A&) = default;
|
---|
| 41 | XMFLOAT2A& operator=(const XMFLOAT2A&) = default;
|
---|
| 42 | XMFLOAT2A(XMFLOAT2A&&) = default;
|
---|
| 43 | XMFLOAT2A& operator=(XMFLOAT2A&&) = default;
|
---|
| 44 | XM_CONSTEXPR XMFLOAT2A(float _x, float _y) : XMFLOAT2(_x, _y) {}
|
---|
| 45 | explicit XMFLOAT2A(const float *pArray) : XMFLOAT2(pArray) {}
|
---|
| 46 | };
|
---|
| 47 |
|
---|
| 48 | struct XMINT2 {
|
---|
| 49 | int32_t x, y;
|
---|
| 50 | XMINT2() = default;
|
---|
| 51 | XMINT2(const XMINT2&) = default;
|
---|
| 52 | XMINT2& operator=(const XMINT2&) = default;
|
---|
| 53 | XMINT2(XMINT2&&) = default;
|
---|
| 54 | XMINT2& operator=(XMINT2&&) = default;
|
---|
| 55 | XM_CONSTEXPR XMINT2(int32_t _x, int32_t _y) : x(_x), y(_y) {}
|
---|
| 56 | explicit XMINT2(const int32_t *pArray) : x(pArray[0]), y(pArray[1]) {}
|
---|
| 57 | };
|
---|
| 58 |
|
---|
| 59 | struct XMUINT2 {
|
---|
| 60 | uint32_t x, y;
|
---|
| 61 | XMUINT2() = default;
|
---|
| 62 | XMUINT2(const XMUINT2&) = default;
|
---|
| 63 | XMUINT2& operator=(const XMUINT2&) = default;
|
---|
| 64 | XMUINT2(XMUINT2&&) = default;
|
---|
| 65 | XMUINT2& operator=(XMUINT2&&) = default;
|
---|
| 66 | XM_CONSTEXPR XMUINT2(uint32_t _x, uint32_t _y) : x(_x), y(_y) {}
|
---|
| 67 | explicit XMUINT2(const uint32_t *pArray) : x(pArray[0]), y(pArray[1]) {}
|
---|
| 68 | };
|
---|
| 69 |
|
---|
| 70 | struct XMFLOAT3 {
|
---|
| 71 | float x, y, z;
|
---|
| 72 | XMFLOAT3() = default;
|
---|
| 73 | XMFLOAT3(const XMFLOAT3&) = default;
|
---|
| 74 | XMFLOAT3& operator=(const XMFLOAT3&) = default;
|
---|
| 75 | XMFLOAT3(XMFLOAT3&&) = default;
|
---|
| 76 | XMFLOAT3& operator=(XMFLOAT3&&) = default;
|
---|
| 77 | XM_CONSTEXPR XMFLOAT3(float _x, float _y, float _z) : x(_x), y(_y), z(_z) {}
|
---|
| 78 | explicit XMFLOAT3(const float *pArray) : x(pArray[0]), y(pArray[1]), z(pArray[2]) {}
|
---|
| 79 | };
|
---|
| 80 |
|
---|
| 81 | struct __attribute__ ((__aligned__ (16))) XMFLOAT3A : public XMFLOAT3 {
|
---|
| 82 | XMFLOAT3A() = default;
|
---|
| 83 | XMFLOAT3A(const XMFLOAT3A&) = default;
|
---|
| 84 | XMFLOAT3A& operator=(const XMFLOAT3A&) = default;
|
---|
| 85 | XMFLOAT3A(XMFLOAT3A&&) = default;
|
---|
| 86 | XMFLOAT3A& operator=(XMFLOAT3A&&) = default;
|
---|
| 87 | XM_CONSTEXPR XMFLOAT3A(float _x, float _y, float _z) : XMFLOAT3(_x, _y, _z) {}
|
---|
| 88 | explicit XMFLOAT3A(const float *pArray) : XMFLOAT3(pArray) {}
|
---|
| 89 | };
|
---|
| 90 |
|
---|
| 91 | struct XMINT3 {
|
---|
| 92 | int32_t x, y, z;
|
---|
| 93 | XMINT3() = default;
|
---|
| 94 | XMINT3(const XMINT3&) = default;
|
---|
| 95 | XMINT3& operator=(const XMINT3&) = default;
|
---|
| 96 | XMINT3(XMINT3&&) = default;
|
---|
| 97 | XMINT3& operator=(XMINT3&&) = default;
|
---|
| 98 | XM_CONSTEXPR XMINT3(int32_t _x, int32_t _y, int32_t _z) : x(_x), y(_y), z(_z) {}
|
---|
| 99 | explicit XMINT3(const int32_t *pArray) : x(pArray[0]), y(pArray[1]), z(pArray[2]) {}
|
---|
| 100 | };
|
---|
| 101 |
|
---|
| 102 | struct XMUINT3 {
|
---|
| 103 | uint32_t x, y, z;
|
---|
| 104 | XMUINT3() = default;
|
---|
| 105 | XMUINT3(const XMUINT3&) = default;
|
---|
| 106 | XMUINT3& operator=(const XMUINT3&) = default;
|
---|
| 107 | XMUINT3(XMUINT3&&) = default;
|
---|
| 108 | XMUINT3& operator=(XMUINT3&&) = default;
|
---|
| 109 | XM_CONSTEXPR XMUINT3(uint32_t _x, uint32_t _y, uint32_t _z) : x(_x), y(_y), z(_z) {}
|
---|
| 110 | explicit XMUINT3(const uint32_t *pArray) : x(pArray[0]), y(pArray[1]), z(pArray[2]) {}
|
---|
| 111 | };
|
---|
| 112 |
|
---|
| 113 | struct XMFLOAT4 {
|
---|
| 114 | float x, y, z, w;
|
---|
| 115 | XMFLOAT4() = default;
|
---|
| 116 | XMFLOAT4(const XMFLOAT4&) = default;
|
---|
| 117 | XMFLOAT4& operator=(const XMFLOAT4&) = default;
|
---|
| 118 | XMFLOAT4(XMFLOAT4&&) = default;
|
---|
| 119 | XMFLOAT4& operator=(XMFLOAT4&&) = default;
|
---|
| 120 | XM_CONSTEXPR XMFLOAT4(float _x, float _y, float _z, float _w) : x(_x), y(_y), z(_z), w(_w) {}
|
---|
| 121 | explicit XMFLOAT4(const float *pArray) : x(pArray[0]), y(pArray[1]), z(pArray[2]), w(pArray[3]) {}
|
---|
| 122 | };
|
---|
| 123 |
|
---|
| 124 | struct __attribute__ ((__aligned__ (16))) XMFLOAT4A : public XMFLOAT4 {
|
---|
| 125 | XMFLOAT4A() = default;
|
---|
| 126 | XMFLOAT4A(const XMFLOAT4A&) = default;
|
---|
| 127 | XMFLOAT4A& operator=(const XMFLOAT4A&) = default;
|
---|
| 128 | XMFLOAT4A(XMFLOAT4A&&) = default;
|
---|
| 129 | XMFLOAT4A& operator=(XMFLOAT4A&&) = default;
|
---|
| 130 | XM_CONSTEXPR XMFLOAT4A(float _x, float _y, float _z, float _w) : XMFLOAT4(_x, _y, _z, _w) {}
|
---|
| 131 | explicit XMFLOAT4A(const float *pArray) : XMFLOAT4(pArray) {}
|
---|
| 132 | };
|
---|
| 133 |
|
---|
| 134 | struct XMINT4 {
|
---|
| 135 | int32_t x, y, z, w;
|
---|
| 136 | XMINT4() = default;
|
---|
| 137 | XMINT4(const XMINT4&) = default;
|
---|
| 138 | XMINT4& operator=(const XMINT4&) = default;
|
---|
| 139 | XMINT4(XMINT4&&) = default;
|
---|
| 140 | XMINT4& operator=(XMINT4&&) = default;
|
---|
| 141 | XM_CONSTEXPR XMINT4(int32_t _x, int32_t _y, int32_t _z, int32_t _w) : x(_x), y(_y), z(_z), w(_w) {}
|
---|
| 142 | explicit XMINT4(const int32_t *pArray) : x(pArray[0]), y(pArray[1]), z(pArray[2]), w(pArray[3]) {}
|
---|
| 143 | };
|
---|
| 144 |
|
---|
| 145 | struct XMUINT4 {
|
---|
| 146 | uint32_t x, y, z, w;
|
---|
| 147 | XMUINT4() = default;
|
---|
| 148 | XMUINT4(const XMUINT4&) = default;
|
---|
| 149 | XMUINT4& operator=(const XMUINT4&) = default;
|
---|
| 150 | XMUINT4(XMUINT4&&) = default;
|
---|
| 151 | XMUINT4& operator=(XMUINT4&&) = default;
|
---|
| 152 | XM_CONSTEXPR XMUINT4(uint32_t _x, uint32_t _y, uint32_t _z, uint32_t _w) : x(_x), y(_y), z(_z), w(_w) {}
|
---|
| 153 | explicit XMUINT4(const uint32_t *pArray) : x(pArray[0]), y(pArray[1]), z(pArray[2]), w(pArray[3]) {}
|
---|
| 154 | };
|
---|
| 155 |
|
---|
| 156 | struct XMFLOAT3X3 {
|
---|
| 157 | union
|
---|
| 158 | {
|
---|
| 159 | struct
|
---|
| 160 | {
|
---|
| 161 | float _11, _12, _13;
|
---|
| 162 | float _21, _22, _23;
|
---|
| 163 | float _31, _32, _33;
|
---|
| 164 | };
|
---|
| 165 | float m[3][3];
|
---|
| 166 | };
|
---|
| 167 |
|
---|
| 168 | XMFLOAT3X3() = default;
|
---|
| 169 | XMFLOAT3X3(const XMFLOAT3X3&) = default;
|
---|
| 170 | XMFLOAT3X3& operator=(const XMFLOAT3X3&) = default;
|
---|
| 171 | XMFLOAT3X3(XMFLOAT3X3&&) = default;
|
---|
| 172 | XMFLOAT3X3& operator=(XMFLOAT3X3&&) = default;
|
---|
| 173 | XM_CONSTEXPR XMFLOAT3X3(
|
---|
| 174 | float m00, float m01, float m02,
|
---|
| 175 | float m10, float m11, float m12,
|
---|
| 176 | float m20, float m21, float m22)
|
---|
| 177 | : _11(m00), _12(m01), _13(m02),
|
---|
| 178 | _21(m10), _22(m11), _23(m12),
|
---|
| 179 | _31(m20), _32(m21), _33(m22) {}
|
---|
| 180 | explicit XMFLOAT3X3(const float *pArray);
|
---|
| 181 | float operator() (size_t Row, size_t Column) const { return m[Row][Column]; }
|
---|
| 182 | float& operator() (size_t Row, size_t Column) { return m[Row][Column]; }
|
---|
| 183 | };
|
---|
| 184 |
|
---|
| 185 | struct XMFLOAT4X3 {
|
---|
| 186 | union
|
---|
| 187 | {
|
---|
| 188 | struct
|
---|
| 189 | {
|
---|
| 190 | float _11, _12, _13;
|
---|
| 191 | float _21, _22, _23;
|
---|
| 192 | float _31, _32, _33;
|
---|
| 193 | float _41, _42, _43;
|
---|
| 194 | };
|
---|
| 195 | float m[4][3];
|
---|
| 196 | float f[12];
|
---|
| 197 | };
|
---|
| 198 |
|
---|
| 199 | XMFLOAT4X3() = default;
|
---|
| 200 | XMFLOAT4X3(const XMFLOAT4X3&) = default;
|
---|
| 201 | XMFLOAT4X3& operator=(const XMFLOAT4X3&) = default;
|
---|
| 202 | XMFLOAT4X3(XMFLOAT4X3&&) = default;
|
---|
| 203 | XMFLOAT4X3& operator=(XMFLOAT4X3&&) = default;
|
---|
| 204 | XM_CONSTEXPR XMFLOAT4X3(
|
---|
| 205 | float m00, float m01, float m02,
|
---|
| 206 | float m10, float m11, float m12,
|
---|
| 207 | float m20, float m21, float m22,
|
---|
| 208 | float m30, float m31, float m32)
|
---|
| 209 | : _11(m00), _12(m01), _13(m02),
|
---|
| 210 | _21(m10), _22(m11), _23(m12),
|
---|
| 211 | _31(m20), _32(m21), _33(m22),
|
---|
| 212 | _41(m30), _42(m31), _43(m32) {}
|
---|
| 213 | explicit XMFLOAT4X3(const float *pArray);
|
---|
| 214 | float operator() (size_t Row, size_t Column) const { return m[Row][Column]; }
|
---|
| 215 | float& operator() (size_t Row, size_t Column) { return m[Row][Column]; }
|
---|
| 216 | };
|
---|
| 217 |
|
---|
| 218 | struct __attribute__ ((__aligned__ (16))) XMFLOAT4X3A : public XMFLOAT4X3 {
|
---|
| 219 | XMFLOAT4X3A() = default;
|
---|
| 220 | XMFLOAT4X3A(const XMFLOAT4X3A&) = default;
|
---|
| 221 | XMFLOAT4X3A& operator=(const XMFLOAT4X3A&) = default;
|
---|
| 222 | XMFLOAT4X3A(XMFLOAT4X3A&&) = default;
|
---|
| 223 | XMFLOAT4X3A& operator=(XMFLOAT4X3A&&) = default;
|
---|
| 224 | XM_CONSTEXPR XMFLOAT4X3A(
|
---|
| 225 | float m00, float m01, float m02,
|
---|
| 226 | float m10, float m11, float m12,
|
---|
| 227 | float m20, float m21, float m22,
|
---|
| 228 | float m30, float m31, float m32) :
|
---|
| 229 | XMFLOAT4X3(m00,m01,m02,m10,m11,m12,m20,m21,m22,m30,m31,m32) {}
|
---|
| 230 | explicit XMFLOAT4X3A(const float *pArray) : XMFLOAT4X3(pArray) {}
|
---|
| 231 | };
|
---|
| 232 |
|
---|
| 233 | struct XMFLOAT3X4 {
|
---|
| 234 | union
|
---|
| 235 | {
|
---|
| 236 | struct
|
---|
| 237 | {
|
---|
| 238 | float _11, _12, _13, _14;
|
---|
| 239 | float _21, _22, _23, _24;
|
---|
| 240 | float _31, _32, _33, _34;
|
---|
| 241 | };
|
---|
| 242 | float m[3][4];
|
---|
| 243 | float f[12];
|
---|
| 244 | };
|
---|
| 245 |
|
---|
| 246 | XMFLOAT3X4() = default;
|
---|
| 247 | XMFLOAT3X4(const XMFLOAT3X4&) = default;
|
---|
| 248 | XMFLOAT3X4& operator=(const XMFLOAT3X4&) = default;
|
---|
| 249 | XMFLOAT3X4(XMFLOAT3X4&&) = default;
|
---|
| 250 | XMFLOAT3X4& operator=(XMFLOAT3X4&&) = default;
|
---|
| 251 | XM_CONSTEXPR XMFLOAT3X4(
|
---|
| 252 | float m00, float m01, float m02, float m03,
|
---|
| 253 | float m10, float m11, float m12, float m13,
|
---|
| 254 | float m20, float m21, float m22, float m23)
|
---|
| 255 | : _11(m00), _12(m01), _13(m02), _14(m03),
|
---|
| 256 | _21(m10), _22(m11), _23(m12), _24(m13),
|
---|
| 257 | _31(m20), _32(m21), _33(m22), _34(m23) {}
|
---|
| 258 | explicit XMFLOAT3X4(const float *pArray);
|
---|
| 259 | float operator() (size_t Row, size_t Column) const { return m[Row][Column]; }
|
---|
| 260 | float& operator() (size_t Row, size_t Column) { return m[Row][Column]; }
|
---|
| 261 | };
|
---|
| 262 |
|
---|
| 263 | struct __attribute__ ((__aligned__ (16))) XMFLOAT3X4A : public XMFLOAT3X4 {
|
---|
| 264 | XMFLOAT3X4A() = default;
|
---|
| 265 | XMFLOAT3X4A(const XMFLOAT3X4A&) = default;
|
---|
| 266 | XMFLOAT3X4A& operator=(const XMFLOAT3X4A&) = default;
|
---|
| 267 | XMFLOAT3X4A(XMFLOAT3X4A&&) = default;
|
---|
| 268 | XMFLOAT3X4A& operator=(XMFLOAT3X4A&&) = default;
|
---|
| 269 | XM_CONSTEXPR XMFLOAT3X4A(
|
---|
| 270 | float m00, float m01, float m02, float m03,
|
---|
| 271 | float m10, float m11, float m12, float m13,
|
---|
| 272 | float m20, float m21, float m22, float m23) :
|
---|
| 273 | XMFLOAT3X4(m00, m01, m02, m03, m10, m11, m12, m13, m20, m21, m22, m23) {}
|
---|
| 274 | explicit XMFLOAT3X4A(const float *pArray) : XMFLOAT3X4(pArray) {}
|
---|
| 275 | };
|
---|
| 276 |
|
---|
| 277 | struct XMFLOAT4X4 {
|
---|
| 278 | union
|
---|
| 279 | {
|
---|
| 280 | struct
|
---|
| 281 | {
|
---|
| 282 | float _11, _12, _13, _14;
|
---|
| 283 | float _21, _22, _23, _24;
|
---|
| 284 | float _31, _32, _33, _34;
|
---|
| 285 | float _41, _42, _43, _44;
|
---|
| 286 | };
|
---|
| 287 | float m[4][4];
|
---|
| 288 | };
|
---|
| 289 |
|
---|
| 290 | XMFLOAT4X4() = default;
|
---|
| 291 | XMFLOAT4X4(const XMFLOAT4X4&) = default;
|
---|
| 292 | XMFLOAT4X4& operator=(const XMFLOAT4X4&) = default;
|
---|
| 293 | XMFLOAT4X4(XMFLOAT4X4&&) = default;
|
---|
| 294 | XMFLOAT4X4& operator=(XMFLOAT4X4&&) = default;
|
---|
| 295 | XM_CONSTEXPR XMFLOAT4X4(
|
---|
| 296 | float m00, float m01, float m02, float m03,
|
---|
| 297 | float m10, float m11, float m12, float m13,
|
---|
| 298 | float m20, float m21, float m22, float m23,
|
---|
| 299 | float m30, float m31, float m32, float m33)
|
---|
| 300 | : _11(m00), _12(m01), _13(m02), _14(m03),
|
---|
| 301 | _21(m10), _22(m11), _23(m12), _24(m13),
|
---|
| 302 | _31(m20), _32(m21), _33(m22), _34(m23),
|
---|
| 303 | _41(m30), _42(m31), _43(m32), _44(m33) {}
|
---|
| 304 | explicit XMFLOAT4X4(const float *pArray);
|
---|
| 305 | float operator() (size_t Row, size_t Column) const { return m[Row][Column]; }
|
---|
| 306 | float& operator() (size_t Row, size_t Column) { return m[Row][Column]; }
|
---|
| 307 | };
|
---|
| 308 |
|
---|
| 309 | struct __attribute__ ((__aligned__ (16))) XMFLOAT4X4A : public XMFLOAT4X4 {
|
---|
| 310 | XMFLOAT4X4A() = default;
|
---|
| 311 | XMFLOAT4X4A(const XMFLOAT4X4A&) = default;
|
---|
| 312 | XMFLOAT4X4A& operator=(const XMFLOAT4X4A&) = default;
|
---|
| 313 | XMFLOAT4X4A(XMFLOAT4X4A&&) = default;
|
---|
| 314 | XMFLOAT4X4A& operator=(XMFLOAT4X4A&&) = default;
|
---|
| 315 | XM_CONSTEXPR XMFLOAT4X4A(
|
---|
| 316 | float m00, float m01, float m02, float m03,
|
---|
| 317 | float m10, float m11, float m12, float m13,
|
---|
| 318 | float m20, float m21, float m22, float m23,
|
---|
| 319 | float m30, float m31, float m32, float m33)
|
---|
| 320 | : XMFLOAT4X4(m00,m01,m02,m03,m10,m11,m12,m13,m20,m21,m22,m23,m30,m31,m32,m33) {}
|
---|
| 321 | explicit XMFLOAT4X4A(const float *pArray) : XMFLOAT4X4(pArray) {}
|
---|
| 322 | };
|
---|
| 323 |
|
---|
| 324 | } /* namespace DirectX */
|
---|
| 325 |
|
---|
| 326 | #endif /* DIRECTXMATH_H */
|
---|