Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/trunk/src/external/bullet/BulletDynamics/Dynamics/btDiscreteDynamicsWorld.h @ 6741

Last change on this file since 6741 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
RevLine 
[1963]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;
[2882]26class btActionInterface;
[1963]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
[2882]53        btAlignedObjectArray<btActionInterface*>        m_actions;
[1963]54       
55        int     m_profileTimings;
56
57        virtual void    predictUnconstraintMotion(btScalar timeStep);
58       
59        virtual void    integrateTransforms(btScalar timeStep);
60               
[2430]61        virtual void    calculateSimulationIslands();
[1963]62
[2430]63        virtual void    solveConstraints(btContactSolverInfo& solverInfo);
[1963]64       
65        void    updateActivationState(btScalar timeStep);
66
[2882]67        void    updateActions(btScalar timeStep);
[1963]68
69        void    startProfiling(btScalar timeStep);
70
71        virtual void    internalSingleStepSimulation( btScalar timeStep);
72
73
[2430]74        virtual void    saveKinematicState(btScalar timeStep);
[1963]75
76        void    debugDrawSphere(btScalar radius, const btTransform& transform, const btVector3& color);
77
[2430]78
[1963]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
[2430]91        virtual void    synchronizeMotionStates();
[1963]92
[2430]93        ///this can be useful to synchronize a single rigid body -> graphics object
94        void    synchronizeSingleMotionState(btRigidBody* body);
[1963]95
[2430]96        virtual void    addConstraint(btTypedConstraint* constraint, bool disableCollisionsBetweenLinkedBodies=false);
[1963]97
[2430]98        virtual void    removeConstraint(btTypedConstraint* constraint);
[1963]99
[2882]100        virtual void    addAction(btActionInterface*);
[2430]101
[2882]102        virtual void    removeAction(btActionInterface*);
[2430]103       
[1963]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);
[2882]120
[1963]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
[2882]131        void    debugDrawConstraint(btTypedConstraint* constraint);
132
[1963]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        {
[2430]159        (void) numTasks;
[1963]160        }
161
[2882]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
[1963]177};
178
179#endif //BT_DISCRETE_DYNAMICS_WORLD_H
Note: See TracBrowser for help on using the repository browser.