Here is a picture of the geometry I am trying to use for collision with the bullet vehicle.
My goal is to be able to use a model like this with concave faces that is similar to the course model I am rendering. I am currently using btBvhTriangleMeshShape for the collision but the vehicle is falling through the mesh. I am able to make collision work with a simple collection of convex shapes but a complex concave shape like the one pictured is giving me trouble.
Is there a way to set up bullet to use a collision mesh as pictured above or any other guidance you can give me to get this working?
Thanks for your help and your work on this awesome engine
Yes, there is a thing that you need to set up in bullet for simulating that world.
First of all, btBvhTriangleMeshShape objects are very thin, and have almost none thickness. So when your vehicle collides the scenary it will pass through, may because your vehicle are moving too fast, or you have set up very strong forces on your simulation.
So you can increment the thickness of your btBvhTriangleMeshShape, by calling the setMargin() method in the collision shape and setting its value to 0.1f ; actually is the same trick that I've made for GIMPACT 0.2 for avoiding that meshes getting stuck.
Another thing that you can do is to subdivide the time fraction for your simulatioin loop. For example subdivide the current time by 10 and run 10 times the simulation each frame.
Thanks for the suggestions. However I am still having the same problems after trying setMargin() and running the physics multiple times a frame.
I don't think that the vehicle is passing through the world because of it's speed as even with around 100 fps it passes though (with the vehicle starting a couple of meters above the world).
Also, as the vehicle falls to the world it seems to "hit" part of the world (the edge of a polygon as far as I can tell visually). This causes it to roll and spin as it continues to fall through.
We also did a simple test with a flat plane and a boxed mesh. The vehicle feel though the flat plane but stopped on the boxed mesh.
Any other suggestions would be greatly appreciated.
I don't know if current Quantized meshes have this bug fixed, but would be better to avoid Quantization.
This bug was fixed, and you are highly recommended to use quantization and btBvhTriangleMeshShape.
- Have you tried btTriangleMesh instead of btStridingMeshInterface?
- Did you already add debug rendering through btIDebugDrawer?
- Are you using any scaling at all?
- what is the vehicle collision shape exactly?
- does a smaller timestep help?
Well, I am an idiot, this problem ended up being my fault
We didn't triangulate the mesh before exporting it. It looked close enough in the debug drawer so we didn't notice until doing some tests with some smaller meshes.
I do have a question still though. What is the difference between btTriangleMesh and btStridingMeshInterface? I would assume that btTriangleMesh would be faster but btStridingMeshInterface would take less memory.
Murphy wrote:We didn't triangulate the mesh before exporting it. It looked close enough in the debug drawer so we didn't notice until doing some tests with some smaller meshes.
Glad it is sorted.
I do have a question still though. What is the difference between btTriangleMesh and btStridingMeshInterface? I would assume that btTriangleMesh would be faster but btStridingMeshInterface would take less memory.
btTriangleMesh is a container for triangle data, so it is typically a duplicate of the graphics meshes. btStridingMeshInterface only indexes into existing triangle meshes, so there is no duplicate mesh data. Setting up the proper indexing is tricky, hence when things go wrong, it is good to first get the btTriangleMesh working.