Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/physics/src/bullet/BulletDynamics/Dynamics/btDiscreteDynamicsWorld.h @ 2274

Last change on this file since 2274 was 2192, checked in by rgrieder, 16 years ago

Reverted all changes of attempt to update physics branch.

  • Property svn:eol-style set to native
File size: 4.5 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;
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
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;
57
58        int     m_profileTimings;
59
60        virtual void    predictUnconstraintMotion(btScalar timeStep);
61       
62        virtual void    integrateTransforms(btScalar timeStep);
63               
64        void    calculateSimulationIslands();
65
66        void    solveConstraints(btContactSolverInfo& solverInfo);
67       
68        void    updateActivationState(btScalar timeStep);
69
70        void    updateVehicles(btScalar timeStep);
71
72        void    startProfiling(btScalar timeStep);
73
74        virtual void    internalSingleStepSimulation( btScalar timeStep);
75
76        void    synchronizeMotionStates();
77
78        void    saveKinematicState(btScalar timeStep);
79
80        void    debugDrawSphere(btScalar radius, const btTransform& transform, const btVector3& color);
81
82public:
83
84
85        ///this btDiscreteDynamicsWorld constructor gets created objects from the user, and will not delete those
86        btDiscreteDynamicsWorld(btDispatcher* dispatcher,btBroadphaseInterface* pairCache,btConstraintSolver* constraintSolver,btCollisionConfiguration* collisionConfiguration);
87
88        virtual ~btDiscreteDynamicsWorld();
89
90        ///if maxSubSteps > 0, it will interpolate motion between fixedTimeStep's
91        virtual int     stepSimulation( btScalar timeStep,int maxSubSteps=1, btScalar fixedTimeStep=btScalar(1.)/btScalar(60.));
92
93
94        void    addConstraint(btTypedConstraint* constraint, bool disableCollisionsBetweenLinkedBodies=false);
95
96        void    removeConstraint(btTypedConstraint* constraint);
97
98        void    addVehicle(btRaycastVehicle* vehicle);
99
100        void    removeVehicle(btRaycastVehicle* vehicle);
101
102        btSimulationIslandManager*      getSimulationIslandManager()
103        {
104                return m_islandManager;
105        }
106
107        const btSimulationIslandManager*        getSimulationIslandManager() const 
108        {
109                return m_islandManager;
110        }
111
112        btCollisionWorld*       getCollisionWorld()
113        {
114                return this;
115        }
116
117
118        virtual void    setGravity(const btVector3& gravity);
119        virtual btVector3 getGravity () const;
120
121        virtual void    addRigidBody(btRigidBody* body);
122
123        virtual void    addRigidBody(btRigidBody* body, short group, short mask);
124
125        virtual void    removeRigidBody(btRigidBody* body);
126
127        void    debugDrawObject(const btTransform& worldTransform, const btCollisionShape* shape, const btVector3& color);
128
129        virtual void    debugDrawWorld();
130
131        virtual void    setConstraintSolver(btConstraintSolver* solver);
132
133        virtual btConstraintSolver* getConstraintSolver();
134       
135        virtual int             getNumConstraints() const;
136
137        virtual btTypedConstraint* getConstraint(int index)     ;
138
139        virtual const btTypedConstraint* getConstraint(int index) const;
140
141       
142        virtual btDynamicsWorldType     getWorldType() const
143        {
144                return BT_DISCRETE_DYNAMICS_WORLD;
145        }
146       
147        ///the forces on each rigidbody is accumulating together with gravity. clear this after each timestep.
148        virtual void    clearForces();
149
150        ///apply gravity, call this once per timestep
151        virtual void    applyGravity();
152
153        virtual void    setNumTasks(int numTasks)
154        {
155        }
156
157};
158
159#endif //BT_DISCRETE_DYNAMICS_WORLD_H
Note: See TracBrowser for help on using the repository browser.