Page 1 of 1

Non-SPU multithreaded collision detection

Posted: Thu May 24, 2012 1:28 pm
by alex-weej
Has anyone any experiences/code to share in hacking Bullet to do multithreaded collision detection? I remember reading somewhere that at least one group of people had hacked their own dispatcher together.

(The SPU code gives quite different results to the normal dispatcher particularly when dealing with compounds - GJK seems to be used over box-box, for example.)

Currently naively hacking at btOverlappingPairCache.cpp to make it run the callbacks via a pool of pthreads, but quickly finding that this is not a straightforward exercise not least due to the thread unsafeness of Bullet's memory allocator functions.

Anyone have any tips? We're using 2.79 as a base for our engine. I hear 3.x will have a new threading implementation, but we'd like to hack something simple together for 2.x if possible.

Thanks

Alex

Re: Non-SPU multithreaded collision detection

Posted: Fri May 25, 2012 9:34 am
by Yann
Got exactly the same needs, but not enough time to work on it for now...
Would be happy to hear about if you find something interesting ;)

Re: Non-SPU multithreaded collision detection

Posted: Sat May 26, 2012 6:18 pm
by Erwin Coumans
I'll get to that hopefully soon.

There is an older branch that refactors the BUllet collision detection so it is easier to make it multi-threaded.

See
http://code.google.com/p/bullet/source/ ... Allocation

There are two main issues that prevent multi-threaded regular collision algorithm execution:
1) contact manifold allocation. This can be relatively easily fixed in the contact allocation.
2) temporary modification of collision shapes, while processing collision algorithms (such as btCompoundShape). This is fixed by that StackAllocation branch.

Thanks,
Erwin

Re: Non-SPU multithreaded collision detection

Posted: Mon May 28, 2012 2:39 pm
by alex-weej
Thanks Erwin, good to hear I was on the right track! Am currently hacking the Compound collision algo but will check out this branch.

Cheers

Re: Non-SPU multithreaded collision detection

Posted: Thu May 31, 2012 8:02 am
by Erwin Coumans
I started working on this, in a work-in-progress branch here:
https://www.assembla.com/code/bullet3/subversion/nodes

assembla is basically the latest Bullet trunk from GoogleCode with a new contribution from Apple (SIMD for x86 and iOS) and passing a btCollisionObjectWrapper around instead of modifying the collision objects/shapes. Note that it is not fully finished yet, collision filtering and softbody versus concave is broken (and possibly other things).
Once the work in this repository is stable, I commit it to Bullet trunk in GoogleCode.

Thanks,
Erwin