Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/presentation/src/bullet/LinearMath/btQuadWord.h @ 2736

Last change on this file since 2736 was 2459, checked in by rgrieder, 16 years ago

Merged physics_merge back to presentation branch.

  • Property svn:eol-style set to native
File size: 6.1 KB
RevLine 
[1963]1/*
2Copyright (c) 2003-2006 Gino van den Bergen / Erwin Coumans  http://continuousphysics.com/Bullet/
3
4This software is provided 'as-is', without any express or implied warranty.
5In no event will the authors be held liable for any damages arising from the use of this software.
6Permission is granted to anyone to use this software for any purpose,
7including commercial applications, and to alter it and redistribute it freely,
8subject to the following restrictions:
9
101. 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.
112. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
123. This notice may not be removed or altered from any source distribution.
13*/
14
15
16#ifndef SIMD_QUADWORD_H
17#define SIMD_QUADWORD_H
18
19#include "btScalar.h"
20#include "btMinMax.h"
21
22
[2430]23#if defined (__CELLOS_LV2) && defined (__SPU__)
24#include <altivec.h>
25#endif
[1963]26
[2430]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
[1963]33class btQuadWordStorage
[2430]34#endif
[1963]35{
36protected:
37
[2430]38#if defined (__SPU__) && defined (__CELLOS_LV2__)
39        union {
40                vec_float4 mVec128;
41                btScalar        m_floats[4];
42        };
[1963]43public:
[2430]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__
[1963]51
52};
53
[2430]54/** @brief The btQuadWord is base-class for vectors, points */
[1963]55class   btQuadWord : public btQuadWordStorage
56{
57        public:
[2430]58 
[1963]59
[2430]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]; }
[1963]82
[2430]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]; }
[1963]88
[2430]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        }
[1963]93
[2430]94        SIMD_FORCE_INLINE       bool    operator!=(const btQuadWord& other) const
95        {
96                return !(*this == other);
97        }
[1963]98
[2430]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   */
[1963]104                SIMD_FORCE_INLINE void  setValue(const btScalar& x, const btScalar& y, const btScalar& z)
105                {
[2430]106                        m_floats[0]=x;
107                        m_floats[1]=y;
108                        m_floats[2]=z;
109                        m_floats[3] = 0.f;
[1963]110                }
111
112/*              void getValue(btScalar *m) const
113                {
[2430]114                        m[0] = m_floats[0];
115                        m[1] = m_floats[1];
116                        m[2] = m_floats[2];
[1963]117                }
118*/
[2430]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   */
[1963]125                SIMD_FORCE_INLINE void  setValue(const btScalar& x, const btScalar& y, const btScalar& z,const btScalar& w)
126                {
[2430]127                        m_floats[0]=x;
128                        m_floats[1]=y;
129                        m_floats[2]=z;
130                        m_floats[3]=w;
[1963]131                }
[2430]132  /**@brief No initialization constructor */
[1963]133                SIMD_FORCE_INLINE btQuadWord()
[2430]134                //      :m_floats[0](btScalar(0.)),m_floats[1](btScalar(0.)),m_floats[2](btScalar(0.)),m_floats[3](btScalar(0.))
[1963]135                {
136                }
[2430]137  /**@brief Copy constructor */
[1963]138                SIMD_FORCE_INLINE btQuadWord(const btQuadWordStorage& q)
139                {
140                        *((btQuadWordStorage*)this) = q;
141                }
[2430]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   */
[1963]147                SIMD_FORCE_INLINE btQuadWord(const btScalar& x, const btScalar& y, const btScalar& z)           
148                {
[2430]149                        m_floats[0] = x, m_floats[1] = y, m_floats[2] = z, m_floats[3] = 0.0f;
[1963]150                }
151
[2430]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   */
[1963]158                SIMD_FORCE_INLINE btQuadWord(const btScalar& x, const btScalar& y, const btScalar& z,const btScalar& w) 
159                {
[2430]160                        m_floats[0] = x, m_floats[1] = y, m_floats[2] = z, m_floats[3] = w;
[1963]161                }
162
[2430]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   */
[1963]166                SIMD_FORCE_INLINE void  setMax(const btQuadWord& other)
167                {
[2430]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]);
[1963]172                }
[2430]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   */
[1963]176                SIMD_FORCE_INLINE void  setMin(const btQuadWord& other)
177                {
[2430]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]);
[1963]182                }
183
184
185
186};
187
188#endif //SIMD_QUADWORD_H
Note: See TracBrowser for help on using the repository browser.