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

Bullet Collision Detection & Physics Library

- Main Page
- Namespaces
- Classes
- Files

- File List
- File Members

btDiscreteDynamicsWorldMt.h
Go to the documentation of this file.
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#ifndef BT_DISCRETE_DYNAMICS_WORLD_MT_H
17#define BT_DISCRETE_DYNAMICS_WORLD_MT_H
18
19#include "btDiscreteDynamicsWorld.h"
20#include "btSimulationIslandManagerMt.h"
21#include "BulletDynamics/ConstraintSolver/btConstraintSolver.h"
22
32 class btConstraintSolverPoolMt : public btConstraintSolver
33{
34public:
35 // create the solvers for me
36 explicit btConstraintSolverPoolMt(int numSolvers);
37
38 // pass in fully constructed solvers (destructor will delete them)
39 btConstraintSolverPoolMt(btConstraintSolver** solvers, int numSolvers);
40
41 virtual ~btConstraintSolverPoolMt();
42
44 virtual btScalar solveGroup(btCollisionObject** bodies,
45 int numBodies,
46 btPersistentManifold** manifolds,
47 int numManifolds,
48 btTypedConstraint** constraints,
49 int numConstraints,
50 const btContactSolverInfo& info,
51 btIDebugDraw* debugDrawer,
52 btDispatcher* dispatcher) BT_OVERRIDE;
53
54 virtual void reset() BT_OVERRIDE;
55 virtual btConstraintSolverType getSolverType() const BT_OVERRIDE { return m_solverType; }
56
57private:
58 const static size_t kCacheLineSize = 128;
59 struct ThreadSolver
60 {
61 btConstraintSolver* solver;
62 btSpinMutex mutex;
63 char _cachelinePadding[kCacheLineSize - sizeof(btSpinMutex) - sizeof(void*)]; // keep mutexes from sharing a cache line
64 };
65 btAlignedObjectArray<ThreadSolver> m_solvers;
66 btConstraintSolverType m_solverType;
67
68 ThreadSolver* getAndLockThreadSolver();
69 void init(btConstraintSolver** solvers, int numSolvers);
70};
71
82 ATTRIBUTE_ALIGNED16(class)
83 btDiscreteDynamicsWorldMt : public btDiscreteDynamicsWorld
84{
85protected:
86 btConstraintSolver* m_constraintSolverMt;
87
88 virtual void solveConstraints(btContactSolverInfo & solverInfo) BT_OVERRIDE;
89
90 virtual void predictUnconstraintMotion(btScalar timeStep) BT_OVERRIDE;
91
92 struct UpdaterCreatePredictiveContacts : public btIParallelForBody
93 {
94 btScalar timeStep;
95 btRigidBody** rigidBodies;
96 btDiscreteDynamicsWorldMt* world;
97
98 void forLoop(int iBegin, int iEnd) const BT_OVERRIDE
99 {
100 world->createPredictiveContactsInternal(&rigidBodies[iBegin], iEnd - iBegin, timeStep);
101 }
102 };
103 virtual void createPredictiveContacts(btScalar timeStep) BT_OVERRIDE;
104
105 struct UpdaterIntegrateTransforms : public btIParallelForBody
106 {
107 btScalar timeStep;
108 btRigidBody** rigidBodies;
109 btDiscreteDynamicsWorldMt* world;
110
111 void forLoop(int iBegin, int iEnd) const BT_OVERRIDE
112 {
113 world->integrateTransformsInternal(&rigidBodies[iBegin], iEnd - iBegin, timeStep);
114 }
115 };
116 virtual void integrateTransforms(btScalar timeStep) BT_OVERRIDE;
117
118public:
119 BT_DECLARE_ALIGNED_ALLOCATOR();
120
121 btDiscreteDynamicsWorldMt(btDispatcher * dispatcher,
122 btBroadphaseInterface * pairCache,
123 btConstraintSolverPoolMt * solverPool, // Note this should be a solver-pool for multi-threading
124 btConstraintSolver * constraintSolverMt, // single multi-threaded solver for large islands (or NULL)
125 btCollisionConfiguration * collisionConfiguration);
126 virtual ~btDiscreteDynamicsWorldMt();
127
128 virtual int stepSimulation(btScalar timeStep, int maxSubSteps, btScalar fixedTimeStep) BT_OVERRIDE;
129};
130
131#endif //BT_DISCRETE_DYNAMICS_WORLD_H
btConstraintSolver.h
btConstraintSolverType
btConstraintSolverType
btConstraintSolver provides solver interface
Definition: btConstraintSolver.h:33
btDiscreteDynamicsWorld.h
btScalar
float btScalar
The btScalar type abstracts floating point numbers, to easily switch between double and single floati...
Definition: btScalar.h:314
ATTRIBUTE_ALIGNED16
#define ATTRIBUTE_ALIGNED16(a)
Definition: btScalar.h:99
btSimulationIslandManagerMt.h
BT_OVERRIDE
#define BT_OVERRIDE
Definition: btThreads.h:26
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
btCollisionObject
btCollisionObject can be used to manage collision detection objects.
Definition: btCollisionObject.h:51
btConstraintSolverPoolMt
btConstraintSolverPoolMt - masquerades as a constraint solver, but really it is a threadsafe pool of ...
Definition: btDiscreteDynamicsWorldMt.h:33
btConstraintSolverPoolMt::kCacheLineSize
static const size_t kCacheLineSize
Definition: btDiscreteDynamicsWorldMt.h:58
btConstraintSolverPoolMt::getAndLockThreadSolver
ThreadSolver * getAndLockThreadSolver()
btConstraintSolverPoolMt
Definition: btDiscreteDynamicsWorldMt.cpp:53
btConstraintSolverPoolMt::reset
virtual void reset() BT_OVERRIDE
clear internal cached data and reset random seed
Definition: btDiscreteDynamicsWorldMt.cpp:133
btConstraintSolverPoolMt::m_solverType
btConstraintSolverType m_solverType
Definition: btDiscreteDynamicsWorldMt.h:66
btConstraintSolverPoolMt::init
void init(btConstraintSolver **solvers, int numSolvers)
Definition: btDiscreteDynamicsWorldMt.cpp:72
btConstraintSolverPoolMt::~btConstraintSolverPoolMt
virtual ~btConstraintSolverPoolMt()
Definition: btDiscreteDynamicsWorldMt.cpp:105
btConstraintSolverPoolMt::getSolverType
virtual btConstraintSolverType getSolverType() const BT_OVERRIDE
Definition: btDiscreteDynamicsWorldMt.h:55
btConstraintSolverPoolMt::solveGroup
virtual btScalar solveGroup(btCollisionObject **bodies, int numBodies, btPersistentManifold **manifolds, int numManifolds, btTypedConstraint **constraints, int numConstraints, const btContactSolverInfo &info, btIDebugDraw *debugDrawer, btDispatcher *dispatcher) BT_OVERRIDE
solve a group of constraints
Definition: btDiscreteDynamicsWorldMt.cpp:117
btConstraintSolverPoolMt::m_solvers
btAlignedObjectArray< ThreadSolver > m_solvers
Definition: btDiscreteDynamicsWorldMt.h:65
btConstraintSolver
Definition: btConstraintSolver.h:42
btDiscreteDynamicsWorldMt
btDiscreteDynamicsWorldMt – a version of DiscreteDynamicsWorld with some minor changes to support sol...
Definition: btDiscreteDynamicsWorldMt.h:84
btDiscreteDynamicsWorldMt::m_constraintSolverMt
btConstraintSolver * m_constraintSolverMt
Definition: btDiscreteDynamicsWorldMt.h:86
btDiscreteDynamicsWorldMt::BT_DECLARE_ALIGNED_ALLOCATOR
BT_DECLARE_ALIGNED_ALLOCATOR()
btDiscreteDynamicsWorld
btDiscreteDynamicsWorld provides discrete rigid body simulation those classes replace the obsolete Cc...
Definition: btDiscreteDynamicsWorld.h:38
btDiscreteDynamicsWorld::integrateTransformsInternal
void integrateTransformsInternal(btRigidBody **bodies, int numBodies, btScalar timeStep)
Definition: btDiscreteDynamicsWorld.cpp:951
btDiscreteDynamicsWorld::createPredictiveContactsInternal
void createPredictiveContactsInternal(btRigidBody **bodies, int numBodies, btScalar timeStep)
Definition: btDiscreteDynamicsWorld.cpp:849
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
btIParallelForBody
Definition: btThreads.h:102
btPersistentManifold
btPersistentManifold is a contact point cache, it stays persistent as long as objects are overlapping...
Definition: btPersistentManifold.h:65
btRigidBody
The btRigidBody is the main class for rigid body objects.
Definition: btRigidBody.h:60
btSpinMutex
btSpinMutex – lightweight spin-mutex implemented with atomic ops, never puts a thread to sleep becaus...
Definition: btThreads.h:46
btTypedConstraint
TypedConstraint is the baseclass for Bullet constraints and vehicles.
Definition: btTypedConstraint.h:76
btConstraintSolverPoolMt::ThreadSolver
Definition: btDiscreteDynamicsWorldMt.h:60
btConstraintSolverPoolMt::ThreadSolver::_cachelinePadding
char _cachelinePadding[kCacheLineSize - sizeof(btSpinMutex) - sizeof(void *)]
Definition: btDiscreteDynamicsWorldMt.h:63
btConstraintSolverPoolMt::ThreadSolver::mutex
btSpinMutex mutex
Definition: btDiscreteDynamicsWorldMt.h:62
btConstraintSolverPoolMt::ThreadSolver::solver
btConstraintSolver * solver
Definition: btDiscreteDynamicsWorldMt.h:61
btContactSolverInfo
Definition: btContactSolverInfo.h:76
btDiscreteDynamicsWorldMt::UpdaterCreatePredictiveContacts
Definition: btDiscreteDynamicsWorldMt.h:93
btDiscreteDynamicsWorldMt::UpdaterCreatePredictiveContacts::world
btDiscreteDynamicsWorldMt * world
Definition: btDiscreteDynamicsWorldMt.h:96
btDiscreteDynamicsWorldMt::UpdaterCreatePredictiveContacts::forLoop
void forLoop(int iBegin, int iEnd) const BT_OVERRIDE
Definition: btDiscreteDynamicsWorldMt.h:98
btDiscreteDynamicsWorldMt::UpdaterCreatePredictiveContacts::timeStep
btScalar timeStep
Definition: btDiscreteDynamicsWorldMt.h:94
btDiscreteDynamicsWorldMt::UpdaterCreatePredictiveContacts::rigidBodies
btRigidBody ** rigidBodies
Definition: btDiscreteDynamicsWorldMt.h:95
btDiscreteDynamicsWorldMt::UpdaterIntegrateTransforms
Definition: btDiscreteDynamicsWorldMt.h:106
btDiscreteDynamicsWorldMt::UpdaterIntegrateTransforms::forLoop
void forLoop(int iBegin, int iEnd) const BT_OVERRIDE
Definition: btDiscreteDynamicsWorldMt.h:111
btDiscreteDynamicsWorldMt::UpdaterIntegrateTransforms::timeStep
btScalar timeStep
Definition: btDiscreteDynamicsWorldMt.h:107
btDiscreteDynamicsWorldMt::UpdaterIntegrateTransforms::rigidBodies
btRigidBody ** rigidBodies
Definition: btDiscreteDynamicsWorldMt.h:108
btDiscreteDynamicsWorldMt::UpdaterIntegrateTransforms::world
btDiscreteDynamicsWorldMt * world
Definition: btDiscreteDynamicsWorldMt.h:109