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