Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016 #ifndef BT_DYNAMICS_WORLD_H
00017 #define BT_DYNAMICS_WORLD_H
00018
00019 #include "BulletCollision/CollisionDispatch/btCollisionWorld.h"
00020 #include "BulletDynamics/ConstraintSolver/btContactSolverInfo.h"
00021
00022 class btTypedConstraint;
00023 class btActionInterface;
00024 class btConstraintSolver;
00025 class btDynamicsWorld;
00026
00027
00029 typedef void (*btInternalTickCallback)(btDynamicsWorld *world, btScalar timeStep);
00030
00031 enum btDynamicsWorldType
00032 {
00033 BT_SIMPLE_DYNAMICS_WORLD=1,
00034 BT_DISCRETE_DYNAMICS_WORLD=2,
00035 BT_CONTINUOUS_DYNAMICS_WORLD=3,
00036 BT_SOFT_RIGID_DYNAMICS_WORLD=4
00037 };
00038
00040 class btDynamicsWorld : public btCollisionWorld
00041 {
00042
00043 protected:
00044 btInternalTickCallback m_internalTickCallback;
00045 btInternalTickCallback m_internalPreTickCallback;
00046 void* m_worldUserInfo;
00047
00048 btContactSolverInfo m_solverInfo;
00049
00050 public:
00051
00052
00053 btDynamicsWorld(btDispatcher* dispatcher,btBroadphaseInterface* broadphase,btCollisionConfiguration* collisionConfiguration)
00054 :btCollisionWorld(dispatcher,broadphase,collisionConfiguration), m_internalTickCallback(0),m_internalPreTickCallback(0), m_worldUserInfo(0)
00055 {
00056 }
00057
00058 virtual ~btDynamicsWorld()
00059 {
00060 }
00061
00066 virtual int stepSimulation( btScalar timeStep,int maxSubSteps=1, btScalar fixedTimeStep=btScalar(1.)/btScalar(60.))=0;
00067
00068 virtual void debugDrawWorld() = 0;
00069
00070 virtual void addConstraint(btTypedConstraint* constraint, bool disableCollisionsBetweenLinkedBodies=false)
00071 {
00072 (void)constraint; (void)disableCollisionsBetweenLinkedBodies;
00073 }
00074
00075 virtual void removeConstraint(btTypedConstraint* constraint) {(void)constraint;}
00076
00077 virtual void addAction(btActionInterface* action) = 0;
00078
00079 virtual void removeAction(btActionInterface* action) = 0;
00080
00081
00082
00083 virtual void setGravity(const btVector3& gravity) = 0;
00084 virtual btVector3 getGravity () const = 0;
00085
00086 virtual void synchronizeMotionStates() = 0;
00087
00088 virtual void addRigidBody(btRigidBody* body) = 0;
00089
00090 virtual void addRigidBody(btRigidBody* body, short group, short mask) = 0;
00091
00092 virtual void removeRigidBody(btRigidBody* body) = 0;
00093
00094 virtual void setConstraintSolver(btConstraintSolver* solver) = 0;
00095
00096 virtual btConstraintSolver* getConstraintSolver() = 0;
00097
00098 virtual int getNumConstraints() const { return 0; }
00099
00100 virtual btTypedConstraint* getConstraint(int index) { (void)index; return 0; }
00101
00102 virtual const btTypedConstraint* getConstraint(int index) const { (void)index; return 0; }
00103
00104 virtual btDynamicsWorldType getWorldType() const=0;
00105
00106 virtual void clearForces() = 0;
00107
00109 void setInternalTickCallback(btInternalTickCallback cb, void* worldUserInfo=0,bool isPreTick=false)
00110 {
00111 if (isPreTick)
00112 {
00113 m_internalPreTickCallback = cb;
00114 } else
00115 {
00116 m_internalTickCallback = cb;
00117 }
00118 m_worldUserInfo = worldUserInfo;
00119 }
00120
00121 void setWorldUserInfo(void* worldUserInfo)
00122 {
00123 m_worldUserInfo = worldUserInfo;
00124 }
00125
00126 void* getWorldUserInfo() const
00127 {
00128 return m_worldUserInfo;
00129 }
00130
00131 btContactSolverInfo& getSolverInfo()
00132 {
00133 return m_solverInfo;
00134 }
00135
00136
00138 virtual void addVehicle(btActionInterface* vehicle) {(void)vehicle;}
00140 virtual void removeVehicle(btActionInterface* vehicle) {(void)vehicle;}
00142 virtual void addCharacter(btActionInterface* character) {(void)character;}
00144 virtual void removeCharacter(btActionInterface* character) {(void)character;}
00145
00146
00147 };
00148
00149 #endif //BT_DYNAMICS_WORLD_H
00150
00151