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

Bullet Collision Detection & Physics Library

- Main Page
- Namespaces
- Classes
- Files

- File List
- File Members

btSimulationIslandManagerMt.h
Go to the documentation of this file.
1/*
2Bullet Continuous Collision Detection and Physics Library
3Copyright (c) 2003-2006 Erwin Coumans https://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_SIMULATION_ISLAND_MANAGER_MT_H
17#define BT_SIMULATION_ISLAND_MANAGER_MT_H
18
19#include "BulletCollision/CollisionDispatch/btSimulationIslandManager.h"
20
21class btTypedConstraint;
22class btConstraintSolver;
23struct btContactSolverInfo;
24class btIDebugDraw;
25
35 class btSimulationIslandManagerMt : public btSimulationIslandManager
36{
37public:
38 struct Island
39 {
40 // a simulation island consisting of bodies, manifolds and constraints,
41 // to be passed into a constraint solver.
42 btAlignedObjectArray<btCollisionObject*> bodyArray;
43 btAlignedObjectArray<btPersistentManifold*> manifoldArray;
44 btAlignedObjectArray<btTypedConstraint*> constraintArray;
45 int id; // island id
46 bool isSleeping;
47
48 void append(const Island& other); // add bodies, manifolds, constraints to my own
49 };
50 struct SolverParams
51 {
52 btConstraintSolver* m_solverPool;
53 btConstraintSolver* m_solverMt;
54 btContactSolverInfo* m_solverInfo;
55 btIDebugDraw* m_debugDrawer;
56 btDispatcher* m_dispatcher;
57 };
58 static void solveIsland(btConstraintSolver* solver, Island& island, const SolverParams& solverParams);
59
60 typedef void (*IslandDispatchFunc)(btAlignedObjectArray<Island*>* islands, const SolverParams& solverParams);
61 static void serialIslandDispatch(btAlignedObjectArray<Island*>* islandsPtr, const SolverParams& solverParams);
62 static void parallelIslandDispatch(btAlignedObjectArray<Island*>* islandsPtr, const SolverParams& solverParams);
63
64protected:
65 btAlignedObjectArray<Island*> m_allocatedIslands; // owner of all Islands
66 btAlignedObjectArray<Island*> m_activeIslands; // islands actively in use
67 btAlignedObjectArray<Island*> m_freeIslands; // islands ready to be reused
68 btAlignedObjectArray<Island*> m_lookupIslandFromId; // big lookup table to map islandId to Island pointer
69 Island* m_batchIsland;
70 int m_minimumSolverBatchSize;
71 int m_batchIslandMinBodyCount;
72 IslandDispatchFunc m_islandDispatch;
73
74 Island* getIsland(int id);
75 virtual Island* allocateIsland(int id, int numBodies);
76 virtual void initIslandPools();
77 virtual void addBodiesToIslands(btCollisionWorld* collisionWorld);
78 virtual void addManifoldsToIslands(btDispatcher* dispatcher);
79 virtual void addConstraintsToIslands(btAlignedObjectArray<btTypedConstraint*>& constraints);
80 virtual void mergeIslands();
81
82public:
83 btSimulationIslandManagerMt();
84 virtual ~btSimulationIslandManagerMt();
85
86 virtual void buildAndProcessIslands(btDispatcher* dispatcher,
87 btCollisionWorld* collisionWorld,
88 btAlignedObjectArray<btTypedConstraint*>& constraints,
89 const SolverParams& solverParams);
90
91 virtual void buildIslands(btDispatcher* dispatcher, btCollisionWorld* colWorld);
92
93 int getMinimumSolverBatchSize() const
94 {
95 return m_minimumSolverBatchSize;
96 }
97 void setMinimumSolverBatchSize(int sz)
98 {
99 m_minimumSolverBatchSize = sz;
100 }
101 IslandDispatchFunc getIslandDispatchFunction() const
102 {
103 return m_islandDispatch;
104 }
105 // allow users to set their own dispatch function for multithreaded dispatch
106 void setIslandDispatchFunction(IslandDispatchFunc func)
107 {
108 m_islandDispatch = func;
109 }
110};
111
112#endif //BT_SIMULATION_ISLAND_MANAGER_H
btSimulationIslandManager.h
btAlignedObjectArray
The btAlignedObjectArray template class uses a subset of the stl::vector interface for its methods It...
Definition btAlignedObjectArray.h:46
btCollisionWorld
CollisionWorld is interface and container for the collision detection.
Definition btCollisionWorld.h:86
btConstraintSolver
Definition btConstraintSolver.h:42
btDispatcher
The btDispatcher interface class can be used in combination with broadphase to dispatch calculations ...
Definition btDispatcher.h:77
btIDebugDraw
The btIDebugDraw interface class allows hooking up a debug renderer to visually debug simulations.
Definition btIDebugDraw.h:27
btSimulationIslandManagerMt
SimulationIslandManagerMt – Multithread capable version of SimulationIslandManager Splits the world u...
Definition btSimulationIslandManagerMt.h:36
btSimulationIslandManagerMt::m_allocatedIslands
btAlignedObjectArray< Island * > m_allocatedIslands
Definition btSimulationIslandManagerMt.h:65
btSimulationIslandManagerMt::addBodiesToIslands
virtual void addBodiesToIslands(btCollisionWorld *collisionWorld)
Definition btSimulationIslandManagerMt.cpp:362
btSimulationIslandManagerMt::m_batchIsland
Island * m_batchIsland
Definition btSimulationIslandManagerMt.h:69
btSimulationIslandManagerMt::buildAndProcessIslands
virtual void buildAndProcessIslands(btDispatcher *dispatcher, btCollisionWorld *collisionWorld, btAlignedObjectArray< btTypedConstraint * > &constraints, const SolverParams &solverParams)
Definition btSimulationIslandManagerMt.cpp:625
btSimulationIslandManagerMt::initIslandPools
virtual void initIslandPools()
Definition btSimulationIslandManagerMt.cpp:128
btSimulationIslandManagerMt::getIslandDispatchFunction
IslandDispatchFunc getIslandDispatchFunction() const
Definition btSimulationIslandManagerMt.h:101
btSimulationIslandManagerMt::getIsland
Island * getIsland(int id)
Definition btSimulationIslandManagerMt.cpp:172
btSimulationIslandManagerMt::m_batchIslandMinBodyCount
int m_batchIslandMinBodyCount
Definition btSimulationIslandManagerMt.h:71
btSimulationIslandManagerMt::allocateIsland
virtual Island * allocateIsland(int id, int numBodies)
Definition btSimulationIslandManagerMt.cpp:193
btSimulationIslandManagerMt::m_freeIslands
btAlignedObjectArray< Island * > m_freeIslands
Definition btSimulationIslandManagerMt.h:67
btSimulationIslandManagerMt::~btSimulationIslandManagerMt
virtual ~btSimulationIslandManagerMt()
Definition btSimulationIslandManagerMt.cpp:49
btSimulationIslandManagerMt::m_lookupIslandFromId
btAlignedObjectArray< Island * > m_lookupIslandFromId
Definition btSimulationIslandManagerMt.h:68
btSimulationIslandManagerMt::addManifoldsToIslands
virtual void addManifoldsToIslands(btDispatcher *dispatcher)
Definition btSimulationIslandManagerMt.cpp:407
btSimulationIslandManagerMt::m_minimumSolverBatchSize
int m_minimumSolverBatchSize
Definition btSimulationIslandManagerMt.h:70
btSimulationIslandManagerMt::addConstraintsToIslands
virtual void addConstraintsToIslands(btAlignedObjectArray< btTypedConstraint * > &constraints)
Definition btSimulationIslandManagerMt.cpp:448
btSimulationIslandManagerMt::m_islandDispatch
IslandDispatchFunc m_islandDispatch
Definition btSimulationIslandManagerMt.h:72
btSimulationIslandManagerMt::m_activeIslands
btAlignedObjectArray< Island * > m_activeIslands
Definition btSimulationIslandManagerMt.h:66
btSimulationIslandManagerMt::parallelIslandDispatch
static void parallelIslandDispatch(btAlignedObjectArray< Island * > *islandsPtr, const SolverParams &solverParams)
Definition btSimulationIslandManagerMt.cpp:576
btSimulationIslandManagerMt::solveIsland
static void solveIsland(btConstraintSolver *solver, Island &island, const SolverParams &solverParams)
Definition btSimulationIslandManagerMt.cpp:528
btSimulationIslandManagerMt::serialIslandDispatch
static void serialIslandDispatch(btAlignedObjectArray< Island * > *islandsPtr, const SolverParams &solverParams)
Definition btSimulationIslandManagerMt.cpp:543
btSimulationIslandManagerMt::setMinimumSolverBatchSize
void setMinimumSolverBatchSize(int sz)
Definition btSimulationIslandManagerMt.h:97
btSimulationIslandManagerMt::btSimulationIslandManagerMt
btSimulationIslandManagerMt()
Definition btSimulationIslandManagerMt.cpp:41
btSimulationIslandManagerMt::mergeIslands
virtual void mergeIslands()
Definition btSimulationIslandManagerMt.cpp:467
btSimulationIslandManagerMt::buildIslands
virtual void buildIslands(btDispatcher *dispatcher, btCollisionWorld *colWorld)
Definition btSimulationIslandManagerMt.cpp:264
btSimulationIslandManagerMt::setIslandDispatchFunction
void setIslandDispatchFunction(IslandDispatchFunc func)
Definition btSimulationIslandManagerMt.h:106
btSimulationIslandManagerMt::IslandDispatchFunc
void(*) IslandDispatchFunc(btAlignedObjectArray< Island * > *islands, const SolverParams &solverParams)
Definition btSimulationIslandManagerMt.h:60
btSimulationIslandManagerMt::getMinimumSolverBatchSize
int getMinimumSolverBatchSize() const
Definition btSimulationIslandManagerMt.h:93
btSimulationIslandManager
SimulationIslandManager creates and handles simulation islands, using btUnionFind.
Definition btSimulationIslandManager.h:31
btTypedConstraint
TypedConstraint is the baseclass for Bullet constraints and vehicles.
Definition btTypedConstraint.h:76
btContactSolverInfo
Definition btContactSolverInfo.h:76
btSimulationIslandManagerMt::Island
Definition btSimulationIslandManagerMt.h:39
btSimulationIslandManagerMt::Island::isSleeping
bool isSleeping
Definition btSimulationIslandManagerMt.h:46
btSimulationIslandManagerMt::Island::constraintArray
btAlignedObjectArray< btTypedConstraint * > constraintArray
Definition btSimulationIslandManagerMt.h:44
btSimulationIslandManagerMt::Island::append
void append(const Island &other)
Definition btSimulationIslandManagerMt.cpp:97
btSimulationIslandManagerMt::Island::id
int id
Definition btSimulationIslandManagerMt.h:45
btSimulationIslandManagerMt::Island::bodyArray
btAlignedObjectArray< btCollisionObject * > bodyArray
Definition btSimulationIslandManagerMt.h:42
btSimulationIslandManagerMt::Island::manifoldArray
btAlignedObjectArray< btPersistentManifold * > manifoldArray
Definition btSimulationIslandManagerMt.h:43
btSimulationIslandManagerMt::SolverParams
Definition btSimulationIslandManagerMt.h:51
btSimulationIslandManagerMt::SolverParams::m_solverInfo
btContactSolverInfo * m_solverInfo
Definition btSimulationIslandManagerMt.h:54
btSimulationIslandManagerMt::SolverParams::m_dispatcher
btDispatcher * m_dispatcher
Definition btSimulationIslandManagerMt.h:56
btSimulationIslandManagerMt::SolverParams::m_solverPool
btConstraintSolver * m_solverPool
Definition btSimulationIslandManagerMt.h:52
btSimulationIslandManagerMt::SolverParams::m_solverMt
btConstraintSolver * m_solverMt
Definition btSimulationIslandManagerMt.h:53
btSimulationIslandManagerMt::SolverParams::m_debugDrawer
btIDebugDraw * m_debugDrawer
Definition btSimulationIslandManagerMt.h:55