I recently picked up Bullet and I'm working to implement it in my small game engine. However there is a thing that bugs me - assuming we have a tower of N stacked boxes (btBoxShape) ideally one above another, shouldn't they be stable no matter what are their masses and number of them?
Usually in my case the bottom boxes slide underneath the tower and the rest of the boxes soon follows.
Tower of stacked boxes?
-
Erwin Coumans
- Site Admin
- Posts: 4221
- Joined: Sun Jun 26, 2005 6:43 pm
- Location: California, USA
Re: Tower of stacked boxes?
There are limitations in Bullet, just like in most other physics engines (although the limitations are different for each SDK).
Stacks of more than 15 to 20 tend to collapse after a while, unless the sleeping/deactivation kicks in.
This is not a simple topic: there are many settings that can influence simulation stability. Object size (keep them around 1 unit/meter), gravity, friction, mass ratios should be kept small etc etc.
Welcome to the world of game physics
Thanks,
Erwin
Stacks of more than 15 to 20 tend to collapse after a while, unless the sleeping/deactivation kicks in.
This is not a simple topic: there are many settings that can influence simulation stability. Object size (keep them around 1 unit/meter), gravity, friction, mass ratios should be kept small etc etc.
Welcome to the world of game physics
Thanks,
Erwin
-
Calder
- Posts: 11
- Joined: Fri May 15, 2009 10:01 pm
Re: Tower of stacked boxes?
Think of it as wind! 
-
RBD
- Posts: 141
- Joined: Tue Sep 16, 2008 11:31 am
Re: Tower of stacked boxes?
Taking into account some of the factors Erwin mentions (size, gravity, friction, mass, etc.), and of course depending on the height of your stack, try increasing your sim steps. Of course, with games, the budget for sim steps is limited, but try to do as many as you can afford for stable stacking.
I've been messing around with Kapla style plank stacks. I just tried a large stack of btBoxShapes (over 5200 actually) and was amazed at how the Bullet Physics simulated stack was rock steady. For reference, my btBoxShapes (Kapla planks) sizes are all 7.5 x 0.5 x 1.5 with a mass of 1. Spheres have a radius of 2 with a mass of 20 (really tried to make an impact on that solid stack). timeStep = 1/24, fixedTimeStep = 1/240, maxSubSteps = 10. It's not real-time with that many rigid bodies, but I was still getting around 1fps actual (includes UI overhead)... Oh... and deactivation was turned off (to avoid strange results)!
If interested, check out the rendered result of my "little" stack test:
I've been messing around with Kapla style plank stacks. I just tried a large stack of btBoxShapes (over 5200 actually) and was amazed at how the Bullet Physics simulated stack was rock steady. For reference, my btBoxShapes (Kapla planks) sizes are all 7.5 x 0.5 x 1.5 with a mass of 1. Spheres have a radius of 2 with a mass of 20 (really tried to make an impact on that solid stack). timeStep = 1/24, fixedTimeStep = 1/240, maxSubSteps = 10. It's not real-time with that many rigid bodies, but I was still getting around 1fps actual (includes UI overhead)... Oh... and deactivation was turned off (to avoid strange results)!
If interested, check out the rendered result of my "little" stack test:
-
SatelliteBiker
- Posts: 7
- Joined: Wed Jan 20, 2010 2:30 pm
Re: Tower of stacked boxes?
Pardon my revival of a slightly dated topic. The latest prototype I've been working on in Bullet was a tower of Kapla planks, and I found your videos on youtube. Those are some fantastic demos, RBD!
My first attempt was to use units==meters, and actual Kapla plank dimensions, just to see how Bullet handled it. These raw dimensions, such as 8mm (0.008) made for entirely unstable towers. I've scaled the numbers by 10, and the stability greatly increased, so I'll try much larger values as you mention.
The questions I have for you RBD, are:
(a) Did you render each frame directly from your program, or serialize and render it "offline"? If offline, what tools did you use?
(b) Are your buildings constructed at once, or do you add planks incrementally, letting Bullet settle after each addition? I've found that if I add a stack of boxes or planks at once, there is an initial sinking of the objects, followed by a bounce. Sometimes this unsettles the structure, and sometimes not. My most recent code has a Generator that tracks where in the construction it is, and adds one piece at a time (every few sim steps). This seems more stable.
My first attempt was to use units==meters, and actual Kapla plank dimensions, just to see how Bullet handled it. These raw dimensions, such as 8mm (0.008) made for entirely unstable towers. I've scaled the numbers by 10, and the stability greatly increased, so I'll try much larger values as you mention.
The questions I have for you RBD, are:
(a) Did you render each frame directly from your program, or serialize and render it "offline"? If offline, what tools did you use?
(b) Are your buildings constructed at once, or do you add planks incrementally, letting Bullet settle after each addition? I've found that if I add a stack of boxes or planks at once, there is an initial sinking of the objects, followed by a bounce. Sometimes this unsettles the structure, and sometimes not. My most recent code has a Generator that tracks where in the construction it is, and adds one piece at a time (every few sim steps). This seems more stable.
-
SatelliteBiker
- Posts: 7
- Joined: Wed Jan 20, 2010 2:30 pm
Re: Tower of stacked boxes?
I found that scaling the dimensions up helps considerably with stacking stability, and adjusting masses while keeping the same proportions helps also.
Here's a video from a demo program that shows stacking a 60-story tower, and destroys it in various ways. This test program uses OpenGL, a 100 HZ simulation step, a 25 FPS rendering, and it writes out PNG files which are later converted to MP4. Each plank has a mass of 1, small balls have mass 5, and the big balls have mass of 200.
YouTube: Plank Tower Sim.
Enjoy.
Here's a video from a demo program that shows stacking a 60-story tower, and destroys it in various ways. This test program uses OpenGL, a 100 HZ simulation step, a 25 FPS rendering, and it writes out PNG files which are later converted to MP4. Each plank has a mass of 1, small balls have mass 5, and the big balls have mass of 200.
YouTube: Plank Tower Sim.
Enjoy.