Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/buildsystem3/src/bullet/BulletDynamics/Dynamics/btDiscreteDynamicsWorld.h @ 2697

Last change on this file since 2697 was 2662, checked in by rgrieder, 16 years ago

Merged presentation branch back to trunk.

  • Property svn:eol-style set to native
File size: 5.0 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_DISCRETE_DYNAMICS_WORLD_H
17#define BT_DISCRETE_DYNAMICS_WORLD_H
18
19#include "btDynamicsWorld.h"
20
21class btDispatcher;
22class btOverlappingPairCache;
23class btConstraintSolver;
24class btSimulationIslandManager;
25class btTypedConstraint;
26
27
28class btRaycastVehicle;
29class btCharacterControllerInterface;
30class btIDebugDraw;
31#include "LinearMath/btAlignedObjectArray.h"
32
33
34///btDiscreteDynamicsWorld provides discrete rigid body simulation
35///those classes replace the obsolete CcdPhysicsEnvironment/CcdPhysicsController
36class btDiscreteDynamicsWorld : public btDynamicsWorld
37{
38protected:
39
40        btConstraintSolver*     m_constraintSolver;
41
42        btSimulationIslandManager*      m_islandManager;
43
44        btAlignedObjectArray<btTypedConstraint*> m_constraints;
45
46        btVector3       m_gravity;
47
48        //for variable timesteps
49        btScalar        m_localTime;
50        //for variable timesteps
51
52        bool    m_ownsIslandManager;
53        bool    m_ownsConstraintSolver;
54
55       
56        btAlignedObjectArray<btRaycastVehicle*> m_vehicles;
57       
58        btAlignedObjectArray<btCharacterControllerInterface*> m_characters;
59       
60
61        int     m_profileTimings;
62
63        virtual void    predictUnconstraintMotion(btScalar timeStep);
64       
65        virtual void    integrateTransforms(btScalar timeStep);
66               
67        virtual void    calculateSimulationIslands();
68
69        virtual void    solveConstraints(btContactSolverInfo& solverInfo);
70       
71        void    updateActivationState(btScalar timeStep);
72
73        void    updateVehicles(btScalar timeStep);
74
75        void    updateCharacters(btScalar timeStep);
76
77        void    startProfiling(btScalar timeStep);
78
79        virtual void    internalSingleStepSimulation( btScalar timeStep);
80
81
82        virtual void    saveKinematicState(btScalar timeStep);
83
84        void    debugDrawSphere(btScalar radius, const btTransform& transform, const btVector3& color);
85
86
87public:
88
89
90        ///this btDiscreteDynamicsWorld constructor gets created objects from the user, and will not delete those
91        btDiscreteDynamicsWorld(btDispatcher* dispatcher,btBroadphaseInterface* pairCache,btConstraintSolver* constraintSolver,btCollisionConfiguration* collisionConfiguration);
92
93        virtual ~btDiscreteDynamicsWorld();
94
95        ///if maxSubSteps > 0, it will interpolate motion between fixedTimeStep's
96        virtual int     stepSimulation( btScalar timeStep,int maxSubSteps=1, btScalar fixedTimeStep=btScalar(1.)/btScalar(60.));
97
98
99        virtual void    synchronizeMotionStates();
100
101        ///this can be useful to synchronize a single rigid body -> graphics object
102        void    synchronizeSingleMotionState(btRigidBody* body);
103
104        virtual void    addConstraint(btTypedConstraint* constraint, bool disableCollisionsBetweenLinkedBodies=false);
105
106        virtual void    removeConstraint(btTypedConstraint* constraint);
107
108        virtual void    addVehicle(btRaycastVehicle* vehicle);
109
110        virtual void    removeVehicle(btRaycastVehicle* vehicle);
111       
112        virtual void    addCharacter(btCharacterControllerInterface* character);
113
114        virtual void    removeCharacter(btCharacterControllerInterface* character);
115               
116
117        btSimulationIslandManager*      getSimulationIslandManager()
118        {
119                return m_islandManager;
120        }
121
122        const btSimulationIslandManager*        getSimulationIslandManager() const 
123        {
124                return m_islandManager;
125        }
126
127        btCollisionWorld*       getCollisionWorld()
128        {
129                return this;
130        }
131
132        virtual void    setGravity(const btVector3& gravity);
133        virtual btVector3 getGravity () const;
134
135        virtual void    addRigidBody(btRigidBody* body);
136
137        virtual void    addRigidBody(btRigidBody* body, short group, short mask);
138
139        virtual void    removeRigidBody(btRigidBody* body);
140
141        void    debugDrawObject(const btTransform& worldTransform, const btCollisionShape* shape, const btVector3& color);
142
143        virtual void    debugDrawWorld();
144
145        virtual void    setConstraintSolver(btConstraintSolver* solver);
146
147        virtual btConstraintSolver* getConstraintSolver();
148       
149        virtual int             getNumConstraints() const;
150
151        virtual btTypedConstraint* getConstraint(int index)     ;
152
153        virtual const btTypedConstraint* getConstraint(int index) const;
154
155       
156        virtual btDynamicsWorldType     getWorldType() const
157        {
158                return BT_DISCRETE_DYNAMICS_WORLD;
159        }
160       
161        ///the forces on each rigidbody is accumulating together with gravity. clear this after each timestep.
162        virtual void    clearForces();
163
164        ///apply gravity, call this once per timestep
165        virtual void    applyGravity();
166
167        virtual void    setNumTasks(int numTasks)
168        {
169        (void) numTasks;
170        }
171
172};
173
174#endif //BT_DISCRETE_DYNAMICS_WORLD_H
Note: See TracBrowser for help on using the repository browser.