Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

Last change on this file since 2736 was 2662, checked in by rgrieder, 16 years ago

Merged presentation branch back to trunk.

  • Property svn:eol-style set to native
File size: 5.0 KB
RevLine 
[1963]1/*
2Bullet Continuous Collision Detection and Physics Library
3Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/
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
16#ifndef BT_DISCRETE_DYNAMICS_WORLD_H
17#define BT_DISCRETE_DYNAMICS_WORLD_H
18
19#include "btDynamicsWorld.h"
20
21class btDispatcher;
22class btOverlappingPairCache;
23class btConstraintSolver;
24class btSimulationIslandManager;
25class btTypedConstraint;
26
27
28class btRaycastVehicle;
[2430]29class btCharacterControllerInterface;
[1963]30class btIDebugDraw;
31#include "LinearMath/btAlignedObjectArray.h"
32
33
34///btDiscreteDynamicsWorld provides discrete rigid body simulation
35///those classes replace the obsolete CcdPhysicsEnvironment/CcdPhysicsController
36class btDiscreteDynamicsWorld : public btDynamicsWorld
37{
38protected:
39
40        btConstraintSolver*     m_constraintSolver;
41
42        btSimulationIslandManager*      m_islandManager;
43
44        btAlignedObjectArray<btTypedConstraint*> m_constraints;
45
46        btVector3       m_gravity;
47
48        //for variable timesteps
49        btScalar        m_localTime;
50        //for variable timesteps
51
52        bool    m_ownsIslandManager;
53        bool    m_ownsConstraintSolver;
54
55       
56        btAlignedObjectArray<btRaycastVehicle*> m_vehicles;
[2430]57       
58        btAlignedObjectArray<btCharacterControllerInterface*> m_characters;
59       
[1963]60
61        int     m_profileTimings;
62
63        virtual void    predictUnconstraintMotion(btScalar timeStep);
64       
65        virtual void    integrateTransforms(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
73        void    updateVehicles(btScalar timeStep);
74
[2430]75        void    updateCharacters(btScalar timeStep);
76
[1963]77        void    startProfiling(btScalar timeStep);
78
79        virtual void    internalSingleStepSimulation( btScalar timeStep);
80
81
[2430]82        virtual void    saveKinematicState(btScalar timeStep);
[1963]83
84        void    debugDrawSphere(btScalar radius, const btTransform& transform, const btVector3& color);
85
[2430]86
[1963]87public:
88
89
90        ///this btDiscreteDynamicsWorld constructor gets created objects from the user, and will not delete those
91        btDiscreteDynamicsWorld(btDispatcher* dispatcher,btBroadphaseInterface* pairCache,btConstraintSolver* constraintSolver,btCollisionConfiguration* collisionConfiguration);
92
93        virtual ~btDiscreteDynamicsWorld();
94
95        ///if maxSubSteps > 0, it will interpolate motion between fixedTimeStep's
96        virtual int     stepSimulation( btScalar timeStep,int maxSubSteps=1, btScalar fixedTimeStep=btScalar(1.)/btScalar(60.));
97
98
[2430]99        virtual void    synchronizeMotionStates();
[1963]100
[2430]101        ///this can be useful to synchronize a single rigid body -> graphics object
102        void    synchronizeSingleMotionState(btRigidBody* body);
[1963]103
[2430]104        virtual void    addConstraint(btTypedConstraint* constraint, bool disableCollisionsBetweenLinkedBodies=false);
[1963]105
[2430]106        virtual void    removeConstraint(btTypedConstraint* constraint);
[1963]107
[2430]108        virtual void    addVehicle(btRaycastVehicle* vehicle);
109
110        virtual void    removeVehicle(btRaycastVehicle* vehicle);
111       
112        virtual void    addCharacter(btCharacterControllerInterface* character);
113
114        virtual void    removeCharacter(btCharacterControllerInterface* character);
115               
116
[1963]117        btSimulationIslandManager*      getSimulationIslandManager()
118        {
119                return m_islandManager;
120        }
121
122        const btSimulationIslandManager*        getSimulationIslandManager() const 
123        {
124                return m_islandManager;
125        }
126
127        btCollisionWorld*       getCollisionWorld()
128        {
129                return this;
130        }
131
132        virtual void    setGravity(const btVector3& gravity);
133        virtual btVector3 getGravity () const;
134
135        virtual void    addRigidBody(btRigidBody* body);
136
137        virtual void    addRigidBody(btRigidBody* body, short group, short mask);
138
139        virtual void    removeRigidBody(btRigidBody* body);
140
141        void    debugDrawObject(const btTransform& worldTransform, const btCollisionShape* shape, const btVector3& color);
142
143        virtual void    debugDrawWorld();
144
145        virtual void    setConstraintSolver(btConstraintSolver* solver);
146
147        virtual btConstraintSolver* getConstraintSolver();
148       
149        virtual int             getNumConstraints() const;
150
151        virtual btTypedConstraint* getConstraint(int index)     ;
152
153        virtual const btTypedConstraint* getConstraint(int index) const;
154
155       
156        virtual btDynamicsWorldType     getWorldType() const
157        {
158                return BT_DISCRETE_DYNAMICS_WORLD;
159        }
160       
161        ///the forces on each rigidbody is accumulating together with gravity. clear this after each timestep.
162        virtual void    clearForces();
163
164        ///apply gravity, call this once per timestep
165        virtual void    applyGravity();
166
167        virtual void    setNumTasks(int numTasks)
168        {
[2430]169        (void) numTasks;
[1963]170        }
171
172};
173
174#endif //BT_DISCRETE_DYNAMICS_WORLD_H
Note: See TracBrowser for help on using the repository browser.