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

Bullet Collision Detection & Physics Library

btSimulationIslandManagerMt.h
Go to the documentation of this file.
1 /*
2 Bullet Continuous Collision Detection and Physics Library
3 Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/
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_SIMULATION_ISLAND_MANAGER_MT_H
17 #define BT_SIMULATION_ISLAND_MANAGER_MT_H
18
19 #include "BulletCollision/CollisionDispatch/btSimulationIslandManager.h"
20
21 class btTypedConstraint;
22
23
33 class btSimulationIslandManagerMt : public btSimulationIslandManager
34 {
35 public:
36 struct Island
37 {
38 // a simulation island consisting of bodies, manifolds and constraints,
39 // to be passed into a constraint solver.
40 btAlignedObjectArray<btCollisionObject*> bodyArray;
41 btAlignedObjectArray<btPersistentManifold*> manifoldArray;
42 btAlignedObjectArray<btTypedConstraint*> constraintArray;
43 int id; // island id
44 bool isSleeping;
45
46 void append( const Island& other ); // add bodies, manifolds, constraints to my own
47 };
48 struct IslandCallback
49 {
50 virtual ~IslandCallback() {};
51
52 virtual void processIsland( btCollisionObject** bodies,
53 int numBodies,
54 btPersistentManifold** manifolds,
55 int numManifolds,
56 btTypedConstraint** constraints,
57 int numConstraints,
58 int islandId
59 ) = 0;
60 };
61 typedef void( *IslandDispatchFunc ) ( btAlignedObjectArray<Island*>* islands, IslandCallback* callback );
62 static void defaultIslandDispatch( btAlignedObjectArray<Island*>* islands, IslandCallback* callback );
63 protected:
64 btAlignedObjectArray<Island*> m_allocatedIslands; // owner of all Islands
65 btAlignedObjectArray<Island*> m_activeIslands; // islands actively in use
66 btAlignedObjectArray<Island*> m_freeIslands; // islands ready to be reused
67 btAlignedObjectArray<Island*> m_lookupIslandFromId; // big lookup table to map islandId to Island pointer
68 Island* m_batchIsland;
69 int m_minimumSolverBatchSize;
70 int m_batchIslandMinBodyCount;
71 IslandDispatchFunc m_islandDispatch;
72
73 Island* getIsland( int id );
74 virtual Island* allocateIsland( int id, int numBodies );
75 virtual void initIslandPools();
76 virtual void addBodiesToIslands( btCollisionWorld* collisionWorld );
77 virtual void addManifoldsToIslands( btDispatcher* dispatcher );
78 virtual void addConstraintsToIslands( btAlignedObjectArray<btTypedConstraint*>& constraints );
79 virtual void mergeIslands();
80
81 public:
82 btSimulationIslandManagerMt();
83 virtual ~btSimulationIslandManagerMt();
84
85 virtual void buildAndProcessIslands( btDispatcher* dispatcher, btCollisionWorld* collisionWorld, btAlignedObjectArray<btTypedConstraint*>& constraints, IslandCallback* callback );
86
87 virtual void buildIslands(btDispatcher* dispatcher,btCollisionWorld* colWorld);
88
89 int getMinimumSolverBatchSize() const
90 {
91 return m_minimumSolverBatchSize;
92 }
93 void setMinimumSolverBatchSize( int sz )
94 {
95 m_minimumSolverBatchSize = sz;
96 }
97 IslandDispatchFunc getIslandDispatchFunction() const
98 {
99 return m_islandDispatch;
100 }
101 // allow users to set their own dispatch function for multithreaded dispatch
102 void setIslandDispatchFunction( IslandDispatchFunc func )
103 {
104 m_islandDispatch = func;
105 }
106 };
107
108 #endif //BT_SIMULATION_ISLAND_MANAGER_H
109
btSimulationIslandManagerMt::allocateIsland
virtual Island * allocateIsland(int id, int numBodies)
Definition: btSimulationIslandManagerMt.cpp:202
btSimulationIslandManagerMt::initIslandPools
virtual void initIslandPools()
Definition: btSimulationIslandManagerMt.cpp:137
btPersistentManifold
btPersistentManifold is a contact point cache, it stays persistent as long as objects are overlapping...
Definition: btPersistentManifold.h:55
btSimulationIslandManagerMt::setIslandDispatchFunction
void setIslandDispatchFunction(IslandDispatchFunc func)
Definition: btSimulationIslandManagerMt.h:102
btSimulationIslandManagerMt::getIsland
Island * getIsland(int id)
Definition: btSimulationIslandManagerMt.cpp:182
btSimulationIslandManagerMt::Island::manifoldArray
btAlignedObjectArray< btPersistentManifold * > manifoldArray
Definition: btSimulationIslandManagerMt.h:41
btSimulationIslandManagerMt::m_freeIslands
btAlignedObjectArray< Island * > m_freeIslands
Definition: btSimulationIslandManagerMt.h:66
btSimulationIslandManagerMt::Island::append
void append(const Island &other)
Definition: btSimulationIslandManagerMt.cpp:104
btAlignedObjectArray
The btAlignedObjectArray template class uses a subset of the stl::vector interface for its methods It...
Definition: btAlignedObjectArray.h:53
btSimulationIslandManagerMt::Island::id
int id
Definition: btSimulationIslandManagerMt.h:43
btSimulationIslandManagerMt::m_lookupIslandFromId
btAlignedObjectArray< Island * > m_lookupIslandFromId
Definition: btSimulationIslandManagerMt.h:67
btSimulationIslandManagerMt::buildAndProcessIslands
virtual void buildAndProcessIslands(btDispatcher *dispatcher, btCollisionWorld *collisionWorld, btAlignedObjectArray< btTypedConstraint *> &constraints, IslandCallback *callback)
Definition: btSimulationIslandManagerMt.cpp:569
btSimulationIslandManagerMt::Island
Definition: btSimulationIslandManagerMt.h:36
btSimulationIslandManager
SimulationIslandManager creates and handles simulation islands, using btUnionFind.
Definition: btSimulationIslandManager.h:31
btSimulationIslandManagerMt::addBodiesToIslands
virtual void addBodiesToIslands(btCollisionWorld *collisionWorld)
Definition: btSimulationIslandManagerMt.cpp:376
btSimulationIslandManagerMt::~btSimulationIslandManagerMt
virtual ~btSimulationIslandManagerMt()
Definition: btSimulationIslandManagerMt.cpp:52
btSimulationIslandManagerMt::IslandCallback::~IslandCallback
virtual ~IslandCallback()
Definition: btSimulationIslandManagerMt.h:50
btSimulationIslandManagerMt::defaultIslandDispatch
static void defaultIslandDispatch(btAlignedObjectArray< Island *> *islands, IslandCallback *callback)
Definition: btSimulationIslandManagerMt.cpp:548
btSimulationIslandManagerMt::Island::isSleeping
bool isSleeping
Definition: btSimulationIslandManagerMt.h:44
btSimulationIslandManagerMt::m_activeIslands
btAlignedObjectArray< Island * > m_activeIslands
Definition: btSimulationIslandManagerMt.h:65
btSimulationIslandManagerMt::m_minimumSolverBatchSize
int m_minimumSolverBatchSize
Definition: btSimulationIslandManagerMt.h:69
btSimulationIslandManagerMt::m_allocatedIslands
btAlignedObjectArray< Island * > m_allocatedIslands
Definition: btSimulationIslandManagerMt.h:64
btSimulationIslandManagerMt::getMinimumSolverBatchSize
int getMinimumSolverBatchSize() const
Definition: btSimulationIslandManagerMt.h:89
btCollisionObject
btCollisionObject can be used to manage collision detection objects.
Definition: btCollisionObject.h:49
btSimulationIslandManagerMt::m_batchIslandMinBodyCount
int m_batchIslandMinBodyCount
Definition: btSimulationIslandManagerMt.h:70
btSimulationIslandManagerMt::Island::constraintArray
btAlignedObjectArray< btTypedConstraint * > constraintArray
Definition: btSimulationIslandManagerMt.h:42
btSimulationIslandManagerMt::IslandCallback
Definition: btSimulationIslandManagerMt.h:48
btCollisionWorld
CollisionWorld is interface and container for the collision detection.
Definition: btCollisionWorld.h:88
btSimulationIslandManagerMt::mergeIslands
virtual void mergeIslands()
Definition: btSimulationIslandManagerMt.cpp:486
btSimulationIslandManagerMt::btSimulationIslandManagerMt
btSimulationIslandManagerMt()
Definition: btSimulationIslandManagerMt.cpp:43
btSimulationIslandManagerMt::addConstraintsToIslands
virtual void addConstraintsToIslands(btAlignedObjectArray< btTypedConstraint *> &constraints)
Definition: btSimulationIslandManagerMt.cpp:466
btTypedConstraint
TypedConstraint is the baseclass for Bullet constraints and vehicles.
Definition: btTypedConstraint.h:78
btSimulationIslandManagerMt::IslandDispatchFunc
void(* IslandDispatchFunc)(btAlignedObjectArray< Island *> *islands, IslandCallback *callback)
Definition: btSimulationIslandManagerMt.h:61
btSimulationIslandManagerMt::setMinimumSolverBatchSize
void setMinimumSolverBatchSize(int sz)
Definition: btSimulationIslandManagerMt.h:93
btSimulationIslandManagerMt::buildIslands
virtual void buildIslands(btDispatcher *dispatcher, btCollisionWorld *colWorld)
Definition: btSimulationIslandManagerMt.cpp:274
btSimulationIslandManagerMt::Island::bodyArray
btAlignedObjectArray< btCollisionObject * > bodyArray
Definition: btSimulationIslandManagerMt.h:40
btSimulationIslandManagerMt::m_islandDispatch
IslandDispatchFunc m_islandDispatch
Definition: btSimulationIslandManagerMt.h:71
btDispatcher
The btDispatcher interface class can be used in combination with broadphase to dispatch calculations ...
Definition: btDispatcher.h:75
btSimulationIslandManager.h
btSimulationIslandManagerMt::getIslandDispatchFunction
IslandDispatchFunc getIslandDispatchFunction() const
Definition: btSimulationIslandManagerMt.h:97
btSimulationIslandManagerMt::addManifoldsToIslands
virtual void addManifoldsToIslands(btDispatcher *dispatcher)
Definition: btSimulationIslandManagerMt.cpp:423
btSimulationIslandManagerMt::m_batchIsland
Island * m_batchIsland
Definition: btSimulationIslandManagerMt.h:68
btSimulationIslandManagerMt
SimulationIslandManagerMt – Multithread capable version of SimulationIslandManager Splits the world...
Definition: btSimulationIslandManagerMt.h:33