Collision detection between a dynamic object and a static terrain

Post Reply
Bicyclette
Posts: 6
Joined: Sat Jan 04, 2020 4:46 pm

Collision detection between a dynamic object and a static terrain

Post by Bicyclette »

Hello everyone,

I'm creating this topic in order to gather some informations about how to properly feed bullet's data structures with my 3D objects for a racing game.
I've already tried to set up a very simple scene with a cube falling on a rectangular ground shape with success.
For the cube I choosed to reprsent it with the btConvexHullShape type, and for the ground I choosed the btBvhTriangleMeshShape.
I also binded some keys to move the cube on the ground with the setLinearVelocity method and so on.

Once that little test done, I tried to apply the same code pattern to my game, and it just failed completely. At first, when the vehicle isn't moving, he falls onto the ground then it bounces on top of it in a very weird way then he stops moving, it's ok so far, but when I try to move forward, the vehicle falls through the ground.

The only difference is that for the vehicle I use a btBoxShape. I tried lots of data types for the static terrain and the moving vehicle, I wasn't able to have nice results, sometimes the vehicle collide with some invisble things in front of it when it is supposed to move in a 100% flat plane (weird), or it falls through the ground.

Recently I tried to get back to my working test with the cube and the small ground. I scaled the ground by 10000, and the cube wasn't colliding anymore with the ground, so I thought that it was a scale issue. I then scaled everything down in my game, but this time, at the very beginning of the game, no collisions at all.

So I guess I need some help to understand a bit better how bullet works, I think I have missed something but I don't know what since I don't know bullet very well.

You can find a video of the current state of the game here => https://www.youtube.com/watch?v=YHnheFcNZV0 it will allow you to see the dimensions of the objects. The terrain with the buildings and the cliffs is one single .obj file which contains 300 meshes, those are quite large.

To conclude, I'd like to have some hints about what to do, what I shall avoid when creating the collision shapes etc.

Thank you in advance.

P.S.: on the video I use the camera model matrix to update the vehicle model matrix, but once I'll have the collisions, bullet will handle the vehicle's movements (I hope)
Post Reply