Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/gamestate/src/external/bullet/BulletDynamics/Dynamics/btDiscreteDynamicsWorld.h @ 6815

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