Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016 #ifndef SIMD_QUADWORD_H
00017 #define SIMD_QUADWORD_H
00018
00019 #include "btScalar.h"
00020 #include "btMinMax.h"
00021
00022
00023 #if defined (__CELLOS_LV2) && defined (__SPU__)
00024 #include <altivec.h>
00025 #endif
00026
00030 #ifndef USE_LIBSPE2
00031 ATTRIBUTE_ALIGNED16(class) btQuadWord
00032 #else
00033 class btQuadWord
00034 #endif
00035 {
00036 protected:
00037
00038 #if defined (__SPU__) && defined (__CELLOS_LV2__)
00039 union {
00040 vec_float4 mVec128;
00041 btScalar m_floats[4];
00042 };
00043 public:
00044 vec_float4 get128() const
00045 {
00046 return mVec128;
00047 }
00048 protected:
00049 #else //__CELLOS_LV2__ __SPU__
00050 btScalar m_floats[4];
00051 #endif //__CELLOS_LV2__ __SPU__
00052
00053 public:
00054
00055
00057 SIMD_FORCE_INLINE const btScalar& getX() const { return m_floats[0]; }
00059 SIMD_FORCE_INLINE const btScalar& getY() const { return m_floats[1]; }
00061 SIMD_FORCE_INLINE const btScalar& getZ() const { return m_floats[2]; }
00063 SIMD_FORCE_INLINE void setX(btScalar x) { m_floats[0] = x;};
00065 SIMD_FORCE_INLINE void setY(btScalar y) { m_floats[1] = y;};
00067 SIMD_FORCE_INLINE void setZ(btScalar z) { m_floats[2] = z;};
00069 SIMD_FORCE_INLINE void setW(btScalar w) { m_floats[3] = w;};
00071 SIMD_FORCE_INLINE const btScalar& x() const { return m_floats[0]; }
00073 SIMD_FORCE_INLINE const btScalar& y() const { return m_floats[1]; }
00075 SIMD_FORCE_INLINE const btScalar& z() const { return m_floats[2]; }
00077 SIMD_FORCE_INLINE const btScalar& w() const { return m_floats[3]; }
00078
00079
00080
00082 SIMD_FORCE_INLINE operator btScalar *() { return &m_floats[0]; }
00083 SIMD_FORCE_INLINE operator const btScalar *() const { return &m_floats[0]; }
00084
00085 SIMD_FORCE_INLINE bool operator==(const btQuadWord& other) const
00086 {
00087 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]));
00088 }
00089
00090 SIMD_FORCE_INLINE bool operator!=(const btQuadWord& other) const
00091 {
00092 return !(*this == other);
00093 }
00094
00100 SIMD_FORCE_INLINE void setValue(const btScalar& x, const btScalar& y, const btScalar& z)
00101 {
00102 m_floats[0]=x;
00103 m_floats[1]=y;
00104 m_floats[2]=z;
00105 m_floats[3] = 0.f;
00106 }
00107
00108
00109
00110
00111
00112
00113
00114
00121 SIMD_FORCE_INLINE void setValue(const btScalar& x, const btScalar& y, const btScalar& z,const btScalar& w)
00122 {
00123 m_floats[0]=x;
00124 m_floats[1]=y;
00125 m_floats[2]=z;
00126 m_floats[3]=w;
00127 }
00129 SIMD_FORCE_INLINE btQuadWord()
00130
00131 {
00132 }
00133
00139 SIMD_FORCE_INLINE btQuadWord(const btScalar& x, const btScalar& y, const btScalar& z)
00140 {
00141 m_floats[0] = x, m_floats[1] = y, m_floats[2] = z, m_floats[3] = 0.0f;
00142 }
00143
00150 SIMD_FORCE_INLINE btQuadWord(const btScalar& x, const btScalar& y, const btScalar& z,const btScalar& w)
00151 {
00152 m_floats[0] = x, m_floats[1] = y, m_floats[2] = z, m_floats[3] = w;
00153 }
00154
00158 SIMD_FORCE_INLINE void setMax(const btQuadWord& other)
00159 {
00160 btSetMax(m_floats[0], other.m_floats[0]);
00161 btSetMax(m_floats[1], other.m_floats[1]);
00162 btSetMax(m_floats[2], other.m_floats[2]);
00163 btSetMax(m_floats[3], other.m_floats[3]);
00164 }
00168 SIMD_FORCE_INLINE void setMin(const btQuadWord& other)
00169 {
00170 btSetMin(m_floats[0], other.m_floats[0]);
00171 btSetMin(m_floats[1], other.m_floats[1]);
00172 btSetMin(m_floats[2], other.m_floats[2]);
00173 btSetMin(m_floats[3], other.m_floats[3]);
00174 }
00175
00176
00177
00178 };
00179
00180 #endif //SIMD_QUADWORD_H