advanced "raycast" vehicle wheel model using a cylinder

ola
Posts: 169
Joined: Sun Jan 14, 2007 7:56 pm
Location: Norway

advanced "raycast" vehicle wheel model using a cylinder

Post by ola »

Hi all,

I've implemented a vehicle model based on raycasts for the wheels. One ray per wheel, pointing down, just like in the bullet example vehicle. The game I'm working on needs some offroad and obstacle driving, so the ray is often not accurate enough. To make it worse, the wheels are in the open, so it would be nice to get collisions when something collides with the wheel (an Avatar, some boxes or whatever).

I'm considering various approaches to making this better. Creating wheels with cylinder rigibodies and connecting them to the chassis with constraints is not really an option, the constraints don't have any good options for suspension, and it's not accurate enough for normal fast road driving.

So, I'm now considering to use a cylinder collision shape instead of the ray to check for contact points, and generate my forces based on that. If any of you have already tried this, I'd be really grateful for any hints on how it worked out. What's the best way to do this in Bullet? I am thinking of something like to try to create a btCollisionObject and manually test for collisions against the physics world.

Best regards,
Ola
User avatar
Erwin Coumans
Site Admin
Posts: 4221
Joined: Sun Jun 26, 2005 6:43 pm
Location: California, USA

Re: advanced "raycast" vehicle wheel model using a cylinder

Post by Erwin Coumans »

ola wrote:Hi all,
So, I'm now considering to use a cylinder collision shape instead of the ray to check for contact points, and generate my forces based on that. If any of you have already tried this, I'd be really grateful for any hints on how it worked out.
Some big upcoming commercial game used this approach, using Bullet (confidentially so no mention which title). They use a sphere/convex cast for the wheels, and also for their character controller. They created a new convex shape, that approximates a wheel better then a sphere. We can add such shape to Bullet, but you could try the cylinder too. You need to filter/ignore some false collision hits, against walls etc.
What's the best way to do this in Bullet? I am thinking of something like to try to create a btCollisionObject and manually test for collisions against the physics world.
I suggest trying out the 'swept' collision using btCollisionWorld::convexTest, you can choose a sphere or other convex shape. Check the ConcaveConvexcastDemo how to use this.

Hope this helps,
Erwin
ola
Posts: 169
Joined: Sun Jan 14, 2007 7:56 pm
Location: Norway

Re: advanced "raycast" vehicle wheel model using a cylinder

Post by ola »

Hi Erwin,

that's excellent, thank you!

I'd be quite interested in that special wheel convex shape. I'd guess it's something like a "convex torus"? The cylinder might end up driving on it's edges all the time, so it might not be optimal. I'll try to use that first, anyway.

Best regards,
Ola
ola
Posts: 169
Joined: Sun Jan 14, 2007 7:56 pm
Location: Norway

Re: advanced "raycast" vehicle wheel model using a cylinder

Post by ola »

I'm a bit confused about the "swept test". In my case here I have a shape (the wheel) at some position in the world that I want to test against everything else. So I don't really need to sweep it as I have just one position. Should I then use the same transform twice in the function call, where the transform contains the position of the center of the wheel? Or maybe I have misunderstood the meaning of "sweep"?

example:

Code: Select all

convexSweepTest(wheel_shape_, wheelpos, wheelpos, wheeltest_callback_);
By the way, the ConcaveConvexcastDemo doesn't compile with double precision, there's a problem with btScalar and GLfloat not being the same in that case:
Demos/AllBulletDemos/../ConcaveConvexcastDemo/ConcaveConvexcastDemo.cpp:203: error: cannot convert ‘btScalar*’ to ‘const GLfloat*’ for argument ‘1’ to ‘void glMultMatrixf(const GLfloat*)’

Best regards,
Ola