-
Notifications
You must be signed in to change notification settings - Fork 2.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
MultiThreading for Bullet 2.x #847
Conversation
- 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
I've tested this on Windows 7 with Cmake/Visual Studio 2013. I also used a virtual machine with Ubuntu 16 32-bit to test it with Cmake/GCC. I didn't add the threading options to premake but I tried to keep from breaking premake. I added GUI buttons to the example browser so that for those demos that call CommonRigidBodyBase::createEmptyPhysicsWorld() a button appears which allows switching to a multi-threaded physics world (requires re-double-clicking on the demo). |
thanks a lot for updating this, I'll review it soon and either merge the pull request or get back to you . Thanks! |
I'll accept the pull request but will reorganize some files afterwards: the 'CommonInterfaces' should just have header files, and I'll move some of the new classes out of that. |
Moved the CommonRigidBodyBase.cpp out of interfaces into MultiThreadedDemo/CommonRigidBodyBaseMT.cpp: |
I ran into another issue, BulletCollision is not allowed to depend in any way on BulletDynamics, this is violated in btSimulationIslandManagerMt.cpp: |
How about moving it into BulletDynamics? On Thursday, November 10, 2016, erwincoumans notifications@github.com
|
Yes, I move it to BulletDynamics/Dynamics |
Yes that looks like a bug. I thought I had put something in to handle the removal case, but evidently I forgot. I can make a PR to fix that. |
There is already a unique Id in each object through its broadphase handle. Given a btCollisionObject, you can access this UID using colObj->getBroadphaseHandle()->m_uniqueId; |
Actually the broadphase handle unique id is an always increasing value which is not quite what I need. What I need is the index of the body in the world's collisionObjects array (i.e. an id that is unique for each object existing at the current moment, but no larger than necessary). |
See PR #860 |
Apparently this pull request broke friction on kinematic animated objects, see #893 |
(an updated version of #390)
crashing (null pointer returned)
(default is un-threadsafe)
before calling allocate(), instead it just calls allocate() and
checks if the return is null -- this avoids a race condition
getOrInitSolverBody() to avoid a race condition with kinematic bodies
in parallel:
OpenMP, Microsoft PPL, and Intel TBB