Page 1 of 1

btDbvtBroadphase::performDiscreteCollisionDetection() perf?

Posted: Tue Jul 22, 2008 10:57 pm
by reltham
My game has around 1200 static collision object in it, and no dynamic objects (we currently use only ray and convex sweep tests). It's just the static world (ground, rocks, trees, etc.).

If I call performDiscreteCollisionDetection() while using btDbvtBroadphase, it consumes between 2 and 3 ms. This seems rather high considering all of my objects are static and I have the Filters and Masks set so they don't collide with eachother.

Is there something I am missing?

Re: btDbvtBroadphase::performDiscreteCollisionDetection() perf?

Posted: Wed Jul 23, 2008 12:53 am
by Nathanael
Can you provide a reproduction case ?

Thanks for the feedback,
Nathanael.

Re: btDbvtBroadphase::performDiscreteCollisionDetection() perf?

Posted: Wed Jul 23, 2008 1:14 am
by reltham
Not easily. This is a commercial project.

It's an area with ground broken up into tiles, and a bunch of objects sitting on the ground (rocks, trees, houses, etc.)

I'm using just btCollisionWorld (no dynamics).
The total count of collision objects in the system is around 1200.
They are all flagged as static (the filters/masks setup as Erwin suggested in an other thread).
There should be no collision pairs at all.

I was mainly just asking if there is something I missed in setting up btDbvtBroadphase. Perhaps something related to static objects?

Re: btDbvtBroadphase::performDiscreteCollisionDetection() perf?

Posted: Wed Jul 23, 2008 2:21 am
by Nathanael
Ok, here's a quick work around, if after your objects creation you call myrigidbody->setActivationState(ISLAND_SLEEPING); that should fix the issue.

In the upcoming version (2.70), btDbvtBroadphase is optimized for your use case, and add the following method: bDbvttBroadphase::optimize() to be called after world creation to ensure fast queries right away (and not over time like now).

I attached (
btDbvtBroadphase2.70.zip
) an uncommitted version of btDbvtBroadphase if you cannot wait for 2.70, but make sure you build against the latest svn version.
If you can't, give me the svn version you build against, and I'll try to give you a quick patch.

In CDTestframework, btDbvtBroaphase do ~0.3 ms for 8192 static objects, versus ~2ms for btAxisSweep3 (SAP), so btDbvtBroadphase should actually be faster than SAP in your case.

Hope it help,
Nathanael.

Re: btDbvtBroadphase::performDiscreteCollisionDetection() perf?

Posted: Wed Jul 23, 2008 6:57 pm
by reltham
Okay!

I first tried just using your updated files with no changes to my code and it didn't have any effect, it was still 2-3ms per frame (I did wait quite a while after starting to allow for settling if any).

However, when I added a call to btCollisionObject->setActivationState(ISLAND_SLEEPING) it worked. The timing was down to 0.1 to 0.2 ms per frame.

Just to clarify, I am not using btDynamicsWorld at all, and don't have rigidbody objects. I am just using btCollisionWorld with btCollisionObjects. Perhaps the activation state is not updated in this case?

Thank you for your help,
Roy Eltham
Senior Programmer
SOE Free Realms

Re: btDbvtBroadphase::performDiscreteCollisionDetection() perf?

Posted: Thu Jul 24, 2008 2:47 am
by Nathanael
Humm, if you have time, can you post timings of btDbvtBroadphase and btSweepAxis ? and if possible a more detailed profiling output, i'd like to get to the bottom of this.
Did you called btDbvtBroadphase optimize after your static world creation?

Nathanael.

btw, FreeRealms like very nice.