Back to index

supertuxkart  0.5+dfsg1
btDiscreteDynamicsWorld.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_DISCRETE_DYNAMICS_WORLD_H
00017 #define BT_DISCRETE_DYNAMICS_WORLD_H
00018 
00019 #include "btDynamicsWorld.h"
00020 
00021 class btDispatcher;
00022 class btOverlappingPairCache;
00023 class btConstraintSolver;
00024 class btSimulationIslandManager;
00025 class btTypedConstraint;
00026 #include "BulletDynamics/ConstraintSolver/btContactSolverInfo.h"
00027 
00028 class btRaycastVehicle;
00029 class btIDebugDraw;
00030 #include "LinearMath/btAlignedObjectArray.h"
00031 
00032 
00035 class btDiscreteDynamicsWorld : public btDynamicsWorld
00036 {
00037 protected:
00038 
00039        btConstraintSolver*  m_constraintSolver;
00040 
00041        btSimulationIslandManager*  m_islandManager;
00042 
00043        btAlignedObjectArray<btTypedConstraint*> m_constraints;
00044 
00045 
00046        btVector3     m_gravity;
00047 
00048        //for variable timesteps
00049        btScalar      m_localTime;
00050        //for variable timesteps
00051 
00052        bool   m_ownsIslandManager;
00053        bool   m_ownsConstraintSolver;
00054 
00055        btContactSolverInfo  m_solverInfo;
00056 
00057 
00058        btAlignedObjectArray<btRaycastVehicle*>   m_vehicles;
00059 
00060        int    m_profileTimings;
00061 
00062        virtual void  predictUnconstraintMotion(btScalar timeStep);
00063        
00064        void   integrateTransforms(btScalar timeStep);
00065               
00066        void   calculateSimulationIslands();
00067 
00068        void   solveConstraints(btContactSolverInfo& solverInfo);
00069        
00070        void   updateActivationState(btScalar timeStep);
00071 
00072        void   updateVehicles(btScalar timeStep);
00073 
00074        void   startProfiling(btScalar timeStep);
00075 
00076        virtual void  internalSingleStepSimulation( btScalar timeStep);
00077 
00078        void   synchronizeMotionStates();
00079 
00080        void   saveKinematicState(btScalar timeStep);
00081 
00082        void   debugDrawSphere(btScalar radius, const btTransform& transform, const btVector3& color);
00083 
00084 public:
00085 
00086 
00088        btDiscreteDynamicsWorld(btDispatcher* dispatcher,btBroadphaseInterface* pairCache,btConstraintSolver* constraintSolver,btCollisionConfiguration* collisionConfiguration);
00089 
00090        virtual ~btDiscreteDynamicsWorld();
00091 
00093        virtual int   stepSimulation( btScalar timeStep,int maxSubSteps=1, btScalar fixedTimeStep=btScalar(1.)/btScalar(60.));
00094 
00095 
00096        void   addConstraint(btTypedConstraint* constraint, bool disableCollisionsBetweenLinkedBodies=false);
00097 
00098        void   removeConstraint(btTypedConstraint* constraint);
00099 
00100        void   addVehicle(btRaycastVehicle* vehicle);
00101 
00102        void   removeVehicle(btRaycastVehicle* vehicle);
00103 
00104        btSimulationIslandManager*  getSimulationIslandManager()
00105        {
00106               return m_islandManager;
00107        }
00108 
00109        const btSimulationIslandManager*   getSimulationIslandManager() const 
00110        {
00111               return m_islandManager;
00112        }
00113 
00114        btCollisionWorld*    getCollisionWorld()
00115        {
00116               return this;
00117        }
00118 
00119 
00120        virtual void  setGravity(const btVector3& gravity);
00121        virtual btVector3 getGravity () const;
00122 
00123        virtual void  addRigidBody(btRigidBody* body);
00124 
00125        virtual void  addRigidBody(btRigidBody* body, short group, short mask);
00126 
00127        virtual void  removeRigidBody(btRigidBody* body);
00128 
00129        void   debugDrawObject(const btTransform& worldTransform, const btCollisionShape* shape, const btVector3& color);
00130 
00131        virtual void  debugDrawWorld();
00132 
00133        virtual void  setConstraintSolver(btConstraintSolver* solver);
00134 
00135        virtual btConstraintSolver* getConstraintSolver();
00136        
00137        virtual       int           getNumConstraints() const;
00138 
00139        virtual btTypedConstraint* getConstraint(int index)     ;
00140 
00141        virtual const btTypedConstraint* getConstraint(int index) const;
00142 
00143        btContactSolverInfo& getSolverInfo()
00144        {
00145               return m_solverInfo;
00146        }
00147 
00148        virtual btDynamicsWorldType getWorldType() const
00149        {
00150               return BT_DISCRETE_DYNAMICS_WORLD;
00151        }
00152        
00154        virtual void  clearForces();
00155 
00157        virtual void  applyGravity();
00158 
00159 
00160 };
00161 
00162 #endif //BT_DISCRETE_DYNAMICS_WORLD_H