1 | /* |
---|
2 | Copyright (c) 2003-2006 Gino van den Bergen / Erwin Coumans http://continuousphysics.com/Bullet/ |
---|
3 | |
---|
4 | This software is provided 'as-is', without any express or implied warranty. |
---|
5 | In no event will the authors be held liable for any damages arising from the use of this software. |
---|
6 | Permission is granted to anyone to use this software for any purpose, |
---|
7 | including commercial applications, and to alter it and redistribute it freely, |
---|
8 | subject to the following restrictions: |
---|
9 | |
---|
10 | 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. |
---|
11 | 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. |
---|
12 | 3. This notice may not be removed or altered from any source distribution. |
---|
13 | */ |
---|
14 | |
---|
15 | |
---|
16 | #ifndef SIMD_QUADWORD_H |
---|
17 | #define SIMD_QUADWORD_H |
---|
18 | |
---|
19 | #include "btScalar.h" |
---|
20 | #include "btMinMax.h" |
---|
21 | #include <math.h> |
---|
22 | |
---|
23 | |
---|
24 | |
---|
25 | ///The btQuadWordStorage class is base class for btVector3 and btQuaternion. |
---|
26 | ///Some issues under PS3 Linux with IBM 2.1 SDK, gcc compiler prevent from using aligned quadword. todo: look into this |
---|
27 | ///ATTRIBUTE_ALIGNED16(class) btQuadWordStorage |
---|
28 | class btQuadWordStorage |
---|
29 | { |
---|
30 | protected: |
---|
31 | |
---|
32 | btScalar m_x; |
---|
33 | btScalar m_y; |
---|
34 | btScalar m_z; |
---|
35 | btScalar m_unusedW; |
---|
36 | |
---|
37 | public: |
---|
38 | |
---|
39 | }; |
---|
40 | |
---|
41 | |
---|
42 | ///btQuadWord is base-class for vectors, points |
---|
43 | class btQuadWord : public btQuadWordStorage |
---|
44 | { |
---|
45 | public: |
---|
46 | |
---|
47 | // SIMD_FORCE_INLINE btScalar& operator[](int i) { return (&m_x)[i]; } |
---|
48 | // SIMD_FORCE_INLINE const btScalar& operator[](int i) const { return (&m_x)[i]; } |
---|
49 | |
---|
50 | SIMD_FORCE_INLINE const btScalar& getX() const { return m_x; } |
---|
51 | |
---|
52 | SIMD_FORCE_INLINE const btScalar& getY() const { return m_y; } |
---|
53 | |
---|
54 | SIMD_FORCE_INLINE const btScalar& getZ() const { return m_z; } |
---|
55 | |
---|
56 | SIMD_FORCE_INLINE void setX(btScalar x) { m_x = x;}; |
---|
57 | |
---|
58 | SIMD_FORCE_INLINE void setY(btScalar y) { m_y = y;}; |
---|
59 | |
---|
60 | SIMD_FORCE_INLINE void setZ(btScalar z) { m_z = z;}; |
---|
61 | |
---|
62 | SIMD_FORCE_INLINE void setW(btScalar w) { m_unusedW = w;}; |
---|
63 | |
---|
64 | SIMD_FORCE_INLINE const btScalar& x() const { return m_x; } |
---|
65 | |
---|
66 | SIMD_FORCE_INLINE const btScalar& y() const { return m_y; } |
---|
67 | |
---|
68 | SIMD_FORCE_INLINE const btScalar& z() const { return m_z; } |
---|
69 | |
---|
70 | SIMD_FORCE_INLINE const btScalar& w() const { return m_unusedW; } |
---|
71 | |
---|
72 | |
---|
73 | SIMD_FORCE_INLINE operator btScalar *() { return &m_x; } |
---|
74 | SIMD_FORCE_INLINE operator const btScalar *() const { return &m_x; } |
---|
75 | |
---|
76 | |
---|
77 | |
---|
78 | SIMD_FORCE_INLINE void setValue(const btScalar& x, const btScalar& y, const btScalar& z) |
---|
79 | { |
---|
80 | m_x=x; |
---|
81 | m_y=y; |
---|
82 | m_z=z; |
---|
83 | m_unusedW = 0.f; |
---|
84 | } |
---|
85 | |
---|
86 | /* void getValue(btScalar *m) const |
---|
87 | { |
---|
88 | m[0] = m_x; |
---|
89 | m[1] = m_y; |
---|
90 | m[2] = m_z; |
---|
91 | } |
---|
92 | */ |
---|
93 | SIMD_FORCE_INLINE void setValue(const btScalar& x, const btScalar& y, const btScalar& z,const btScalar& w) |
---|
94 | { |
---|
95 | m_x=x; |
---|
96 | m_y=y; |
---|
97 | m_z=z; |
---|
98 | m_unusedW=w; |
---|
99 | } |
---|
100 | |
---|
101 | SIMD_FORCE_INLINE btQuadWord() |
---|
102 | // :m_x(btScalar(0.)),m_y(btScalar(0.)),m_z(btScalar(0.)),m_unusedW(btScalar(0.)) |
---|
103 | { |
---|
104 | } |
---|
105 | |
---|
106 | SIMD_FORCE_INLINE btQuadWord(const btQuadWordStorage& q) |
---|
107 | { |
---|
108 | *((btQuadWordStorage*)this) = q; |
---|
109 | } |
---|
110 | |
---|
111 | SIMD_FORCE_INLINE btQuadWord(const btScalar& x, const btScalar& y, const btScalar& z) |
---|
112 | { |
---|
113 | m_x = x, m_y = y, m_z = z, m_unusedW = 0.0f; |
---|
114 | } |
---|
115 | |
---|
116 | SIMD_FORCE_INLINE btQuadWord(const btScalar& x, const btScalar& y, const btScalar& z,const btScalar& w) |
---|
117 | { |
---|
118 | m_x = x, m_y = y, m_z = z, m_unusedW = w; |
---|
119 | } |
---|
120 | |
---|
121 | |
---|
122 | SIMD_FORCE_INLINE void setMax(const btQuadWord& other) |
---|
123 | { |
---|
124 | btSetMax(m_x, other.m_x); |
---|
125 | btSetMax(m_y, other.m_y); |
---|
126 | btSetMax(m_z, other.m_z); |
---|
127 | btSetMax(m_unusedW, other.m_unusedW); |
---|
128 | } |
---|
129 | |
---|
130 | SIMD_FORCE_INLINE void setMin(const btQuadWord& other) |
---|
131 | { |
---|
132 | btSetMin(m_x, other.m_x); |
---|
133 | btSetMin(m_y, other.m_y); |
---|
134 | btSetMin(m_z, other.m_z); |
---|
135 | btSetMin(m_unusedW, other.m_unusedW); |
---|
136 | } |
---|
137 | |
---|
138 | |
---|
139 | |
---|
140 | }; |
---|
141 | |
---|
142 | #endif //SIMD_QUADWORD_H |
---|