Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/OrxyRoad_FS18/src/external/bullet/LinearMath/btQuadWord.h @ 12209

Last change on this file since 12209 was 8393, checked in by rgrieder, 14 years ago

Updated Bullet from v2.77 to v2.78.
(I'm not going to make a branch for that since the update from 2.74 to 2.77 hasn't been tested that much either).

You will HAVE to do a complete RECOMPILE! I tested with MSVC and MinGW and they both threw linker errors at me.

  • Property svn:eol-style set to native
File size: 5.8 KB
Line 
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 BT_SIMD_QUADWORD_H
17#define BT_SIMD_QUADWORD_H
18
19#include "btScalar.h"
20#include "btMinMax.h"
21
22
23#if defined (__CELLOS_LV2) && defined (__SPU__)
24#include <altivec.h>
25#endif
26
27/**@brief The btQuadWord 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) btQuadWord
32#else
33class btQuadWord
34#endif
35{
36protected:
37
38#if defined (__SPU__) && defined (__CELLOS_LV2__)
39        union {
40                vec_float4 mVec128;
41                btScalar        m_floats[4];
42        };
43public:
44        vec_float4      get128() const
45        {
46                return mVec128;
47        }
48protected:
49#else //__CELLOS_LV2__ __SPU__
50        btScalar        m_floats[4];
51#endif //__CELLOS_LV2__ __SPU__
52
53        public:
54 
55
56  /**@brief Return the x value */
57                SIMD_FORCE_INLINE const btScalar& getX() const { return m_floats[0]; }
58  /**@brief Return the y value */
59                SIMD_FORCE_INLINE const btScalar& getY() const { return m_floats[1]; }
60  /**@brief Return the z value */
61                SIMD_FORCE_INLINE const btScalar& getZ() const { return m_floats[2]; }
62  /**@brief Set the x value */
63                SIMD_FORCE_INLINE void  setX(btScalar x) { m_floats[0] = x;};
64  /**@brief Set the y value */
65                SIMD_FORCE_INLINE void  setY(btScalar y) { m_floats[1] = y;};
66  /**@brief Set the z value */
67                SIMD_FORCE_INLINE void  setZ(btScalar z) { m_floats[2] = z;};
68  /**@brief Set the w value */
69                SIMD_FORCE_INLINE void  setW(btScalar w) { m_floats[3] = w;};
70  /**@brief Return the x value */
71                SIMD_FORCE_INLINE const btScalar& x() const { return m_floats[0]; }
72  /**@brief Return the y value */
73                SIMD_FORCE_INLINE const btScalar& y() const { return m_floats[1]; }
74  /**@brief Return the z value */
75                SIMD_FORCE_INLINE const btScalar& z() const { return m_floats[2]; }
76  /**@brief Return the w value */
77                SIMD_FORCE_INLINE const btScalar& w() const { return m_floats[3]; }
78
79        //SIMD_FORCE_INLINE btScalar&       operator[](int i)       { return (&m_floats[0])[i]; }     
80        //SIMD_FORCE_INLINE const btScalar& operator[](int i) const { return (&m_floats[0])[i]; }
81        ///operator btScalar*() replaces operator[], using implicit conversion. We added operator != and operator == to avoid pointer comparisons.
82        SIMD_FORCE_INLINE       operator       btScalar *()       { return &m_floats[0]; }
83        SIMD_FORCE_INLINE       operator const btScalar *() const { return &m_floats[0]; }
84
85        SIMD_FORCE_INLINE       bool    operator==(const btQuadWord& other) const
86        {
87                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]));
88        }
89
90        SIMD_FORCE_INLINE       bool    operator!=(const btQuadWord& other) const
91        {
92                return !(*this == other);
93        }
94
95  /**@brief Set x,y,z and zero w
96   * @param x Value of x
97   * @param y Value of y
98   * @param z Value of z
99   */
100                SIMD_FORCE_INLINE void  setValue(const btScalar& x, const btScalar& y, const btScalar& z)
101                {
102                        m_floats[0]=x;
103                        m_floats[1]=y;
104                        m_floats[2]=z;
105                        m_floats[3] = 0.f;
106                }
107
108/*              void getValue(btScalar *m) const
109                {
110                        m[0] = m_floats[0];
111                        m[1] = m_floats[1];
112                        m[2] = m_floats[2];
113                }
114*/
115/**@brief Set the values
116   * @param x Value of x
117   * @param y Value of y
118   * @param z Value of z
119   * @param w Value of w
120   */
121                SIMD_FORCE_INLINE void  setValue(const btScalar& x, const btScalar& y, const btScalar& z,const btScalar& w)
122                {
123                        m_floats[0]=x;
124                        m_floats[1]=y;
125                        m_floats[2]=z;
126                        m_floats[3]=w;
127                }
128  /**@brief No initialization constructor */
129                SIMD_FORCE_INLINE btQuadWord()
130                //      :m_floats[0](btScalar(0.)),m_floats[1](btScalar(0.)),m_floats[2](btScalar(0.)),m_floats[3](btScalar(0.))
131                {
132                }
133 
134  /**@brief Three argument constructor (zeros w)
135   * @param x Value of x
136   * @param y Value of y
137   * @param z Value of z
138   */
139                SIMD_FORCE_INLINE btQuadWord(const btScalar& x, const btScalar& y, const btScalar& z)           
140                {
141                        m_floats[0] = x, m_floats[1] = y, m_floats[2] = z, m_floats[3] = 0.0f;
142                }
143
144/**@brief Initializing constructor
145   * @param x Value of x
146   * @param y Value of y
147   * @param z Value of z
148   * @param w Value of w
149   */
150                SIMD_FORCE_INLINE btQuadWord(const btScalar& x, const btScalar& y, const btScalar& z,const btScalar& w) 
151                {
152                        m_floats[0] = x, m_floats[1] = y, m_floats[2] = z, m_floats[3] = w;
153                }
154
155  /**@brief Set each element to the max of the current values and the values of another btQuadWord
156   * @param other The other btQuadWord to compare with
157   */
158                SIMD_FORCE_INLINE void  setMax(const btQuadWord& other)
159                {
160                        btSetMax(m_floats[0], other.m_floats[0]);
161                        btSetMax(m_floats[1], other.m_floats[1]);
162                        btSetMax(m_floats[2], other.m_floats[2]);
163                        btSetMax(m_floats[3], other.m_floats[3]);
164                }
165  /**@brief Set each element to the min of the current values and the values of another btQuadWord
166   * @param other The other btQuadWord to compare with
167   */
168                SIMD_FORCE_INLINE void  setMin(const btQuadWord& other)
169                {
170                        btSetMin(m_floats[0], other.m_floats[0]);
171                        btSetMin(m_floats[1], other.m_floats[1]);
172                        btSetMin(m_floats[2], other.m_floats[2]);
173                        btSetMin(m_floats[3], other.m_floats[3]);
174                }
175
176
177
178};
179
180#endif //BT_SIMD_QUADWORD_H
Note: See TracBrowser for help on using the repository browser.