QuadWord.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 TF_QUADWORD_H
00017 #define TF_QUADWORD_H
00018 
00019 #include "Scalar.h"
00020 #include "MinMax.h"
00021 
00022 
00023 #if defined (__CELLOS_LV2) && defined (__SPU__)
00024 #include <altivec.h>
00025 #endif
00026 
00027 
00028 namespace tf
00029 {
00033 #ifndef USE_LIBSPE2
00034 ATTRIBUTE_ALIGNED16(class) QuadWord
00035 #else
00036 class QuadWord
00037 #endif
00038 {
00039 protected:
00040 
00041 #if defined (__SPU__) && defined (__CELLOS_LV2__)
00042         union {
00043                 vec_float4 mVec128;
00044                 tfScalar        m_floats[4];
00045         };
00046 public:
00047         vec_float4      get128() const
00048         {
00049                 return mVec128;
00050         }
00051 protected:
00052 #else //__CELLOS_LV2__ __SPU__
00053         tfScalar        m_floats[4];
00054 #endif //__CELLOS_LV2__ __SPU__
00055 
00056         public:
00057   
00058 
00060                 TFSIMD_FORCE_INLINE const tfScalar& getX() const { return m_floats[0]; }
00062                 TFSIMD_FORCE_INLINE const tfScalar& getY() const { return m_floats[1]; }
00064                 TFSIMD_FORCE_INLINE const tfScalar& getZ() const { return m_floats[2]; }
00066                 TFSIMD_FORCE_INLINE void        setX(tfScalar x) { m_floats[0] = x;};
00068                 TFSIMD_FORCE_INLINE void        setY(tfScalar y) { m_floats[1] = y;};
00070                 TFSIMD_FORCE_INLINE void        setZ(tfScalar z) { m_floats[2] = z;};
00072                 TFSIMD_FORCE_INLINE void        setW(tfScalar w) { m_floats[3] = w;};
00074                 TFSIMD_FORCE_INLINE const tfScalar& x() const { return m_floats[0]; }
00076                 TFSIMD_FORCE_INLINE const tfScalar& y() const { return m_floats[1]; }
00078                 TFSIMD_FORCE_INLINE const tfScalar& z() const { return m_floats[2]; }
00080                 TFSIMD_FORCE_INLINE const tfScalar& w() const { return m_floats[3]; }
00081 
00082         //TFSIMD_FORCE_INLINE tfScalar&       operator[](int i)       { return (&m_floats[0])[i];       }      
00083         //TFSIMD_FORCE_INLINE const tfScalar& operator[](int i) const { return (&m_floats[0])[i]; }
00085         TFSIMD_FORCE_INLINE     operator       tfScalar *()       { return &m_floats[0]; }
00086         TFSIMD_FORCE_INLINE     operator const tfScalar *() const { return &m_floats[0]; }
00087 
00088         TFSIMD_FORCE_INLINE     bool    operator==(const QuadWord& other) const
00089         {
00090                 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]));
00091         }
00092 
00093         TFSIMD_FORCE_INLINE     bool    operator!=(const QuadWord& other) const
00094         {
00095                 return !(*this == other);
00096         }
00097 
00103                 TFSIMD_FORCE_INLINE void        setValue(const tfScalar& x, const tfScalar& y, const tfScalar& z)
00104                 {
00105                         m_floats[0]=x;
00106                         m_floats[1]=y;
00107                         m_floats[2]=z;
00108                         m_floats[3] = 0.f;
00109                 }
00110 
00111 /*              void getValue(tfScalar *m) const 
00112                 {
00113                         m[0] = m_floats[0];
00114                         m[1] = m_floats[1];
00115                         m[2] = m_floats[2];
00116                 }
00117 */
00124                 TFSIMD_FORCE_INLINE void        setValue(const tfScalar& x, const tfScalar& y, const tfScalar& z,const tfScalar& w)
00125                 {
00126                         m_floats[0]=x;
00127                         m_floats[1]=y;
00128                         m_floats[2]=z;
00129                         m_floats[3]=w;
00130                 }
00132                 TFSIMD_FORCE_INLINE QuadWord()
00133                 //      :m_floats[0](tfScalar(0.)),m_floats[1](tfScalar(0.)),m_floats[2](tfScalar(0.)),m_floats[3](tfScalar(0.))
00134                 {
00135                 }
00136  
00142                 TFSIMD_FORCE_INLINE QuadWord(const tfScalar& x, const tfScalar& y, const tfScalar& z)           
00143                 {
00144                         m_floats[0] = x, m_floats[1] = y, m_floats[2] = z, m_floats[3] = 0.0f;
00145                 }
00146 
00153                 TFSIMD_FORCE_INLINE QuadWord(const tfScalar& x, const tfScalar& y, const tfScalar& z,const tfScalar& w) 
00154                 {
00155                         m_floats[0] = x, m_floats[1] = y, m_floats[2] = z, m_floats[3] = w;
00156                 }
00157 
00161                 TFSIMD_FORCE_INLINE void        setMax(const QuadWord& other)
00162                 {
00163                         tfSetMax(m_floats[0], other.m_floats[0]);
00164                         tfSetMax(m_floats[1], other.m_floats[1]);
00165                         tfSetMax(m_floats[2], other.m_floats[2]);
00166                         tfSetMax(m_floats[3], other.m_floats[3]);
00167                 }
00171                 TFSIMD_FORCE_INLINE void        setMin(const QuadWord& other)
00172                 {
00173                         tfSetMin(m_floats[0], other.m_floats[0]);
00174                         tfSetMin(m_floats[1], other.m_floats[1]);
00175                         tfSetMin(m_floats[2], other.m_floats[2]);
00176                         tfSetMin(m_floats[3], other.m_floats[3]);
00177                 }
00178 
00179 
00180 
00181 };
00182 
00183 }
00184 
00185 #endif //TFSIMD_QUADWORD_H
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines


tf
Author(s): Tully Foote, Eitan Marder-Eppstein, Wim Meeussen
autogenerated on Thu Aug 22 2013 11:29:01