Another collision problem

hiker
Posts: 83
Joined: Tue Oct 24, 2006 11:52 pm
Location: Australia

Another collision problem

Post by hiker »

Hi all,

I got another collision problem, this time a collision that is happening is not being reported back to the application. Attached a modified version of the VehicleDemo.

Compiled the way it is, a cylinder (my soon to be rocket :) ) will fly towards the kart, hit it, and is then reflected to the right. No collision is reported (you might want to remove the debug print in line 674), even though the cylinder clearly hits the kart.

More suprising: if the kart is rotated slightly differently (#undef SHOWCOLLISIONBUG in line 516 to see this case), the collision between cylinder and kart is reported.

Changing the collision shape from a cylinder to a box doesn't solve the problem, the same behaviour appears.

Any ideas what I might be doing wrong?

In my actual game the undetected collision is happening between the track (a static object) and the rocket, but I assume that the reason is the same.

Cheers,
Joerg
You do not have the required permissions to view the files attached to this post.
hiker
Posts: 83
Joined: Tue Oct 24, 2006 11:52 pm
Location: Australia

Re: Another collision problem

Post by hiker »

Hi,

Erwin helped me finding the problem. The first and main problem is that I was calling 'refreshContactPoints', which can remove some of the collisions. This actually solved my problem, but there is a potential second issue: if several substeps are used (which might for my application happen if you are using a slower computer), a collision might happen in one substep, and be removed in the second substep, so your application will never catch it.

A similar issue is reported here: http://www.bulletphysics.com/Bullet/php ... oop+#p6388

The solution (till a better API might be available) is to either:
- derive from btSequentialImpulseConstraintSolver, and overriding the solveGroup method
- use the ContactAddedCallback

Of course, you have to be aware that the same two objects might be reported more than once. I am not sure if you can actually remove any rigid bodies when using the solveGroup overriding way (i.e. some data about the rigid bodies might be cached, e.g. in the collision manifolds). For now I collect all collisions in a list, and process the list at the end of the full simulation step.

Having a bullet API which would report each collision exactly once would make programming much easier, but then again I am not sure if it's useful for other applications as well, I am happy with my solution for now.

Thanks to Erwin for his quick help!
Joerg