Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/trunk/src/external/bullet/BulletDynamics/Dynamics/btDiscreteDynamicsWorld.h @ 8416

Last change on this file since 8416 was 8393, checked in by rgrieder, 14 years ago

Updated Bullet from v2.77 to v2.78.
(I'm not going to make a branch for that since the update from 2.74 to 2.77 hasn't been tested that much either).

You will HAVE to do a complete RECOMPILE! I tested with MSVC and MinGW and they both threw linker errors at me.

  • Property svn:eol-style set to native
File size: 6.0 KB
RevLine 
[1963]1/*
2Bullet Continuous Collision Detection and Physics Library
[8351]3Copyright (c) 2003-2009 Erwin Coumans  http://bulletphysics.org
[1963]4
5This software is provided 'as-is', without any express or implied warranty.
6In no event will the authors be held liable for any damages arising from the use of this software.
7Permission is granted to anyone to use this software for any purpose,
8including commercial applications, and to alter it and redistribute it freely,
9subject to the following restrictions:
10
111. 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.
122. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
133. This notice may not be removed or altered from any source distribution.
14*/
15
[8351]16
[1963]17#ifndef BT_DISCRETE_DYNAMICS_WORLD_H
18#define BT_DISCRETE_DYNAMICS_WORLD_H
19
20#include "btDynamicsWorld.h"
21
22class btDispatcher;
23class btOverlappingPairCache;
24class btConstraintSolver;
25class btSimulationIslandManager;
26class btTypedConstraint;
[2882]27class btActionInterface;
[1963]28
29class btIDebugDraw;
30#include "LinearMath/btAlignedObjectArray.h"
31
32
33///btDiscreteDynamicsWorld provides discrete rigid body simulation
34///those classes replace the obsolete CcdPhysicsEnvironment/CcdPhysicsController
35class btDiscreteDynamicsWorld : public btDynamicsWorld
36{
37protected:
38
39        btConstraintSolver*     m_constraintSolver;
40
41        btSimulationIslandManager*      m_islandManager;
42
43        btAlignedObjectArray<btTypedConstraint*> m_constraints;
44
[8351]45        btAlignedObjectArray<btRigidBody*> m_nonStaticRigidBodies;
46
[1963]47        btVector3       m_gravity;
48
49        //for variable timesteps
50        btScalar        m_localTime;
51        //for variable timesteps
52
53        bool    m_ownsIslandManager;
54        bool    m_ownsConstraintSolver;
[8351]55        bool    m_synchronizeAllMotionStates;
[1963]56
[2882]57        btAlignedObjectArray<btActionInterface*>        m_actions;
[1963]58       
59        int     m_profileTimings;
60
61        virtual void    predictUnconstraintMotion(btScalar timeStep);
62       
63        virtual void    integrateTransforms(btScalar timeStep);
64               
[8393]65        virtual void    addSpeculativeContacts(btScalar timeStep);
66
[2430]67        virtual void    calculateSimulationIslands();
[1963]68
[2430]69        virtual void    solveConstraints(btContactSolverInfo& solverInfo);
[1963]70       
71        void    updateActivationState(btScalar timeStep);
72
[2882]73        void    updateActions(btScalar timeStep);
[1963]74
75        void    startProfiling(btScalar timeStep);
76
77        virtual void    internalSingleStepSimulation( btScalar timeStep);
78
79
[2430]80        virtual void    saveKinematicState(btScalar timeStep);
[1963]81
[8351]82        void    serializeRigidBodies(btSerializer* serializer);
[1963]83
84public:
85
86
87        ///this btDiscreteDynamicsWorld constructor gets created objects from the user, and will not delete those
88        btDiscreteDynamicsWorld(btDispatcher* dispatcher,btBroadphaseInterface* pairCache,btConstraintSolver* constraintSolver,btCollisionConfiguration* collisionConfiguration);
89
90        virtual ~btDiscreteDynamicsWorld();
91
92        ///if maxSubSteps > 0, it will interpolate motion between fixedTimeStep's
93        virtual int     stepSimulation( btScalar timeStep,int maxSubSteps=1, btScalar fixedTimeStep=btScalar(1.)/btScalar(60.));
94
95
[2430]96        virtual void    synchronizeMotionStates();
[1963]97
[2430]98        ///this can be useful to synchronize a single rigid body -> graphics object
99        void    synchronizeSingleMotionState(btRigidBody* body);
[1963]100
[2430]101        virtual void    addConstraint(btTypedConstraint* constraint, bool disableCollisionsBetweenLinkedBodies=false);
[1963]102
[2430]103        virtual void    removeConstraint(btTypedConstraint* constraint);
[1963]104
[2882]105        virtual void    addAction(btActionInterface*);
[2430]106
[2882]107        virtual void    removeAction(btActionInterface*);
[2430]108       
[1963]109        btSimulationIslandManager*      getSimulationIslandManager()
110        {
111                return m_islandManager;
112        }
113
114        const btSimulationIslandManager*        getSimulationIslandManager() const 
115        {
116                return m_islandManager;
117        }
118
119        btCollisionWorld*       getCollisionWorld()
120        {
121                return this;
122        }
123
124        virtual void    setGravity(const btVector3& gravity);
[2882]125
[1963]126        virtual btVector3 getGravity () const;
127
[8351]128        virtual void    addCollisionObject(btCollisionObject* collisionObject,short int collisionFilterGroup=btBroadphaseProxy::StaticFilter,short int collisionFilterMask=btBroadphaseProxy::AllFilter ^ btBroadphaseProxy::StaticFilter);
129
[1963]130        virtual void    addRigidBody(btRigidBody* body);
131
132        virtual void    addRigidBody(btRigidBody* body, short group, short mask);
133
134        virtual void    removeRigidBody(btRigidBody* body);
135
[8351]136        ///removeCollisionObject will first check if it is a rigid body, if so call removeRigidBody otherwise call btCollisionWorld::removeCollisionObject
137        virtual void    removeCollisionObject(btCollisionObject* collisionObject);
[1963]138
[8351]139
[2882]140        void    debugDrawConstraint(btTypedConstraint* constraint);
141
[1963]142        virtual void    debugDrawWorld();
143
144        virtual void    setConstraintSolver(btConstraintSolver* solver);
145
146        virtual btConstraintSolver* getConstraintSolver();
147       
148        virtual int             getNumConstraints() const;
149
150        virtual btTypedConstraint* getConstraint(int index)     ;
151
152        virtual const btTypedConstraint* getConstraint(int index) const;
153
154       
155        virtual btDynamicsWorldType     getWorldType() const
156        {
157                return BT_DISCRETE_DYNAMICS_WORLD;
158        }
159       
160        ///the forces on each rigidbody is accumulating together with gravity. clear this after each timestep.
161        virtual void    clearForces();
162
163        ///apply gravity, call this once per timestep
164        virtual void    applyGravity();
165
166        virtual void    setNumTasks(int numTasks)
167        {
[2430]168        (void) numTasks;
[1963]169        }
170
[2882]171        ///obsolete, use updateActions instead
172        virtual void updateVehicles(btScalar timeStep)
173        {
174                updateActions(timeStep);
175        }
176
177        ///obsolete, use addAction instead
178        virtual void    addVehicle(btActionInterface* vehicle);
179        ///obsolete, use removeAction instead
180        virtual void    removeVehicle(btActionInterface* vehicle);
181        ///obsolete, use addAction instead
182        virtual void    addCharacter(btActionInterface* character);
183        ///obsolete, use removeAction instead
184        virtual void    removeCharacter(btActionInterface* character);
185
[8351]186        void    setSynchronizeAllMotionStates(bool synchronizeAll)
187        {
188                m_synchronizeAllMotionStates = synchronizeAll;
189        }
190        bool getSynchronizeAllMotionStates() const
191        {
192                return m_synchronizeAllMotionStates;
193        }
194
195        ///Preliminary serialization test for Bullet 2.76. Loading those files requires a separate parser (see Bullet/Demos/SerializeDemo)
196        virtual void    serialize(btSerializer* serializer);
197
[1963]198};
199
200#endif //BT_DISCRETE_DYNAMICS_WORLD_H
Note: See TracBrowser for help on using the repository browser.