Bullet Collision Detection & Physics Library
btDynamicsWorld.h
Go to the documentation of this file.
1 /*
2 Bullet Continuous Collision Detection and Physics Library
3 Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/
4 
5 This software is provided 'as-is', without any express or implied warranty.
6 In no event will the authors be held liable for any damages arising from the use of this software.
7 Permission is granted to anyone to use this software for any purpose,
8 including commercial applications, and to alter it and redistribute it freely,
9 subject to the following restrictions:
10 
11 1. 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.
12 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
13 3. 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 
21 
22 class btTypedConstraint;
23 class btActionInterface;
24 class btConstraintSolver;
25 class btDynamicsWorld;
26 
27 
29 typedef void (*btInternalTickCallback)(btDynamicsWorld *world, btScalar timeStep);
30 
32 {
38 };
39 
42 {
43 
44 protected:
48 
50 
51 public:
52 
53 
54  btDynamicsWorld(btDispatcher* dispatcher,btBroadphaseInterface* broadphase,btCollisionConfiguration* collisionConfiguration)
55  :btCollisionWorld(dispatcher,broadphase,collisionConfiguration), m_internalTickCallback(0),m_internalPreTickCallback(0), m_worldUserInfo(0)
56  {
57  }
58 
59  virtual ~btDynamicsWorld()
60  {
61  }
62 
67  virtual int stepSimulation( btScalar timeStep,int maxSubSteps=1, btScalar fixedTimeStep=btScalar(1.)/btScalar(60.))=0;
68 
69  virtual void debugDrawWorld() = 0;
70 
71  virtual void addConstraint(btTypedConstraint* constraint, bool disableCollisionsBetweenLinkedBodies=false)
72  {
73  (void)constraint; (void)disableCollisionsBetweenLinkedBodies;
74  }
75 
76  virtual void removeConstraint(btTypedConstraint* constraint) {(void)constraint;}
77 
78  virtual void addAction(btActionInterface* action) = 0;
79 
80  virtual void removeAction(btActionInterface* action) = 0;
81 
82  //once a rigidbody is added to the dynamics world, it will get this gravity assigned
83  //existing rigidbodies in the world get gravity assigned too, during this method
84  virtual void setGravity(const btVector3& gravity) = 0;
85  virtual btVector3 getGravity () const = 0;
86 
87  virtual void synchronizeMotionStates() = 0;
88 
89  virtual void addRigidBody(btRigidBody* body) = 0;
90 
91  virtual void addRigidBody(btRigidBody* body, short group, short mask) = 0;
92 
93  virtual void removeRigidBody(btRigidBody* body) = 0;
94 
95  virtual void setConstraintSolver(btConstraintSolver* solver) = 0;
96 
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 
110  void setInternalTickCallback(btInternalTickCallback cb, void* worldUserInfo=0,bool isPreTick=false)
111  {
112  if (isPreTick)
113  {
115  } else
116  {
118  }
119  m_worldUserInfo = worldUserInfo;
120  }
121 
122  void setWorldUserInfo(void* worldUserInfo)
123  {
124  m_worldUserInfo = worldUserInfo;
125  }
126 
127  void* getWorldUserInfo() const
128  {
129  return m_worldUserInfo;
130  }
131 
133  {
134  return m_solverInfo;
135  }
136 
137 
139  virtual void addVehicle(btActionInterface* vehicle) {(void)vehicle;}
141  virtual void removeVehicle(btActionInterface* vehicle) {(void)vehicle;}
143  virtual void addCharacter(btActionInterface* character) {(void)character;}
145  virtual void removeCharacter(btActionInterface* character) {(void)character;}
146 
147 
148 };
149 
152 {
155 };
156 
159 {
162 };
163 
164 
165 #endif //BT_DYNAMICS_WORLD_H
166 
167 
btVector3DoubleData m_gravity
void(* btInternalTickCallback)(btDynamicsWorld *world, btScalar timeStep)
Type for the callback for each tick.
virtual const btTypedConstraint * getConstraint(int index) const
void setWorldUserInfo(void *worldUserInfo)
virtual void removeCharacter(btActionInterface *character)
obsolete, use removeAction instead
virtual void addVehicle(btActionInterface *vehicle)
obsolete, use addAction instead.
virtual void clearForces()=0
virtual btDynamicsWorldType getWorldType() const =0
virtual void addCharacter(btActionInterface *character)
obsolete, use addAction instead.
do not change those serialization structures, it requires an updated sBulletDNAstr/sBulletDNAstr64 ...
virtual void synchronizeMotionStates()=0
void setInternalTickCallback(btInternalTickCallback cb, void *worldUserInfo=0, bool isPreTick=false)
Set the callback for when an internal tick (simulation substep) happens, optional user info...
btInternalTickCallback m_internalTickCallback
The btDynamicsWorld is the interface class for several dynamics implementation, basic, discrete, parallel, and continuous etc.
btCollisionConfiguration allows to configure Bullet collision detection stack allocator size...
Basic interface to allow actions such as vehicles and characters to be updated inside a btDynamicsWor...
virtual void setGravity(const btVector3 &gravity)=0
virtual int getNumConstraints() const
btVector3FloatData m_gravity
btContactSolverInfo m_solverInfo
virtual btVector3 getGravity() const =0
virtual void removeAction(btActionInterface *action)=0
virtual void addRigidBody(btRigidBody *body)=0
btContactSolverInfoFloatData m_solverInfo
btInternalTickCallback m_internalPreTickCallback
virtual void removeConstraint(btTypedConstraint *constraint)
virtual void setConstraintSolver(btConstraintSolver *solver)=0
virtual ~btDynamicsWorld()
virtual void removeRigidBody(btRigidBody *body)=0
virtual btTypedConstraint * getConstraint(int index)
The btRigidBody is the main class for rigid body objects.
Definition: btRigidBody.h:59
The btBroadphaseInterface class provides an interface to detect aabb-overlapping object pairs...
void * getWorldUserInfo() const
do not change those serialization structures, it requires an updated sBulletDNAstr/sBulletDNAstr64 ...
btContactSolverInfoDoubleData m_solverInfo
btVector3 can be used to represent 3D points and vectors.
Definition: btVector3.h:83
virtual int stepSimulation(btScalar timeStep, int maxSubSteps=1, btScalar fixedTimeStep=btScalar(1.)/btScalar(60.))=0
stepSimulation proceeds the simulation over 'timeStep', units in preferably in seconds.
CollisionWorld is interface and container for the collision detection.
TypedConstraint is the baseclass for Bullet constraints and vehicles.
virtual void addConstraint(btTypedConstraint *constraint, bool disableCollisionsBetweenLinkedBodies=false)
btDynamicsWorldType
virtual void debugDrawWorld()=0
btDynamicsWorld(btDispatcher *dispatcher, btBroadphaseInterface *broadphase, btCollisionConfiguration *collisionConfiguration)
do not change those serialization structures, it requires an updated sBulletDNAstr/sBulletDNAstr64 ...
The btDispatcher interface class can be used in combination with broadphase to dispatch calculations ...
Definition: btDispatcher.h:69
btContactSolverInfo & getSolverInfo()
float btScalar
The btScalar type abstracts floating point numbers, to easily switch between double and single floati...
Definition: btScalar.h:266
do not change those serialization structures, it requires an updated sBulletDNAstr/sBulletDNAstr64 ...
virtual void addAction(btActionInterface *action)=0
virtual void removeVehicle(btActionInterface *vehicle)
obsolete, use removeAction instead
virtual btConstraintSolver * getConstraintSolver()=0