Bullet Collision Detection & Physics Library
btDiscreteDynamicsWorldMt.h
Go to the documentation of this file.
1 /*
2 Bullet Continuous Collision Detection and Physics Library
3 Copyright (c) 2003-2009 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 
17 #ifndef BT_DISCRETE_DYNAMICS_WORLD_MT_H
18 #define BT_DISCRETE_DYNAMICS_WORLD_MT_H
19 
23 
24 
35 {
36 public:
37  // create the solvers for me
38  explicit btConstraintSolverPoolMt( int numSolvers );
39 
40  // pass in fully constructed solvers (destructor will delete them)
41  btConstraintSolverPoolMt( btConstraintSolver** solvers, int numSolvers );
42 
43  virtual ~btConstraintSolverPoolMt();
44 
46  virtual btScalar solveGroup( btCollisionObject** bodies,
47  int numBodies,
48  btPersistentManifold** manifolds,
49  int numManifolds,
50  btTypedConstraint** constraints,
51  int numConstraints,
52  const btContactSolverInfo& info,
53  btIDebugDraw* debugDrawer,
54  btDispatcher* dispatcher
55  ) BT_OVERRIDE;
56 
57  virtual void reset() BT_OVERRIDE;
58  virtual btConstraintSolverType getSolverType() const BT_OVERRIDE { return m_solverType; }
59 
60 private:
61  const static size_t kCacheLineSize = 128;
62  struct ThreadSolver
63  {
66  char _cachelinePadding[ kCacheLineSize - sizeof( btSpinMutex ) - sizeof( void* ) ]; // keep mutexes from sharing a cache line
67  };
70 
72  void init( btConstraintSolver** solvers, int numSolvers );
73 };
74 
75 
76 
88 {
89 protected:
91 
92  virtual void solveConstraints(btContactSolverInfo& solverInfo) BT_OVERRIDE;
93 
94  virtual void predictUnconstraintMotion( btScalar timeStep ) BT_OVERRIDE;
95 
97  {
101 
102  void forLoop( int iBegin, int iEnd ) const BT_OVERRIDE
103  {
104  world->createPredictiveContactsInternal( &rigidBodies[ iBegin ], iEnd - iBegin, timeStep );
105  }
106  };
107  virtual void createPredictiveContacts( btScalar timeStep ) BT_OVERRIDE;
108 
110  {
114 
115  void forLoop( int iBegin, int iEnd ) const BT_OVERRIDE
116  {
117  world->integrateTransformsInternal( &rigidBodies[ iBegin ], iEnd - iBegin, timeStep );
118  }
119  };
120  virtual void integrateTransforms( btScalar timeStep ) BT_OVERRIDE;
121 
122 public:
124 
126  btBroadphaseInterface* pairCache,
127  btConstraintSolverPoolMt* constraintSolver, // Note this should be a solver-pool for multi-threading
128  btConstraintSolver* constraintSolverMt, // single multi-threaded solver for large islands (or NULL)
129  btCollisionConfiguration* collisionConfiguration
130  );
131  virtual ~btDiscreteDynamicsWorldMt();
132 
133  virtual int stepSimulation( btScalar timeStep, int maxSubSteps, btScalar fixedTimeStep ) BT_OVERRIDE;
134 };
135 
136 #endif //BT_DISCRETE_DYNAMICS_WORLD_H
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
btPersistentManifold is a contact point cache, it stays persistent as long as objects are overlapping...
btConstraintSolverPoolMt - masquerades as a constraint solver, but really it is a threadsafe pool of ...
The btAlignedObjectArray template class uses a subset of the stl::vector interface for its methods It...
btConstraintSolverType
btConstraintSolver provides solver interface
void integrateTransformsInternal(btRigidBody **bodies, int numBodies, btScalar timeStep)
btDiscreteDynamicsWorld provides discrete rigid body simulation those classes replace the obsolete Cc...
btCollisionConfiguration allows to configure Bullet collision detection stack allocator size...
void forLoop(int iBegin, int iEnd) const BT_OVERRIDE
btSpinMutex – lightweight spin-mutex implemented with atomic ops, never puts a thread to sleep becau...
Definition: btThreads.h:47
void init(btConstraintSolver **solvers, int numSolvers)
virtual void reset() BT_OVERRIDE
clear internal cached data and reset random seed
btConstraintSolver * m_constraintSolverMt
#define BT_OVERRIDE
Definition: btThreads.h:28
ThreadSolver * getAndLockThreadSolver()
btConstraintSolverPoolMt
btCollisionObject can be used to manage collision detection objects.
The btIDebugDraw interface class allows hooking up a debug renderer to visually debug simulations...
Definition: btIDebugDraw.h:29
The btRigidBody is the main class for rigid body objects.
Definition: btRigidBody.h:62
The btBroadphaseInterface class provides an interface to detect aabb-overlapping object pairs...
#define ATTRIBUTE_ALIGNED16(a)
Definition: btScalar.h:82
btDiscreteDynamicsWorldMt – a version of DiscreteDynamicsWorld with some minor changes to support so...
btAlignedObjectArray< ThreadSolver > m_solvers
TypedConstraint is the baseclass for Bullet constraints and vehicles.
#define BT_DECLARE_ALIGNED_ALLOCATOR()
Definition: btScalar.h:403
btConstraintSolverType m_solverType
void createPredictiveContactsInternal(btRigidBody **bodies, int numBodies, btScalar timeStep)
The btDispatcher interface class can be used in combination with broadphase to dispatch calculations ...
Definition: btDispatcher.h:77
float btScalar
The btScalar type abstracts floating point numbers, to easily switch between double and single floati...
Definition: btScalar.h:292
char _cachelinePadding[kCacheLineSize-sizeof(btSpinMutex)-sizeof(void *)]
virtual btConstraintSolverType getSolverType() const BT_OVERRIDE