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

Bullet Collision Detection & Physics Library

btMultiBodyDynamicsWorld.h
Go to the documentation of this file.
1/*
2Bullet Continuous Collision Detection and Physics Library
3Copyright (c) 2013 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#ifndef BT_MULTIBODY_DYNAMICS_WORLD_H
17#define BT_MULTIBODY_DYNAMICS_WORLD_H
18
19#include "BulletDynamics/Dynamics/btDiscreteDynamicsWorld.h"
20#include "BulletDynamics/Featherstone/btMultiBodyInplaceSolverIslandCallback.h"
21
22#define BT_USE_VIRTUAL_CLEARFORCES_AND_GRAVITY
23
24class btMultiBody;
25class btMultiBodyConstraint;
26class btMultiBodyConstraintSolver;
27struct MultiBodyInplaceSolverIslandCallback;
28
31 class btMultiBodyDynamicsWorld : public btDiscreteDynamicsWorld
32{
33protected:
34 btAlignedObjectArray<btMultiBody*> m_multiBodies;
35 btAlignedObjectArray<btMultiBodyConstraint*> m_multiBodyConstraints;
36 btAlignedObjectArray<btMultiBodyConstraint*> m_sortedMultiBodyConstraints;
37 btMultiBodyConstraintSolver* m_multiBodyConstraintSolver;
38 MultiBodyInplaceSolverIslandCallback* m_solverMultiBodyIslandCallback;
39
40 //cached data to avoid memory allocations
41 btAlignedObjectArray<btQuaternion> m_scratch_world_to_local;
42 btAlignedObjectArray<btVector3> m_scratch_local_origin;
43 btAlignedObjectArray<btQuaternion> m_scratch_world_to_local1;
44 btAlignedObjectArray<btVector3> m_scratch_local_origin1;
45 btAlignedObjectArray<btScalar> m_scratch_r;
46 btAlignedObjectArray<btVector3> m_scratch_v;
47 btAlignedObjectArray<btMatrix3x3> m_scratch_m;
48
49 virtual void calculateSimulationIslands();
50 virtual void updateActivationState(btScalar timeStep);
51
52
53 virtual void serializeMultiBodies(btSerializer* serializer);
54
55public:
56 btMultiBodyDynamicsWorld(btDispatcher* dispatcher, btBroadphaseInterface* pairCache, btMultiBodyConstraintSolver* constraintSolver, btCollisionConfiguration* collisionConfiguration);
57
58 virtual ~btMultiBodyDynamicsWorld();
59
60 virtual void solveConstraints(btContactSolverInfo& solverInfo);
61
62 virtual void addMultiBody(btMultiBody* body, int group = btBroadphaseProxy::DefaultFilter, int mask = btBroadphaseProxy::AllFilter);
63
64 virtual void removeMultiBody(btMultiBody* body);
65
66 virtual int getNumMultibodies() const
67 {
68 return m_multiBodies.size();
69 }
70
71 btMultiBody* getMultiBody(int mbIndex)
72 {
73 return m_multiBodies[mbIndex];
74 }
75
76 const btMultiBody* getMultiBody(int mbIndex) const
77 {
78 return m_multiBodies[mbIndex];
79 }
80
81 virtual void addMultiBodyConstraint(btMultiBodyConstraint* constraint);
82
83 virtual int getNumMultiBodyConstraints() const
84 {
85 return m_multiBodyConstraints.size();
86 }
87
88 virtual btMultiBodyConstraint* getMultiBodyConstraint(int constraintIndex)
89 {
90 return m_multiBodyConstraints[constraintIndex];
91 }
92
93 virtual const btMultiBodyConstraint* getMultiBodyConstraint(int constraintIndex) const
94 {
95 return m_multiBodyConstraints[constraintIndex];
96 }
97
98 virtual void removeMultiBodyConstraint(btMultiBodyConstraint* constraint);
99
100 virtual void integrateTransforms(btScalar timeStep);
101 void integrateMultiBodyTransforms(btScalar timeStep);
102 void predictMultiBodyTransforms(btScalar timeStep);
103
104 virtual void predictUnconstraintMotion(btScalar timeStep);
105 virtual void debugDrawWorld();
106
107 virtual void debugDrawMultiBodyConstraint(btMultiBodyConstraint* constraint);
108
109 void forwardKinematics();
110 virtual void clearForces();
111 virtual void clearMultiBodyConstraintForces();
112 virtual void clearMultiBodyForces();
113 virtual void applyGravity();
114
115 virtual void serialize(btSerializer* serializer);
116 virtual void setMultiBodyConstraintSolver(btMultiBodyConstraintSolver* solver);
117 virtual void setConstraintSolver(btConstraintSolver* solver);
118 virtual void getAnalyticsData(btAlignedObjectArray<struct btSolverAnalyticsData>& m_islandAnalyticsData) const;
119
120 virtual void solveExternalForces(btContactSolverInfo& solverInfo);
121 virtual void solveInternalConstraints(btContactSolverInfo& solverInfo);
122 void buildIslands();
123
124 virtual void saveKinematicState(btScalar timeStep);
125};
126#endif //BT_MULTIBODY_DYNAMICS_WORLD_H
btDiscreteDynamicsWorld.h
btMultiBodyInplaceSolverIslandCallback.h
btScalar
float btScalar
The btScalar type abstracts floating point numbers, to easily switch between double and single floati...
Definition btScalar.h:314
btAlignedObjectArray
The btAlignedObjectArray template class uses a subset of the stl::vector interface for its methods It...
Definition btAlignedObjectArray.h:46
btBroadphaseInterface
The btBroadphaseInterface class provides an interface to detect aabb-overlapping object pairs.
Definition btBroadphaseInterface.h:50
btCollisionConfiguration
btCollisionConfiguration allows to configure Bullet collision detection stack allocator size,...
Definition btCollisionConfiguration.h:27
btConstraintSolver
Definition btConstraintSolver.h:42
btDiscreteDynamicsWorld::btDiscreteDynamicsWorld
btDiscreteDynamicsWorld(btDispatcher *dispatcher, btBroadphaseInterface *pairCache, btConstraintSolver *constraintSolver, btCollisionConfiguration *collisionConfiguration)
this btDiscreteDynamicsWorld constructor gets created objects from the user, and will not delete thos...
Definition btDiscreteDynamicsWorld.cpp:191
btDispatcher
The btDispatcher interface class can be used in combination with broadphase to dispatch calculations ...
Definition btDispatcher.h:77
btMultiBodyConstraintSolver
Definition btMultiBodyConstraintSolver.h:30
btMultiBodyConstraint
Definition btMultiBodyConstraint.h:57
btMultiBodyDynamicsWorld::getMultiBodyConstraint
virtual btMultiBodyConstraint * getMultiBodyConstraint(int constraintIndex)
Definition btMultiBodyDynamicsWorld.h:88
btMultiBodyDynamicsWorld::m_multiBodyConstraints
btAlignedObjectArray< btMultiBodyConstraint * > m_multiBodyConstraints
Definition btMultiBodyDynamicsWorld.h:35
btMultiBodyDynamicsWorld::clearForces
virtual void clearForces()
the forces on each rigidbody is accumulating together with gravity. clear this after each timestep.
Definition btMultiBodyDynamicsWorld.cpp:825
btMultiBodyDynamicsWorld::solveInternalConstraints
virtual void solveInternalConstraints(btContactSolverInfo &solverInfo)
Definition btMultiBodyDynamicsWorld.cpp:235
btMultiBodyDynamicsWorld::updateActivationState
virtual void updateActivationState(btScalar timeStep)
Definition btMultiBodyDynamicsWorld.cpp:125
btMultiBodyDynamicsWorld::forwardKinematics
void forwardKinematics()
Definition btMultiBodyDynamicsWorld.cpp:215
btMultiBodyDynamicsWorld::m_scratch_world_to_local
btAlignedObjectArray< btQuaternion > m_scratch_world_to_local
Definition btMultiBodyDynamicsWorld.h:41
btMultiBodyDynamicsWorld::getMultiBody
btMultiBody * getMultiBody(int mbIndex)
Definition btMultiBodyDynamicsWorld.h:71
btMultiBodyDynamicsWorld::m_scratch_world_to_local1
btAlignedObjectArray< btQuaternion > m_scratch_world_to_local1
Definition btMultiBodyDynamicsWorld.h:43
btMultiBodyDynamicsWorld::m_scratch_m
btAlignedObjectArray< btMatrix3x3 > m_scratch_m
Definition btMultiBodyDynamicsWorld.h:47
btMultiBodyDynamicsWorld::m_solverMultiBodyIslandCallback
MultiBodyInplaceSolverIslandCallback * m_solverMultiBodyIslandCallback
Definition btMultiBodyDynamicsWorld.h:38
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:834
btMultiBodyDynamicsWorld::~btMultiBodyDynamicsWorld
virtual ~btMultiBodyDynamicsWorld()
Definition btMultiBodyDynamicsWorld.cpp:194
btMultiBodyDynamicsWorld::m_scratch_local_origin1
btAlignedObjectArray< btVector3 > m_scratch_local_origin1
Definition btMultiBodyDynamicsWorld.h:44
btMultiBodyDynamicsWorld::serializeMultiBodies
virtual void serializeMultiBodies(btSerializer *serializer)
Definition btMultiBodyDynamicsWorld.cpp:851
btMultiBodyDynamicsWorld::addMultiBodyConstraint
virtual void addMultiBodyConstraint(btMultiBodyConstraint *constraint)
Definition btMultiBodyDynamicsWorld.cpp:664
btMultiBodyDynamicsWorld::m_scratch_v
btAlignedObjectArray< btVector3 > m_scratch_v
Definition btMultiBodyDynamicsWorld.h:46
btMultiBodyDynamicsWorld::getMultiBody
const btMultiBody * getMultiBody(int mbIndex) const
Definition btMultiBodyDynamicsWorld.h:76
btMultiBodyDynamicsWorld::predictUnconstraintMotion
virtual void predictUnconstraintMotion(btScalar timeStep)
Definition btMultiBodyDynamicsWorld.cpp:36
btMultiBodyDynamicsWorld::buildIslands
void buildIslands()
Definition btMultiBodyDynamicsWorld.cpp:230
btMultiBodyDynamicsWorld::calculateSimulationIslands
virtual void calculateSimulationIslands()
Definition btMultiBodyDynamicsWorld.cpp:42
btMultiBodyDynamicsWorld::removeMultiBodyConstraint
virtual void removeMultiBodyConstraint(btMultiBodyConstraint *constraint)
Definition btMultiBodyDynamicsWorld.cpp:669
btMultiBodyDynamicsWorld::predictMultiBodyTransforms
void predictMultiBodyTransforms(btScalar timeStep)
Definition btMultiBodyDynamicsWorld.cpp:630
btMultiBodyDynamicsWorld::integrateTransforms
virtual void integrateTransforms(btScalar timeStep)
Definition btMultiBodyDynamicsWorld.cpp:575
btMultiBodyDynamicsWorld::m_multiBodyConstraintSolver
btMultiBodyConstraintSolver * m_multiBodyConstraintSolver
Definition btMultiBodyDynamicsWorld.h:37
btMultiBodyDynamicsWorld::m_multiBodies
btAlignedObjectArray< btMultiBody * > m_multiBodies
Definition btMultiBodyDynamicsWorld.h:34
btMultiBodyDynamicsWorld::getAnalyticsData
virtual void getAnalyticsData(btAlignedObjectArray< struct btSolverAnalyticsData > &m_islandAnalyticsData) const
Definition btMultiBodyDynamicsWorld.cpp:179
btMultiBodyDynamicsWorld::solveConstraints
virtual void solveConstraints(btContactSolverInfo &solverInfo)
Definition btMultiBodyDynamicsWorld.cpp:223
btMultiBodyDynamicsWorld::integrateMultiBodyTransforms
void integrateMultiBodyTransforms(btScalar timeStep)
Definition btMultiBodyDynamicsWorld.cpp:581
btMultiBodyDynamicsWorld::debugDrawMultiBodyConstraint
virtual void debugDrawMultiBodyConstraint(btMultiBodyConstraint *constraint)
Definition btMultiBodyDynamicsWorld.cpp:674
btMultiBodyDynamicsWorld::getNumMultibodies
virtual int getNumMultibodies() const
Definition btMultiBodyDynamicsWorld.h:66
btMultiBodyDynamicsWorld::solveExternalForces
virtual void solveExternalForces(btContactSolverInfo &solverInfo)
Definition btMultiBodyDynamicsWorld.cpp:288
btMultiBodyDynamicsWorld::setConstraintSolver
virtual void setConstraintSolver(btConstraintSolver *solver)
Definition btMultiBodyDynamicsWorld.cpp:206
btMultiBodyDynamicsWorld::m_scratch_local_origin
btAlignedObjectArray< btVector3 > m_scratch_local_origin
Definition btMultiBodyDynamicsWorld.h:42
btMultiBodyDynamicsWorld::clearMultiBodyForces
virtual void clearMultiBodyForces()
Definition btMultiBodyDynamicsWorld.cpp:797
btMultiBodyDynamicsWorld::getNumMultiBodyConstraints
virtual int getNumMultiBodyConstraints() const
Definition btMultiBodyDynamicsWorld.h:83
btMultiBodyDynamicsWorld::m_scratch_r
btAlignedObjectArray< btScalar > m_scratch_r
Definition btMultiBodyDynamicsWorld.h:45
btMultiBodyDynamicsWorld::removeMultiBody
virtual void removeMultiBody(btMultiBody *body)
Definition btMultiBodyDynamicsWorld.cpp:31
btMultiBodyDynamicsWorld::m_sortedMultiBodyConstraints
btAlignedObjectArray< btMultiBodyConstraint * > m_sortedMultiBodyConstraints
Definition btMultiBodyDynamicsWorld.h:36
btMultiBodyDynamicsWorld::addMultiBody
virtual void addMultiBody(btMultiBody *body, int group=btBroadphaseProxy::DefaultFilter, int mask=btBroadphaseProxy::AllFilter)
Definition btMultiBodyDynamicsWorld.cpp:26
btMultiBodyDynamicsWorld::btMultiBodyDynamicsWorld
btMultiBodyDynamicsWorld(btDispatcher *dispatcher, btBroadphaseInterface *pairCache, btMultiBodyConstraintSolver *constraintSolver, btCollisionConfiguration *collisionConfiguration)
Definition btMultiBodyDynamicsWorld.cpp:184
btMultiBodyDynamicsWorld::clearMultiBodyConstraintForces
virtual void clearMultiBodyConstraintForces()
Definition btMultiBodyDynamicsWorld.cpp:789
btMultiBodyDynamicsWorld::saveKinematicState
virtual void saveKinematicState(btScalar timeStep)
Definition btMultiBodyDynamicsWorld.cpp:880
btMultiBodyDynamicsWorld::applyGravity
virtual void applyGravity()
apply gravity, call this once per timestep
Definition btMultiBodyDynamicsWorld.cpp:755
btMultiBodyDynamicsWorld::setMultiBodyConstraintSolver
virtual void setMultiBodyConstraintSolver(btMultiBodyConstraintSolver *solver)
Definition btMultiBodyDynamicsWorld.cpp:199
btMultiBodyDynamicsWorld::debugDrawWorld
virtual void debugDrawWorld()
Definition btMultiBodyDynamicsWorld.cpp:679
btMultiBodyDynamicsWorld::getMultiBodyConstraint
virtual const btMultiBodyConstraint * getMultiBodyConstraint(int constraintIndex) const
Definition btMultiBodyDynamicsWorld.h:93
btMultiBody
Definition btMultiBody.h:51
btSerializer
Definition btSerializer.h:66
MultiBodyInplaceSolverIslandCallback
Definition btMultiBodyInplaceSolverIslandCallback.h:66
btBroadphaseProxy::AllFilter
@ AllFilter
Definition btBroadphaseProxy.h:98
btBroadphaseProxy::DefaultFilter
@ DefaultFilter
Definition btBroadphaseProxy.h:92
btContactSolverInfo
Definition btContactSolverInfo.h:76