Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/trunk/src/external/bullet/LinearMath/btQuadWord.h @ 6880

Last change on this file since 6880 was 5781, checked in by rgrieder, 15 years ago

Reverted trunk again. We might want to find a way to delete these revisions again (x3n's changes are still available as diff in the commit mails).

  • Property svn:eol-style set to native
File size: 5.8 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
[2882]27/**@brief The btQuadWord class is base class for btVector3 and btQuaternion.
[2430]28 * Some issues under PS3 Linux with IBM 2.1 SDK, gcc compiler prevent from using aligned quadword.
29 */
30#ifndef USE_LIBSPE2
[2882]31ATTRIBUTE_ALIGNED16(class) btQuadWord
[2430]32#else
[2882]33class btQuadWord
[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        }
[2882]48protected:
[2430]49#else //__CELLOS_LV2__ __SPU__
50        btScalar        m_floats[4];
51#endif //__CELLOS_LV2__ __SPU__
[1963]52
53        public:
[2430]54 
[1963]55
[2430]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]; }
[1963]78
[2430]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]; }
[1963]84
[2430]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        }
[1963]89
[2430]90        SIMD_FORCE_INLINE       bool    operator!=(const btQuadWord& other) const
91        {
92                return !(*this == other);
93        }
[1963]94
[2430]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   */
[1963]100                SIMD_FORCE_INLINE void  setValue(const btScalar& x, const btScalar& y, const btScalar& z)
101                {
[2430]102                        m_floats[0]=x;
103                        m_floats[1]=y;
104                        m_floats[2]=z;
105                        m_floats[3] = 0.f;
[1963]106                }
107
108/*              void getValue(btScalar *m) const
109                {
[2430]110                        m[0] = m_floats[0];
111                        m[1] = m_floats[1];
112                        m[2] = m_floats[2];
[1963]113                }
114*/
[2430]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   */
[1963]121                SIMD_FORCE_INLINE void  setValue(const btScalar& x, const btScalar& y, const btScalar& z,const btScalar& w)
122                {
[2430]123                        m_floats[0]=x;
124                        m_floats[1]=y;
125                        m_floats[2]=z;
126                        m_floats[3]=w;
[1963]127                }
[2430]128  /**@brief No initialization constructor */
[1963]129                SIMD_FORCE_INLINE btQuadWord()
[2430]130                //      :m_floats[0](btScalar(0.)),m_floats[1](btScalar(0.)),m_floats[2](btScalar(0.)),m_floats[3](btScalar(0.))
[1963]131                {
132                }
[2882]133 
[2430]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   */
[1963]139                SIMD_FORCE_INLINE btQuadWord(const btScalar& x, const btScalar& y, const btScalar& z)           
140                {
[2430]141                        m_floats[0] = x, m_floats[1] = y, m_floats[2] = z, m_floats[3] = 0.0f;
[1963]142                }
143
[2430]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   */
[1963]150                SIMD_FORCE_INLINE btQuadWord(const btScalar& x, const btScalar& y, const btScalar& z,const btScalar& w) 
151                {
[2430]152                        m_floats[0] = x, m_floats[1] = y, m_floats[2] = z, m_floats[3] = w;
[1963]153                }
154
[2430]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   */
[1963]158                SIMD_FORCE_INLINE void  setMax(const btQuadWord& other)
159                {
[2430]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]);
[1963]164                }
[2430]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   */
[1963]168                SIMD_FORCE_INLINE void  setMin(const btQuadWord& other)
169                {
[2430]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]);
[1963]174                }
175
176
177
178};
179
180#endif //SIMD_QUADWORD_H
Note: See TracBrowser for help on using the repository browser.