Vehicle collision against concave mesh problem

Murphy
Posts: 32
Joined: Fri Aug 31, 2007 6:36 am

Vehicle collision against concave mesh problem

Post by Murphy »

Image

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 :)
User avatar
projectileman
Posts: 109
Joined: Thu Dec 14, 2006 4:27 pm
Location: Colombia

Post by projectileman »

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.
Murphy
Posts: 32
Joined: Fri Aug 31, 2007 6:36 am

Post by Murphy »

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.
User avatar
projectileman
Posts: 109
Joined: Thu Dec 14, 2006 4:27 pm
Location: Colombia

Post by projectileman »

In that case I think that it's an issue of Quantized meshes.
http://code.google.com/p/bullet/issues/detail?id=18

I don't know if current Quantized meshes have this bug fixed, but would be better to avoid Quantization.

In the constructor

Code: Select all

btBvhTriangleMeshShape(btStridingMeshInterface* meshInterface, bool useQuantizedAabbCompression,const btVector3& bvhAabbMin,const btVector3& bvhAabbMax);
Set useQuantizedAabbCompression = false;

Also you can try GIMPACT (btGImpactMeshShape), which comes in the Extras Folder.
User avatar
Erwin Coumans
Site Admin
Posts: 4221
Joined: Sun Jun 26, 2005 6:43 pm
Location: California, USA

Post by Erwin Coumans »

projectileman wrote:In that case I think that it's an issue of Quantized meshes.
http://code.google.com/p/bullet/issues/detail?id=18

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?

Code: Select all

dynaWorld->stepSimulation(deltaTime,100,1./240.0);
- can you provide a reproducable case in a Bullet demo?

Thanks,
Erwin
Murphy
Posts: 32
Joined: Fri Aug 31, 2007 6:36 am

Post by Murphy »

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.
User avatar
Erwin Coumans
Site Admin
Posts: 4221
Joined: Sun Jun 26, 2005 6:43 pm
Location: California, USA

Post by Erwin Coumans »

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.

Hope this helps,
Erwin
mikon
Posts: 6
Joined: Tue Sep 18, 2007 3:15 pm
Location: Germany

Re:

Post by mikon »

Hi Erwin
Erwin Coumans wrote:This bug was fixed, and you are highly recommended to use quantization and btBvhTriangleMeshShape.
What is the difference between btBvhTriangleMeshShape and btTriangleMeshShape? What does Bvh mean?

Thx/Brgds
Mikhail Konev
Ripgiblet
Posts: 4
Joined: Thu Dec 30, 2010 1:03 pm

Re: Vehicle collision against concave mesh problem

Post by Ripgiblet »

It uses Bounding Volume Hierarchy and cache friendly traversal for PlayStation 3 Cell SPU.
Just look at the .h files... :mrgreen: