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 TF2SIMD_QUADWORD_H
00017 #define TF2SIMD_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 namespace tf2
00028 {
00032 #ifndef USE_LIBSPE2
00033 ATTRIBUTE_ALIGNED16(class) QuadWord
00034 #else
00035 class QuadWord
00036 #endif
00037 {
00038 protected:
00039 
00040 #if defined (__SPU__) && defined (__CELLOS_LV2__)
00041         union {
00042                 vec_float4 mVec128;
00043                 tf2Scalar       m_floats[4];
00044         };
00045 public:
00046         vec_float4      get128() const
00047         {
00048                 return mVec128;
00049         }
00050 protected:
00051 #else //__CELLOS_LV2__ __SPU__
00052         tf2Scalar       m_floats[4];
00053 #endif //__CELLOS_LV2__ __SPU__
00054 
00055         public:
00056   
00057 
00059                 TF2SIMD_FORCE_INLINE const tf2Scalar& getX() const { return m_floats[0]; }
00061                 TF2SIMD_FORCE_INLINE const tf2Scalar& getY() const { return m_floats[1]; }
00063                 TF2SIMD_FORCE_INLINE const tf2Scalar& getZ() const { return m_floats[2]; }
00065                 TF2SIMD_FORCE_INLINE void       setX(tf2Scalar x) { m_floats[0] = x;};
00067                 TF2SIMD_FORCE_INLINE void       setY(tf2Scalar y) { m_floats[1] = y;};
00069                 TF2SIMD_FORCE_INLINE void       setZ(tf2Scalar z) { m_floats[2] = z;};
00071                 TF2SIMD_FORCE_INLINE void       setW(tf2Scalar w) { m_floats[3] = w;};
00073                 TF2SIMD_FORCE_INLINE const tf2Scalar& x() const { return m_floats[0]; }
00075                 TF2SIMD_FORCE_INLINE const tf2Scalar& y() const { return m_floats[1]; }
00077                 TF2SIMD_FORCE_INLINE const tf2Scalar& z() const { return m_floats[2]; }
00079                 TF2SIMD_FORCE_INLINE const tf2Scalar& w() const { return m_floats[3]; }
00080 
00081         //TF2SIMD_FORCE_INLINE tf2Scalar&       operator[](int i)       { return (&m_floats[0])[i];     }      
00082         //TF2SIMD_FORCE_INLINE const tf2Scalar& operator[](int i) const { return (&m_floats[0])[i]; }
00084         TF2SIMD_FORCE_INLINE    operator       tf2Scalar *()       { return &m_floats[0]; }
00085         TF2SIMD_FORCE_INLINE    operator const tf2Scalar *() const { return &m_floats[0]; }
00086 
00087         TF2SIMD_FORCE_INLINE    bool    operator==(const QuadWord& other) const
00088         {
00089                 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]));
00090         }
00091 
00092         TF2SIMD_FORCE_INLINE    bool    operator!=(const QuadWord& other) const
00093         {
00094                 return !(*this == other);
00095         }
00096 
00102                 TF2SIMD_FORCE_INLINE void       setValue(const tf2Scalar& x, const tf2Scalar& y, const tf2Scalar& z)
00103                 {
00104                         m_floats[0]=x;
00105                         m_floats[1]=y;
00106                         m_floats[2]=z;
00107                         m_floats[3] = 0.f;
00108                 }
00109 
00110 /*              void getValue(tf2Scalar *m) const 
00111                 {
00112                         m[0] = m_floats[0];
00113                         m[1] = m_floats[1];
00114                         m[2] = m_floats[2];
00115                 }
00116 */
00123                 TF2SIMD_FORCE_INLINE void       setValue(const tf2Scalar& x, const tf2Scalar& y, const tf2Scalar& z,const tf2Scalar& w)
00124                 {
00125                         m_floats[0]=x;
00126                         m_floats[1]=y;
00127                         m_floats[2]=z;
00128                         m_floats[3]=w;
00129                 }
00131                 TF2SIMD_FORCE_INLINE QuadWord()
00132                 //      :m_floats[0](tf2Scalar(0.)),m_floats[1](tf2Scalar(0.)),m_floats[2](tf2Scalar(0.)),m_floats[3](tf2Scalar(0.))
00133                 {
00134                 }
00135  
00141                 TF2SIMD_FORCE_INLINE QuadWord(const tf2Scalar& x, const tf2Scalar& y, const tf2Scalar& z)               
00142                 {
00143                         m_floats[0] = x, m_floats[1] = y, m_floats[2] = z, m_floats[3] = 0.0f;
00144                 }
00145 
00152                 TF2SIMD_FORCE_INLINE QuadWord(const tf2Scalar& x, const tf2Scalar& y, const tf2Scalar& z,const tf2Scalar& w) 
00153                 {
00154                         m_floats[0] = x, m_floats[1] = y, m_floats[2] = z, m_floats[3] = w;
00155                 }
00156 
00160                 TF2SIMD_FORCE_INLINE void       setMax(const QuadWord& other)
00161                 {
00162                         tf2SetMax(m_floats[0], other.m_floats[0]);
00163                         tf2SetMax(m_floats[1], other.m_floats[1]);
00164                         tf2SetMax(m_floats[2], other.m_floats[2]);
00165                         tf2SetMax(m_floats[3], other.m_floats[3]);
00166                 }
00170                 TF2SIMD_FORCE_INLINE void       setMin(const QuadWord& other)
00171                 {
00172                         tf2SetMin(m_floats[0], other.m_floats[0]);
00173                         tf2SetMin(m_floats[1], other.m_floats[1]);
00174                         tf2SetMin(m_floats[2], other.m_floats[2]);
00175                         tf2SetMin(m_floats[3], other.m_floats[3]);
00176                 }
00177 
00178 
00179 
00180 };
00181 
00182 }
00183 #endif //TF2SIMD_QUADWORD_H


tf2
Author(s): Tully Foote, Eitan Marder-Eppstein, Wim Meeussen
autogenerated on Thu Jan 4 2018 03:35:29