MultiThreaded Demo:
- fixing various race conditions throughout (usage of static vars, etc)
- addition of a few lightweight mutexes (which are compiled out by default)
- slight code rearrangement in discreteDynamicsWorld to facilitate multithreading
- PoolAllocator::allocate() can now be called when pool is full without
crashing (null pointer returned)
- PoolAllocator allocate and freeMemory, are OPTIONALLY threadsafe
(default is un-threadsafe)
- CollisionDispatcher no longer checks if the pool allocator is full
before calling allocate(), instead it just calls allocate() and
checks if the return is null -- this avoids a race condition
- SequentialImpulseConstraintSolver OPTIONALLY uses different logic in
getOrInitSolverBody() to avoid a race condition with kinematic bodies
- addition of 2 classes which together allow simulation islands to be run
in parallel:
- btSimulationIslandManagerMt
- btDiscreteDynamicsWorldMt
- MultiThreadedDemo example in the example browser demonstrating use of
OpenMP, Microsoft PPL, and Intel TBB
- use multithreading for other demos
- benchmark demo: add parallel raycasting
This commit is contained in:
@@ -21,6 +21,8 @@ struct CommonRigidBodyBase : public CommonExampleInterface
|
||||
btConstraintSolver* m_solver;
|
||||
btDefaultCollisionConfiguration* m_collisionConfiguration;
|
||||
btDiscreteDynamicsWorld* m_dynamicsWorld;
|
||||
bool m_multithreadedWorld;
|
||||
bool m_multithreadCapable;
|
||||
|
||||
//data for picking objects
|
||||
class btRigidBody* m_pickedBody;
|
||||
@@ -31,20 +33,8 @@ struct CommonRigidBodyBase : public CommonExampleInterface
|
||||
btScalar m_oldPickingDist;
|
||||
struct GUIHelperInterface* m_guiHelper;
|
||||
|
||||
CommonRigidBodyBase(struct GUIHelperInterface* helper)
|
||||
:m_broadphase(0),
|
||||
m_dispatcher(0),
|
||||
m_solver(0),
|
||||
m_collisionConfiguration(0),
|
||||
m_dynamicsWorld(0),
|
||||
m_pickedBody(0),
|
||||
m_pickedConstraint(0),
|
||||
m_guiHelper(helper)
|
||||
{
|
||||
}
|
||||
virtual ~CommonRigidBodyBase()
|
||||
{
|
||||
}
|
||||
CommonRigidBodyBase(struct GUIHelperInterface* helper);
|
||||
virtual ~CommonRigidBodyBase();
|
||||
|
||||
|
||||
btDiscreteDynamicsWorld* getDynamicsWorld()
|
||||
@@ -52,26 +42,8 @@ struct CommonRigidBodyBase : public CommonExampleInterface
|
||||
return m_dynamicsWorld;
|
||||
}
|
||||
|
||||
virtual void createEmptyDynamicsWorld()
|
||||
{
|
||||
///collision configuration contains default setup for memory, collision setup
|
||||
m_collisionConfiguration = new btDefaultCollisionConfiguration();
|
||||
//m_collisionConfiguration->setConvexConvexMultipointIterations();
|
||||
|
||||
///use the default collision dispatcher. For parallel processing you can use a diffent dispatcher (see Extras/BulletMultiThreaded)
|
||||
m_dispatcher = new btCollisionDispatcher(m_collisionConfiguration);
|
||||
|
||||
m_broadphase = new btDbvtBroadphase();
|
||||
|
||||
///the default constraint solver. For parallel processing you can use a different solver (see Extras/BulletMultiThreaded)
|
||||
btSequentialImpulseConstraintSolver* sol = new btSequentialImpulseConstraintSolver;
|
||||
m_solver = sol;
|
||||
|
||||
m_dynamicsWorld = new btDiscreteDynamicsWorld(m_dispatcher, m_broadphase, m_solver, m_collisionConfiguration);
|
||||
|
||||
m_dynamicsWorld->setGravity(btVector3(0, -10, 0));
|
||||
}
|
||||
|
||||
virtual void createDefaultParameters();
|
||||
virtual void createEmptyDynamicsWorld();
|
||||
|
||||
virtual void stepSimulation(float deltaTime)
|
||||
{
|
||||
@@ -81,14 +53,7 @@ struct CommonRigidBodyBase : public CommonExampleInterface
|
||||
}
|
||||
}
|
||||
|
||||
virtual void physicsDebugDraw(int debugFlags)
|
||||
{
|
||||
if (m_dynamicsWorld && m_dynamicsWorld->getDebugDrawer())
|
||||
{
|
||||
m_dynamicsWorld->getDebugDrawer()->setDebugMode(debugFlags);
|
||||
m_dynamicsWorld->debugDrawWorld();
|
||||
}
|
||||
}
|
||||
virtual void physicsDebugDraw(int debugFlags);
|
||||
|
||||
virtual void exitPhysics()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user