Bullet Collision Detection & Physics Library: btMultiBodyDynamicsWorld.h Source File

Bullet Collision Detection & Physics Library

btMultiBodyDynamicsWorld.h
Go to the documentation of this file.
1 /*
2 Bullet Continuous Collision Detection and Physics Library
3 Copyright (c) 2013 Erwin Coumans http://bulletphysics.org
4
5 This software is provided 'as-is', without any express or implied warranty.
6 In no event will the authors be held liable for any damages arising from the use of this software.
7 Permission is granted to anyone to use this software for any purpose,
8 including commercial applications, and to alter it and redistribute it freely,
9 subject to the following restrictions:
10
11 1. 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.
12 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
13 3. This notice may not be removed or altered from any source distribution.
14 */
15
16 #ifndef BT_MULTIBODY_DYNAMICS_WORLD_H
17 #define BT_MULTIBODY_DYNAMICS_WORLD_H
18
19 #include "BulletDynamics/Dynamics/btDiscreteDynamicsWorld.h"
20
21 #define BT_USE_VIRTUAL_CLEARFORCES_AND_GRAVITY
22
23 class btMultiBody;
24 class btMultiBodyConstraint;
25 class btMultiBodyConstraintSolver;
26 struct MultiBodyInplaceSolverIslandCallback;
27
30 class btMultiBodyDynamicsWorld : public btDiscreteDynamicsWorld
31 {
32 protected:
33 btAlignedObjectArray<btMultiBody*> m_multiBodies;
34 btAlignedObjectArray<btMultiBodyConstraint*> m_multiBodyConstraints;
35 btAlignedObjectArray<btMultiBodyConstraint*> m_sortedMultiBodyConstraints;
36 btMultiBodyConstraintSolver* m_multiBodyConstraintSolver;
37 MultiBodyInplaceSolverIslandCallback* m_solverMultiBodyIslandCallback;
38
39 //cached data to avoid memory allocations
40 btAlignedObjectArray<btQuaternion> m_scratch_world_to_local;
41 btAlignedObjectArray<btVector3> m_scratch_local_origin;
42 btAlignedObjectArray<btQuaternion> m_scratch_world_to_local1;
43 btAlignedObjectArray<btVector3> m_scratch_local_origin1;
44 btAlignedObjectArray<btScalar> m_scratch_r;
45 btAlignedObjectArray<btVector3> m_scratch_v;
46 btAlignedObjectArray<btMatrix3x3> m_scratch_m;
47
48
49 virtual void calculateSimulationIslands();
50 virtual void updateActivationState(btScalar timeStep);
51 virtual void solveConstraints(btContactSolverInfo& solverInfo);
52
53 virtual void serializeMultiBodies(btSerializer* serializer);
54
55 public:
56
57 btMultiBodyDynamicsWorld(btDispatcher* dispatcher,btBroadphaseInterface* pairCache,btMultiBodyConstraintSolver* constraintSolver,btCollisionConfiguration* collisionConfiguration);
58
59 virtual ~btMultiBodyDynamicsWorld ();
60
61 virtual void addMultiBody(btMultiBody* body, int group= btBroadphaseProxy::DefaultFilter, int mask=btBroadphaseProxy::AllFilter);
62
63 virtual void removeMultiBody(btMultiBody* body);
64
65 virtual int getNumMultibodies() const
66 {
67 return m_multiBodies.size();
68 }
69
70 btMultiBody* getMultiBody(int mbIndex)
71 {
72 return m_multiBodies[mbIndex];
73 }
74
75 virtual void addMultiBodyConstraint( btMultiBodyConstraint* constraint);
76
77 virtual int getNumMultiBodyConstraints() const
78 {
79 return m_multiBodyConstraints.size();
80 }
81
82 virtual btMultiBodyConstraint* getMultiBodyConstraint( int constraintIndex)
83 {
84 return m_multiBodyConstraints[constraintIndex];
85 }
86
87 virtual const btMultiBodyConstraint* getMultiBodyConstraint( int constraintIndex) const
88 {
89 return m_multiBodyConstraints[constraintIndex];
90 }
91
92 virtual void removeMultiBodyConstraint( btMultiBodyConstraint* constraint);
93
94 virtual void integrateTransforms(btScalar timeStep);
95
96 virtual void debugDrawWorld();
97
98 virtual void debugDrawMultiBodyConstraint(btMultiBodyConstraint* constraint);
99
100 void forwardKinematics();
101 virtual void clearForces();
102 virtual void clearMultiBodyConstraintForces();
103 virtual void clearMultiBodyForces();
104 virtual void applyGravity();
105
106 virtual void serialize(btSerializer* serializer);
107
108 };
109 #endif //BT_MULTIBODY_DYNAMICS_WORLD_H
btMultiBodyDynamicsWorld::getNumMultibodies
virtual int getNumMultibodies() const
Definition: btMultiBodyDynamicsWorld.h:65
btMultiBodyDynamicsWorld::getMultiBodyConstraint
virtual const btMultiBodyConstraint * getMultiBodyConstraint(int constraintIndex) const
Definition: btMultiBodyDynamicsWorld.h:87
btMultiBodyDynamicsWorld::updateActivationState
virtual void updateActivationState(btScalar timeStep)
Definition: btMultiBodyDynamicsWorld.cpp:124
btMultiBodyDynamicsWorld::debugDrawMultiBodyConstraint
virtual void debugDrawMultiBodyConstraint(btMultiBodyConstraint *constraint)
Definition: btMultiBodyDynamicsWorld.cpp:791
btMultiBodyDynamicsWorld::serialize
virtual void serialize(btSerializer *serializer)
Preliminary serialization test for Bullet 2.76. Loading those files requires a separate parser (see B...
Definition: btMultiBodyDynamicsWorld.cpp:958
btAlignedObjectArray
The btAlignedObjectArray template class uses a subset of the stl::vector interface for its methods It...
Definition: btAlignedObjectArray.h:53
btMultiBodyDynamicsWorld::clearForces
virtual void clearForces()
the forces on each rigidbody is accumulating together with gravity. clear this after each timestep...
Definition: btMultiBodyDynamicsWorld.cpp:946
btDiscreteDynamicsWorld
btDiscreteDynamicsWorld provides discrete rigid body simulation those classes replace the obsolete Cc...
Definition: btDiscreteDynamicsWorld.h:38
btMultiBodyDynamicsWorld::addMultiBody
virtual void addMultiBody(btMultiBody *body, int group=btBroadphaseProxy::DefaultFilter, int mask=btBroadphaseProxy::AllFilter)
Definition: btMultiBodyDynamicsWorld.cpp:27
btMultiBodyDynamicsWorld::m_scratch_r
btAlignedObjectArray< btScalar > m_scratch_r
Definition: btMultiBodyDynamicsWorld.h:44
btCollisionConfiguration
btCollisionConfiguration allows to configure Bullet collision detection stack allocator size...
Definition: btCollisionConfiguration.h:26
btMultiBodyDynamicsWorld::debugDrawWorld
virtual void debugDrawWorld()
Definition: btMultiBodyDynamicsWorld.cpp:797
btMultiBodyDynamicsWorld::integrateTransforms
virtual void integrateTransforms(btScalar timeStep)
Definition: btMultiBodyDynamicsWorld.cpp:723
btMultiBody
Definition: btMultiBody.h:51
btMultiBodyDynamicsWorld::m_scratch_local_origin
btAlignedObjectArray< btVector3 > m_scratch_local_origin
Definition: btMultiBodyDynamicsWorld.h:41
btMultiBodyConstraint
Definition: btMultiBodyConstraint.h:42
btSerializer
Definition: btSerializer.h:68
btMultiBodyDynamicsWorld::m_multiBodyConstraintSolver
btMultiBodyConstraintSolver * m_multiBodyConstraintSolver
Definition: btMultiBodyDynamicsWorld.h:36
btMultiBodyDynamicsWorld::m_solverMultiBodyIslandCallback
MultiBodyInplaceSolverIslandCallback * m_solverMultiBodyIslandCallback
Definition: btMultiBodyDynamicsWorld.h:37
btMultiBodyDynamicsWorld::m_scratch_v
btAlignedObjectArray< btVector3 > m_scratch_v
Definition: btMultiBodyDynamicsWorld.h:45
btMultiBodyDynamicsWorld::clearMultiBodyConstraintForces
virtual void clearMultiBodyConstraintForces()
Definition: btMultiBodyDynamicsWorld.cpp:909
btMultiBodyDynamicsWorld::~btMultiBodyDynamicsWorld
virtual ~btMultiBodyDynamicsWorld()
Definition: btMultiBodyDynamicsWorld.cpp:392
btMultiBodyDynamicsWorld::removeMultiBodyConstraint
virtual void removeMultiBodyConstraint(btMultiBodyConstraint *constraint)
Definition: btMultiBodyDynamicsWorld.cpp:786
btMultiBodyDynamicsWorld::getMultiBody
btMultiBody * getMultiBody(int mbIndex)
Definition: btMultiBodyDynamicsWorld.h:70
btMultiBodyConstraintSolver
Definition: btMultiBodyConstraintSolver.h:30
btMultiBodyDynamicsWorld::applyGravity
virtual void applyGravity()
apply gravity, call this once per timestep
Definition: btMultiBodyDynamicsWorld.cpp:875
btBroadphaseInterface
The btBroadphaseInterface class provides an interface to detect aabb-overlapping object pairs...
Definition: btBroadphaseInterface.h:51
btMultiBodyDynamicsWorld::solveConstraints
virtual void solveConstraints(btContactSolverInfo &solverInfo)
Definition: btMultiBodyDynamicsWorld.cpp:406
btMultiBodyDynamicsWorld::m_multiBodies
btAlignedObjectArray< btMultiBody * > m_multiBodies
Definition: btMultiBodyDynamicsWorld.h:33
btMultiBodyDynamicsWorld::m_multiBodyConstraints
btAlignedObjectArray< btMultiBodyConstraint * > m_multiBodyConstraints
Definition: btMultiBodyDynamicsWorld.h:34
btMultiBodyDynamicsWorld::btMultiBodyDynamicsWorld
btMultiBodyDynamicsWorld(btDispatcher *dispatcher, btBroadphaseInterface *pairCache, btMultiBodyConstraintSolver *constraintSolver, btCollisionConfiguration *collisionConfiguration)
Definition: btMultiBodyDynamicsWorld.cpp:382
btAlignedObjectArray::size
int size() const
return the number of elements in the array
Definition: btAlignedObjectArray.h:155
btMultiBodyDynamicsWorld::serializeMultiBodies
virtual void serializeMultiBodies(btSerializer *serializer)
Definition: btMultiBodyDynamicsWorld.cpp:974
btContactSolverInfo
Definition: btContactSolverInfo.h:65
btMultiBodyDynamicsWorld::m_sortedMultiBodyConstraints
btAlignedObjectArray< btMultiBodyConstraint * > m_sortedMultiBodyConstraints
Definition: btMultiBodyDynamicsWorld.h:35
btMultiBodyDynamicsWorld::clearMultiBodyForces
virtual void clearMultiBodyForces()
Definition: btMultiBodyDynamicsWorld.cpp:917
btMultiBodyDynamicsWorld::getMultiBodyConstraint
virtual btMultiBodyConstraint * getMultiBodyConstraint(int constraintIndex)
Definition: btMultiBodyDynamicsWorld.h:82
btMultiBodyDynamicsWorld::m_scratch_world_to_local1
btAlignedObjectArray< btQuaternion > m_scratch_world_to_local1
Definition: btMultiBodyDynamicsWorld.h:42
btMultiBodyDynamicsWorld::removeMultiBody
virtual void removeMultiBody(btMultiBody *body)
Definition: btMultiBodyDynamicsWorld.cpp:33
btMultiBodyDynamicsWorld::forwardKinematics
void forwardKinematics()
Definition: btMultiBodyDynamicsWorld.cpp:397
btBroadphaseProxy::DefaultFilter
Definition: btBroadphaseProxy.h:93
btMultiBodyDynamicsWorld::m_scratch_m
btAlignedObjectArray< btMatrix3x3 > m_scratch_m
Definition: btMultiBodyDynamicsWorld.h:46
btBroadphaseProxy::AllFilter
Definition: btBroadphaseProxy.h:99
btDiscreteDynamicsWorld.h
btMultiBodyDynamicsWorld::m_scratch_world_to_local
btAlignedObjectArray< btQuaternion > m_scratch_world_to_local
Definition: btMultiBodyDynamicsWorld.h:40
btMultiBodyDynamicsWorld::m_scratch_local_origin1
btAlignedObjectArray< btVector3 > m_scratch_local_origin1
Definition: btMultiBodyDynamicsWorld.h:43
btMultiBodyDynamicsWorld::addMultiBodyConstraint
virtual void addMultiBodyConstraint(btMultiBodyConstraint *constraint)
Definition: btMultiBodyDynamicsWorld.cpp:781
btDispatcher
The btDispatcher interface class can be used in combination with broadphase to dispatch calculations ...
Definition: btDispatcher.h:75
btMultiBodyDynamicsWorld
The btMultiBodyDynamicsWorld adds Featherstone multi body dynamics to Bullet This implementation is s...
Definition: btMultiBodyDynamicsWorld.h:30
btScalar
float btScalar
The btScalar type abstracts floating point numbers, to easily switch between double and single floati...
Definition: btScalar.h:279
btMultiBodyDynamicsWorld::getNumMultiBodyConstraints
virtual int getNumMultiBodyConstraints() const
Definition: btMultiBodyDynamicsWorld.h:77
btMultiBodyDynamicsWorld::calculateSimulationIslands
virtual void calculateSimulationIslands()
Definition: btMultiBodyDynamicsWorld.cpp:38
MultiBodyInplaceSolverIslandCallback
Definition: btMultiBodyDynamicsWorld.cpp:226