Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

Last change on this file since 11520 was 10726, checked in by landauf, 9 years ago

fixed alignment warnings in MSVC14 (caused by SSE instructions in bullet)

  • Property svn:eol-style set to native
File size: 6.1 KB
Line 
1/*
2Bullet Continuous Collision Detection and Physics Library
3Copyright (c) 2003-2009 Erwin Coumans  http://bulletphysics.org
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
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;
27class btActionInterface;
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
45        btAlignedObjectArray<btRigidBody*> m_nonStaticRigidBodies;
46
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;
55        bool    m_synchronizeAllMotionStates;
56
57        btAlignedObjectArray<btActionInterface*>        m_actions;
58       
59        int     m_profileTimings;
60
61        virtual void    predictUnconstraintMotion(btScalar timeStep);
62       
63        virtual void    integrateTransforms(btScalar timeStep);
64               
65        virtual void    addSpeculativeContacts(btScalar timeStep);
66
67        virtual void    calculateSimulationIslands();
68
69        virtual void    solveConstraints(btContactSolverInfo& solverInfo);
70       
71        void    updateActivationState(btScalar timeStep);
72
73        void    updateActions(btScalar timeStep);
74
75        void    startProfiling(btScalar timeStep);
76
77        virtual void    internalSingleStepSimulation( btScalar timeStep);
78
79
80        virtual void    saveKinematicState(btScalar timeStep);
81
82        void    serializeRigidBodies(btSerializer* serializer);
83
84public:
85
86        BT_DECLARE_ALIGNED_ALLOCATOR();
87
88
89        ///this btDiscreteDynamicsWorld constructor gets created objects from the user, and will not delete those
90        btDiscreteDynamicsWorld(btDispatcher* dispatcher,btBroadphaseInterface* pairCache,btConstraintSolver* constraintSolver,btCollisionConfiguration* collisionConfiguration);
91
92        virtual ~btDiscreteDynamicsWorld();
93
94        ///if maxSubSteps > 0, it will interpolate motion between fixedTimeStep's
95        virtual int     stepSimulation( btScalar timeStep,int maxSubSteps=1, btScalar fixedTimeStep=btScalar(1.)/btScalar(60.));
96
97
98        virtual void    synchronizeMotionStates();
99
100        ///this can be useful to synchronize a single rigid body -> graphics object
101        void    synchronizeSingleMotionState(btRigidBody* body);
102
103        virtual void    addConstraint(btTypedConstraint* constraint, bool disableCollisionsBetweenLinkedBodies=false);
104
105        virtual void    removeConstraint(btTypedConstraint* constraint);
106
107        virtual void    addAction(btActionInterface*);
108
109        virtual void    removeAction(btActionInterface*);
110       
111        btSimulationIslandManager*      getSimulationIslandManager()
112        {
113                return m_islandManager;
114        }
115
116        const btSimulationIslandManager*        getSimulationIslandManager() const 
117        {
118                return m_islandManager;
119        }
120
121        btCollisionWorld*       getCollisionWorld()
122        {
123                return this;
124        }
125
126        virtual void    setGravity(const btVector3& gravity);
127
128        virtual btVector3 getGravity () const;
129
130        virtual void    addCollisionObject(btCollisionObject* collisionObject,short int collisionFilterGroup=btBroadphaseProxy::StaticFilter,short int collisionFilterMask=btBroadphaseProxy::AllFilter ^ btBroadphaseProxy::StaticFilter);
131
132        virtual void    addRigidBody(btRigidBody* body);
133
134        virtual void    addRigidBody(btRigidBody* body, short group, short mask);
135
136        virtual void    removeRigidBody(btRigidBody* body);
137
138        ///removeCollisionObject will first check if it is a rigid body, if so call removeRigidBody otherwise call btCollisionWorld::removeCollisionObject
139        virtual void    removeCollisionObject(btCollisionObject* collisionObject);
140
141
142        void    debugDrawConstraint(btTypedConstraint* constraint);
143
144        virtual void    debugDrawWorld();
145
146        virtual void    setConstraintSolver(btConstraintSolver* solver);
147
148        virtual btConstraintSolver* getConstraintSolver();
149       
150        virtual int             getNumConstraints() const;
151
152        virtual btTypedConstraint* getConstraint(int index)     ;
153
154        virtual const btTypedConstraint* getConstraint(int index) const;
155
156       
157        virtual btDynamicsWorldType     getWorldType() const
158        {
159                return BT_DISCRETE_DYNAMICS_WORLD;
160        }
161       
162        ///the forces on each rigidbody is accumulating together with gravity. clear this after each timestep.
163        virtual void    clearForces();
164
165        ///apply gravity, call this once per timestep
166        virtual void    applyGravity();
167
168        virtual void    setNumTasks(int numTasks)
169        {
170        (void) numTasks;
171        }
172
173        ///obsolete, use updateActions instead
174        virtual void updateVehicles(btScalar timeStep)
175        {
176                updateActions(timeStep);
177        }
178
179        ///obsolete, use addAction instead
180        virtual void    addVehicle(btActionInterface* vehicle);
181        ///obsolete, use removeAction instead
182        virtual void    removeVehicle(btActionInterface* vehicle);
183        ///obsolete, use addAction instead
184        virtual void    addCharacter(btActionInterface* character);
185        ///obsolete, use removeAction instead
186        virtual void    removeCharacter(btActionInterface* character);
187
188        void    setSynchronizeAllMotionStates(bool synchronizeAll)
189        {
190                m_synchronizeAllMotionStates = synchronizeAll;
191        }
192        bool getSynchronizeAllMotionStates() const
193        {
194                return m_synchronizeAllMotionStates;
195        }
196
197        ///Preliminary serialization test for Bullet 2.76. Loading those files requires a separate parser (see Bullet/Demos/SerializeDemo)
198        virtual void    serialize(btSerializer* serializer);
199
200};
201
202#endif //BT_DISCRETE_DYNAMICS_WORLD_H
Note: See TracBrowser for help on using the repository browser.