Disappointed with Bullet physics simulation speed...
-
- Posts: 73
- Joined: Fri May 01, 2015 8:23 pm
Disappointed with Bullet physics simulation speed...
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
i have about 400 boxes and im trying to speed it up
Re: Disappointed with Bullet physics simulation speed...
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
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
-
- Posts: 73
- Joined: Fri May 01, 2015 8:23 pm
Re: Disappointed with Bullet physics simulation speed...
How would i control the sleep threshold?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
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.
Re: Disappointed with Bullet physics simulation speed...
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)
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)
-
- Posts: 73
- Joined: Fri May 01, 2015 8:23 pm
Re: Disappointed with Bullet physics simulation speed...
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
Re: Disappointed with Bullet physics simulation speed...
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.
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.
- drleviathan
- Posts: 849
- Joined: Tue Sep 30, 2014 6:03 pm
- Location: San Francisco
Re: Disappointed with Bullet physics simulation speed...
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.
- 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...
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(...)'?
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(...)'?
-
- Posts: 73
- Joined: Fri May 01, 2015 8:23 pm
Re: Disappointed with Bullet physics simulation speed...
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);
}
Re: Disappointed with Bullet physics simulation speed...
May be a dumb question, but you're not doing any console output anywhere are you?