VirtualBox

source: vbox/trunk/src/VBox/Devices/Graphics/shaderlib/wine/include/d3dx9math.inl@ 69505

Last change on this file since 69505 was 69505, checked in by vboxsync, 7 years ago

More scm updates

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 31.3 KB
Line 
1/*
2 * Copyright (C) 2007 David Adam
3 * Copyright (C) 2007 Tony Wasserka
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
9 *
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
14 *
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
18 */
19
20/*
21 * Oracle LGPL Disclaimer: For the avoidance of doubt, except that if any license choice
22 * other than GPL or LGPL is available it will apply instead, Oracle elects to use only
23 * the Lesser General Public License version 2.1 (LGPLv2) at this time for any software where
24 * a choice of LGPL license versions is made available with the language indicating
25 * that LGPLv2 or any later version may be used, or where a choice of which version
26 * of the LGPL is applied is otherwise unspecified.
27 */
28
29#ifndef __D3DX9MATH_INL__
30#define __D3DX9MATH_INL__
31
32/* constructors & operators */
33#ifdef __cplusplus
34
35inline D3DXVECTOR2::D3DXVECTOR2()
36{
37}
38
39inline D3DXVECTOR2::D3DXVECTOR2(const FLOAT *pf)
40{
41 if(!pf) return;
42 x = pf[0];
43 y = pf[1];
44}
45
46inline D3DXVECTOR2::D3DXVECTOR2(FLOAT fx, FLOAT fy)
47{
48 x = fx;
49 y = fy;
50}
51
52inline D3DXVECTOR2::operator FLOAT* ()
53{
54 return (FLOAT*)&x;
55}
56
57inline D3DXVECTOR2::operator const FLOAT* () const
58{
59 return (const FLOAT*)&x;
60}
61
62inline D3DXVECTOR2& D3DXVECTOR2::operator += (const D3DXVECTOR2& v)
63{
64 x += v.x;
65 y += v.y;
66 return *this;
67}
68
69inline D3DXVECTOR2& D3DXVECTOR2::operator -= (const D3DXVECTOR2& v)
70{
71 x -= v.x;
72 y -= v.y;
73 return *this;
74}
75
76inline D3DXVECTOR2& D3DXVECTOR2::operator *= (FLOAT f)
77{
78 x *= f;
79 y *= f;
80 return *this;
81}
82
83inline D3DXVECTOR2& D3DXVECTOR2::operator /= (FLOAT f)
84{
85 x /= f;
86 y /= f;
87 return *this;
88}
89
90inline D3DXVECTOR2 D3DXVECTOR2::operator + () const
91{
92 return *this;
93}
94
95inline D3DXVECTOR2 D3DXVECTOR2::operator - () const
96{
97 return D3DXVECTOR2(-x, -y);
98}
99
100inline D3DXVECTOR2 D3DXVECTOR2::operator + (const D3DXVECTOR2& v) const
101{
102 return D3DXVECTOR2(x + v.x, y + v.y);
103}
104
105inline D3DXVECTOR2 D3DXVECTOR2::operator - (const D3DXVECTOR2& v) const
106{
107 return D3DXVECTOR2(x - v.x, y - v.y);
108}
109
110inline D3DXVECTOR2 D3DXVECTOR2::operator * (FLOAT f) const
111{
112 return D3DXVECTOR2(x * f, y * f);
113}
114
115inline D3DXVECTOR2 D3DXVECTOR2::operator / (FLOAT f) const
116{
117 return D3DXVECTOR2(x / f, y / f);
118}
119
120inline D3DXVECTOR2 operator * (FLOAT f, const D3DXVECTOR2& v)
121{
122 return D3DXVECTOR2(f * v.x, f * v.y);
123}
124
125inline BOOL D3DXVECTOR2::operator == (const D3DXVECTOR2& v) const
126{
127 return x == v.x && y == v.y;
128}
129
130inline BOOL D3DXVECTOR2::operator != (const D3DXVECTOR2& v) const
131{
132 return x != v.x || y != v.y;
133}
134
135inline D3DXVECTOR3::D3DXVECTOR3()
136{
137}
138
139inline D3DXVECTOR3::D3DXVECTOR3(const FLOAT *pf)
140{
141 if(!pf) return;
142 x = pf[0];
143 y = pf[1];
144 z = pf[2];
145}
146
147inline D3DXVECTOR3::D3DXVECTOR3(const D3DVECTOR& v)
148{
149 x = v.x;
150 y = v.y;
151 z = v.z;
152}
153
154inline D3DXVECTOR3::D3DXVECTOR3(FLOAT fx, FLOAT fy, FLOAT fz)
155{
156 x = fx;
157 y = fy;
158 z = fz;
159}
160
161inline D3DXVECTOR3::operator FLOAT* ()
162{
163 return (FLOAT*)&x;
164}
165
166inline D3DXVECTOR3::operator const FLOAT* () const
167{
168 return (const FLOAT*)&x;
169}
170
171inline D3DXVECTOR3& D3DXVECTOR3::operator += (const D3DXVECTOR3& v)
172{
173 x += v.x;
174 y += v.y;
175 z += v.z;
176 return *this;
177}
178
179inline D3DXVECTOR3& D3DXVECTOR3::operator -= (const D3DXVECTOR3& v)
180{
181 x -= v.x;
182 y -= v.y;
183 z -= v.z;
184 return *this;
185}
186
187inline D3DXVECTOR3& D3DXVECTOR3::operator *= (FLOAT f)
188{
189 x *= f;
190 y *= f;
191 z *= f;
192 return *this;
193}
194
195inline D3DXVECTOR3& D3DXVECTOR3::operator /= (FLOAT f)
196{
197 x /= f;
198 y /= f;
199 z /= f;
200 return *this;
201}
202
203inline D3DXVECTOR3 D3DXVECTOR3::operator + () const
204{
205 return *this;
206}
207
208inline D3DXVECTOR3 D3DXVECTOR3::operator - () const
209{
210 return D3DXVECTOR3(-x, -y, -z);
211}
212
213inline D3DXVECTOR3 D3DXVECTOR3::operator + (const D3DXVECTOR3& v) const
214{
215 return D3DXVECTOR3(x + v.x, y + v.y, z + v.z);
216}
217
218inline D3DXVECTOR3 D3DXVECTOR3::operator - (const D3DXVECTOR3& v) const
219{
220 return D3DXVECTOR3(x - v.x, y - v.y, z - v.z);
221}
222
223inline D3DXVECTOR3 D3DXVECTOR3::operator * (FLOAT f) const
224{
225 return D3DXVECTOR3(x * f, y * f, z * f);
226}
227
228inline D3DXVECTOR3 D3DXVECTOR3::operator / (FLOAT f) const
229{
230 return D3DXVECTOR3(x / f, y / f, z / f);
231}
232
233inline D3DXVECTOR3 operator * (FLOAT f, const D3DXVECTOR3& v)
234{
235 return D3DXVECTOR3(f * v.x, f * v.y, f * v.z);
236}
237
238inline BOOL D3DXVECTOR3::operator == (const D3DXVECTOR3& v) const
239{
240 return x == v.x && y == v.y && z == v.z;
241}
242
243inline BOOL D3DXVECTOR3::operator != (const D3DXVECTOR3& v) const
244{
245 return x != v.x || y != v.y || z != v.z;
246}
247
248inline D3DXVECTOR4::D3DXVECTOR4()
249{
250}
251
252inline D3DXVECTOR4::D3DXVECTOR4(const FLOAT *pf)
253{
254 if(!pf) return;
255 x = pf[0];
256 y = pf[1];
257 z = pf[2];
258 w = pf[3];
259}
260
261inline D3DXVECTOR4::D3DXVECTOR4(FLOAT fx, FLOAT fy, FLOAT fz, FLOAT fw)
262{
263 x = fx;
264 y = fy;
265 z = fz;
266 w = fw;
267}
268
269inline D3DXVECTOR4::operator FLOAT* ()
270{
271 return (FLOAT*)&x;
272}
273
274inline D3DXVECTOR4::operator const FLOAT* () const
275{
276 return (const FLOAT*)&x;
277}
278
279inline D3DXVECTOR4& D3DXVECTOR4::operator += (const D3DXVECTOR4& v)
280{
281 x += v.x;
282 y += v.y;
283 z += v.z;
284 w += v.w;
285 return *this;
286}
287
288inline D3DXVECTOR4& D3DXVECTOR4::operator -= (const D3DXVECTOR4& v)
289{
290 x -= v.x;
291 y -= v.y;
292 z -= v.z;
293 w -= v.w;
294 return *this;
295}
296
297inline D3DXVECTOR4& D3DXVECTOR4::operator *= (FLOAT f)
298{
299 x *= f;
300 y *= f;
301 z *= f;
302 w *= f;
303 return *this;
304}
305
306inline D3DXVECTOR4& D3DXVECTOR4::operator /= (FLOAT f)
307{
308 x /= f;
309 y /= f;
310 z /= f;
311 w /= f;
312 return *this;
313}
314
315inline D3DXVECTOR4 D3DXVECTOR4::operator + () const
316{
317 return *this;
318}
319
320inline D3DXVECTOR4 D3DXVECTOR4::operator - () const
321{
322 return D3DXVECTOR4(-x, -y, -z, -w);
323}
324
325inline D3DXVECTOR4 D3DXVECTOR4::operator + (const D3DXVECTOR4& v) const
326{
327 return D3DXVECTOR4(x + v.x, y + v.y, z + v.z, w + v.w);
328}
329
330inline D3DXVECTOR4 D3DXVECTOR4::operator - (const D3DXVECTOR4& v) const
331{
332 return D3DXVECTOR4(x - v.x, y - v.y, z - v.z, w - v.w);
333}
334
335inline D3DXVECTOR4 D3DXVECTOR4::operator * (FLOAT f) const
336{
337 return D3DXVECTOR4(x * f, y * f, z * f, w * f);
338}
339
340inline D3DXVECTOR4 D3DXVECTOR4::operator / (FLOAT f) const
341{
342 return D3DXVECTOR4(x / f, y / f, z / f, w / f);
343}
344
345inline D3DXVECTOR4 operator * (FLOAT f, const D3DXVECTOR4& v)
346{
347 return D3DXVECTOR4(f * v.x, f * v.y, f * v.z, f * v.w);
348}
349
350inline BOOL D3DXVECTOR4::operator == (const D3DXVECTOR4& v) const
351{
352 return x == v.x && y == v.y && z == v.z && w == v.w;
353}
354
355inline BOOL D3DXVECTOR4::operator != (const D3DXVECTOR4& v) const
356{
357 return x != v.x || y != v.y || z != v.z || w != v.w;
358}
359
360inline D3DXMATRIX::D3DXMATRIX()
361{
362}
363
364inline D3DXMATRIX::D3DXMATRIX(const FLOAT *pf)
365{
366 if(!pf) return;
367 memcpy(&_11, pf, sizeof(D3DXMATRIX));
368}
369
370inline D3DXMATRIX::D3DXMATRIX(const D3DMATRIX& mat)
371{
372 memcpy(&_11, &mat, sizeof(D3DXMATRIX));
373}
374
375inline D3DXMATRIX::D3DXMATRIX(FLOAT f11, FLOAT f12, FLOAT f13, FLOAT f14,
376 FLOAT f21, FLOAT f22, FLOAT f23, FLOAT f24,
377 FLOAT f31, FLOAT f32, FLOAT f33, FLOAT f34,
378 FLOAT f41, FLOAT f42, FLOAT f43, FLOAT f44)
379{
380 _11 = f11; _12 = f12; _13 = f13; _14 = f14;
381 _21 = f21; _22 = f22; _23 = f23; _24 = f24;
382 _31 = f31; _32 = f32; _33 = f33; _34 = f34;
383 _41 = f41; _42 = f42; _43 = f43; _44 = f44;
384}
385
386inline FLOAT& D3DXMATRIX::operator () (UINT row, UINT col)
387{
388 return m[row][col];
389}
390
391inline FLOAT D3DXMATRIX::operator () (UINT row, UINT col) const
392{
393 return m[row][col];
394}
395
396inline D3DXMATRIX::operator FLOAT* ()
397{
398 return (FLOAT*)&_11;
399}
400
401inline D3DXMATRIX::operator const FLOAT* () const
402{
403 return (const FLOAT*)&_11;
404}
405
406inline D3DXMATRIX& D3DXMATRIX::operator *= (const D3DXMATRIX& mat)
407{
408 D3DXMatrixMultiply(this, this, &mat);
409 return *this;
410}
411
412inline D3DXMATRIX& D3DXMATRIX::operator += (const D3DXMATRIX& mat)
413{
414 _11 += mat._11; _12 += mat._12; _13 += mat._13; _14 += mat._14;
415 _21 += mat._21; _22 += mat._22; _23 += mat._23; _24 += mat._24;
416 _31 += mat._31; _32 += mat._32; _33 += mat._33; _34 += mat._34;
417 _41 += mat._41; _42 += mat._42; _43 += mat._43; _44 += mat._44;
418 return *this;
419}
420
421inline D3DXMATRIX& D3DXMATRIX::operator -= (const D3DXMATRIX& mat)
422{
423 _11 -= mat._11; _12 -= mat._12; _13 -= mat._13; _14 -= mat._14;
424 _21 -= mat._21; _22 -= mat._22; _23 -= mat._23; _24 -= mat._24;
425 _31 -= mat._31; _32 -= mat._32; _33 -= mat._33; _34 -= mat._34;
426 _41 -= mat._41; _42 -= mat._42; _43 -= mat._43; _44 -= mat._44;
427 return *this;
428}
429
430inline D3DXMATRIX& D3DXMATRIX::operator *= (FLOAT f)
431{
432 _11 *= f; _12 *= f; _13 *= f; _14 *= f;
433 _21 *= f; _22 *= f; _23 *= f; _24 *= f;
434 _31 *= f; _32 *= f; _33 *= f; _34 *= f;
435 _41 *= f; _42 *= f; _43 *= f; _44 *= f;
436 return *this;
437}
438
439inline D3DXMATRIX& D3DXMATRIX::operator /= (FLOAT f)
440{
441 FLOAT inv = 1.0f / f;
442 _11 *= inv; _12 *= inv; _13 *= inv; _14 *= inv;
443 _21 *= inv; _22 *= inv; _23 *= inv; _24 *= inv;
444 _31 *= inv; _32 *= inv; _33 *= inv; _34 *= inv;
445 _41 *= inv; _42 *= inv; _43 *= inv; _44 *= inv;
446 return *this;
447}
448
449inline D3DXMATRIX D3DXMATRIX::operator + () const
450{
451 return *this;
452}
453
454inline D3DXMATRIX D3DXMATRIX::operator - () const
455{
456 return D3DXMATRIX(-_11, -_12, -_13, -_14,
457 -_21, -_22, -_23, -_24,
458 -_31, -_32, -_33, -_34,
459 -_41, -_42, -_43, -_44);
460}
461
462inline D3DXMATRIX D3DXMATRIX::operator * (const D3DXMATRIX& mat) const
463{
464 D3DXMATRIX buf;
465 D3DXMatrixMultiply(&buf, this, &mat);
466 return buf;
467}
468
469inline D3DXMATRIX D3DXMATRIX::operator + (const D3DXMATRIX& mat) const
470{
471 return D3DXMATRIX(_11 + mat._11, _12 + mat._12, _13 + mat._13, _14 + mat._14,
472 _21 + mat._21, _22 + mat._22, _23 + mat._23, _24 + mat._24,
473 _31 + mat._31, _32 + mat._32, _33 + mat._33, _34 + mat._34,
474 _41 + mat._41, _42 + mat._42, _43 + mat._43, _44 + mat._44);
475}
476
477inline D3DXMATRIX D3DXMATRIX::operator - (const D3DXMATRIX& mat) const
478{
479 return D3DXMATRIX(_11 - mat._11, _12 - mat._12, _13 - mat._13, _14 - mat._14,
480 _21 - mat._21, _22 - mat._22, _23 - mat._23, _24 - mat._24,
481 _31 - mat._31, _32 - mat._32, _33 - mat._33, _34 - mat._34,
482 _41 - mat._41, _42 - mat._42, _43 - mat._43, _44 - mat._44);
483}
484
485inline D3DXMATRIX D3DXMATRIX::operator * (FLOAT f) const
486{
487 return D3DXMATRIX(_11 * f, _12 * f, _13 * f, _14 * f,
488 _21 * f, _22 * f, _23 * f, _24 * f,
489 _31 * f, _32 * f, _33 * f, _34 * f,
490 _41 * f, _42 * f, _43 * f, _44 * f);
491}
492
493inline D3DXMATRIX D3DXMATRIX::operator / (FLOAT f) const
494{
495 FLOAT inv = 1.0f / f;
496 return D3DXMATRIX(_11 * inv, _12 * inv, _13 * inv, _14 * inv,
497 _21 * inv, _22 * inv, _23 * inv, _24 * inv,
498 _31 * inv, _32 * inv, _33 * inv, _34 * inv,
499 _41 * inv, _42 * inv, _43 * inv, _44 * inv);
500}
501
502inline D3DXMATRIX operator * (FLOAT f, const D3DXMATRIX& mat)
503{
504 return D3DXMATRIX(f * mat._11, f * mat._12, f * mat._13, f * mat._14,
505 f * mat._21, f * mat._22, f * mat._23, f * mat._24,
506 f * mat._31, f * mat._32, f * mat._33, f * mat._34,
507 f * mat._41, f * mat._42, f * mat._43, f * mat._44);
508}
509
510inline BOOL D3DXMATRIX::operator == (const D3DXMATRIX& mat) const
511{
512 return (memcmp(this, &mat, sizeof(D3DXMATRIX)) == 0);
513}
514
515inline BOOL D3DXMATRIX::operator != (const D3DXMATRIX& mat) const
516{
517 return (memcmp(this, &mat, sizeof(D3DXMATRIX)) != 0);
518}
519
520inline D3DXQUATERNION::D3DXQUATERNION()
521{
522}
523
524inline D3DXQUATERNION::D3DXQUATERNION(const FLOAT *pf)
525{
526 if(!pf) return;
527 x = pf[0];
528 y = pf[1];
529 z = pf[2];
530 w = pf[3];
531}
532
533inline D3DXQUATERNION::D3DXQUATERNION(FLOAT fx, FLOAT fy, FLOAT fz, FLOAT fw)
534{
535 x = fx;
536 y = fy;
537 z = fz;
538 w = fw;
539}
540
541inline D3DXQUATERNION::operator FLOAT* ()
542{
543 return (FLOAT*)&x;
544}
545
546inline D3DXQUATERNION::operator const FLOAT* () const
547{
548 return (const FLOAT*)&x;
549}
550
551inline D3DXQUATERNION& D3DXQUATERNION::operator += (const D3DXQUATERNION& quat)
552{
553 x += quat.x;
554 y += quat.y;
555 z += quat.z;
556 w += quat.w;
557 return *this;
558}
559
560inline D3DXQUATERNION& D3DXQUATERNION::operator -= (const D3DXQUATERNION& quat)
561{
562 x -= quat.x;
563 y -= quat.y;
564 z -= quat.z;
565 w -= quat.w;
566 return *this;
567}
568
569inline D3DXQUATERNION& D3DXQUATERNION::operator *= (const D3DXQUATERNION& quat)
570{
571 D3DXQuaternionMultiply(this, this, &quat);
572 return *this;
573}
574
575inline D3DXQUATERNION& D3DXQUATERNION::operator *= (FLOAT f)
576{
577 x *= f;
578 y *= f;
579 z *= f;
580 w *= f;
581 return *this;
582}
583
584inline D3DXQUATERNION& D3DXQUATERNION::operator /= (FLOAT f)
585{
586 FLOAT inv = 1.0f / f;
587 x *= inv;
588 y *= inv;
589 z *= inv;
590 w *= inv;
591 return *this;
592}
593
594inline D3DXQUATERNION D3DXQUATERNION::operator + () const
595{
596 return *this;
597}
598
599inline D3DXQUATERNION D3DXQUATERNION::operator - () const
600{
601 return D3DXQUATERNION(-x, -y, -z, -w);
602}
603
604inline D3DXQUATERNION D3DXQUATERNION::operator + (const D3DXQUATERNION& quat) const
605{
606 return D3DXQUATERNION(x + quat.x, y + quat.y, z + quat.z, w + quat.w);
607}
608
609inline D3DXQUATERNION D3DXQUATERNION::operator - (const D3DXQUATERNION& quat) const
610{
611 return D3DXQUATERNION(x - quat.x, y - quat.y, z - quat.z, w - quat.w);
612}
613
614inline D3DXQUATERNION D3DXQUATERNION::operator * (const D3DXQUATERNION& quat) const
615{
616 D3DXQUATERNION buf;
617 D3DXQuaternionMultiply(&buf, this, &quat);
618 return buf;
619}
620
621inline D3DXQUATERNION D3DXQUATERNION::operator * (FLOAT f) const
622{
623 return D3DXQUATERNION(x * f, y * f, z * f, w * f);
624}
625
626inline D3DXQUATERNION D3DXQUATERNION::operator / (FLOAT f) const
627{
628 FLOAT inv = 1.0f / f;
629 return D3DXQUATERNION(x * inv, y * inv, z * inv, w * inv);
630}
631
632inline D3DXQUATERNION operator * (FLOAT f, const D3DXQUATERNION& quat)
633{
634 return D3DXQUATERNION(f * quat.x, f * quat.y, f * quat.z, f * quat.w);
635}
636
637inline BOOL D3DXQUATERNION::operator == (const D3DXQUATERNION& quat) const
638{
639 return x == quat.x && y == quat.y && z == quat.z && w == quat.w;
640}
641
642inline BOOL D3DXQUATERNION::operator != (const D3DXQUATERNION& quat) const
643{
644 return x != quat.x || y != quat.y || z != quat.z || w != quat.w;
645}
646
647inline D3DXPLANE::D3DXPLANE()
648{
649}
650
651inline D3DXPLANE::D3DXPLANE(const FLOAT *pf)
652{
653 if(!pf) return;
654 a = pf[0];
655 b = pf[1];
656 c = pf[2];
657 d = pf[3];
658}
659
660inline D3DXPLANE::D3DXPLANE(FLOAT fa, FLOAT fb, FLOAT fc, FLOAT fd)
661{
662 a = fa;
663 b = fb;
664 c = fc;
665 d = fd;
666}
667
668inline D3DXPLANE::operator FLOAT* ()
669{
670 return (FLOAT*)&a;
671}
672
673inline D3DXPLANE::operator const FLOAT* () const
674{
675 return (const FLOAT*)&a;
676}
677
678inline D3DXPLANE D3DXPLANE::operator + () const
679{
680 return *this;
681}
682
683inline D3DXPLANE D3DXPLANE::operator - () const
684{
685 return D3DXPLANE(-a, -b, -c, -d);
686}
687
688inline BOOL D3DXPLANE::operator == (const D3DXPLANE& pl) const
689{
690 return a == pl.a && b == pl.b && c == pl.c && d == pl.d;
691}
692
693inline BOOL D3DXPLANE::operator != (const D3DXPLANE& pl) const
694{
695 return a != pl.a || b != pl.b || c != pl.c || d != pl.d;
696}
697
698inline D3DXCOLOR::D3DXCOLOR()
699{
700}
701
702inline D3DXCOLOR::D3DXCOLOR(DWORD col)
703{
704 const FLOAT f = 1.0f / 255.0f;
705 r = f * (FLOAT)(unsigned char)(col >> 16);
706 g = f * (FLOAT)(unsigned char)(col >> 8);
707 b = f * (FLOAT)(unsigned char)col;
708 a = f * (FLOAT)(unsigned char)(col >> 24);
709}
710
711inline D3DXCOLOR::D3DXCOLOR(const FLOAT *pf)
712{
713 if(!pf) return;
714 r = pf[0];
715 g = pf[1];
716 b = pf[2];
717 a = pf[3];
718}
719
720inline D3DXCOLOR::D3DXCOLOR(const D3DCOLORVALUE& col)
721{
722 r = col.r;
723 g = col.g;
724 b = col.b;
725 a = col.a;
726}
727
728inline D3DXCOLOR::D3DXCOLOR(FLOAT fr, FLOAT fg, FLOAT fb, FLOAT fa)
729{
730 r = fr;
731 g = fg;
732 b = fb;
733 a = fa;
734}
735
736inline D3DXCOLOR::operator DWORD () const
737{
738 DWORD _r = r >= 1.0f ? 0xff : r <= 0.0f ? 0x00 : (DWORD)(r * 255.0f + 0.5f);
739 DWORD _g = g >= 1.0f ? 0xff : g <= 0.0f ? 0x00 : (DWORD)(g * 255.0f + 0.5f);
740 DWORD _b = b >= 1.0f ? 0xff : b <= 0.0f ? 0x00 : (DWORD)(b * 255.0f + 0.5f);
741 DWORD _a = a >= 1.0f ? 0xff : a <= 0.0f ? 0x00 : (DWORD)(a * 255.0f + 0.5f);
742
743 return (_a << 24) | (_r << 16) | (_g << 8) | _b;
744}
745
746inline D3DXCOLOR::operator FLOAT * ()
747{
748 return (FLOAT*)&r;
749}
750
751inline D3DXCOLOR::operator const FLOAT * () const
752{
753 return (const FLOAT*)&r;
754}
755
756inline D3DXCOLOR::operator D3DCOLORVALUE * ()
757{
758 return (D3DCOLORVALUE*)&r;
759}
760
761inline D3DXCOLOR::operator const D3DCOLORVALUE * () const
762{
763 return (const D3DCOLORVALUE*)&r;
764}
765
766inline D3DXCOLOR::operator D3DCOLORVALUE& ()
767{
768 return *((D3DCOLORVALUE*)&r);
769}
770
771inline D3DXCOLOR::operator const D3DCOLORVALUE& () const
772{
773 return *((const D3DCOLORVALUE*)&r);
774}
775
776inline D3DXCOLOR& D3DXCOLOR::operator += (const D3DXCOLOR& col)
777{
778 r += col.r;
779 g += col.g;
780 b += col.b;
781 a += col.a;
782 return *this;
783}
784
785inline D3DXCOLOR& D3DXCOLOR::operator -= (const D3DXCOLOR& col)
786{
787 r -= col.r;
788 g -= col.g;
789 b -= col.b;
790 a -= col.a;
791 return *this;
792}
793
794inline D3DXCOLOR& D3DXCOLOR::operator *= (FLOAT f)
795{
796 r *= f;
797 g *= f;
798 b *= f;
799 a *= f;
800 return *this;
801}
802
803inline D3DXCOLOR& D3DXCOLOR::operator /= (FLOAT f)
804{
805 FLOAT inv = 1.0f / f;
806 r *= inv;
807 g *= inv;
808 b *= inv;
809 a *= inv;
810 return *this;
811}
812
813inline D3DXCOLOR D3DXCOLOR::operator + () const
814{
815 return *this;
816}
817
818inline D3DXCOLOR D3DXCOLOR::operator - () const
819{
820 return D3DXCOLOR(-r, -g, -b, -a);
821}
822
823inline D3DXCOLOR D3DXCOLOR::operator + (const D3DXCOLOR& col) const
824{
825 return D3DXCOLOR(r + col.r, g + col.g, b + col.b, a + col.a);
826}
827
828inline D3DXCOLOR D3DXCOLOR::operator - (const D3DXCOLOR& col) const
829{
830 return D3DXCOLOR(r - col.r, g - col.g, b - col.b, a - col.a);
831}
832
833inline D3DXCOLOR D3DXCOLOR::operator * (FLOAT f) const
834{
835 return D3DXCOLOR(r * f, g * f, b * f, a * f);
836}
837
838inline D3DXCOLOR D3DXCOLOR::operator / (FLOAT f) const
839{
840 FLOAT inv = 1.0f / f;
841 return D3DXCOLOR(r * inv, g * inv, b * inv, a * inv);
842}
843
844inline D3DXCOLOR operator * (FLOAT f, const D3DXCOLOR& col)
845{
846 return D3DXCOLOR(f * col.r, f * col.g, f * col.b, f * col.a);
847}
848
849inline BOOL D3DXCOLOR::operator == (const D3DXCOLOR& col) const
850{
851 return r == col.r && g == col.g && b == col.b && a == col.a;
852}
853
854inline BOOL D3DXCOLOR::operator != (const D3DXCOLOR& col) const
855{
856 return r != col.r || g != col.g || b != col.b || a != col.a;
857}
858
859inline D3DXFLOAT16::D3DXFLOAT16()
860{
861}
862
863inline D3DXFLOAT16::D3DXFLOAT16(FLOAT f)
864{
865 D3DXFloat32To16Array(this, &f, 1);
866}
867
868inline D3DXFLOAT16::D3DXFLOAT16(const D3DXFLOAT16 &f)
869{
870 value = f.value;
871}
872
873inline D3DXFLOAT16::operator FLOAT ()
874{
875 FLOAT f;
876 D3DXFloat16To32Array(&f, this, 1);
877 return f;
878}
879
880inline BOOL D3DXFLOAT16::operator == (const D3DXFLOAT16 &f) const
881{
882 return value == f.value;
883}
884
885inline BOOL D3DXFLOAT16::operator != (const D3DXFLOAT16 &f) const
886{
887 return value != f.value;
888}
889
890#endif /* __cplusplus */
891
892/*_______________D3DXCOLOR_____________________*/
893
894static inline D3DXCOLOR* D3DXColorAdd(D3DXCOLOR *pout, const D3DXCOLOR *pc1, const D3DXCOLOR *pc2)
895{
896 if ( !pout || !pc1 || !pc2 ) return NULL;
897 pout->r = (pc1->r) + (pc2->r);
898 pout->g = (pc1->g) + (pc2->g);
899 pout->b = (pc1->b) + (pc2->b);
900 pout->a = (pc1->a) + (pc2->a);
901 return pout;
902}
903
904static inline D3DXCOLOR* D3DXColorLerp(D3DXCOLOR *pout, const D3DXCOLOR *pc1, const D3DXCOLOR *pc2, FLOAT s)
905{
906 if ( !pout || !pc1 || !pc2 ) return NULL;
907 pout->r = (1-s) * (pc1->r) + s *(pc2->r);
908 pout->g = (1-s) * (pc1->g) + s *(pc2->g);
909 pout->b = (1-s) * (pc1->b) + s *(pc2->b);
910 pout->a = (1-s) * (pc1->a) + s *(pc2->a);
911 return pout;
912}
913
914static inline D3DXCOLOR* D3DXColorModulate(D3DXCOLOR *pout, const D3DXCOLOR *pc1, const D3DXCOLOR *pc2)
915{
916 if ( !pout || !pc1 || !pc2 ) return NULL;
917 pout->r = (pc1->r) * (pc2->r);
918 pout->g = (pc1->g) * (pc2->g);
919 pout->b = (pc1->b) * (pc2->b);
920 pout->a = (pc1->a) * (pc2->a);
921 return pout;
922}
923
924static inline D3DXCOLOR* D3DXColorNegative(D3DXCOLOR *pout, const D3DXCOLOR *pc)
925{
926 if ( !pout || !pc ) return NULL;
927 pout->r = 1.0f - pc->r;
928 pout->g = 1.0f - pc->g;
929 pout->b = 1.0f - pc->b;
930 pout->a = pc->a;
931 return pout;
932}
933
934static inline D3DXCOLOR* D3DXColorScale(D3DXCOLOR *pout, const D3DXCOLOR *pc, FLOAT s)
935{
936 if ( !pout || !pc ) return NULL;
937 pout->r = s* (pc->r);
938 pout->g = s* (pc->g);
939 pout->b = s* (pc->b);
940 pout->a = s* (pc->a);
941 return pout;
942}
943
944static inline D3DXCOLOR* D3DXColorSubtract(D3DXCOLOR *pout, const D3DXCOLOR *pc1, const D3DXCOLOR *pc2)
945{
946 if ( !pout || !pc1 || !pc2 ) return NULL;
947 pout->r = (pc1->r) - (pc2->r);
948 pout->g = (pc1->g) - (pc2->g);
949 pout->b = (pc1->b) - (pc2->b);
950 pout->a = (pc1->a) - (pc2->a);
951 return pout;
952}
953
954/*_______________D3DXVECTOR2________________________*/
955
956static inline D3DXVECTOR2* D3DXVec2Add(D3DXVECTOR2 *pout, const D3DXVECTOR2 *pv1, const D3DXVECTOR2 *pv2)
957{
958 if ( !pout || !pv1 || !pv2) return NULL;
959 pout->x = pv1->x + pv2->x;
960 pout->y = pv1->y + pv2->y;
961 return pout;
962}
963
964static inline FLOAT D3DXVec2CCW(const D3DXVECTOR2 *pv1, const D3DXVECTOR2 *pv2)
965{
966 if ( !pv1 || !pv2) return 0.0f;
967 return ( (pv1->x) * (pv2->y) - (pv1->y) * (pv2->x) );
968}
969
970static inline FLOAT D3DXVec2Dot(const D3DXVECTOR2 *pv1, const D3DXVECTOR2 *pv2)
971{
972 if ( !pv1 || !pv2) return 0.0f;
973 return ( (pv1->x * pv2->x + pv1->y * pv2->y) );
974}
975
976static inline FLOAT D3DXVec2Length(const D3DXVECTOR2 *pv)
977{
978 if (!pv) return 0.0f;
979 return sqrtf( pv->x * pv->x + pv->y * pv->y );
980}
981
982static inline FLOAT D3DXVec2LengthSq(const D3DXVECTOR2 *pv)
983{
984 if (!pv) return 0.0f;
985 return( (pv->x) * (pv->x) + (pv->y) * (pv->y) );
986}
987
988static inline D3DXVECTOR2* D3DXVec2Lerp(D3DXVECTOR2 *pout, const D3DXVECTOR2 *pv1, const D3DXVECTOR2 *pv2, FLOAT s)
989{
990 if ( !pout || !pv1 || !pv2) return NULL;
991 pout->x = (1-s) * (pv1->x) + s * (pv2->x);
992 pout->y = (1-s) * (pv1->y) + s * (pv2->y);
993 return pout;
994}
995
996static inline D3DXVECTOR2* D3DXVec2Maximize(D3DXVECTOR2 *pout, const D3DXVECTOR2 *pv1, const D3DXVECTOR2 *pv2)
997{
998 if ( !pout || !pv1 || !pv2) return NULL;
999 pout->x = pv1->x > pv2->x ? pv1->x : pv2->x;
1000 pout->y = pv1->y > pv2->y ? pv1->y : pv2->y;
1001 return pout;
1002}
1003
1004static inline D3DXVECTOR2* D3DXVec2Minimize(D3DXVECTOR2 *pout, const D3DXVECTOR2 *pv1, const D3DXVECTOR2 *pv2)
1005{
1006 if ( !pout || !pv1 || !pv2) return NULL;
1007 pout->x = pv1->x < pv2->x ? pv1->x : pv2->x;
1008 pout->y = pv1->y < pv2->y ? pv1->y : pv2->y;
1009 return pout;
1010}
1011
1012static inline D3DXVECTOR2* D3DXVec2Scale(D3DXVECTOR2 *pout, const D3DXVECTOR2 *pv, FLOAT s)
1013{
1014 if ( !pout || !pv) return NULL;
1015 pout->x = s * (pv->x);
1016 pout->y = s * (pv->y);
1017 return pout;
1018}
1019
1020static inline D3DXVECTOR2* D3DXVec2Subtract(D3DXVECTOR2 *pout, const D3DXVECTOR2 *pv1, const D3DXVECTOR2 *pv2)
1021{
1022 if ( !pout || !pv1 || !pv2) return NULL;
1023 pout->x = pv1->x - pv2->x;
1024 pout->y = pv1->y - pv2->y;
1025 return pout;
1026}
1027
1028/*__________________D3DXVECTOR3_______________________*/
1029
1030static inline D3DXVECTOR3* D3DXVec3Add(D3DXVECTOR3 *pout, const D3DXVECTOR3 *pv1, const D3DXVECTOR3 *pv2)
1031{
1032 if ( !pout || !pv1 || !pv2) return NULL;
1033 pout->x = pv1->x + pv2->x;
1034 pout->y = pv1->y + pv2->y;
1035 pout->z = pv1->z + pv2->z;
1036 return pout;
1037}
1038
1039static inline D3DXVECTOR3* D3DXVec3Cross(D3DXVECTOR3 *pout, const D3DXVECTOR3 *pv1, const D3DXVECTOR3 *pv2)
1040{
1041 D3DXVECTOR3 temp;
1042
1043 if ( !pout || !pv1 || !pv2) return NULL;
1044 temp.x = (pv1->y) * (pv2->z) - (pv1->z) * (pv2->y);
1045 temp.y = (pv1->z) * (pv2->x) - (pv1->x) * (pv2->z);
1046 temp.z = (pv1->x) * (pv2->y) - (pv1->y) * (pv2->x);
1047 *pout = temp;
1048 return pout;
1049}
1050
1051static inline FLOAT D3DXVec3Dot(const D3DXVECTOR3 *pv1, const D3DXVECTOR3 *pv2)
1052{
1053 if ( !pv1 || !pv2 ) return 0.0f;
1054 return (pv1->x) * (pv2->x) + (pv1->y) * (pv2->y) + (pv1->z) * (pv2->z);
1055}
1056
1057static inline FLOAT D3DXVec3Length(const D3DXVECTOR3 *pv)
1058{
1059 if (!pv) return 0.0f;
1060 return sqrtf( pv->x * pv->x + pv->y * pv->y + pv->z * pv->z );
1061}
1062
1063static inline FLOAT D3DXVec3LengthSq(const D3DXVECTOR3 *pv)
1064{
1065 if (!pv) return 0.0f;
1066 return (pv->x) * (pv->x) + (pv->y) * (pv->y) + (pv->z) * (pv->z);
1067}
1068
1069static inline D3DXVECTOR3* D3DXVec3Lerp(D3DXVECTOR3 *pout, const D3DXVECTOR3 *pv1, const D3DXVECTOR3 *pv2, FLOAT s)
1070{
1071 if ( !pout || !pv1 || !pv2) return NULL;
1072 pout->x = (1-s) * (pv1->x) + s * (pv2->x);
1073 pout->y = (1-s) * (pv1->y) + s * (pv2->y);
1074 pout->z = (1-s) * (pv1->z) + s * (pv2->z);
1075 return pout;
1076}
1077
1078static inline D3DXVECTOR3* D3DXVec3Maximize(D3DXVECTOR3 *pout, const D3DXVECTOR3 *pv1, const D3DXVECTOR3 *pv2)
1079{
1080 if ( !pout || !pv1 || !pv2) return NULL;
1081 pout->x = pv1->x > pv2->x ? pv1->x : pv2->x;
1082 pout->y = pv1->y > pv2->y ? pv1->y : pv2->y;
1083 pout->z = pv1->z > pv2->z ? pv1->z : pv2->z;
1084 return pout;
1085}
1086
1087static inline D3DXVECTOR3* D3DXVec3Minimize(D3DXVECTOR3 *pout, const D3DXVECTOR3 *pv1, const D3DXVECTOR3 *pv2)
1088{
1089 if ( !pout || !pv1 || !pv2) return NULL;
1090 pout->x = pv1->x < pv2->x ? pv1->x : pv2->x;
1091 pout->y = pv1->y < pv2->y ? pv1->y : pv2->y;
1092 pout->z = pv1->z < pv2->z ? pv1->z : pv2->z;
1093 return pout;
1094}
1095
1096static inline D3DXVECTOR3* D3DXVec3Scale(D3DXVECTOR3 *pout, const D3DXVECTOR3 *pv, FLOAT s)
1097{
1098 if ( !pout || !pv) return NULL;
1099 pout->x = s * (pv->x);
1100 pout->y = s * (pv->y);
1101 pout->z = s * (pv->z);
1102 return pout;
1103}
1104
1105static inline D3DXVECTOR3* D3DXVec3Subtract(D3DXVECTOR3 *pout, const D3DXVECTOR3 *pv1, const D3DXVECTOR3 *pv2)
1106{
1107 if ( !pout || !pv1 || !pv2) return NULL;
1108 pout->x = pv1->x - pv2->x;
1109 pout->y = pv1->y - pv2->y;
1110 pout->z = pv1->z - pv2->z;
1111 return pout;
1112}
1113/*__________________D3DXVECTOR4_______________________*/
1114
1115static inline D3DXVECTOR4* D3DXVec4Add(D3DXVECTOR4 *pout, const D3DXVECTOR4 *pv1, const D3DXVECTOR4 *pv2)
1116{
1117 if ( !pout || !pv1 || !pv2) return NULL;
1118 pout->x = pv1->x + pv2->x;
1119 pout->y = pv1->y + pv2->y;
1120 pout->z = pv1->z + pv2->z;
1121 pout->w = pv1->w + pv2->w;
1122 return pout;
1123}
1124
1125static inline FLOAT D3DXVec4Dot(const D3DXVECTOR4 *pv1, const D3DXVECTOR4 *pv2)
1126{
1127 if (!pv1 || !pv2 ) return 0.0f;
1128 return (pv1->x) * (pv2->x) + (pv1->y) * (pv2->y) + (pv1->z) * (pv2->z) + (pv1->w) * (pv2->w);
1129}
1130
1131static inline FLOAT D3DXVec4Length(const D3DXVECTOR4 *pv)
1132{
1133 if (!pv) return 0.0f;
1134 return sqrtf( pv->x * pv->x + pv->y * pv->y + pv->z * pv->z + pv->w * pv->w );
1135}
1136
1137static inline FLOAT D3DXVec4LengthSq(const D3DXVECTOR4 *pv)
1138{
1139 if (!pv) return 0.0f;
1140 return (pv->x) * (pv->x) + (pv->y) * (pv->y) + (pv->z) * (pv->z) + (pv->w) * (pv->w);
1141}
1142
1143static inline D3DXVECTOR4* D3DXVec4Lerp(D3DXVECTOR4 *pout, const D3DXVECTOR4 *pv1, const D3DXVECTOR4 *pv2, FLOAT s)
1144{
1145 if ( !pout || !pv1 || !pv2) return NULL;
1146 pout->x = (1-s) * (pv1->x) + s * (pv2->x);
1147 pout->y = (1-s) * (pv1->y) + s * (pv2->y);
1148 pout->z = (1-s) * (pv1->z) + s * (pv2->z);
1149 pout->w = (1-s) * (pv1->w) + s * (pv2->w);
1150 return pout;
1151}
1152
1153
1154static inline D3DXVECTOR4* D3DXVec4Maximize(D3DXVECTOR4 *pout, const D3DXVECTOR4 *pv1, const D3DXVECTOR4 *pv2)
1155{
1156 if ( !pout || !pv1 || !pv2) return NULL;
1157 pout->x = pv1->x > pv2->x ? pv1->x : pv2->x;
1158 pout->y = pv1->y > pv2->y ? pv1->y : pv2->y;
1159 pout->z = pv1->z > pv2->z ? pv1->z : pv2->z;
1160 pout->w = pv1->w > pv2->w ? pv1->w : pv2->w;
1161 return pout;
1162}
1163
1164static inline D3DXVECTOR4* D3DXVec4Minimize(D3DXVECTOR4 *pout, const D3DXVECTOR4 *pv1, const D3DXVECTOR4 *pv2)
1165{
1166 if ( !pout || !pv1 || !pv2) return NULL;
1167 pout->x = pv1->x < pv2->x ? pv1->x : pv2->x;
1168 pout->y = pv1->y < pv2->y ? pv1->y : pv2->y;
1169 pout->z = pv1->z < pv2->z ? pv1->z : pv2->z;
1170 pout->w = pv1->w < pv2->w ? pv1->w : pv2->w;
1171 return pout;
1172}
1173
1174static inline D3DXVECTOR4* D3DXVec4Scale(D3DXVECTOR4 *pout, const D3DXVECTOR4 *pv, FLOAT s)
1175{
1176 if ( !pout || !pv) return NULL;
1177 pout->x = s * (pv->x);
1178 pout->y = s * (pv->y);
1179 pout->z = s * (pv->z);
1180 pout->w = s * (pv->w);
1181 return pout;
1182}
1183
1184static inline D3DXVECTOR4* D3DXVec4Subtract(D3DXVECTOR4 *pout, const D3DXVECTOR4 *pv1, const D3DXVECTOR4 *pv2)
1185{
1186 if ( !pout || !pv1 || !pv2) return NULL;
1187 pout->x = pv1->x - pv2->x;
1188 pout->y = pv1->y - pv2->y;
1189 pout->z = pv1->z - pv2->z;
1190 pout->w = pv1->w - pv2->w;
1191 return pout;
1192}
1193
1194/*__________________D3DXMatrix____________________*/
1195#ifdef NONAMELESSUNION
1196# define D3DX_U(x) (x).u
1197#else
1198# define D3DX_U(x) (x)
1199#endif
1200
1201static inline D3DXMATRIX* D3DXMatrixIdentity(D3DXMATRIX *pout)
1202{
1203 if ( !pout ) return NULL;
1204 D3DX_U(*pout).m[0][1] = 0.0f;
1205 D3DX_U(*pout).m[0][2] = 0.0f;
1206 D3DX_U(*pout).m[0][3] = 0.0f;
1207 D3DX_U(*pout).m[1][0] = 0.0f;
1208 D3DX_U(*pout).m[1][2] = 0.0f;
1209 D3DX_U(*pout).m[1][3] = 0.0f;
1210 D3DX_U(*pout).m[2][0] = 0.0f;
1211 D3DX_U(*pout).m[2][1] = 0.0f;
1212 D3DX_U(*pout).m[2][3] = 0.0f;
1213 D3DX_U(*pout).m[3][0] = 0.0f;
1214 D3DX_U(*pout).m[3][1] = 0.0f;
1215 D3DX_U(*pout).m[3][2] = 0.0f;
1216 D3DX_U(*pout).m[0][0] = 1.0f;
1217 D3DX_U(*pout).m[1][1] = 1.0f;
1218 D3DX_U(*pout).m[2][2] = 1.0f;
1219 D3DX_U(*pout).m[3][3] = 1.0f;
1220 return pout;
1221}
1222
1223static inline BOOL D3DXMatrixIsIdentity(D3DXMATRIX *pm)
1224{
1225 int i,j;
1226 D3DXMATRIX testmatrix;
1227
1228 if ( !pm ) return FALSE;
1229 D3DXMatrixIdentity(&testmatrix);
1230 for (i=0; i<4; i++)
1231 {
1232 for (j=0; j<4; j++)
1233 {
1234 if ( D3DX_U(*pm).m[i][j] != D3DX_U(testmatrix).m[i][j] ) return FALSE;
1235 }
1236 }
1237 return TRUE;
1238}
1239#undef D3DX_U
1240
1241/*__________________D3DXPLANE____________________*/
1242
1243static inline FLOAT D3DXPlaneDot(const D3DXPLANE *pp, const D3DXVECTOR4 *pv)
1244{
1245 if ( !pp || !pv ) return 0.0f;
1246 return ( (pp->a) * (pv->x) + (pp->b) * (pv->y) + (pp->c) * (pv->z) + (pp->d) * (pv->w) );
1247}
1248
1249static inline FLOAT D3DXPlaneDotCoord(const D3DXPLANE *pp, const D3DXVECTOR4 *pv)
1250{
1251 if ( !pp || !pv ) return 0.0f;
1252 return ( (pp->a) * (pv->x) + (pp->b) * (pv->y) + (pp->c) * (pv->z) + (pp->d) );
1253}
1254
1255static inline FLOAT D3DXPlaneDotNormal(const D3DXPLANE *pp, const D3DXVECTOR4 *pv)
1256{
1257 if ( !pp || !pv ) return 0.0f;
1258 return ( (pp->a) * (pv->x) + (pp->b) * (pv->y) + (pp->c) * (pv->z) );
1259}
1260
1261/*__________________D3DXQUATERNION____________________*/
1262
1263static inline D3DXQUATERNION* D3DXQuaternionConjugate(D3DXQUATERNION *pout, const D3DXQUATERNION *pq)
1264{
1265 if ( !pout || !pq) return NULL;
1266 pout->x = -pq->x;
1267 pout->y = -pq->y;
1268 pout->z = -pq->z;
1269 pout->w = pq->w;
1270 return pout;
1271}
1272
1273static inline FLOAT D3DXQuaternionDot(const D3DXQUATERNION *pq1, const D3DXQUATERNION *pq2)
1274{
1275 if ( !pq1 || !pq2 ) return 0.0f;
1276 return (pq1->x) * (pq2->x) + (pq1->y) * (pq2->y) + (pq1->z) * (pq2->z) + (pq1->w) * (pq2->w);
1277}
1278
1279static inline D3DXQUATERNION* D3DXQuaternionIdentity(D3DXQUATERNION *pout)
1280{
1281 if ( !pout) return NULL;
1282 pout->x = 0.0f;
1283 pout->y = 0.0f;
1284 pout->z = 0.0f;
1285 pout->w = 1.0f;
1286 return pout;
1287}
1288
1289static inline BOOL D3DXQuaternionIsIdentity(D3DXQUATERNION *pq)
1290{
1291 if ( !pq) return FALSE;
1292 return ( (pq->x == 0.0f) && (pq->y == 0.0f) && (pq->z == 0.0f) && (pq->w == 1.0f) );
1293}
1294
1295static inline FLOAT D3DXQuaternionLength(const D3DXQUATERNION *pq)
1296{
1297 if (!pq) return 0.0f;
1298 return sqrtf( pq->x * pq->x + pq->y * pq->y + pq->z * pq->z + pq->w * pq->w );
1299}
1300
1301static inline FLOAT D3DXQuaternionLengthSq(const D3DXQUATERNION *pq)
1302{
1303 if (!pq) return 0.0f;
1304 return (pq->x) * (pq->x) + (pq->y) * (pq->y) + (pq->z) * (pq->z) + (pq->w) * (pq->w);
1305}
1306
1307#endif
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette