Changeset 2430 for code/branches/physics/src/bullet/LinearMath/btQuadWord.h
- Timestamp:
- Dec 13, 2008, 11:45:51 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/physics/src/bullet/LinearMath/btQuadWord.h
r2192 r2430 19 19 #include "btScalar.h" 20 20 #include "btMinMax.h" 21 #include <math.h>22 21 23 22 23 #if defined (__CELLOS_LV2) && defined (__SPU__) 24 #include <altivec.h> 25 #endif 24 26 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 27 /**@brief The btQuadWordStorage class is base class for btVector3 and btQuaternion. 28 * Some issues under PS3 Linux with IBM 2.1 SDK, gcc compiler prevent from using aligned quadword. 29 */ 30 #ifndef USE_LIBSPE2 31 ATTRIBUTE_ALIGNED16(class) btQuadWordStorage 32 #else 28 33 class btQuadWordStorage 34 #endif 29 35 { 30 36 protected: 31 37 32 btScalar m_x; 33 btScalar m_y;34 btScalar m_z;35 btScalar m_unusedW;36 38 #if defined (__SPU__) && defined (__CELLOS_LV2__) 39 union { 40 vec_float4 mVec128; 41 btScalar m_floats[4]; 42 }; 37 43 public: 44 vec_float4 get128() const 45 { 46 return mVec128; 47 } 48 #else //__CELLOS_LV2__ __SPU__ 49 btScalar m_floats[4]; 50 #endif //__CELLOS_LV2__ __SPU__ 38 51 39 52 }; 40 53 41 42 ///btQuadWord is base-class for vectors, points 54 /** @brief The btQuadWord is base-class for vectors, points */ 43 55 class btQuadWord : public btQuadWordStorage 44 56 { 45 57 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]; } 58 49 59 50 SIMD_FORCE_INLINE const btScalar& getX() const { return m_x; } 60 /**@brief Return the x value */ 61 SIMD_FORCE_INLINE const btScalar& getX() const { return m_floats[0]; } 62 /**@brief Return the y value */ 63 SIMD_FORCE_INLINE const btScalar& getY() const { return m_floats[1]; } 64 /**@brief Return the z value */ 65 SIMD_FORCE_INLINE const btScalar& getZ() const { return m_floats[2]; } 66 /**@brief Set the x value */ 67 SIMD_FORCE_INLINE void setX(btScalar x) { m_floats[0] = x;}; 68 /**@brief Set the y value */ 69 SIMD_FORCE_INLINE void setY(btScalar y) { m_floats[1] = y;}; 70 /**@brief Set the z value */ 71 SIMD_FORCE_INLINE void setZ(btScalar z) { m_floats[2] = z;}; 72 /**@brief Set the w value */ 73 SIMD_FORCE_INLINE void setW(btScalar w) { m_floats[3] = w;}; 74 /**@brief Return the x value */ 75 SIMD_FORCE_INLINE const btScalar& x() const { return m_floats[0]; } 76 /**@brief Return the y value */ 77 SIMD_FORCE_INLINE const btScalar& y() const { return m_floats[1]; } 78 /**@brief Return the z value */ 79 SIMD_FORCE_INLINE const btScalar& z() const { return m_floats[2]; } 80 /**@brief Return the w value */ 81 SIMD_FORCE_INLINE const btScalar& w() const { return m_floats[3]; } 51 82 52 SIMD_FORCE_INLINE const btScalar& getY() const { return m_y; } 83 //SIMD_FORCE_INLINE btScalar& operator[](int i) { return (&m_floats[0])[i]; } 84 //SIMD_FORCE_INLINE const btScalar& operator[](int i) const { return (&m_floats[0])[i]; } 85 ///operator btScalar*() replaces operator[], using implicit conversion. We added operator != and operator == to avoid pointer comparisons. 86 SIMD_FORCE_INLINE operator btScalar *() { return &m_floats[0]; } 87 SIMD_FORCE_INLINE operator const btScalar *() const { return &m_floats[0]; } 53 88 54 SIMD_FORCE_INLINE const btScalar& getZ() const { return m_z; } 89 SIMD_FORCE_INLINE bool operator==(const btQuadWord& other) const 90 { 91 return ((m_floats[3]==other.m_floats[3]) && (m_floats[2]==other.m_floats[2]) && (m_floats[1]==other.m_floats[1]) && (m_floats[0]==other.m_floats[0])); 92 } 55 93 56 SIMD_FORCE_INLINE void setX(btScalar x) { m_x = x;}; 94 SIMD_FORCE_INLINE bool operator!=(const btQuadWord& other) const 95 { 96 return !(*this == other); 97 } 57 98 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 99 /**@brief Set x,y,z and zero w 100 * @param x Value of x 101 * @param y Value of y 102 * @param z Value of z 103 */ 78 104 SIMD_FORCE_INLINE void setValue(const btScalar& x, const btScalar& y, const btScalar& z) 79 105 { 80 m_ x=x;81 m_ y=y;82 m_ z=z;83 m_ unusedW= 0.f;106 m_floats[0]=x; 107 m_floats[1]=y; 108 m_floats[2]=z; 109 m_floats[3] = 0.f; 84 110 } 85 111 86 112 /* void getValue(btScalar *m) const 87 113 { 88 m[0] = m_ x;89 m[1] = m_ y;90 m[2] = m_ z;114 m[0] = m_floats[0]; 115 m[1] = m_floats[1]; 116 m[2] = m_floats[2]; 91 117 } 92 118 */ 119 /**@brief Set the values 120 * @param x Value of x 121 * @param y Value of y 122 * @param z Value of z 123 * @param w Value of w 124 */ 93 125 SIMD_FORCE_INLINE void setValue(const btScalar& x, const btScalar& y, const btScalar& z,const btScalar& w) 94 126 { 95 m_ x=x;96 m_ y=y;97 m_ z=z;98 m_ unusedW=w;127 m_floats[0]=x; 128 m_floats[1]=y; 129 m_floats[2]=z; 130 m_floats[3]=w; 99 131 } 100 132 /**@brief No initialization constructor */ 101 133 SIMD_FORCE_INLINE btQuadWord() 102 // :m_ x(btScalar(0.)),m_y(btScalar(0.)),m_z(btScalar(0.)),m_unusedW(btScalar(0.))134 // :m_floats[0](btScalar(0.)),m_floats[1](btScalar(0.)),m_floats[2](btScalar(0.)),m_floats[3](btScalar(0.)) 103 135 { 104 136 } 105 137 /**@brief Copy constructor */ 106 138 SIMD_FORCE_INLINE btQuadWord(const btQuadWordStorage& q) 107 139 { 108 140 *((btQuadWordStorage*)this) = q; 109 141 } 110 142 /**@brief Three argument constructor (zeros w) 143 * @param x Value of x 144 * @param y Value of y 145 * @param z Value of z 146 */ 111 147 SIMD_FORCE_INLINE btQuadWord(const btScalar& x, const btScalar& y, const btScalar& z) 112 148 { 113 m_ x = x, m_y = y, m_z = z, m_unusedW= 0.0f;149 m_floats[0] = x, m_floats[1] = y, m_floats[2] = z, m_floats[3] = 0.0f; 114 150 } 115 151 152 /**@brief Initializing constructor 153 * @param x Value of x 154 * @param y Value of y 155 * @param z Value of z 156 * @param w Value of w 157 */ 116 158 SIMD_FORCE_INLINE btQuadWord(const btScalar& x, const btScalar& y, const btScalar& z,const btScalar& w) 117 159 { 118 m_ x = x, m_y = y, m_z = z, m_unusedW= w;160 m_floats[0] = x, m_floats[1] = y, m_floats[2] = z, m_floats[3] = w; 119 161 } 120 162 121 163 /**@brief Set each element to the max of the current values and the values of another btQuadWord 164 * @param other The other btQuadWord to compare with 165 */ 122 166 SIMD_FORCE_INLINE void setMax(const btQuadWord& other) 123 167 { 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);168 btSetMax(m_floats[0], other.m_floats[0]); 169 btSetMax(m_floats[1], other.m_floats[1]); 170 btSetMax(m_floats[2], other.m_floats[2]); 171 btSetMax(m_floats[3], other.m_floats[3]); 128 172 } 129 173 /**@brief Set each element to the min of the current values and the values of another btQuadWord 174 * @param other The other btQuadWord to compare with 175 */ 130 176 SIMD_FORCE_INLINE void setMin(const btQuadWord& other) 131 177 { 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);178 btSetMin(m_floats[0], other.m_floats[0]); 179 btSetMin(m_floats[1], other.m_floats[1]); 180 btSetMin(m_floats[2], other.m_floats[2]); 181 btSetMin(m_floats[3], other.m_floats[3]); 136 182 } 137 183
Note: See TracChangeset
for help on using the changeset viewer.