Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #ifndef BT_DISCRETE_DYNAMICS_WORLD_H
00018 #define BT_DISCRETE_DYNAMICS_WORLD_H
00019
00020 #include "btDynamicsWorld.h"
00021
00022 class btDispatcher;
00023 class btOverlappingPairCache;
00024 class btConstraintSolver;
00025 class btSimulationIslandManager;
00026 class btTypedConstraint;
00027 class btActionInterface;
00028
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 btAlignedObjectArray<btRigidBody*> m_nonStaticRigidBodies;
00046
00047 btVector3 m_gravity;
00048
00049
00050 btScalar m_localTime;
00051
00052
00053 bool m_ownsIslandManager;
00054 bool m_ownsConstraintSolver;
00055 bool m_synchronizeAllMotionStates;
00056
00057 btAlignedObjectArray<btActionInterface*> m_actions;
00058
00059 int m_profileTimings;
00060
00061 virtual void predictUnconstraintMotion(btScalar timeStep);
00062
00063 virtual void integrateTransforms(btScalar timeStep);
00064
00065 virtual void calculateSimulationIslands();
00066
00067 virtual void solveConstraints(btContactSolverInfo& solverInfo);
00068
00069 void updateActivationState(btScalar timeStep);
00070
00071 void updateActions(btScalar timeStep);
00072
00073 void startProfiling(btScalar timeStep);
00074
00075 virtual void internalSingleStepSimulation( btScalar timeStep);
00076
00077
00078 virtual void saveKinematicState(btScalar timeStep);
00079
00080 void serializeRigidBodies(btSerializer* serializer);
00081
00082 public:
00083
00084
00086 btDiscreteDynamicsWorld(btDispatcher* dispatcher,btBroadphaseInterface* pairCache,btConstraintSolver* constraintSolver,btCollisionConfiguration* collisionConfiguration);
00087
00088 virtual ~btDiscreteDynamicsWorld();
00089
00091 virtual int stepSimulation( btScalar timeStep,int maxSubSteps=1, btScalar fixedTimeStep=btScalar(1.)/btScalar(60.));
00092
00093
00094 virtual void synchronizeMotionStates();
00095
00097 void synchronizeSingleMotionState(btRigidBody* body);
00098
00099 virtual void addConstraint(btTypedConstraint* constraint, bool disableCollisionsBetweenLinkedBodies=false);
00100
00101 virtual void removeConstraint(btTypedConstraint* constraint);
00102
00103 virtual void addAction(btActionInterface*);
00104
00105 virtual void removeAction(btActionInterface*);
00106
00107 btSimulationIslandManager* getSimulationIslandManager()
00108 {
00109 return m_islandManager;
00110 }
00111
00112 const btSimulationIslandManager* getSimulationIslandManager() const
00113 {
00114 return m_islandManager;
00115 }
00116
00117 btCollisionWorld* getCollisionWorld()
00118 {
00119 return this;
00120 }
00121
00122 virtual void setGravity(const btVector3& gravity);
00123
00124 virtual btVector3 getGravity () const;
00125
00126 virtual void addCollisionObject(btCollisionObject* collisionObject,short int collisionFilterGroup=btBroadphaseProxy::StaticFilter,short int collisionFilterMask=btBroadphaseProxy::AllFilter ^ btBroadphaseProxy::StaticFilter);
00127
00128 virtual void addRigidBody(btRigidBody* body);
00129
00130 virtual void addRigidBody(btRigidBody* body, short group, short mask);
00131
00132 virtual void removeRigidBody(btRigidBody* body);
00133
00135 virtual void removeCollisionObject(btCollisionObject* collisionObject);
00136
00137
00138 void debugDrawConstraint(btTypedConstraint* constraint);
00139
00140 virtual void debugDrawWorld();
00141
00142 virtual void setConstraintSolver(btConstraintSolver* solver);
00143
00144 virtual btConstraintSolver* getConstraintSolver();
00145
00146 virtual int getNumConstraints() const;
00147
00148 virtual btTypedConstraint* getConstraint(int index) ;
00149
00150 virtual const btTypedConstraint* getConstraint(int index) const;
00151
00152
00153 virtual btDynamicsWorldType getWorldType() const
00154 {
00155 return BT_DISCRETE_DYNAMICS_WORLD;
00156 }
00157
00159 virtual void clearForces();
00160
00162 virtual void applyGravity();
00163
00164 virtual void setNumTasks(int numTasks)
00165 {
00166 (void) numTasks;
00167 }
00168
00170 virtual void updateVehicles(btScalar timeStep)
00171 {
00172 updateActions(timeStep);
00173 }
00174
00176 virtual void addVehicle(btActionInterface* vehicle);
00178 virtual void removeVehicle(btActionInterface* vehicle);
00180 virtual void addCharacter(btActionInterface* character);
00182 virtual void removeCharacter(btActionInterface* character);
00183
00184 void setSynchronizeAllMotionStates(bool synchronizeAll)
00185 {
00186 m_synchronizeAllMotionStates = synchronizeAll;
00187 }
00188 bool getSynchronizeAllMotionStates() const
00189 {
00190 return m_synchronizeAllMotionStates;
00191 }
00192
00194 virtual void serialize(btSerializer* serializer);
00195
00196 };
00197
00198 #endif //BT_DISCRETE_DYNAMICS_WORLD_H