source: Daodan/MSYS2/mingw32/i686-w64-mingw32/include/d3dx9math.inl@ 1186

Last change on this file since 1186 was 1166, checked in by rossy, 3 years ago

Daodan: Replace MinGW build env with an up-to-date MSYS2 env

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