VirtualBox

source: vbox/trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/d3dx8math.inl@ 27512

Last change on this file since 27512 was 22496, checked in by vboxsync, 16 years ago

crOpenGL: update wine to 1.1.27 and better fix for depthstencil surface refcounting

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

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