Page 1 of 1

btDefaultVehicleRaycaster issue related to no contact bodies

Posted: Wed Aug 20, 2008 10:58 pm
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.

Re: btDefaultVehicleRaycaster issue related to no contact bodies

Posted: Fri Aug 29, 2008 4:51 am
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

Re: btDefaultVehicleRaycaster issue related to no contact bodies

Posted: Thu Sep 04, 2008 4:19 am
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

Re: btDefaultVehicleRaycaster issue related to no contact bodies

Posted: Thu Sep 04, 2008 3:20 pm
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.

Re: btDefaultVehicleRaycaster issue related to no contact bodies

Posted: Thu Sep 04, 2008 6:04 pm
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

Re: btDefaultVehicleRaycaster issue related to no contact bodies

Posted: Thu Sep 04, 2008 7:00 pm
by Murphy
I can't find where this happens. Do you know which class and function this is supposed to happen in?