Page 1 of 1

[solved] scale world 100x -> performance increase 3x

Posted: Thu Sep 07, 2017 11:34 am
by hyyou
It is surprising that just scale every thing make so much difference in performance. :shock:

First Experiment
I created a scene with 1,000 cubes.
Cube's size = 0.01f
They scattered around a plane size = 5*5 (w*h)
I got 20fps.
The profile result states that Bullet Physics is the bottleneck.

Second Experiment
1,000 cubes
size = 1.0f
They scattered around a plane size = 500*500
I got >> 60fps.

The cause (my guess)
It must be Bullet's boardphase aabb culling.
In the first experiment, many cubes probably fall into the same slot of boardphase's grid.

Question
Are there any way to guide Bullet's boardphase about my world scale?

I have read :-
boardphase : http://www.bulletphysics.org/mediawiki- ... Broadphase
btDbvtBroadphase : http://www.bulletphysics.org/mediawiki- ... _aabb_tree
scale the world (unrelated) : http://www.bulletphysics.org/mediawiki- ... _The_World

Edit: No one answer.
I doubt that I didn't do research enough / my question is unclear, too easy, not interesting /
or no one know the answer? :(

Edit2: I am very satisfied with drleviathan's answer, so I marked it as solved for now. Thank!

Re: scale the world up 100x -> performance increase 3x

Posted: Fri Sep 15, 2017 9:37 pm
by drleviathan
My guess is that the "collision margin" feature on the shapes expands their bounding box. If you aren't setting the collision margin manually then you're using the default margin (which is 0.04m!). Meanwhile, it appears that the broadphase data structure also has a hard coded default margin (look for DBVT_BP_MARGIN in the codebase -- I assume you're using the btDbvtBroadphase class) which is 0.05m. In short, the aabb of each object is larger than you think, and in the tiny-case it is relatively much larger than the large-case. More overlaps means more narrowphase evaluations means more CPU costs.

Re: scale the world up 100x -> performance increase 3x

Posted: Sat Sep 16, 2017 2:01 am
by hyyou
Thank drleviathan. This is a very reasonable guess.

Re: [solved] scale world 100x -> performance increase 3x

Posted: Mon Sep 18, 2017 8:30 pm
by cameron
IIRC, there is also a contact processing threshold that further expands the bounding boxes by a small amount