Terrain collision - what am I missing?
Posted: Fri Dec 31, 2010 7:49 am
Hey, everyone. I started integrating Bullet into my project a few days ago, and I've come across a problem with my terrain. In short, it produces excessive tunneling.
My terrain is essentially a height field, and so I've tried using btBvhTriangleMeshShape, btHeightfieldTerrainShape, etc. to represent it. The thing that all the terrain-friendly shapes have in common, and the source of my problem, is that they are infinitely thin and two-sided. Thus, there is a relatively small window in which collisions are resolved properly.
It doesn't seem to matter how large I make my collision shapes; even at low velocities (relative to the size), they will reliably tunnel. As for other solutions, I've tried:
- CCD: This doesn't seem to work as expected with any of the shapes I've used for terrain. Behavior is the same as without it.
- Increased collision margins: Maybe I just don't know how to use them (I'm just calling setMargin()), but they don't help at all, even at ridiculous sizes.
- Debug drawing: There's nothing wrong with my terrain shapes. Large spheres can roll around perfectly on them.
- Decreased internal timestep: This one actually helps somewhat, of course, but I would really prefer not to rely on something that increases computations so greatly.
To give some perspective, here's an example scenario. I have flat terrain, and 100m above it, a .25m cube. The cube accelerates downward at 9.8m/ss, and goes straight through the terrain. Is that normal? How do I make collision information for my terrain that can reliably collide with objects at greater velocities?
Please remember, I've tried a variety of shapes here, and I'm aware of the problem - objects are penetrating the terrain too deeply, and are thus coming out the other side. So, I guess my real question is this:
What can be done to ensure that no collision involving terrain will be resolved such that the other object is pushed even deeper into the terrain?
I've looked through more posts on these forums than I care to remember, and yet the solution eludes me. I would love to just have a btHeightfieldTerrainShape with thickness. I've seen really old posts stating that such a shape might be implemented, but if it's there, I don't see it.
My terrain is essentially a height field, and so I've tried using btBvhTriangleMeshShape, btHeightfieldTerrainShape, etc. to represent it. The thing that all the terrain-friendly shapes have in common, and the source of my problem, is that they are infinitely thin and two-sided. Thus, there is a relatively small window in which collisions are resolved properly.
It doesn't seem to matter how large I make my collision shapes; even at low velocities (relative to the size), they will reliably tunnel. As for other solutions, I've tried:
- CCD: This doesn't seem to work as expected with any of the shapes I've used for terrain. Behavior is the same as without it.
- Increased collision margins: Maybe I just don't know how to use them (I'm just calling setMargin()), but they don't help at all, even at ridiculous sizes.
- Debug drawing: There's nothing wrong with my terrain shapes. Large spheres can roll around perfectly on them.
- Decreased internal timestep: This one actually helps somewhat, of course, but I would really prefer not to rely on something that increases computations so greatly.
To give some perspective, here's an example scenario. I have flat terrain, and 100m above it, a .25m cube. The cube accelerates downward at 9.8m/ss, and goes straight through the terrain. Is that normal? How do I make collision information for my terrain that can reliably collide with objects at greater velocities?
Please remember, I've tried a variety of shapes here, and I'm aware of the problem - objects are penetrating the terrain too deeply, and are thus coming out the other side. So, I guess my real question is this:
What can be done to ensure that no collision involving terrain will be resolved such that the other object is pushed even deeper into the terrain?
I've looked through more posts on these forums than I care to remember, and yet the solution eludes me. I would love to just have a btHeightfieldTerrainShape with thickness. I've seen really old posts stating that such a shape might be implemented, but if it's there, I don't see it.