Blender V2.61 - r43446
|
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 addRigidBody(btRigidBody* body, short group, short mask) = 0; 00090 00091 virtual void removeRigidBody(btRigidBody* body) = 0; 00092 00093 virtual void setConstraintSolver(btConstraintSolver* solver) = 0; 00094 00095 virtual btConstraintSolver* getConstraintSolver() = 0; 00096 00097 virtual int getNumConstraints() const { return 0; } 00098 00099 virtual btTypedConstraint* getConstraint(int index) { (void)index; return 0; } 00100 00101 virtual const btTypedConstraint* getConstraint(int index) const { (void)index; return 0; } 00102 00103 virtual btDynamicsWorldType getWorldType() const=0; 00104 00105 virtual void clearForces() = 0; 00106 00108 void setInternalTickCallback(btInternalTickCallback cb, void* worldUserInfo=0,bool isPreTick=false) 00109 { 00110 if (isPreTick) 00111 { 00112 m_internalPreTickCallback = cb; 00113 } else 00114 { 00115 m_internalTickCallback = cb; 00116 } 00117 m_worldUserInfo = worldUserInfo; 00118 } 00119 00120 void setWorldUserInfo(void* worldUserInfo) 00121 { 00122 m_worldUserInfo = worldUserInfo; 00123 } 00124 00125 void* getWorldUserInfo() const 00126 { 00127 return m_worldUserInfo; 00128 } 00129 00130 btContactSolverInfo& getSolverInfo() 00131 { 00132 return m_solverInfo; 00133 } 00134 00135 00137 virtual void addVehicle(btActionInterface* vehicle) {(void)vehicle;} 00139 virtual void removeVehicle(btActionInterface* vehicle) {(void)vehicle;} 00141 virtual void addCharacter(btActionInterface* character) {(void)character;} 00143 virtual void removeCharacter(btActionInterface* character) {(void)character;} 00144 00145 00146 }; 00147 00148 #endif //BT_DYNAMICS_WORLD_H 00149 00150