btDefaultVehicleRaycaster issue related to no contact bodies

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

btDefaultVehicleRaycaster issue related to no contact bodies

Post by Murphy »

I also posted the issue here: http://code.google.com/p/bullet/issues/detail?id=79

Basically, while creating a "sensor" type object I noticed that my vehicles were sometimes colliding with the sensor body. For example, while driving on a curved surface I would hit a static plane sensor even though it was set to no contact response. The body of the kart would go through it no problem but sometimes the wheels would seem to "catch" onto to the plane.

After a bit of thinking I realized that the btDefaultVehicleRaycaster doesn't check if the body that is casted against has contact response enabled.

The fix is very simple:

Old code:

Code: Select all

if (rayCallback.hasHit())
    {
        btRigidBody* body = btRigidBody::upcast(rayCallback.m_collisionObject);
        if (body)
New code:

Code: Select all

if (rayCallback.hasHit())
    {
        btRigidBody* body = btRigidBody::upcast(rayCallback.m_collisionObject);
        if (body && body->hasContactResponse())
So I basically wanted to just post this for anyone having an issue like this with vehicles and get some feedback on this solution.

Thanks.
User avatar
Erwin Coumans
Site Admin
Posts: 4221
Joined: Sun Jun 26, 2005 6:43 pm
Location: California, USA
Contact:

Re: btDefaultVehicleRaycaster issue related to no contact bodies

Post by Erwin Coumans »

Good point, it has been fixed. If you have other improvements, please let us know.

Thanks a lot for the feedback,
Erwin
hiker
Posts: 83
Joined: Tue Oct 24, 2006 11:52 pm
Location: Australia
Contact:

Re: btDefaultVehicleRaycaster issue related to no contact bodies

Post by hiker »

Hi,
So I basically wanted to just post this for anyone having an issue like this with vehicles and get some feedback on this solution.
I have seen the same issue, but doesn't your solution causes wheels not touching the ground if they are on top of a body without contact response? I would expect that the ray would then go through the no-contact-body and hit whatever is below (i.e. the raycast needs to be fixed, not the result of the raycast).

This behaviour would be bad for our game SuperTuxKart: we have 'zipper' (flat quads) on the track that have no contact response set. If suddenly a wheel on top of a zipper would lose contact with the track (because the raycast returns no object instead of the zipper), it would mean that only one of the wheels causes a force to act on the body, which means the kart starts turning or rotating (see http://www.bulletphysics.com/Bullet/php ... f=9&t=2047).

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

Re: btDefaultVehicleRaycaster issue related to no contact bodies

Post by Murphy »

That is a good point hiker. Perhaps the fix should be in the ray caster. Maybe it could be an option. Some may want to cast against no contact bodies and others (like us) do not.
User avatar
Erwin Coumans
Site Admin
Posts: 4221
Joined: Sun Jun 26, 2005 6:43 pm
Location: California, USA
Contact:

Re: btDefaultVehicleRaycaster issue related to no contact bodies

Post by Erwin Coumans »

The raycast should just ignore the object and continue with other objects, including the ones underneath.

Can someone double-check this?
Thanks,
Erwin
Murphy
Posts: 32
Joined: Fri Aug 31, 2007 6:36 am

Re: btDefaultVehicleRaycaster issue related to no contact bodies

Post by Murphy »

I can't find where this happens. Do you know which class and function this is supposed to happen in?
Post Reply