-
Notifications
You must be signed in to change notification settings - Fork 3
/
xnamath.h
2938 lines (2449 loc) · 113 KB
/
xnamath.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*++
Copyright (c) Microsoft Corporation. All rights reserved.
Module Name:
xnamath.h
Abstract:
XNA math library for Windows and Xbox 360
--*/
#if defined(_MSC_VER) && (_MSC_VER > 1000)
#pragma once
#endif
#ifndef __XNAMATH_H__
#define __XNAMATH_H__
#ifdef __XBOXMATH_H__
#error XNAMATH and XBOXMATH are incompatible in the same compilation module. Use one or the other.
#endif
#define XNAMATH_VERSION 203
#if !defined(_XM_X64_) && !defined(_XM_X86_)
#if defined(_M_AMD64) || defined(_AMD64_)
#define _XM_X64_
#elif defined(_M_IX86) || defined(_X86_)
#define _XM_X86_
#endif
#endif
#if !defined(_XM_BIGENDIAN_) && !defined(_XM_LITTLEENDIAN_)
#if defined(_XM_X64_) || defined(_XM_X86_)
#define _XM_LITTLEENDIAN_
#elif defined(_XBOX_VER)
#define _XM_BIGENDIAN_
#else
#error xnamath.h only supports x86, x64, or XBox 360 targets
#endif
#endif
#if defined(_XM_X86_) || defined(_XM_X64_)
#define _XM_SSE_INTRINSICS_
#if !defined(__cplusplus) && !defined(_XM_NO_INTRINSICS_)
#error xnamath.h only supports C compliation for Xbox 360 targets and no intrinsics cases for x86/x64
#endif
#elif defined(_XBOX_VER)
#if !defined(__VMX128_SUPPORTED) && !defined(_XM_NO_INTRINSICS_)
#error xnamath.h requires VMX128 compiler support for XBOX 360
#endif // !__VMX128_SUPPORTED && !_XM_NO_INTRINSICS_
#define _XM_VMX128_INTRINSICS_
#else
#error xnamath.h only supports x86, x64, or XBox 360 targets
#endif
#if defined(_XM_SSE_INTRINSICS_)
#ifndef _XM_NO_INTRINSICS_
#include <xmmintrin.h>
#include <emmintrin.h>
#endif
#elif defined(_XM_VMX128_INTRINSICS_)
#error This version of xnamath.h is for Windows use only
#endif
#if defined(_XM_SSE_INTRINSICS_)
#pragma warning(push)
#pragma warning(disable:4985)
#endif
#include <math.h>
#if defined(_XM_SSE_INTRINSICS_)
#pragma warning(pop)
#endif
#include <sal.h>
#if !defined(XMINLINE)
#if !defined(XM_NO_MISALIGNED_VECTOR_ACCESS)
#define XMINLINE __inline
#else
#define XMINLINE __forceinline
#endif
#endif
#if !defined(XMFINLINE)
#define XMFINLINE __forceinline
#endif
#if !defined(XMDEBUG)
#if defined(_DEBUG)
#define XMDEBUG
#endif
#endif // !XMDEBUG
#if !defined(XMASSERT)
#if defined(_PREFAST_)
#define XMASSERT(Expression) __analysis_assume((Expression))
#elif defined(XMDEBUG) // !_PREFAST_
#define XMASSERT(Expression) ((VOID)((Expression) || (XMAssert(#Expression, __FILE__, __LINE__), 0)))
#else // !XMDEBUG
#define XMASSERT(Expression) ((VOID)0)
#endif // !XMDEBUG
#endif // !XMASSERT
#if !defined(XM_NO_ALIGNMENT)
#define _DECLSPEC_ALIGN_16_ __declspec(align(16))
#else
#define _DECLSPEC_ALIGN_16_
#endif
#if defined(_MSC_VER) && (_MSC_VER<1500) && (_MSC_VER>=1400)
#define _XM_ISVS2005_
#endif
/****************************************************************************
*
* Constant definitions
*
****************************************************************************/
#define XM_PI 3.141592654f
#define XM_2PI 6.283185307f
#define XM_1DIVPI 0.318309886f
#define XM_1DIV2PI 0.159154943f
#define XM_PIDIV2 1.570796327f
#define XM_PIDIV4 0.785398163f
#define XM_SELECT_0 0x00000000
#define XM_SELECT_1 0xFFFFFFFF
#define XM_PERMUTE_0X 0x00010203
#define XM_PERMUTE_0Y 0x04050607
#define XM_PERMUTE_0Z 0x08090A0B
#define XM_PERMUTE_0W 0x0C0D0E0F
#define XM_PERMUTE_1X 0x10111213
#define XM_PERMUTE_1Y 0x14151617
#define XM_PERMUTE_1Z 0x18191A1B
#define XM_PERMUTE_1W 0x1C1D1E1F
#define XM_CRMASK_CR6 0x000000F0
#define XM_CRMASK_CR6TRUE 0x00000080
#define XM_CRMASK_CR6FALSE 0x00000020
#define XM_CRMASK_CR6BOUNDS XM_CRMASK_CR6FALSE
#define XM_CACHE_LINE_SIZE 64
/****************************************************************************
*
* Macros
*
****************************************************************************/
// Unit conversion
XMFINLINE FLOAT XMConvertToRadians(FLOAT fDegrees) { return fDegrees * (XM_PI / 180.0f); }
XMFINLINE FLOAT XMConvertToDegrees(FLOAT fRadians) { return fRadians * (180.0f / XM_PI); }
// Condition register evaluation proceeding a recording (Rc) comparison
#define XMComparisonAllTrue(CR) (((CR) & XM_CRMASK_CR6TRUE) == XM_CRMASK_CR6TRUE)
#define XMComparisonAnyTrue(CR) (((CR) & XM_CRMASK_CR6FALSE) != XM_CRMASK_CR6FALSE)
#define XMComparisonAllFalse(CR) (((CR) & XM_CRMASK_CR6FALSE) == XM_CRMASK_CR6FALSE)
#define XMComparisonAnyFalse(CR) (((CR) & XM_CRMASK_CR6TRUE) != XM_CRMASK_CR6TRUE)
#define XMComparisonMixed(CR) (((CR) & XM_CRMASK_CR6) == 0)
#define XMComparisonAllInBounds(CR) (((CR) & XM_CRMASK_CR6BOUNDS) == XM_CRMASK_CR6BOUNDS)
#define XMComparisonAnyOutOfBounds(CR) (((CR) & XM_CRMASK_CR6BOUNDS) != XM_CRMASK_CR6BOUNDS)
#define XMMin(a, b) (((a) < (b)) ? (a) : (b))
#define XMMax(a, b) (((a) > (b)) ? (a) : (b))
/****************************************************************************
*
* Data types
*
****************************************************************************/
#pragma warning(push)
#pragma warning(disable:4201 4365 4324)
#if !defined (_XM_X86_) && !defined(_XM_X64_)
#pragma bitfield_order(push)
#pragma bitfield_order(lsb_to_msb)
#endif // !_XM_X86_ && !_XM_X64_
#if defined(_XM_NO_INTRINSICS_) && !defined(_XBOX_VER)
// The __vector4 structure is an intrinsic on Xbox but must be separately defined
// for x86/x64
typedef struct __vector4
{
union
{
float vector4_f32[4];
unsigned int vector4_u32[4];
#ifndef XM_STRICT_VECTOR4
struct
{
FLOAT x;
FLOAT y;
FLOAT z;
FLOAT w;
};
FLOAT v[4];
UINT u[4];
#endif // !XM_STRICT_VECTOR4
};
} __vector4;
#endif // _XM_NO_INTRINSICS_
#if (defined (_XM_X86_) || defined(_XM_X64_)) && defined(_XM_NO_INTRINSICS_)
typedef UINT __vector4i[4];
#else
typedef __declspec(align(16)) UINT __vector4i[4];
#endif
// Vector intrinsic: Four 32 bit floating point components aligned on a 16 byte
// boundary and mapped to hardware vector registers
#if defined(_XM_SSE_INTRINSICS_) && !defined(_XM_NO_INTRINSICS_)
typedef __m128 XMVECTOR;
#else
typedef __vector4 XMVECTOR;
#endif
// Conversion types for constants
typedef _DECLSPEC_ALIGN_16_ struct XMVECTORF32 {
union {
float f[4];
XMVECTOR v;
};
#if defined(__cplusplus)
inline operator XMVECTOR() const { return v; }
#if !defined(_XM_NO_INTRINSICS_) && defined(_XM_SSE_INTRINSICS_)
inline operator __m128i() const { return reinterpret_cast<const __m128i *>(&v)[0]; }
inline operator __m128d() const { return reinterpret_cast<const __m128d *>(&v)[0]; }
#endif
#endif // __cplusplus
} XMVECTORF32;
typedef _DECLSPEC_ALIGN_16_ struct XMVECTORI32 {
union {
INT i[4];
XMVECTOR v;
};
#if defined(__cplusplus)
inline operator XMVECTOR() const { return v; }
#if !defined(_XM_NO_INTRINSICS_) && defined(_XM_SSE_INTRINSICS_)
inline operator __m128i() const { return reinterpret_cast<const __m128i *>(&v)[0]; }
inline operator __m128d() const { return reinterpret_cast<const __m128d *>(&v)[0]; }
#endif
#endif // __cplusplus
} XMVECTORI32;
typedef _DECLSPEC_ALIGN_16_ struct XMVECTORU8 {
union {
BYTE u[16];
XMVECTOR v;
};
#if defined(__cplusplus)
inline operator XMVECTOR() const { return v; }
#if !defined(_XM_NO_INTRINSICS_) && defined(_XM_SSE_INTRINSICS_)
inline operator __m128i() const { return reinterpret_cast<const __m128i *>(&v)[0]; }
inline operator __m128d() const { return reinterpret_cast<const __m128d *>(&v)[0]; }
#endif
#endif // __cplusplus
} XMVECTORU8;
typedef _DECLSPEC_ALIGN_16_ struct XMVECTORU32 {
union {
UINT u[4];
XMVECTOR v;
};
#if defined(__cplusplus)
inline operator XMVECTOR() const { return v; }
#if !defined(_XM_NO_INTRINSICS_) && defined(_XM_SSE_INTRINSICS_)
inline operator __m128i() const { return reinterpret_cast<const __m128i *>(&v)[0]; }
inline operator __m128d() const { return reinterpret_cast<const __m128d *>(&v)[0]; }
#endif
#endif // __cplusplus
} XMVECTORU32;
// Fix-up for (1st-3rd) XMVECTOR parameters that are pass-in-register for x86 and Xbox 360, but not for other targets
#if defined(_XM_VMX128_INTRINSICS_) && !defined(_XM_NO_INTRINSICS_)
typedef const XMVECTOR FXMVECTOR;
#elif defined(_XM_X86_) && !defined(_XM_NO_INTRINSICS_)
typedef const XMVECTOR FXMVECTOR;
#elif defined(__cplusplus)
typedef const XMVECTOR& FXMVECTOR;
#else
typedef const XMVECTOR FXMVECTOR;
#endif
// Fix-up for (4th+) XMVECTOR parameters to pass in-register for Xbox 360 and by reference otherwise
#if defined(_XM_VMX128_INTRINSICS_) && !defined(_XM_NO_INTRINSICS_)
typedef const XMVECTOR CXMVECTOR;
#elif defined(__cplusplus)
typedef const XMVECTOR& CXMVECTOR;
#else
typedef const XMVECTOR CXMVECTOR;
#endif
// Vector operators
#if defined(__cplusplus) && !defined(XM_NO_OPERATOR_OVERLOADS)
XMVECTOR operator+ (FXMVECTOR V);
XMVECTOR operator- (FXMVECTOR V);
XMVECTOR& operator+= (XMVECTOR& V1, FXMVECTOR V2);
XMVECTOR& operator-= (XMVECTOR& V1, FXMVECTOR V2);
XMVECTOR& operator*= (XMVECTOR& V1, FXMVECTOR V2);
XMVECTOR& operator/= (XMVECTOR& V1, FXMVECTOR V2);
XMVECTOR& operator*= (XMVECTOR& V, FLOAT S);
XMVECTOR& operator/= (XMVECTOR& V, FLOAT S);
XMVECTOR operator+ (FXMVECTOR V1, FXMVECTOR V2);
XMVECTOR operator- (FXMVECTOR V1, FXMVECTOR V2);
XMVECTOR operator* (FXMVECTOR V1, FXMVECTOR V2);
XMVECTOR operator/ (FXMVECTOR V1, FXMVECTOR V2);
XMVECTOR operator* (FXMVECTOR V, FLOAT S);
XMVECTOR operator* (FLOAT S, FXMVECTOR V);
XMVECTOR operator/ (FXMVECTOR V, FLOAT S);
#endif // __cplusplus && !XM_NO_OPERATOR_OVERLOADS
// Matrix type: Sixteen 32 bit floating point components aligned on a
// 16 byte boundary and mapped to four hardware vector registers
#if (defined(_XM_X86_) || defined(_XM_X64_)) && defined(_XM_NO_INTRINSICS_)
typedef struct _XMMATRIX
#else
typedef _DECLSPEC_ALIGN_16_ struct _XMMATRIX
#endif
{
union
{
XMVECTOR r[4];
struct
{
FLOAT _11, _12, _13, _14;
FLOAT _21, _22, _23, _24;
FLOAT _31, _32, _33, _34;
FLOAT _41, _42, _43, _44;
};
FLOAT m[4][4];
};
#ifdef __cplusplus
_XMMATRIX() {};
_XMMATRIX(FXMVECTOR R0, FXMVECTOR R1, FXMVECTOR R2, CXMVECTOR R3);
_XMMATRIX(FLOAT m00, FLOAT m01, FLOAT m02, FLOAT m03,
FLOAT m10, FLOAT m11, FLOAT m12, FLOAT m13,
FLOAT m20, FLOAT m21, FLOAT m22, FLOAT m23,
FLOAT m30, FLOAT m31, FLOAT m32, FLOAT m33);
_XMMATRIX(CONST FLOAT *pArray);
FLOAT operator() (UINT Row, UINT Column) CONST { return m[Row][Column]; }
FLOAT& operator() (UINT Row, UINT Column) { return m[Row][Column]; }
_XMMATRIX& operator= (CONST _XMMATRIX& M);
#ifndef XM_NO_OPERATOR_OVERLOADS
_XMMATRIX& operator*= (CONST _XMMATRIX& M);
_XMMATRIX operator* (CONST _XMMATRIX& M) CONST;
#endif // !XM_NO_OPERATOR_OVERLOADS
#endif // __cplusplus
} XMMATRIX;
// Fix-up for XMMATRIX parameters to pass in-register on Xbox 360, by reference otherwise
#if defined(_XM_VMX128_INTRINSICS_)
typedef const XMMATRIX CXMMATRIX;
#elif defined(__cplusplus)
typedef const XMMATRIX& CXMMATRIX;
#else
typedef const XMMATRIX CXMMATRIX;
#endif
// 16 bit floating point number consisting of a sign bit, a 5 bit biased
// exponent, and a 10 bit mantissa
//typedef WORD HALF;
typedef USHORT HALF;
// 2D Vector; 32 bit floating point components
typedef struct _XMFLOAT2
{
FLOAT x;
FLOAT y;
#ifdef __cplusplus
_XMFLOAT2() {};
_XMFLOAT2(FLOAT _x, FLOAT _y) : x(_x), y(_y) {};
_XMFLOAT2(CONST FLOAT *pArray);
_XMFLOAT2& operator= (CONST _XMFLOAT2& Float2);
#endif // __cplusplus
} XMFLOAT2;
// 2D Vector; 32 bit floating point components aligned on a 16 byte boundary
#ifdef __cplusplus
__declspec(align(16)) struct XMFLOAT2A : public XMFLOAT2
{
XMFLOAT2A() : XMFLOAT2() {};
XMFLOAT2A(FLOAT _x, FLOAT _y) : XMFLOAT2(_x, _y) {};
XMFLOAT2A(CONST FLOAT *pArray) : XMFLOAT2(pArray) {};
XMFLOAT2A& operator= (CONST XMFLOAT2A& Float2);
};
#else
typedef __declspec(align(16)) XMFLOAT2 XMFLOAT2A;
#endif // __cplusplus
// 2D Vector; 16 bit floating point components
typedef struct _XMHALF2
{
HALF x;
HALF y;
#ifdef __cplusplus
_XMHALF2() {};
_XMHALF2(HALF _x, HALF _y) : x(_x), y(_y) {};
_XMHALF2(CONST HALF *pArray);
_XMHALF2(FLOAT _x, FLOAT _y);
_XMHALF2(CONST FLOAT *pArray);
_XMHALF2& operator= (CONST _XMHALF2& Half2);
#endif // __cplusplus
} XMHALF2;
// 2D Vector; 16 bit signed normalized integer components
typedef struct _XMSHORTN2
{
SHORT x;
SHORT y;
#ifdef __cplusplus
_XMSHORTN2() {};
_XMSHORTN2(SHORT _x, SHORT _y) : x(_x), y(_y) {};
_XMSHORTN2(CONST SHORT *pArray);
_XMSHORTN2(FLOAT _x, FLOAT _y);
_XMSHORTN2(CONST FLOAT *pArray);
_XMSHORTN2& operator= (CONST _XMSHORTN2& ShortN2);
#endif // __cplusplus
} XMSHORTN2;
// 2D Vector; 16 bit signed integer components
typedef struct _XMSHORT2
{
SHORT x;
SHORT y;
#ifdef __cplusplus
_XMSHORT2() {};
_XMSHORT2(SHORT _x, SHORT _y) : x(_x), y(_y) {};
_XMSHORT2(CONST SHORT *pArray);
_XMSHORT2(FLOAT _x, FLOAT _y);
_XMSHORT2(CONST FLOAT *pArray);
_XMSHORT2& operator= (CONST _XMSHORT2& Short2);
#endif // __cplusplus
} XMSHORT2;
// 2D Vector; 16 bit unsigned normalized integer components
typedef struct _XMUSHORTN2
{
USHORT x;
USHORT y;
#ifdef __cplusplus
_XMUSHORTN2() {};
_XMUSHORTN2(USHORT _x, USHORT _y) : x(_x), y(_y) {};
_XMUSHORTN2(CONST USHORT *pArray);
_XMUSHORTN2(FLOAT _x, FLOAT _y);
_XMUSHORTN2(CONST FLOAT *pArray);
_XMUSHORTN2& operator= (CONST _XMUSHORTN2& UShortN2);
#endif // __cplusplus
} XMUSHORTN2;
// 2D Vector; 16 bit unsigned integer components
typedef struct _XMUSHORT2
{
USHORT x;
USHORT y;
#ifdef __cplusplus
_XMUSHORT2() {};
_XMUSHORT2(USHORT _x, USHORT _y) : x(_x), y(_y) {};
_XMUSHORT2(CONST USHORT *pArray);
_XMUSHORT2(FLOAT _x, FLOAT _y);
_XMUSHORT2(CONST FLOAT *pArray);
_XMUSHORT2& operator= (CONST _XMUSHORT2& UShort2);
#endif // __cplusplus
} XMUSHORT2;
// 3D Vector; 32 bit floating point components
typedef struct _XMFLOAT3
{
FLOAT x;
FLOAT y;
FLOAT z;
#ifdef __cplusplus
_XMFLOAT3() {};
_XMFLOAT3(FLOAT _x, FLOAT _y, FLOAT _z) : x(_x), y(_y), z(_z) {};
_XMFLOAT3(CONST FLOAT *pArray);
_XMFLOAT3& operator= (CONST _XMFLOAT3& Float3);
#endif // __cplusplus
} XMFLOAT3;
// 3D Vector; 32 bit floating point components aligned on a 16 byte boundary
#ifdef __cplusplus
__declspec(align(16)) struct XMFLOAT3A : public XMFLOAT3
{
XMFLOAT3A() : XMFLOAT3() {};
XMFLOAT3A(FLOAT _x, FLOAT _y, FLOAT _z) : XMFLOAT3(_x, _y, _z) {};
XMFLOAT3A(CONST FLOAT *pArray) : XMFLOAT3(pArray) {};
XMFLOAT3A& operator= (CONST XMFLOAT3A& Float3);
};
#else
typedef __declspec(align(16)) XMFLOAT3 XMFLOAT3A;
#endif // __cplusplus
// 3D Vector; 11-11-10 bit normalized components packed into a 32 bit integer
// The normalized 3D Vector is packed into 32 bits as follows: a 10 bit signed,
// normalized integer for the z component and 11 bit signed, normalized
// integers for the x and y components. The z component is stored in the
// most significant bits and the x component in the least significant bits
// (Z10Y11X11): [32] zzzzzzzz zzyyyyyy yyyyyxxx xxxxxxxx [0]
typedef struct _XMHENDN3
{
union
{
struct
{
INT x : 11; // -1023/1023 to 1023/1023
INT y : 11; // -1023/1023 to 1023/1023
INT z : 10; // -511/511 to 511/511
};
UINT v;
};
#ifdef __cplusplus
_XMHENDN3() {};
_XMHENDN3(UINT Packed) : v(Packed) {};
_XMHENDN3(FLOAT _x, FLOAT _y, FLOAT _z);
_XMHENDN3(CONST FLOAT *pArray);
operator UINT () { return v; }
_XMHENDN3& operator= (CONST _XMHENDN3& HenDN3);
_XMHENDN3& operator= (CONST UINT Packed);
#endif // __cplusplus
} XMHENDN3;
// 3D Vector; 11-11-10 bit components packed into a 32 bit integer
// The 3D Vector is packed into 32 bits as follows: a 10 bit signed,
// integer for the z component and 11 bit signed integers for the
// x and y components. The z component is stored in the
// most significant bits and the x component in the least significant bits
// (Z10Y11X11): [32] zzzzzzzz zzyyyyyy yyyyyxxx xxxxxxxx [0]
typedef struct _XMHEND3
{
union
{
struct
{
INT x : 11; // -1023 to 1023
INT y : 11; // -1023 to 1023
INT z : 10; // -511 to 511
};
UINT v;
};
#ifdef __cplusplus
_XMHEND3() {};
_XMHEND3(UINT Packed) : v(Packed) {};
_XMHEND3(FLOAT _x, FLOAT _y, FLOAT _z);
_XMHEND3(CONST FLOAT *pArray);
operator UINT () { return v; }
_XMHEND3& operator= (CONST _XMHEND3& HenD3);
_XMHEND3& operator= (CONST UINT Packed);
#endif // __cplusplus
} XMHEND3;
// 3D Vector; 11-11-10 bit normalized components packed into a 32 bit integer
// The normalized 3D Vector is packed into 32 bits as follows: a 10 bit unsigned,
// normalized integer for the z component and 11 bit unsigned, normalized
// integers for the x and y components. The z component is stored in the
// most significant bits and the x component in the least significant bits
// (Z10Y11X11): [32] zzzzzzzz zzyyyyyy yyyyyxxx xxxxxxxx [0]
typedef struct _XMUHENDN3
{
union
{
struct
{
UINT x : 11; // 0/2047 to 2047/2047
UINT y : 11; // 0/2047 to 2047/2047
UINT z : 10; // 0/1023 to 1023/1023
};
UINT v;
};
#ifdef __cplusplus
_XMUHENDN3() {};
_XMUHENDN3(UINT Packed) : v(Packed) {};
_XMUHENDN3(FLOAT _x, FLOAT _y, FLOAT _z);
_XMUHENDN3(CONST FLOAT *pArray);
operator UINT () { return v; }
_XMUHENDN3& operator= (CONST _XMUHENDN3& UHenDN3);
_XMUHENDN3& operator= (CONST UINT Packed);
#endif // __cplusplus
} XMUHENDN3;
// 3D Vector; 11-11-10 bit components packed into a 32 bit integer
// The 3D Vector is packed into 32 bits as follows: a 10 bit unsigned
// integer for the z component and 11 bit unsigned integers
// for the x and y components. The z component is stored in the
// most significant bits and the x component in the least significant bits
// (Z10Y11X11): [32] zzzzzzzz zzyyyyyy yyyyyxxx xxxxxxxx [0]
typedef struct _XMUHEND3
{
union
{
struct
{
UINT x : 11; // 0 to 2047
UINT y : 11; // 0 to 2047
UINT z : 10; // 0 to 1023
};
UINT v;
};
#ifdef __cplusplus
_XMUHEND3() {};
_XMUHEND3(UINT Packed) : v(Packed) {};
_XMUHEND3(FLOAT _x, FLOAT _y, FLOAT _z);
_XMUHEND3(CONST FLOAT *pArray);
operator UINT () { return v; }
_XMUHEND3& operator= (CONST _XMUHEND3& UHenD3);
_XMUHEND3& operator= (CONST UINT Packed);
#endif // __cplusplus
} XMUHEND3;
// 3D Vector; 10-11-11 bit normalized components packed into a 32 bit integer
// The normalized 3D Vector is packed into 32 bits as follows: a 10 bit signed,
// normalized integer for the x component and 11 bit signed, normalized
// integers for the y and z components. The z component is stored in the
// most significant bits and the x component in the least significant bits
// (Z11Y11X10): [32] zzzzzzzz zzzyyyyy yyyyyyxx xxxxxxxx [0]
typedef struct _XMDHENN3
{
union
{
struct
{
INT x : 10; // -511/511 to 511/511
INT y : 11; // -1023/1023 to 1023/1023
INT z : 11; // -1023/1023 to 1023/1023
};
UINT v;
};
#ifdef __cplusplus
_XMDHENN3() {};
_XMDHENN3(UINT Packed) : v(Packed) {};
_XMDHENN3(FLOAT _x, FLOAT _y, FLOAT _z);
_XMDHENN3(CONST FLOAT *pArray);
operator UINT () { return v; }
_XMDHENN3& operator= (CONST _XMDHENN3& DHenN3);
_XMDHENN3& operator= (CONST UINT Packed);
#endif // __cplusplus
} XMDHENN3;
// 3D Vector; 10-11-11 bit components packed into a 32 bit integer
// The 3D Vector is packed into 32 bits as follows: a 10 bit signed,
// integer for the x component and 11 bit signed integers for the
// y and z components. The w component is stored in the
// most significant bits and the x component in the least significant bits
// (Z11Y11X10): [32] zzzzzzzz zzzyyyyy yyyyyyxx xxxxxxxx [0]
typedef struct _XMDHEN3
{
union
{
struct
{
INT x : 10; // -511 to 511
INT y : 11; // -1023 to 1023
INT z : 11; // -1023 to 1023
};
UINT v;
};
#ifdef __cplusplus
_XMDHEN3() {};
_XMDHEN3(UINT Packed) : v(Packed) {};
_XMDHEN3(FLOAT _x, FLOAT _y, FLOAT _z);
_XMDHEN3(CONST FLOAT *pArray);
operator UINT () { return v; }
_XMDHEN3& operator= (CONST _XMDHEN3& DHen3);
_XMDHEN3& operator= (CONST UINT Packed);
#endif // __cplusplus
} XMDHEN3;
// 3D Vector; 10-11-11 bit normalized components packed into a 32 bit integer
// The normalized 3D Vector is packed into 32 bits as follows: a 10 bit unsigned,
// normalized integer for the x component and 11 bit unsigned, normalized
// integers for the y and z components. The w component is stored in the
// most significant bits and the x component in the least significant bits
// (Z11Y11X10): [32] zzzzzzzz zzzyyyyy yyyyyyxx xxxxxxxx [0]
typedef struct _XMUDHENN3
{
union
{
struct
{
UINT x : 10; // 0/1023 to 1023/1023
UINT y : 11; // 0/2047 to 2047/2047
UINT z : 11; // 0/2047 to 2047/2047
};
UINT v;
};
#ifdef __cplusplus
_XMUDHENN3() {};
_XMUDHENN3(UINT Packed) : v(Packed) {};
_XMUDHENN3(FLOAT _x, FLOAT _y, FLOAT _z);
_XMUDHENN3(CONST FLOAT *pArray);
operator UINT () { return v; }
_XMUDHENN3& operator= (CONST _XMUDHENN3& UDHenN3);
_XMUDHENN3& operator= (CONST UINT Packed);
#endif // __cplusplus
} XMUDHENN3;
// 3D Vector; 10-11-11 bit components packed into a 32 bit integer
// The 3D Vector is packed into 32 bits as follows: a 10 bit unsigned,
// integer for the x component and 11 bit unsigned integers
// for the y and z components. The w component is stored in the
// most significant bits and the x component in the least significant bits
// (Z11Y11X10): [32] zzzzzzzz zzzyyyyy yyyyyyxx xxxxxxxx [0]
typedef struct _XMUDHEN3
{
union
{
struct
{
UINT x : 10; // 0 to 1023
UINT y : 11; // 0 to 2047
UINT z : 11; // 0 to 2047
};
UINT v;
};
#ifdef __cplusplus
_XMUDHEN3() {};
_XMUDHEN3(UINT Packed) : v(Packed) {};
_XMUDHEN3(FLOAT _x, FLOAT _y, FLOAT _z);
_XMUDHEN3(CONST FLOAT *pArray);
operator UINT () { return v; }
_XMUDHEN3& operator= (CONST _XMUDHEN3& UDHen3);
_XMUDHEN3& operator= (CONST UINT Packed);
#endif // __cplusplus
} XMUDHEN3;
// 3D vector: 5/6/5 unsigned integer components
typedef struct _XMU565
{
union
{
struct
{
USHORT x : 5;
USHORT y : 6;
USHORT z : 5;
};
USHORT v;
};
#ifdef __cplusplus
_XMU565() {};
_XMU565(USHORT Packed) : v(Packed) {};
_XMU565(CHAR _x, CHAR _y, CHAR _z) : x(_x), y(_y), z(_z) {};
_XMU565(CONST CHAR *pArray);
_XMU565(FLOAT _x, FLOAT _y, FLOAT _z);
_XMU565(CONST FLOAT *pArray);
operator USHORT () { return v; }
_XMU565& operator= (CONST _XMU565& U565);
_XMU565& operator= (CONST USHORT Packed);
#endif // __cplusplus
} XMU565;
// 3D vector: 11/11/10 floating-point components
// The 3D vector is packed into 32 bits as follows: a 5-bit biased exponent
// and 6-bit mantissa for x component, a 5-bit biased exponent and
// 6-bit mantissa for y component, a 5-bit biased exponent and a 5-bit
// mantissa for z. The z component is stored in the most significant bits
// and the x component in the least significant bits. No sign bits so
// all partial-precision numbers are positive.
// (Z10Y11X11): [32] ZZZZZzzz zzzYYYYY yyyyyyXX XXXxxxxx [0]
typedef struct _XMFLOAT3PK
{
union
{
struct
{
UINT xm : 6;
UINT xe : 5;
UINT ym : 6;
UINT ye : 5;
UINT zm : 5;
UINT ze : 5;
};
UINT v;
};
#ifdef __cplusplus
_XMFLOAT3PK() {};
_XMFLOAT3PK(UINT Packed) : v(Packed) {};
_XMFLOAT3PK(FLOAT _x, FLOAT _y, FLOAT _z);
_XMFLOAT3PK(CONST FLOAT *pArray);
operator UINT () { return v; }
_XMFLOAT3PK& operator= (CONST _XMFLOAT3PK& float3pk);
_XMFLOAT3PK& operator= (CONST UINT Packed);
#endif // __cplusplus
} XMFLOAT3PK;
// 3D vector: 9/9/9 floating-point components with shared 5-bit exponent
// The 3D vector is packed into 32 bits as follows: a 5-bit biased exponent
// with 9-bit mantissa for the x, y, and z component. The shared exponent
// is stored in the most significant bits and the x component mantissa is in
// the least significant bits. No sign bits so all partial-precision numbers
// are positive.
// (E5Z9Y9X9): [32] EEEEEzzz zzzzzzyy yyyyyyyx xxxxxxxx [0]
typedef struct _XMFLOAT3SE
{
union
{
struct
{
UINT xm : 9;
UINT ym : 9;
UINT zm : 9;
UINT e : 5;
};
UINT v;
};
#ifdef __cplusplus
_XMFLOAT3SE() {};
_XMFLOAT3SE(UINT Packed) : v(Packed) {};
_XMFLOAT3SE(FLOAT _x, FLOAT _y, FLOAT _z);
_XMFLOAT3SE(CONST FLOAT *pArray);
operator UINT () { return v; }
_XMFLOAT3SE& operator= (CONST _XMFLOAT3SE& float3se);
_XMFLOAT3SE& operator= (CONST UINT Packed);
#endif // __cplusplus
} XMFLOAT3SE;
// 4D Vector; 32 bit floating point components
typedef struct _XMFLOAT4
{
FLOAT x;
FLOAT y;
FLOAT z;
FLOAT w;
#ifdef __cplusplus
_XMFLOAT4() {};
_XMFLOAT4(FLOAT _x, FLOAT _y, FLOAT _z, FLOAT _w) : x(_x), y(_y), z(_z), w(_w) {};
_XMFLOAT4(CONST FLOAT *pArray);
_XMFLOAT4& operator= (CONST _XMFLOAT4& Float4);
#endif // __cplusplus
} XMFLOAT4;
// 4D Vector; 32 bit floating point components aligned on a 16 byte boundary
#ifdef __cplusplus
__declspec(align(16)) struct XMFLOAT4A : public XMFLOAT4
{
XMFLOAT4A() : XMFLOAT4() {};
XMFLOAT4A(FLOAT _x, FLOAT _y, FLOAT _z, FLOAT _w) : XMFLOAT4(_x, _y, _z, _w) {};
XMFLOAT4A(CONST FLOAT *pArray) : XMFLOAT4(pArray) {};
XMFLOAT4A& operator= (CONST XMFLOAT4A& Float4);
};
#else
typedef __declspec(align(16)) XMFLOAT4 XMFLOAT4A;
#endif // __cplusplus
// 4D Vector; 16 bit floating point components
typedef struct _XMHALF4
{
HALF x;
HALF y;
HALF z;
HALF w;
#ifdef __cplusplus
_XMHALF4() {};
_XMHALF4(HALF _x, HALF _y, HALF _z, HALF _w) : x(_x), y(_y), z(_z), w(_w) {};
_XMHALF4(CONST HALF *pArray);
_XMHALF4(FLOAT _x, FLOAT _y, FLOAT _z, FLOAT _w);
_XMHALF4(CONST FLOAT *pArray);
_XMHALF4& operator= (CONST _XMHALF4& Half4);
#endif // __cplusplus
} XMHALF4;
// 4D Vector; 16 bit signed normalized integer components
typedef struct _XMSHORTN4
{