Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Dec 13, 2008, 11:45:51 PM (16 years ago)
Author:
rgrieder
Message:

Updated to Bullet 2.73 (first part).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/physics/src/bullet/LinearMath/btQuadWord.h

    r2192 r2430  
    1919#include "btScalar.h"
    2020#include "btMinMax.h"
    21 #include <math.h>
    2221
    2322
     23#if defined (__CELLOS_LV2) && defined (__SPU__)
     24#include <altivec.h>
     25#endif
    2426
    25 ///The btQuadWordStorage class is base class for btVector3 and btQuaternion.
    26 ///Some issues under PS3 Linux with IBM 2.1 SDK, gcc compiler prevent from using aligned quadword. todo: look into this
    27 ///ATTRIBUTE_ALIGNED16(class) btQuadWordStorage
     27/**@brief The btQuadWordStorage class is base class for btVector3 and btQuaternion.
     28 * Some issues under PS3 Linux with IBM 2.1 SDK, gcc compiler prevent from using aligned quadword.
     29 */
     30#ifndef USE_LIBSPE2
     31ATTRIBUTE_ALIGNED16(class) btQuadWordStorage
     32#else
    2833class btQuadWordStorage
     34#endif
    2935{
    3036protected:
    3137
    32         btScalar        m_x;
    33         btScalar        m_y;
    34         btScalar        m_z;
    35         btScalar        m_unusedW;
    36 
     38#if defined (__SPU__) && defined (__CELLOS_LV2__)
     39        union {
     40                vec_float4 mVec128;
     41                btScalar        m_floats[4];
     42        };
    3743public:
     44        vec_float4      get128() const
     45        {
     46                return mVec128;
     47        }
     48#else //__CELLOS_LV2__ __SPU__
     49        btScalar        m_floats[4];
     50#endif //__CELLOS_LV2__ __SPU__
    3851
    3952};
    4053
    41 
    42 ///btQuadWord is base-class for vectors, points
     54/** @brief The btQuadWord is base-class for vectors, points */
    4355class   btQuadWord : public btQuadWordStorage
    4456{
    4557        public:
    46        
    47 //              SIMD_FORCE_INLINE btScalar&       operator[](int i)       { return (&m_x)[i];   }     
    48 //              SIMD_FORCE_INLINE const btScalar& operator[](int i) const { return (&m_x)[i]; }
     58 
    4959
    50                 SIMD_FORCE_INLINE const btScalar& getX() const { return m_x; }
     60  /**@brief Return the x value */
     61                SIMD_FORCE_INLINE const btScalar& getX() const { return m_floats[0]; }
     62  /**@brief Return the y value */
     63                SIMD_FORCE_INLINE const btScalar& getY() const { return m_floats[1]; }
     64  /**@brief Return the z value */
     65                SIMD_FORCE_INLINE const btScalar& getZ() const { return m_floats[2]; }
     66  /**@brief Set the x value */
     67                SIMD_FORCE_INLINE void  setX(btScalar x) { m_floats[0] = x;};
     68  /**@brief Set the y value */
     69                SIMD_FORCE_INLINE void  setY(btScalar y) { m_floats[1] = y;};
     70  /**@brief Set the z value */
     71                SIMD_FORCE_INLINE void  setZ(btScalar z) { m_floats[2] = z;};
     72  /**@brief Set the w value */
     73                SIMD_FORCE_INLINE void  setW(btScalar w) { m_floats[3] = w;};
     74  /**@brief Return the x value */
     75                SIMD_FORCE_INLINE const btScalar& x() const { return m_floats[0]; }
     76  /**@brief Return the y value */
     77                SIMD_FORCE_INLINE const btScalar& y() const { return m_floats[1]; }
     78  /**@brief Return the z value */
     79                SIMD_FORCE_INLINE const btScalar& z() const { return m_floats[2]; }
     80  /**@brief Return the w value */
     81                SIMD_FORCE_INLINE const btScalar& w() const { return m_floats[3]; }
    5182
    52                 SIMD_FORCE_INLINE const btScalar& getY() const { return m_y; }
     83        //SIMD_FORCE_INLINE btScalar&       operator[](int i)       { return (&m_floats[0])[i]; }     
     84        //SIMD_FORCE_INLINE const btScalar& operator[](int i) const { return (&m_floats[0])[i]; }
     85        ///operator btScalar*() replaces operator[], using implicit conversion. We added operator != and operator == to avoid pointer comparisons.
     86        SIMD_FORCE_INLINE       operator       btScalar *()       { return &m_floats[0]; }
     87        SIMD_FORCE_INLINE       operator const btScalar *() const { return &m_floats[0]; }
    5388
    54                 SIMD_FORCE_INLINE const btScalar& getZ() const { return m_z; }
     89        SIMD_FORCE_INLINE       bool    operator==(const btQuadWord& other) const
     90        {
     91                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]));
     92        }
    5593
    56                 SIMD_FORCE_INLINE void  setX(btScalar x) { m_x = x;};
     94        SIMD_FORCE_INLINE       bool    operator!=(const btQuadWord& other) const
     95        {
     96                return !(*this == other);
     97        }
    5798
    58                 SIMD_FORCE_INLINE void  setY(btScalar y) { m_y = y;};
    59 
    60                 SIMD_FORCE_INLINE void  setZ(btScalar z) { m_z = z;};
    61 
    62                 SIMD_FORCE_INLINE void  setW(btScalar w) { m_unusedW = w;};
    63 
    64                 SIMD_FORCE_INLINE const btScalar& x() const { return m_x; }
    65 
    66                 SIMD_FORCE_INLINE const btScalar& y() const { return m_y; }
    67 
    68                 SIMD_FORCE_INLINE const btScalar& z() const { return m_z; }
    69 
    70                 SIMD_FORCE_INLINE const btScalar& w() const { return m_unusedW; }
    71 
    72 
    73                 SIMD_FORCE_INLINE       operator       btScalar *()       { return &m_x; }
    74                 SIMD_FORCE_INLINE       operator const btScalar *() const { return &m_x; }
    75 
    76 
    77 
     99  /**@brief Set x,y,z and zero w
     100   * @param x Value of x
     101   * @param y Value of y
     102   * @param z Value of z
     103   */
    78104                SIMD_FORCE_INLINE void  setValue(const btScalar& x, const btScalar& y, const btScalar& z)
    79105                {
    80                         m_x=x;
    81                         m_y=y;
    82                         m_z=z;
    83                         m_unusedW = 0.f;
     106                        m_floats[0]=x;
     107                        m_floats[1]=y;
     108                        m_floats[2]=z;
     109                        m_floats[3] = 0.f;
    84110                }
    85111
    86112/*              void getValue(btScalar *m) const
    87113                {
    88                         m[0] = m_x;
    89                         m[1] = m_y;
    90                         m[2] = m_z;
     114                        m[0] = m_floats[0];
     115                        m[1] = m_floats[1];
     116                        m[2] = m_floats[2];
    91117                }
    92118*/
     119/**@brief Set the values
     120   * @param x Value of x
     121   * @param y Value of y
     122   * @param z Value of z
     123   * @param w Value of w
     124   */
    93125                SIMD_FORCE_INLINE void  setValue(const btScalar& x, const btScalar& y, const btScalar& z,const btScalar& w)
    94126                {
    95                         m_x=x;
    96                         m_y=y;
    97                         m_z=z;
    98                         m_unusedW=w;
     127                        m_floats[0]=x;
     128                        m_floats[1]=y;
     129                        m_floats[2]=z;
     130                        m_floats[3]=w;
    99131                }
    100 
     132  /**@brief No initialization constructor */
    101133                SIMD_FORCE_INLINE btQuadWord()
    102                 //      :m_x(btScalar(0.)),m_y(btScalar(0.)),m_z(btScalar(0.)),m_unusedW(btScalar(0.))
     134                //      :m_floats[0](btScalar(0.)),m_floats[1](btScalar(0.)),m_floats[2](btScalar(0.)),m_floats[3](btScalar(0.))
    103135                {
    104136                }
    105 
     137  /**@brief Copy constructor */
    106138                SIMD_FORCE_INLINE btQuadWord(const btQuadWordStorage& q)
    107139                {
    108140                        *((btQuadWordStorage*)this) = q;
    109141                }
    110 
     142  /**@brief Three argument constructor (zeros w)
     143   * @param x Value of x
     144   * @param y Value of y
     145   * @param z Value of z
     146   */
    111147                SIMD_FORCE_INLINE btQuadWord(const btScalar& x, const btScalar& y, const btScalar& z)           
    112148                {
    113                         m_x = x, m_y = y, m_z = z, m_unusedW = 0.0f;
     149                        m_floats[0] = x, m_floats[1] = y, m_floats[2] = z, m_floats[3] = 0.0f;
    114150                }
    115151
     152/**@brief Initializing constructor
     153   * @param x Value of x
     154   * @param y Value of y
     155   * @param z Value of z
     156   * @param w Value of w
     157   */
    116158                SIMD_FORCE_INLINE btQuadWord(const btScalar& x, const btScalar& y, const btScalar& z,const btScalar& w)
    117159                {
    118                         m_x = x, m_y = y, m_z = z, m_unusedW = w;
     160                        m_floats[0] = x, m_floats[1] = y, m_floats[2] = z, m_floats[3] = w;
    119161                }
    120162
    121 
     163  /**@brief Set each element to the max of the current values and the values of another btQuadWord
     164   * @param other The other btQuadWord to compare with
     165   */
    122166                SIMD_FORCE_INLINE void  setMax(const btQuadWord& other)
    123167                {
    124                         btSetMax(m_x, other.m_x);
    125                         btSetMax(m_y, other.m_y);
    126                         btSetMax(m_z, other.m_z);
    127                         btSetMax(m_unusedW, other.m_unusedW);
     168                        btSetMax(m_floats[0], other.m_floats[0]);
     169                        btSetMax(m_floats[1], other.m_floats[1]);
     170                        btSetMax(m_floats[2], other.m_floats[2]);
     171                        btSetMax(m_floats[3], other.m_floats[3]);
    128172                }
    129 
     173  /**@brief Set each element to the min of the current values and the values of another btQuadWord
     174   * @param other The other btQuadWord to compare with
     175   */
    130176                SIMD_FORCE_INLINE void  setMin(const btQuadWord& other)
    131177                {
    132                         btSetMin(m_x, other.m_x);
    133                         btSetMin(m_y, other.m_y);
    134                         btSetMin(m_z, other.m_z);
    135                         btSetMin(m_unusedW, other.m_unusedW);
     178                        btSetMin(m_floats[0], other.m_floats[0]);
     179                        btSetMin(m_floats[1], other.m_floats[1]);
     180                        btSetMin(m_floats[2], other.m_floats[2]);
     181                        btSetMin(m_floats[3], other.m_floats[3]);
    136182                }
    137183
Note: See TracChangeset for help on using the changeset viewer.