How to optimize the Broadphase

Marc
Posts: 6
Joined: Wed Jul 15, 2009 11:39 pm

How to optimize the Broadphase

Post by Marc »

Hi !

I have a scene consisting of a heightfield, some static obstacles which are simple shapes like box and capsules and rigid bodies that are non static. The heightfield is 1024(+1)^2, there are about 1500 obstacles. the rigid bodies can appear and disappear later on.

I noticed, with an increase in the number of rigid bodies, the simulation gets drastically slower - even if those rigid bodies are shatterend over the heightfield and are at rest. A number of 100 is already making it slower than real time on my pc, while there are 1500 static obstacles. I profiled it and found out that most of the time is spent in "insertleaf" (belongs to btDbvt somehow), btDbvt::collideTV < struct btDbvtTreeCollider >, and bt HashedOverlappingPairCache::internalAddPair(). So I was wondering is there something to tune the broadphase for this setup? Even if everything is at rest, it's slow. My current initialization looks like this:

m_collisionConfiguration = new btDefaultCollisionConfiguration();
m_dispatcher = new btCollisionDispatcher(m_collisionConfiguration);
m_broadphase = new btDbvtBroadphase();
btSequentialImpulseConstraintSolver* sol = new btSequentialImpulseConstraintSolver;
m_solver = sol;
m_dynamicsWorld = new btDiscreteDynamicsWorld(m_dispatcher,m_broadphase,m_solver,m_collisionConfiguration);

As you can see, I didn't modify any parameters. Is there something I could adjust?