Back to index

supertuxkart  0.5+dfsg1
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 //ATTRIBUTE_ALIGNED16(class) btQuadWordStorage
00023 //some issues under PS3 Linux with IBM 2.1 SDK, gcc compiler prevent from using aligned quadword. todo: look into this
00024 
00025 class btQuadWordStorage
00026 {
00027 protected:
00028        btScalar      m_x;
00029        btScalar      m_y;
00030        btScalar      m_z;
00031        btScalar      m_unusedW;
00032 };
00033 
00034 
00036 class  btQuadWord : public btQuadWordStorage
00037 {
00038        public:
00039        
00040 //            SIMD_FORCE_INLINE btScalar&       operator[](int i)       { return (&m_x)[i];       }      
00041 //            SIMD_FORCE_INLINE const btScalar& operator[](int i) const { return (&m_x)[i]; }
00042 
00043               SIMD_FORCE_INLINE const btScalar& getX() const { return m_x; }
00044 
00045               SIMD_FORCE_INLINE const btScalar& getY() const { return m_y; }
00046 
00047               SIMD_FORCE_INLINE const btScalar& getZ() const { return m_z; }
00048 
00049               SIMD_FORCE_INLINE void      setX(btScalar x) { m_x = x;};
00050 
00051               SIMD_FORCE_INLINE void      setY(btScalar y) { m_y = y;};
00052 
00053               SIMD_FORCE_INLINE void      setZ(btScalar z) { m_z = z;};
00054 
00055               SIMD_FORCE_INLINE void      setW(btScalar w) { m_unusedW = w;};
00056 
00057               SIMD_FORCE_INLINE const btScalar& x() const { return m_x; }
00058 
00059               SIMD_FORCE_INLINE const btScalar& y() const { return m_y; }
00060 
00061               SIMD_FORCE_INLINE const btScalar& z() const { return m_z; }
00062 
00063               SIMD_FORCE_INLINE const btScalar& w() const { return m_unusedW; }
00064 
00065 
00066               SIMD_FORCE_INLINE    operator       btScalar *()       { return &m_x; }
00067               SIMD_FORCE_INLINE    operator const btScalar *() const { return &m_x; }
00068 
00069 
00070 
00071               SIMD_FORCE_INLINE void      setValue(const btScalar& x, const btScalar& y, const btScalar& z)
00072               {
00073                      m_x=x;
00074                      m_y=y;
00075                      m_z=z;
00076                      m_unusedW = 0.f;
00077               }
00078 
00079 /*            void getValue(btScalar *m) const 
00080               {
00081                      m[0] = m_x;
00082                      m[1] = m_y;
00083                      m[2] = m_z;
00084               }
00085 */
00086               SIMD_FORCE_INLINE void      setValue(const btScalar& x, const btScalar& y, const btScalar& z,const btScalar& w)
00087               {
00088                      m_x=x;
00089                      m_y=y;
00090                      m_z=z;
00091                      m_unusedW=w;
00092               }
00093 
00094               SIMD_FORCE_INLINE btQuadWord()
00095               //     :m_x(btScalar(0.)),m_y(btScalar(0.)),m_z(btScalar(0.)),m_unusedW(btScalar(0.))
00096               {
00097               }
00098 
00099               SIMD_FORCE_INLINE btQuadWord(const btQuadWordStorage& q)
00100               {
00101                      *((btQuadWordStorage*)this) = q;
00102               }
00103 
00104               SIMD_FORCE_INLINE btQuadWord(const btScalar& x, const btScalar& y, const btScalar& z)             
00105               {
00106                      m_x = x, m_y = y, m_z = z, m_unusedW = 0.0f;
00107               }
00108 
00109               SIMD_FORCE_INLINE btQuadWord(const btScalar& x, const btScalar& y, const btScalar& z,const btScalar& w) 
00110               {
00111                      m_x = x, m_y = y, m_z = z, m_unusedW = w;
00112               }
00113 
00114 
00115               SIMD_FORCE_INLINE void      setMax(const btQuadWord& other)
00116               {
00117                      btSetMax(m_x, other.m_x);
00118                      btSetMax(m_y, other.m_y);
00119                      btSetMax(m_z, other.m_z);
00120                      btSetMax(m_unusedW, other.m_unusedW);
00121               }
00122 
00123               SIMD_FORCE_INLINE void      setMin(const btQuadWord& other)
00124               {
00125                      btSetMin(m_x, other.m_x);
00126                      btSetMin(m_y, other.m_y);
00127                      btSetMin(m_z, other.m_z);
00128                      btSetMin(m_unusedW, other.m_unusedW);
00129               }
00130 
00131 
00132 
00133 };
00134 
00135 #endif //SIMD_QUADWORD_H