Page 1 of 1

btBvhTriangleMeshShape suffering from tunneling

Posted: Tue Jan 08, 2013 4:26 am
by sezaru

I've started playing with Bullet Physics for just 2 days, but so far I've successfully integrated it to my voxel engine, but sometimes the objects suffer from tunneling and fall from the terrain.

Basically what I have is an grid of chunks, each chunk being an 3D array of 16x16x16, which defines what kind of block is in the local, so the chunk transforms it in an mesh which is what I'm using to fill an btBvhTriangleMeshShape. So each chunk generates it own btBvhTriangleMeshShape and register it with Bullet world.

For testing the collision I'm creating a lot of btSphereShape, the collision works as expected until the sphere move so fast that it will fall from the world.

To ilustrate it better I've made an video showing the problem:

reading about it in this forum and in google the solution I've found was activating Ccd, I've tried it using these 2 line for each sphere:

Code: Select all

sphere_->setCcdSweptSphereRadius(radius * 0.9f);
It almost works, It actually makes the tunneling disapear, but it creates another behavior that if a lot of balls are too near each other (kinda inside, or penetrating), it will stuck the balls in the place, and every new ball I create near it gets stuck inside it too, I've a screenshot of it happening, if an video is needed just tell me and I will make one: (Every ball floating in this screenshot is actually stuck)

Fell free to ask for any other information regarding the problem.

Thanks a lot!

Re: btBvhTriangleMeshShape suffering from tunneling

Posted: Tue Jan 08, 2013 4:35 am
by zarlox
Yes CCD is the way to go because your balls seems to sometime get quite a lot of momentum when they collide.

Now if you say the CCD creates issues i would reduce the size of the CCD radius. 0.9*radius seems a bit too close to your sphere shell. Reduce it to ~0.4

Re: btBvhTriangleMeshShape suffering from tunneling

Posted: Tue Jan 08, 2013 5:09 am
by sezaru
I'm not sure if you meant -0.4 or 0.4, but either have the above issue.

Actually I don't need that much momentum, I've set like that just for testing purposes, so I've changed m_restitution from 1.3 to 0.3 and the issue disappeared, it only happens now when I create a lot of balls very fast which increase the momentum of all balls it collide quite a lot.

Knowing that, there is some way of me limit the momentum of an body?

Thanks a lot!

Re: btBvhTriangleMeshShape suffering from tunneling

Posted: Wed Jan 09, 2013 6:41 am
by sezaru
Ok, after more testing, I've found that the problem starts when I have a higher m_restitution value, I've made a video showing the problem, in the video I've set the restitution to 0.95, as you can see, in the beggining I couldn't make the problem happens, but around 1 minute of video It started, if I've made the value higher it is easier to happen, and if it is lower its harder.

I don't know why this is happening, can this be something wrong I'm doing with my code or is this a bug?

Thanks a lot for the help :)