Disappointed with Bullet physics simulation speed...

Post Reply
johnsonalpha
Posts: 73
Joined: Fri May 01, 2015 8:23 pm

Disappointed with Bullet physics simulation speed...

Post by johnsonalpha »

Im running a basic bullet physics simulation what can i do to speed up the simulation?

i have about 400 boxes and im trying to speed it up
Basroil
Posts: 463
Joined: Fri Nov 30, 2012 4:50 am

Re: Disappointed with Bullet physics simulation speed...

Post by Basroil »

400 boxes should be easy enough in most cases, but here's a few tips:
1) Let the boxes go to sleep if they aren't moving, sleeping objects have negligible overhead
2) Use simple primitives instead of convex hulls when possible
3) Try a different broadphase collision method
4) If all else fails there's a partially multithreaded fork of bullet that uses TBB to offload collision checks (usually a big part of the overhead) and allows islands to be calculated on separate threads
johnsonalpha
Posts: 73
Joined: Fri May 01, 2015 8:23 pm

Re: Disappointed with Bullet physics simulation speed...

Post by johnsonalpha »

Basroil wrote:400 boxes should be easy enough in most cases, but here's a few tips:
1) Let the boxes go to sleep if they aren't moving, sleeping objects have negligible overhead
2) Use simple primitives instead of convex hulls when possible
3) Try a different broadphase collision method
4) If all else fails there's a partially multithreaded fork of bullet that uses TBB to offload collision checks (usually a big part of the overhead) and allows islands to be calculated on separate threads
How would i control the sleep threshold?

Ive tried using btsweep3 collision dispacher and dbvt dispatcher i don't see a diffrence in framerate is there anything else i can try ive seen other people simulate 400 boxes almost in realtime.
Basroil
Posts: 463
Joined: Fri Nov 30, 2012 4:50 am

Re: Disappointed with Bullet physics simulation speed...

Post by Basroil »

Here's a few questions you'll need to answer in order to know what's the issue?

Are you running Bullet in a debug mode/environment? (if so that's probably 99% of your issue)
Have you tried profiling the system in order to get a better estimate of what's taking so long?
Are you stacking 400 objects in mostly random orientations? (you could have over few thousand constraints in some cases)
johnsonalpha
Posts: 73
Joined: Fri May 01, 2015 8:23 pm

Re: Disappointed with Bullet physics simulation speed...

Post by johnsonalpha »

Im running in a release build and i no its just 400 boxes with box collision shapes no constraints just a plain dynamicsworld with 400 boxes
anthrax11
Posts: 72
Joined: Wed Feb 24, 2010 9:49 pm

Re: Disappointed with Bullet physics simulation speed...

Post by anthrax11 »

Are the boxes tightly stacked like in the basic demo?
If so, consider that all adjacent boxes have collisions that need to be processed.
If you split the boxes into smaller stacks or groups and leave some distance between them, you'll have much better performance.
Also think about what is a typical scenario in a computer game. You might have 400 objects in a scene, but not all stacked together. If you use any other physics engine designed for real-time simulations, you'll probably get similar results.
User avatar
drleviathan
Posts: 849
Joined: Tue Sep 30, 2014 6:03 pm
Location: San Francisco

Re: Disappointed with Bullet physics simulation speed...

Post by drleviathan »

I'm wondering: are you sharing the box shape? When multiple boxes have the same dimensions you can make one btBoxShape instance and give that to each RigidBody that needs it -- this should help things run a little faster (less cache misses), but I don't know by how much since I haven't experimented.
User avatar
Erwin Coumans
Site Admin
Posts: 4221
Joined: Sun Jun 26, 2005 6:43 pm
Location: California, USA
Contact:

Re: Disappointed with Bullet physics simulation speed...

Post by Erwin Coumans »

Can you use the Bullet 2.83 example browser and view the profiler and share the timings (see 'View'/'Profiler')
That gives an indication where performance is going.

Are there triangle meshes involved at all? What is the simulation timestep and the number of substeps (in other words, what are your arguments to 'world->stepSimulation(...)'?
johnsonalpha
Posts: 73
Joined: Fri May 01, 2015 8:23 pm

Re: Disappointed with Bullet physics simulation speed...

Post by johnsonalpha »

Erwin Coumans wrote:Can you use the Bullet 2.83 example browser and view the profiler and share the timings (see 'View'/'Profiler')
That gives an indication where performance is going.

Are there triangle meshes involved at all? What is the simulation timestep and the number of substeps (in other words, what are your arguments to 'world->stepSimulation(...)'?

Nope thats what puzzling me its a groundplane and 400 boxs with box collision hulls im gettting 10 fps in the bullet 2.83 example browser i do 3000 boxes at 15 fps is bullet 2.83 faster?

heres how im doing the timestep

Code: Select all

int startframe = 0;
int endframe = 0;
int maxSubsteps = 1;

btScalar fixedTimeStep = btScalar(0) / btScalar(60);

for (int i = startframe; i<endframe; i++)
	{
		dynamicsWorld->stepSimulation(fixedTimeStep, maxSubsteps);
        }
xexuxjy
Posts: 225
Joined: Wed Jan 07, 2009 11:43 am
Location: London

Re: Disappointed with Bullet physics simulation speed...

Post by xexuxjy »

May be a dumb question, but you're not doing any console output anywhere are you?
Post Reply