Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/tutorial2/src/external/bullet/BulletDynamics/ConstraintSolver/btSolverBody.h @ 10256

Last change on this file since 10256 was 8351, checked in by rgrieder, 14 years ago

Merged kicklib2 branch back to trunk (includes former branches ois_update, mac_osx and kicklib).

Notes for updating

Linux:
You don't need an extra package for CEGUILua and Tolua, it's already shipped with CEGUI.
However you do need to make sure that the OgreRenderer is installed too with CEGUI 0.7 (may be a separate package).
Also, Orxonox now recognises if you install the CgProgramManager (a separate package available on newer Ubuntu on Debian systems).

Windows:
Download the new dependency packages versioned 6.0 and use these. If you have problems with that or if you don't like the in game console problem mentioned below, you can download the new 4.3 version of the packages (only available for Visual Studio 2005/2008).

Key new features:

  • *Support for Mac OS X*
  • Visual Studio 2010 support
  • Bullet library update to 2.77
  • OIS library update to 1.3
  • Support for CEGUI 0.7 —> Support for Arch Linux and even SuSE
  • Improved install target
  • Compiles now with GCC 4.6
  • Ogre Cg Shader plugin activated for Linux if available
  • And of course lots of bug fixes

There are also some regressions:

  • No support for CEGUI 0.5, Ogre 1.4 and boost 1.35 - 1.39 any more
  • In game console is not working in main menu for CEGUI 0.7
  • Tolua (just the C lib, not the application) and CEGUILua libraries are no longer in our repository. —> You will need to get these as well when compiling Orxonox
  • And of course lots of new bugs we don't yet know about
  • Property svn:eol-style set to native
File size: 5.2 KB
Line 
1/*
2Bullet Continuous Collision Detection and Physics Library
3Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/
4
5This software is provided 'as-is', without any express or implied warranty.
6In no event will the authors be held liable for any damages arising from the use of this software.
7Permission is granted to anyone to use this software for any purpose,
8including commercial applications, and to alter it and redistribute it freely,
9subject to the following restrictions:
10
111. 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.
122. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
133. This notice may not be removed or altered from any source distribution.
14*/
15
16#ifndef BT_SOLVER_BODY_H
17#define BT_SOLVER_BODY_H
18
19class   btRigidBody;
20#include "LinearMath/btVector3.h"
21#include "LinearMath/btMatrix3x3.h"
22#include "BulletDynamics/Dynamics/btRigidBody.h"
23#include "LinearMath/btAlignedAllocator.h"
24#include "LinearMath/btTransformUtil.h"
25
26///Until we get other contributions, only use SIMD on Windows, when using Visual Studio 2008 or later, and not double precision
27#ifdef BT_USE_SSE
28#define USE_SIMD 1
29#endif //
30
31
32#ifdef USE_SIMD
33
34struct  btSimdScalar
35{
36        SIMD_FORCE_INLINE       btSimdScalar()
37        {
38
39        }
40
41        SIMD_FORCE_INLINE       btSimdScalar(float      fl)
42        :m_vec128 (_mm_set1_ps(fl))
43        {
44        }
45
46        SIMD_FORCE_INLINE       btSimdScalar(__m128 v128)
47                :m_vec128(v128)
48        {
49        }
50        union
51        {
52                __m128          m_vec128;
53                float           m_floats[4];
54                int                     m_ints[4];
55                btScalar        m_unusedPadding;
56        };
57        SIMD_FORCE_INLINE       __m128  get128()
58        {
59                return m_vec128;
60        }
61
62        SIMD_FORCE_INLINE       const __m128    get128() const
63        {
64                return m_vec128;
65        }
66
67        SIMD_FORCE_INLINE       void    set128(__m128 v128)
68        {
69                m_vec128 = v128;
70        }
71
72        SIMD_FORCE_INLINE       operator       __m128()       
73        { 
74                return m_vec128; 
75        }
76        SIMD_FORCE_INLINE       operator const __m128() const 
77        { 
78                return m_vec128; 
79        }
80       
81        SIMD_FORCE_INLINE       operator float() const 
82        { 
83                return m_floats[0]; 
84        }
85
86};
87
88///@brief Return the elementwise product of two btSimdScalar
89SIMD_FORCE_INLINE btSimdScalar
90operator*(const btSimdScalar& v1, const btSimdScalar& v2) 
91{
92        return btSimdScalar(_mm_mul_ps(v1.get128(),v2.get128()));
93}
94
95///@brief Return the elementwise product of two btSimdScalar
96SIMD_FORCE_INLINE btSimdScalar
97operator+(const btSimdScalar& v1, const btSimdScalar& v2) 
98{
99        return btSimdScalar(_mm_add_ps(v1.get128(),v2.get128()));
100}
101
102
103#else
104#define btSimdScalar btScalar
105#endif
106
107///The btSolverBody is an internal datastructure for the constraint solver. Only necessary data is packed to increase cache coherence/performance.
108ATTRIBUTE_ALIGNED64 (struct)    btSolverBodyObsolete
109{
110        BT_DECLARE_ALIGNED_ALLOCATOR();
111        btVector3               m_deltaLinearVelocity;
112        btVector3               m_deltaAngularVelocity;
113        btVector3               m_angularFactor;
114        btVector3               m_invMass;
115        btRigidBody*    m_originalBody;
116        btVector3               m_pushVelocity;
117        btVector3               m_turnVelocity;
118
119       
120        SIMD_FORCE_INLINE void  getVelocityInLocalPointObsolete(const btVector3& rel_pos, btVector3& velocity ) const
121        {
122                if (m_originalBody)
123                        velocity = m_originalBody->getLinearVelocity()+m_deltaLinearVelocity + (m_originalBody->getAngularVelocity()+m_deltaAngularVelocity).cross(rel_pos);
124                else
125                        velocity.setValue(0,0,0);
126        }
127
128        SIMD_FORCE_INLINE void  getAngularVelocity(btVector3& angVel) const
129        {
130                if (m_originalBody)
131                        angVel = m_originalBody->getAngularVelocity()+m_deltaAngularVelocity;
132                else
133                        angVel.setValue(0,0,0);
134        }
135
136
137        //Optimization for the iterative solver: avoid calculating constant terms involving inertia, normal, relative position
138        SIMD_FORCE_INLINE void applyImpulse(const btVector3& linearComponent, const btVector3& angularComponent,const btScalar impulseMagnitude)
139        {
140                //if (m_invMass)
141                {
142                        m_deltaLinearVelocity += linearComponent*impulseMagnitude;
143                        m_deltaAngularVelocity += angularComponent*(impulseMagnitude*m_angularFactor);
144                }
145        }
146
147        SIMD_FORCE_INLINE void internalApplyPushImpulse(const btVector3& linearComponent, const btVector3& angularComponent,btScalar impulseMagnitude)
148        {
149                if (m_originalBody)
150                {
151                        m_pushVelocity += linearComponent*impulseMagnitude;
152                        m_turnVelocity += angularComponent*(impulseMagnitude*m_angularFactor);
153                }
154        }
155       
156        void    writebackVelocity()
157        {
158                if (m_originalBody)
159                {
160                        m_originalBody->setLinearVelocity(m_originalBody->getLinearVelocity()+ m_deltaLinearVelocity);
161                        m_originalBody->setAngularVelocity(m_originalBody->getAngularVelocity()+m_deltaAngularVelocity);
162                       
163                        //m_originalBody->setCompanionId(-1);
164                }
165        }
166
167
168        void    writebackVelocity(btScalar timeStep)
169        {
170        (void) timeStep;
171                if (m_originalBody)
172                {
173                        m_originalBody->setLinearVelocity(m_originalBody->getLinearVelocity()+ m_deltaLinearVelocity);
174                        m_originalBody->setAngularVelocity(m_originalBody->getAngularVelocity()+m_deltaAngularVelocity);
175                       
176                        //correct the position/orientation based on push/turn recovery
177                        btTransform newTransform;
178                        btTransformUtil::integrateTransform(m_originalBody->getWorldTransform(),m_pushVelocity,m_turnVelocity,timeStep,newTransform);
179                        m_originalBody->setWorldTransform(newTransform);
180                       
181                        //m_originalBody->setCompanionId(-1);
182                }
183        }
184       
185
186
187};
188
189#endif //BT_SOLVER_BODY_H
190
191
Note: See TracBrowser for help on using the repository browser.