Bullet Collision Detection & Physics Library: btDynamicsWorld.h Source File

Bullet Collision Detection & Physics Library

- Main Page
- Namespaces
- Classes
- Files

- File List
- File Members

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
19 #include "BulletCollision/CollisionDispatch/btCollisionWorld.h"
20 #include "BulletDynamics/ConstraintSolver/btContactSolverInfo.h"
21
22 class btTypedConstraint;
23 class btActionInterface;
24 class btConstraintSolver;
25 class btDynamicsWorld;
26
27
29 typedef void (*btInternalTickCallback)(btDynamicsWorld *world, btScalar timeStep);
30
31 enum btDynamicsWorldType
32 {
33 BT_SIMPLE_DYNAMICS_WORLD=1,
34 BT_DISCRETE_DYNAMICS_WORLD=2,
35 BT_CONTINUOUS_DYNAMICS_WORLD=3,
36 BT_SOFT_RIGID_DYNAMICS_WORLD=4,
37 BT_GPU_DYNAMICS_WORLD=5
38 };
39
41 class btDynamicsWorld : public btCollisionWorld
42 {
43
44 protected:
45 btInternalTickCallback m_internalTickCallback;
46 btInternalTickCallback m_internalPreTickCallback;
47 void* m_worldUserInfo;
48
49 btContactSolverInfo m_solverInfo;
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
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
110 void setInternalTickCallback(btInternalTickCallback cb, void* worldUserInfo=0,bool isPreTick=false)
111 {
112 if (isPreTick)
113 {
114 m_internalPreTickCallback = cb;
115 } else
116 {
117 m_internalTickCallback = cb;
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
132 btContactSolverInfo& getSolverInfo()
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
151 struct btDynamicsWorldDoubleData
152 {
153 btContactSolverInfoDoubleData m_solverInfo;
154 btVector3DoubleData m_gravity;
155 };
156
158 struct btDynamicsWorldFloatData
159 {
160 btContactSolverInfoFloatData m_solverInfo;
161 btVector3FloatData m_gravity;
162 };
163
164
165 #endif //BT_DYNAMICS_WORLD_H
166
167
btDynamicsWorldDoubleData::m_gravity
btVector3DoubleData m_gravity
Definition: btDynamicsWorld.h:154
btDynamicsWorld::getConstraint
virtual const btTypedConstraint * getConstraint(int index) const
Definition: btDynamicsWorld.h:103
btDynamicsWorld::setWorldUserInfo
void setWorldUserInfo(void *worldUserInfo)
Definition: btDynamicsWorld.h:122
btCollisionWorld.h
btDynamicsWorld::removeCharacter
virtual void removeCharacter(btActionInterface *character)
obsolete, use removeAction instead
Definition: btDynamicsWorld.h:145
btDynamicsWorld::addVehicle
virtual void addVehicle(btActionInterface *vehicle)
obsolete, use addAction instead.
Definition: btDynamicsWorld.h:139
btDynamicsWorld::clearForces
virtual void clearForces()=0
btDynamicsWorld::getWorldType
virtual btDynamicsWorldType getWorldType() const =0
btDynamicsWorld::addCharacter
virtual void addCharacter(btActionInterface *character)
obsolete, use addAction instead.
Definition: btDynamicsWorld.h:143
btDynamicsWorldDoubleData
do not change those serialization structures, it requires an updated sBulletDNAstr/sBulletDNAstr64 ...
Definition: btDynamicsWorld.h:151
btDynamicsWorld::synchronizeMotionStates
virtual void synchronizeMotionStates()=0
btDynamicsWorld::setInternalTickCallback
void setInternalTickCallback(btInternalTickCallback cb, void *worldUserInfo=0, bool isPreTick=false)
Set the callback for when an internal tick (simulation substep) happens, optional user info...
Definition: btDynamicsWorld.h:110
BT_CONTINUOUS_DYNAMICS_WORLD
Definition: btDynamicsWorld.h:35
BT_SIMPLE_DYNAMICS_WORLD
Definition: btDynamicsWorld.h:33
btDynamicsWorld::m_internalTickCallback
btInternalTickCallback m_internalTickCallback
Definition: btDynamicsWorld.h:45
btDynamicsWorld
The btDynamicsWorld is the interface class for several dynamics implementation, basic, discrete, parallel, and continuous etc.
Definition: btDynamicsWorld.h:41
btCollisionConfiguration
btCollisionConfiguration allows to configure Bullet collision detection stack allocator size...
Definition: btCollisionConfiguration.h:26
btActionInterface
Basic interface to allow actions such as vehicles and characters to be updated inside a btDynamicsWor...
Definition: btActionInterface.h:26
btDynamicsWorld::setGravity
virtual void setGravity(const btVector3 &gravity)=0
btDynamicsWorld::getNumConstraints
virtual int getNumConstraints() const
Definition: btDynamicsWorld.h:99
btDynamicsWorldFloatData::m_gravity
btVector3FloatData m_gravity
Definition: btDynamicsWorld.h:161
btDynamicsWorld::m_solverInfo
btContactSolverInfo m_solverInfo
Definition: btDynamicsWorld.h:49
btDynamicsWorld::getGravity
virtual btVector3 getGravity() const =0
btDynamicsWorld::removeAction
virtual void removeAction(btActionInterface *action)=0
btDynamicsWorld::addRigidBody
virtual void addRigidBody(btRigidBody *body)=0
btDynamicsWorldFloatData::m_solverInfo
btContactSolverInfoFloatData m_solverInfo
Definition: btDynamicsWorld.h:160
btDynamicsWorld::m_internalPreTickCallback
btInternalTickCallback m_internalPreTickCallback
Definition: btDynamicsWorld.h:46
btDynamicsWorld::removeConstraint
virtual void removeConstraint(btTypedConstraint *constraint)
Definition: btDynamicsWorld.h:76
btDynamicsWorld::setConstraintSolver
virtual void setConstraintSolver(btConstraintSolver *solver)=0
btInternalTickCallback
void(* btInternalTickCallback)(btDynamicsWorld *world, btScalar timeStep)
Type for the callback for each tick.
Definition: btDynamicsWorld.h:29
btDynamicsWorld::~btDynamicsWorld
virtual ~btDynamicsWorld()
Definition: btDynamicsWorld.h:59
btDynamicsWorld::removeRigidBody
virtual void removeRigidBody(btRigidBody *body)=0
btDynamicsWorld::getConstraint
virtual btTypedConstraint * getConstraint(int index)
Definition: btDynamicsWorld.h:101
btRigidBody
The btRigidBody is the main class for rigid body objects.
Definition: btRigidBody.h:62
btBroadphaseInterface
The btBroadphaseInterface class provides an interface to detect aabb-overlapping object pairs...
Definition: btBroadphaseInterface.h:51
BT_GPU_DYNAMICS_WORLD
Definition: btDynamicsWorld.h:37
btDynamicsWorld::getWorldUserInfo
void * getWorldUserInfo() const
Definition: btDynamicsWorld.h:127
btContactSolverInfoFloatData
do not change those serialization structures, it requires an updated sBulletDNAstr/sBulletDNAstr64 ...
Definition: btContactSolverInfo.h:126
btDynamicsWorldDoubleData::m_solverInfo
btContactSolverInfoDoubleData m_solverInfo
Definition: btDynamicsWorld.h:153
btVector3
btVector3 can be used to represent 3D points and vectors.
Definition: btVector3.h:83
btDynamicsWorld::stepSimulation
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.
btContactSolverInfo
Definition: btContactSolverInfo.h:65
btCollisionWorld
CollisionWorld is interface and container for the collision detection.
Definition: btCollisionWorld.h:88
btTypedConstraint
TypedConstraint is the baseclass for Bullet constraints and vehicles.
Definition: btTypedConstraint.h:77
BT_DISCRETE_DYNAMICS_WORLD
Definition: btDynamicsWorld.h:34
btDynamicsWorld::addConstraint
virtual void addConstraint(btTypedConstraint *constraint, bool disableCollisionsBetweenLinkedBodies=false)
Definition: btDynamicsWorld.h:71
btDynamicsWorldType
btDynamicsWorldType
Definition: btDynamicsWorld.h:31
btDynamicsWorld::debugDrawWorld
virtual void debugDrawWorld()=0
btDynamicsWorld::btDynamicsWorld
btDynamicsWorld(btDispatcher *dispatcher, btBroadphaseInterface *broadphase, btCollisionConfiguration *collisionConfiguration)
Definition: btDynamicsWorld.h:54
btDynamicsWorldFloatData
do not change those serialization structures, it requires an updated sBulletDNAstr/sBulletDNAstr64 ...
Definition: btDynamicsWorld.h:158
btVector3FloatData
Definition: btVector3.h:1301
BT_SOFT_RIGID_DYNAMICS_WORLD
Definition: btDynamicsWorld.h:36
btDispatcher
The btDispatcher interface class can be used in combination with broadphase to dispatch calculations ...
Definition: btDispatcher.h:69
btDynamicsWorld::getSolverInfo
btContactSolverInfo & getSolverInfo()
Definition: btDynamicsWorld.h:132
btDynamicsWorld::m_worldUserInfo
void * m_worldUserInfo
Definition: btDynamicsWorld.h:47
btScalar
float btScalar
The btScalar type abstracts floating point numbers, to easily switch between double and single floati...
Definition: btScalar.h:278
btVector3DoubleData
Definition: btVector3.h:1306
btContactSolverInfoDoubleData
do not change those serialization structures, it requires an updated sBulletDNAstr/sBulletDNAstr64 ...
Definition: btContactSolverInfo.h:98
btDynamicsWorld::addAction
virtual void addAction(btActionInterface *action)=0
btDynamicsWorld::removeVehicle
virtual void removeVehicle(btActionInterface *vehicle)
obsolete, use removeAction instead
Definition: btDynamicsWorld.h:141
btDynamicsWorld::getConstraintSolver
virtual btConstraintSolver * getConstraintSolver()=0
btContactSolverInfo.h
btConstraintSolver
Definition: btConstraintSolver.h:40