Blender V2.61 - r43446

btQuadWord.h

Go to the documentation of this file.
00001 /*
00002 Copyright (c) 2003-2006 Gino van den Bergen / Erwin Coumans  http://continuousphysics.com/Bullet/
00003 
00004 This software is provided 'as-is', without any express or implied warranty.
00005 In no event will the authors be held liable for any damages arising from the use of this software.
00006 Permission is granted to anyone to use this software for any purpose, 
00007 including commercial applications, and to alter it and redistribute it freely, 
00008 subject to the following restrictions:
00009 
00010 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.
00011 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
00012 3. This notice may not be removed or altered from any source distribution.
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     //SIMD_FORCE_INLINE btScalar&       operator[](int i)       { return (&m_floats[0])[i]; }      
00080     //SIMD_FORCE_INLINE const btScalar& operator[](int i) const { return (&m_floats[0])[i]; }
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 /*      void getValue(btScalar *m) const 
00109         {
00110             m[0] = m_floats[0];
00111             m[1] = m_floats[1];
00112             m[2] = m_floats[2];
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         //  :m_floats[0](btScalar(0.)),m_floats[1](btScalar(0.)),m_floats[2](btScalar(0.)),m_floats[3](btScalar(0.))
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