Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/archive/tutorialFS09/src/bullet/BulletDynamics/Dynamics/btDynamicsWorld.h @ 12412

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

Merged presentation branch back to trunk.

  • Property svn:eol-style set to native
File size: 4.7 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_DYNAMICS_WORLD_H
17#define BT_DYNAMICS_WORLD_H
18
19#include "BulletCollision/CollisionDispatch/btCollisionWorld.h"
20#include "BulletDynamics/ConstraintSolver/btContactSolverInfo.h"
21
22class btTypedConstraint;
23class btRaycastVehicle;
24class btConstraintSolver;
25class btDynamicsWorld;
26class btCharacterControllerInterface;
27
28/// Type for the callback for each tick
29typedef void (*btInternalTickCallback)(btDynamicsWorld *world, btScalar timeStep);
30
31enum btDynamicsWorldType
32{
33        BT_SIMPLE_DYNAMICS_WORLD=1,
34        BT_DISCRETE_DYNAMICS_WORLD=2,
35        BT_CONTINUOUS_DYNAMICS_WORLD=3
36};
37
38///The btDynamicsWorld is the interface class for several dynamics implementation, basic, discrete, parallel, and continuous etc.
39class btDynamicsWorld : public btCollisionWorld
40{
41
42protected:
43                btInternalTickCallback m_internalTickCallback;
44                void*   m_worldUserInfo;
45
46                btContactSolverInfo     m_solverInfo;
47
48public:
49               
50
51                btDynamicsWorld(btDispatcher* dispatcher,btBroadphaseInterface* broadphase,btCollisionConfiguration* collisionConfiguration)
52                :btCollisionWorld(dispatcher,broadphase,collisionConfiguration), m_internalTickCallback(0), m_worldUserInfo(0)
53                {
54                }
55
56                virtual ~btDynamicsWorld()
57                {
58                }
59               
60                ///stepSimulation proceeds the simulation over 'timeStep', units in preferably in seconds.
61                ///By default, Bullet will subdivide the timestep in constant substeps of each 'fixedTimeStep'.
62                ///in order to keep the simulation real-time, the maximum number of substeps can be clamped to 'maxSubSteps'.
63                ///You can disable subdividing the timestep/substepping by passing maxSubSteps=0 as second argument to stepSimulation, but in that case you have to keep the timeStep constant.
64                virtual int             stepSimulation( btScalar timeStep,int maxSubSteps=1, btScalar fixedTimeStep=btScalar(1.)/btScalar(60.))=0;
65                       
66                virtual void    debugDrawWorld() = 0;
67                               
68                virtual void    addConstraint(btTypedConstraint* constraint, bool disableCollisionsBetweenLinkedBodies=false) 
69                { 
70                        (void)constraint; (void)disableCollisionsBetweenLinkedBodies;
71                }
72
73                virtual void    removeConstraint(btTypedConstraint* constraint) {(void)constraint;}
74
75                virtual void    addVehicle(btRaycastVehicle* vehicle) {(void)vehicle;}
76
77                virtual void    removeVehicle(btRaycastVehicle* vehicle) {(void)vehicle;}
78
79                virtual void    addCharacter(btCharacterControllerInterface* character) {(void)character;}
80
81                virtual void    removeCharacter(btCharacterControllerInterface* character) {(void)character;}
82
83
84                //once a rigidbody is added to the dynamics world, it will get this gravity assigned
85                //existing rigidbodies in the world get gravity assigned too, during this method
86                virtual void    setGravity(const btVector3& gravity) = 0;
87                virtual btVector3 getGravity () const = 0;
88
89                virtual void    synchronizeMotionStates() = 0;
90
91                virtual void    addRigidBody(btRigidBody* body) = 0;
92
93                virtual void    removeRigidBody(btRigidBody* body) = 0;
94
95                virtual void    setConstraintSolver(btConstraintSolver* solver) = 0;
96
97                virtual btConstraintSolver* getConstraintSolver() = 0;
98               
99                virtual int             getNumConstraints() const {     return 0;               }
100               
101                virtual btTypedConstraint* getConstraint(int index)             {       (void)index;            return 0;               }
102               
103                virtual const btTypedConstraint* getConstraint(int index) const {       (void)index;    return 0;       }
104
105                virtual btDynamicsWorldType     getWorldType() const=0;
106
107                virtual void    clearForces() = 0;
108
109                /// Set the callback for when an internal tick (simulation substep) happens, optional user info
110                void setInternalTickCallback(btInternalTickCallback cb, void* worldUserInfo=0) 
111                { 
112                        m_internalTickCallback = cb; 
113                        m_worldUserInfo = worldUserInfo;
114                }
115
116                void    setWorldUserInfo(void* worldUserInfo)
117                {
118                        m_worldUserInfo = worldUserInfo;
119                }
120
121                void*   getWorldUserInfo() const
122                {
123                        return m_worldUserInfo;
124                }
125
126                btContactSolverInfo& getSolverInfo()
127                {
128                        return m_solverInfo;
129                }
130
131
132};
133
134#endif //BT_DYNAMICS_WORLD_H
135
136
Note: See TracBrowser for help on using the repository browser.