btDynamicsWorld.h

Go to the documentation of this file.
00001 /*
00002 Bullet Continuous Collision Detection and Physics Library
00003 Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/
00004 
00005 This software is provided 'as-is', without any express or implied warranty.
00006 In no event will the authors be held liable for any damages arising from the use of this software.
00007 Permission is granted to anyone to use this software for any purpose, 
00008 including commercial applications, and to alter it and redistribute it freely, 
00009 subject to the following restrictions:
00010 
00011 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.
00012 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
00013 3. This notice may not be removed or altered from any source distribution.
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 };
00037 
00039 class btDynamicsWorld : public btCollisionWorld
00040 {
00041 
00042 protected:
00043                 btInternalTickCallback m_internalTickCallback;
00044                 btInternalTickCallback m_internalPreTickCallback;
00045                 void*   m_worldUserInfo;
00046 
00047                 btContactSolverInfo     m_solverInfo;
00048 
00049 public:
00050                 
00051 
00052                 btDynamicsWorld(btDispatcher* dispatcher,btBroadphaseInterface* broadphase,btCollisionConfiguration* collisionConfiguration)
00053                 :btCollisionWorld(dispatcher,broadphase,collisionConfiguration), m_internalTickCallback(0),m_internalPreTickCallback(0), m_worldUserInfo(0)
00054                 {
00055                 }
00056 
00057                 virtual ~btDynamicsWorld()
00058                 {
00059                 }
00060                 
00065                 virtual int             stepSimulation( btScalar timeStep,int maxSubSteps=1, btScalar fixedTimeStep=btScalar(1.)/btScalar(60.))=0;
00066                         
00067                 virtual void    debugDrawWorld() = 0;
00068                                 
00069                 virtual void    addConstraint(btTypedConstraint* constraint, bool disableCollisionsBetweenLinkedBodies=false) 
00070                 { 
00071                         (void)constraint; (void)disableCollisionsBetweenLinkedBodies;
00072                 }
00073 
00074                 virtual void    removeConstraint(btTypedConstraint* constraint) {(void)constraint;}
00075 
00076                 virtual void    addAction(btActionInterface* action) = 0;
00077 
00078                 virtual void    removeAction(btActionInterface* action) = 0;
00079 
00080                 //once a rigidbody is added to the dynamics world, it will get this gravity assigned
00081                 //existing rigidbodies in the world get gravity assigned too, during this method
00082                 virtual void    setGravity(const btVector3& gravity) = 0;
00083                 virtual btVector3 getGravity () const = 0;
00084 
00085                 virtual void    synchronizeMotionStates() = 0;
00086 
00087                 virtual void    addRigidBody(btRigidBody* body) = 0;
00088 
00089                 virtual void    removeRigidBody(btRigidBody* body) = 0;
00090 
00091                 virtual void    setConstraintSolver(btConstraintSolver* solver) = 0;
00092 
00093                 virtual btConstraintSolver* getConstraintSolver() = 0;
00094                 
00095                 virtual int             getNumConstraints() const {     return 0;               }
00096                 
00097                 virtual btTypedConstraint* getConstraint(int index)             {       (void)index;            return 0;               }
00098                 
00099                 virtual const btTypedConstraint* getConstraint(int index) const {       (void)index;    return 0;       }
00100 
00101                 virtual btDynamicsWorldType     getWorldType() const=0;
00102 
00103                 virtual void    clearForces() = 0;
00104 
00106                 void setInternalTickCallback(btInternalTickCallback cb, void* worldUserInfo=0,bool isPreTick=false) 
00107                 { 
00108                         if (isPreTick)
00109                         {
00110                                 m_internalPreTickCallback = cb;
00111                         } else
00112                         {
00113                                 m_internalTickCallback = cb; 
00114                         }
00115                         m_worldUserInfo = worldUserInfo;
00116                 }
00117 
00118                 void    setWorldUserInfo(void* worldUserInfo)
00119                 {
00120                         m_worldUserInfo = worldUserInfo;
00121                 }
00122 
00123                 void*   getWorldUserInfo() const
00124                 {
00125                         return m_worldUserInfo;
00126                 }
00127 
00128                 btContactSolverInfo& getSolverInfo()
00129                 {
00130                         return m_solverInfo;
00131                 }
00132 
00133 
00135                 virtual void    addVehicle(btActionInterface* vehicle) {(void)vehicle;}
00137                 virtual void    removeVehicle(btActionInterface* vehicle) {(void)vehicle;}
00139                 virtual void    addCharacter(btActionInterface* character) {(void)character;}
00141                 virtual void    removeCharacter(btActionInterface* character) {(void)character;}
00142 
00143 
00144 };
00145 
00146 #endif //BT_DYNAMICS_WORLD_H
00147 
00148 

Generated on Mon Feb 15 22:17:04 2010 for Bullet Collision Detection & Physics Library by  doxygen 1.6.1