In btDbvtBroadphase, why is deferred collide not on by default?

Post Reply
niad
Posts: 7
Joined: Sun Mar 11, 2018 9:34 am

In btDbvtBroadphase, why is deferred collide not on by default?

Post by niad »

Recently I was pushing bullets btDbvtBroadphase more than I normally do, in particular I was using it to drive a particle system.

It would spawn a few thousands small dynamics near each other, they would only live a few seconds, then die, and more would be constantly spawning in.

btDbvtBroadphase started to become a significant bottleneck, specifically setAabb, which is called for anything that is active during each physics step.

setAabb cumulatively would take upwards of 5-7 ms, mostly spent in collideTTpersistentStack.

I noticed the btDbvtBroadphase ::m_deferedcollide variable that was set to false, when it is false, is performs immediate collides for whatever node was reinserted, this seems to generate lots of needless work--

By changing it to true, the collideTTpersistentStack calls are now deferred until btDbvtBroadphase::collide() is invoked.
And instead of performing the collide tests over and over, it compares the static and dynamic trees against each other once.

This dropped broadphase time significant, the total time for setAabb + collide is generally around 1.5 ms now(most of it spend in btDbvt::update which removes and re-adds the leafs)

Is there a reason deferred is not the default ?
Well I might create a pull request and see if Erwin rejects--
Badytheprogram
Posts: 9
Joined: Mon Dec 31, 2018 1:00 am

Re: In btDbvtBroadphase, why is deferred collide not on by default?

Post by Badytheprogram »

Hi.
Maybe not the straigthest solution for your problem, but maybe help:
A common solution for this in game programming, to reuse obejcts. Of course it's expensive to create objects, but if you once created, you can hide/show, reposition objects wery fast.
When an object reached it's destinaion and ready to destroy, I recommend you to hide it,reset to the start condition, repositioning to a position where you want to create a new one, instead to delete and recreate it several times. (You said it's a particle system, so they are probaly look the same)

Even the biggest game company use this method, to save resources.

I hope it help.
niad
Posts: 7
Joined: Sun Mar 11, 2018 9:34 am

Re: In btDbvtBroadphase, why is deferred collide not on by default?

Post by niad »

Erwin responded on github-- I guess Bullet has some policy of never changing defaults

I guess that is why this is off --

Also why m_forceUpdateAllAabbs is enabled by default


Badytheprogram : while that will help other unrelated computations, it won't have much effect on bullets broadphase(inserting a new body vs teleportation is basically the same cost).

I think bullet needs a up to date FAQ or something-- I've been searching and I can't even figure out what Bullet3 is exactly, or if it is dead?
Is bullet 2.8__ just in maintenance mode now?
Post Reply