100m drop at 9.81m/s: tunneling through btHeightfieldTerrain

Post Reply
whisp
Posts: 5
Joined: Sun Apr 01, 2012 5:17 pm

100m drop at 9.81m/s: tunneling through btHeightfieldTerrain

Post by whisp »

I let a couple of cylinders drop from 100m at 9.81m/s, and more than 50% tunnel through a btHeightfieldTerrainField.

The cylinders have a diameter of 20cm and a height of 80cm, so they're not specially small.

Also parts of the cylinders stick in the terrain (and sometimes get unstuck after a while). And at some point the program crashes. The more cylinders, the sooner it crashes. (console: bad_memory allocation)

Earlier i didn't notice this problem when my world (and the cylinders) were 10 times larger, yet it looked unrealistic, so i scaled it down to bullet recommendation (1.0 x/y/z = 1m) - that's when the above mentioned problems occured.

I played with the step-simulation which helped a bit, but (beside using more processing power) the crashes also occured more often.

I've also set CcdMotionThreshold and CcdSweptSphereRadius as decribed in the wiki:

body->setCcdMotionThreshold(1)
and
body->setCcdSweptSphereRadius(0.2f)

But it didn't solve the tunneling problem.

Any hints?

Thank you!

whisp
CookieMonster
Posts: 49
Joined: Sun Jan 29, 2012 10:01 pm

Re: 100m drop at 9.81m/s: tunneling through btHeightfieldTer

Post by CookieMonster »

When bullet crashed for me, I was not aligning the memory allocations because I wanted static memory.
Mako_energy02
Posts: 171
Joined: Sun Jan 17, 2010 4:47 am

Re: 100m drop at 9.81m/s: tunneling through btHeightfieldTer

Post by Mako_energy02 »

When you are using objects that are <1m in size, you really have to increase the simulation resolution. By that I mean you have to change the FixedTimeStep you are passing into StepSimulation to at least 1/120(I'm assuming you currently are passing in 1/60). You wouldn't think that your objects are too small for bullet to handle that, but they are. I ran into the same problem with my project.

As for the bad memory allocation errors, I have no idea what could be causing that without more data. :(
whisp
Posts: 5
Joined: Sun Apr 01, 2012 5:17 pm

Re: 100m drop at 9.81m/s: tunneling through btHeightfieldTer

Post by whisp »

Thanks for your answers.

I'm already running the stepsimulation at fixedstep of 1/120. With 1/60 almost all cylinders tunnel. Yet the cylindes are just for testing purposes, so if tunneling at this size is usual it probably won't be much of a problem - for the moment i plannet to use bullet for collision only anyways, i just wanted to test a bit.

I've found out that the crash happens due to fast raising memory usage. With 100 rygid bodies, stepped, it takes only a few seconds from 100mb to 500mb memory usage when it crashes. The only communication between bullet and my graphicsengine is via motion state setworldtransform and there's everything fine. So i guess there's something wrong in the compiled bullet version i'm using. I will download the latest version, compile it and try again.
User avatar
jarno
Posts: 57
Joined: Tue Mar 16, 2010 1:42 am

Re: 100m drop at 9.81m/s: tunneling through btHeightfieldTer

Post by jarno »

After dropping 100m the cylinders will be falling at a speed of about 44m/s. With a timestep of 1/120s, that's about 36cm per timestep. Any collisions between objects with a combined thickness less than that (including collision margins) are likely to be missed. The cylinders are 20cm, while the thickness of the terrain ends up being twice its collision margin I believe (like a thick shell instead of having an infinitely extending inside). So the cylinders are jumping right through the terrain in a single timestep.

You would probably have to go to a timestep in the order of a millisecond to get it to collide accurately.
whisp
Posts: 5
Joined: Sun Apr 01, 2012 5:17 pm

Re: 100m drop at 9.81m/s: tunneling through btHeightfieldTer

Post by whisp »

Thanks again.

The new compiling solved the problem with the memory leak.

Tunneling still happens, even at a 1/240 timestep (although pretty rare, only about 5 per 100 cylinders).

A timestep of 1/1000, even 1/240, uses up a lot of processor power and is not really an alternative. Are there no other possible solutions integrated in bullet?
Mako_energy02
Posts: 171
Joined: Sun Jan 17, 2010 4:47 am

Re: 100m drop at 9.81m/s: tunneling through btHeightfieldTer

Post by Mako_energy02 »

At the scale you are using, anything more then 1/120 shouldn't be necessary. The only other thing off the top of my head to try is increasing the collision margin on one or both of your collision shapes being used. Also if you still have CCD enabled, try disabling it. Every time I've used it it's caused more issues then it was worth.
rknoesel
Posts: 17
Joined: Wed Feb 25, 2009 2:18 am

Re: 100m drop at 9.81m/s: tunneling through btHeightfieldTer

Post by rknoesel »

body->setCcdMotionThreshold(1)
The Motion Threshold is a distance, and you're setting it to 1m. I would suggest setting it to the cylinder radius or less (10cm).
Post Reply