Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/trunk/src/external/bullet/BulletDynamics/Dynamics/btContinuousDynamicsWorld.cpp @ 8351

Last change on this file since 8351 was 8351, checked in by rgrieder, 13 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: 6.0 KB
Line 
1/*
2Bullet Continuous Collision Detection and Physics Library
3Copyright (c) 2003-2007 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
17#include "btContinuousDynamicsWorld.h"
18#include "LinearMath/btQuickprof.h"
19
20//collision detection
21#include "BulletCollision/CollisionDispatch/btCollisionDispatcher.h"
22#include "BulletCollision/BroadphaseCollision/btSimpleBroadphase.h"
23#include "BulletCollision/CollisionShapes/btCollisionShape.h"
24#include "BulletCollision/CollisionDispatch/btSimulationIslandManager.h"
25
26//rigidbody & constraints
27#include "BulletDynamics/Dynamics/btRigidBody.h"
28#include "BulletDynamics/ConstraintSolver/btSequentialImpulseConstraintSolver.h"
29#include "BulletDynamics/ConstraintSolver/btContactSolverInfo.h"
30#include "BulletDynamics/ConstraintSolver/btTypedConstraint.h"
31
32
33
34#include <stdio.h>
35
36btContinuousDynamicsWorld::btContinuousDynamicsWorld(btDispatcher* dispatcher,btBroadphaseInterface* pairCache,btConstraintSolver* constraintSolver,btCollisionConfiguration* collisionConfiguration)
37:btDiscreteDynamicsWorld(dispatcher,pairCache,constraintSolver,collisionConfiguration)
38{
39}
40
41btContinuousDynamicsWorld::~btContinuousDynamicsWorld()
42{
43}
44
45       
46void    btContinuousDynamicsWorld::internalSingleStepSimulation( btScalar timeStep)
47{
48       
49        startProfiling(timeStep);
50       
51        if(0 != m_internalPreTickCallback) {
52                (*m_internalPreTickCallback)(this, timeStep);
53        }
54
55
56        ///update aabbs information
57        updateAabbs();
58        //static int frame=0;
59//      printf("frame %d\n",frame++);
60
61        ///apply gravity, predict motion
62        predictUnconstraintMotion(timeStep);
63
64        btDispatcherInfo& dispatchInfo = getDispatchInfo();
65
66        dispatchInfo.m_timeStep = timeStep;
67        dispatchInfo.m_stepCount = 0;
68        dispatchInfo.m_debugDraw = getDebugDrawer();
69
70        ///perform collision detection
71        performDiscreteCollisionDetection();
72
73        calculateSimulationIslands();
74
75       
76        getSolverInfo().m_timeStep = timeStep;
77       
78
79
80        ///solve contact and other joint constraints
81        solveConstraints(getSolverInfo());
82       
83        ///CallbackTriggers();
84        calculateTimeOfImpacts(timeStep);
85
86        btScalar toi = dispatchInfo.m_timeOfImpact;
87//      if (toi < 1.f)
88//              printf("toi = %f\n",toi);
89        if (toi < 0.f)
90                printf("toi = %f\n",toi);
91
92
93        ///integrate transforms
94        integrateTransforms(timeStep * toi);
95
96        ///update vehicle simulation
97        updateActions(timeStep);
98
99        updateActivationState( timeStep );
100       
101        if(0 != m_internalTickCallback) {
102                (*m_internalTickCallback)(this, timeStep);
103        }
104}
105
106void    btContinuousDynamicsWorld::calculateTimeOfImpacts(btScalar timeStep)
107{
108                ///these should be 'temporal' aabbs!
109                updateTemporalAabbs(timeStep);
110               
111                ///'toi' is the global smallest time of impact. However, we just calculate the time of impact for each object individually.
112                ///so we handle the case moving versus static properly, and we cheat for moving versus moving
113                btScalar toi = 1.f;
114               
115       
116                btDispatcherInfo& dispatchInfo = getDispatchInfo();
117                dispatchInfo.m_timeStep = timeStep;
118                dispatchInfo.m_timeOfImpact = 1.f;
119                dispatchInfo.m_stepCount = 0;
120                dispatchInfo.m_dispatchFunc = btDispatcherInfo::DISPATCH_CONTINUOUS;
121
122                ///calculate time of impact for overlapping pairs
123
124
125                btDispatcher* dispatcher = getDispatcher();
126                if (dispatcher)
127                        dispatcher->dispatchAllCollisionPairs(m_broadphasePairCache->getOverlappingPairCache(),dispatchInfo,m_dispatcher1);
128
129                toi = dispatchInfo.m_timeOfImpact;
130
131                dispatchInfo.m_dispatchFunc = btDispatcherInfo::DISPATCH_DISCRETE;
132
133}
134
135void    btContinuousDynamicsWorld::updateTemporalAabbs(btScalar timeStep)
136{
137
138        btVector3 temporalAabbMin,temporalAabbMax;
139
140        for ( int i=0;i<m_collisionObjects.size();i++)
141        {
142                btCollisionObject* colObj = m_collisionObjects[i];
143               
144                btRigidBody* body = btRigidBody::upcast(colObj);
145                if (body)
146                {
147                        body->getCollisionShape()->getAabb(m_collisionObjects[i]->getWorldTransform(),temporalAabbMin,temporalAabbMax);
148                        const btVector3& linvel = body->getLinearVelocity();
149
150                        //make the AABB temporal
151                        btScalar temporalAabbMaxx = temporalAabbMax.getX();
152                        btScalar temporalAabbMaxy = temporalAabbMax.getY();
153                        btScalar temporalAabbMaxz = temporalAabbMax.getZ();
154                        btScalar temporalAabbMinx = temporalAabbMin.getX();
155                        btScalar temporalAabbMiny = temporalAabbMin.getY();
156                        btScalar temporalAabbMinz = temporalAabbMin.getZ();
157
158                        // add linear motion
159                        btVector3 linMotion = linvel*timeStep;
160               
161                        if (linMotion.x() > 0.f)
162                                temporalAabbMaxx += linMotion.x(); 
163                        else
164                                temporalAabbMinx += linMotion.x();
165                        if (linMotion.y() > 0.f)
166                                temporalAabbMaxy += linMotion.y(); 
167                        else
168                                temporalAabbMiny += linMotion.y();
169                        if (linMotion.z() > 0.f)
170                                temporalAabbMaxz += linMotion.z(); 
171                        else
172                                temporalAabbMinz += linMotion.z();
173
174                        //add conservative angular motion
175                        btScalar angularMotion(0);// = angvel.length() * GetAngularMotionDisc() * timeStep;
176                        btVector3 angularMotion3d(angularMotion,angularMotion,angularMotion);
177                        temporalAabbMin = btVector3(temporalAabbMinx,temporalAabbMiny,temporalAabbMinz);
178                        temporalAabbMax = btVector3(temporalAabbMaxx,temporalAabbMaxy,temporalAabbMaxz);
179
180                        temporalAabbMin -= angularMotion3d;
181                        temporalAabbMax += angularMotion3d;
182
183                        m_broadphasePairCache->setAabb(body->getBroadphaseHandle(),temporalAabbMin,temporalAabbMax,m_dispatcher1);
184                }
185        }
186
187        //update aabb (of all moved objects)
188
189        m_broadphasePairCache->calculateOverlappingPairs(m_dispatcher1);
190       
191
192
193}
194
195
196
Note: See TracBrowser for help on using the repository browser.