It looks like you got inspired by Dennis Gustafsson
? https://twitter.com/tuxedolabs/status/1 ... 4001363968
>> I see that collision detection is also done in parallel. Nice!
Yes apparently, it was a contribution, but the default broadphase/collision dispatcher in Bullet is single threaded.
For multi-threading you need to compile using BT_ENABLE_THREADSAFE
and use btCollisionDispatcherMt and btDiscreteDynamicsWorldMt.
Note that the convex collision detection uses GJK and for deep penetrations EPA.
Ideally you don't get too much in deep penetration.
If you want large scale destruction and lots of convex-convex, you likely need to spend more work on optimizations,
I know Dennis spend a lot of time on it, and so did Pierre Terdiman and crew for PhysX (using SAT and also GJK with persistent manifold nowadays).
Reducing the number of vertices may help. You could try using 'convexShape->optimizeConvexHull' but that call itself is expensive, so it may not be worth it.
Aside from GJK+EPA or SAT, you can also consider using MPR, but I find it less robust (incorrect penetration/normals).
MPR is implemented in the voronoi demo. To enable it, use this code snippet:
Code: Select all
//at the top of your file
m_dispatcher = new MyCollisionDispatcher(m_collisionConfiguration, 40);
//somewhere after you create a collision dispatcher
printf("using GJK+MPR convex-convex collision detection\n");
btConvexConvexMprAlgorithm::CreateFunc* cf = new btConvexConvexMprAlgorithm::CreateFunc;
m_dispatcher->registerCollisionCreateFunc(CONVEX_HULL_SHAPE_PROXYTYPE, CONVEX_HULL_SHAPE_PROXYTYPE, cf);
m_dispatcher->registerCollisionCreateFunc(CONVEX_HULL_SHAPE_PROXYTYPE, BOX_SHAPE_PROXYTYPE, cf);
m_dispatcher->registerCollisionCreateFunc(BOX_SHAPE_PROXYTYPE, CONVEX_HULL_SHAPE_PROXYTYPE, cf);
If you are OK with that (lower) quality, the code is likely easier to optimize.
Also, be careful with 'initializePolyhedralFeatures', it is mainly for when you use SAT, and it changes the way margins work (since margins don't affect SAT etc).