source: trunk/src/bullet/LinearMath/btQuadWord.h @ 1640

Last change on this file since 1640 was 1640, checked in by sam, 9 years ago

core: fix shitloads of compiler warnings in the Bullet source code.

  • Property svn:keywords set to Id
File size: 6.0 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// LOL BEGIN
63  /**@brief Set the x value */
64                SIMD_FORCE_INLINE void  setX(btScalar _x) { m_floats[0] = _x;};
65  /**@brief Set the y value */
66                SIMD_FORCE_INLINE void  setY(btScalar _y) { m_floats[1] = _y;};
67  /**@brief Set the z value */
68                SIMD_FORCE_INLINE void  setZ(btScalar _z) { m_floats[2] = _z;};
69  /**@brief Set the w value */
70                SIMD_FORCE_INLINE void  setW(btScalar _w) { m_floats[3] = _w;};
71// LOL END
72  /**@brief Return the x value */
73                SIMD_FORCE_INLINE const btScalar& x() const { return m_floats[0]; }
74  /**@brief Return the y value */
75                SIMD_FORCE_INLINE const btScalar& y() const { return m_floats[1]; }
76  /**@brief Return the z value */
77                SIMD_FORCE_INLINE const btScalar& z() const { return m_floats[2]; }
78  /**@brief Return the w value */
79                SIMD_FORCE_INLINE const btScalar& w() const { return m_floats[3]; }
80
81        //SIMD_FORCE_INLINE btScalar&       operator[](int i)       { return (&m_floats[0])[i]; }     
82        //SIMD_FORCE_INLINE const btScalar& operator[](int i) const { return (&m_floats[0])[i]; }
83        ///operator btScalar*() replaces operator[], using implicit conversion. We added operator != and operator == to avoid pointer comparisons.
84        SIMD_FORCE_INLINE       operator       btScalar *()       { return &m_floats[0]; }
85        SIMD_FORCE_INLINE       operator const btScalar *() const { return &m_floats[0]; }
86
87        SIMD_FORCE_INLINE       bool    operator==(const btQuadWord& other) const
88        {
89                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]));
90        }
91
92        SIMD_FORCE_INLINE       bool    operator!=(const btQuadWord& other) const
93        {
94                return !(*this == other);
95        }
96
97  /**@brief Set x,y,z and zero w
98   * @param x Value of x
99   * @param y Value of y
100   * @param z Value of z
101   */
102// LOL BEGIN
103                SIMD_FORCE_INLINE void  setValue(const btScalar& _x, const btScalar& _y, const btScalar& _z)
104                {
105                        m_floats[0]=_x;
106                        m_floats[1]=_y;
107                        m_floats[2]=_z;
108                        m_floats[3] = 0.f;
109                }
110// LOL END
111
112/*              void getValue(btScalar *m) const
113                {
114                        m[0] = m_floats[0];
115                        m[1] = m_floats[1];
116                        m[2] = m_floats[2];
117                }
118*/
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   */
125// LOL BEGIN
126                SIMD_FORCE_INLINE void  setValue(const btScalar& _x, const btScalar& _y, const btScalar& _z,const btScalar& _w)
127                {
128                        m_floats[0]=_x;
129                        m_floats[1]=_y;
130                        m_floats[2]=_z;
131                        m_floats[3]=_w;
132                }
133// LOL END
134  /**@brief No initialization constructor */
135                SIMD_FORCE_INLINE btQuadWord()
136                //      :m_floats[0](btScalar(0.)),m_floats[1](btScalar(0.)),m_floats[2](btScalar(0.)),m_floats[3](btScalar(0.))
137                {
138                }
139 
140  /**@brief Three argument constructor (zeros w)
141   * @param x Value of x
142   * @param y Value of y
143   * @param z Value of z
144   */
145// LOL BEGIN
146                SIMD_FORCE_INLINE btQuadWord(const btScalar& _x, const btScalar& _y, const btScalar& _z)               
147                {
148                        m_floats[0] = _x, m_floats[1] = _y, m_floats[2] = _z, m_floats[3] = 0.0f;
149                }
150// LOL END
151
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   */
158// LOL BEGIN
159                SIMD_FORCE_INLINE btQuadWord(const btScalar& _x, const btScalar& _y, const btScalar& _z,const btScalar& _w)
160                {
161                        m_floats[0] = _x, m_floats[1] = _y, m_floats[2] = _z, m_floats[3] = _w;
162                }
163// LOL END
164
165  /**@brief Set each element to the max 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  setMax(const btQuadWord& other)
169                {
170                        btSetMax(m_floats[0], other.m_floats[0]);
171                        btSetMax(m_floats[1], other.m_floats[1]);
172                        btSetMax(m_floats[2], other.m_floats[2]);
173                        btSetMax(m_floats[3], other.m_floats[3]);
174                }
175  /**@brief Set each element to the min of the current values and the values of another btQuadWord
176   * @param other The other btQuadWord to compare with
177   */
178                SIMD_FORCE_INLINE void  setMin(const btQuadWord& other)
179                {
180                        btSetMin(m_floats[0], other.m_floats[0]);
181                        btSetMin(m_floats[1], other.m_floats[1]);
182                        btSetMin(m_floats[2], other.m_floats[2]);
183                        btSetMin(m_floats[3], other.m_floats[3]);
184                }
185
186
187
188};
189
190#endif //BT_SIMD_QUADWORD_H
Note: See TracBrowser for help on using the repository browser.