Contact Points - how do you pick them?

Please don't post Bullet support questions here, use the above forums instead.
samy
Posts: 8
Joined: Wed Nov 29, 2006 12:36 am

Contact Points - how do you pick them?

Post by samy »

I want to extend my own implementation of Erin Catto's solver to handle shapes like circles and arbitrary convex polygons, but I'm not exactly sure how to choose the contact points.

Say I have a circle intersecting a box. Which points should I choose for the contact points? Can I get away with just one? Or should I take the 2 points where the box and circle perimeters actually intersect?

How about convex polygons? I tried to figure out how to extend the ideas presented in Erin's 2k6 GDC powerpoint, but I'm having trouble wrapping my brain around it. If someone could describe in moderate detail how I would choose the contact points, that would be very helpful.

I don't need any implementation details, just tell me to clip this with that and discard these, etc. etc.

Thanks!
Erin Catto
Posts: 316
Joined: Fri Jul 01, 2005 5:29 am
Location: Irvine

Post by Erin Catto »

For circle vs poly, just find the point on the surface of the poly closest to the circle center. That defines the normal and the separation. You should only use a single contact point.

For poly vs poly, find the reference edge and incident edge according to the '06 slide. You want to clip the incident edge against some lines. Use two parallel lines, one at each vertex of the reference face. The outward normal of the lines is parallel (or anti-parallel) to the reference edge. Otheres and I have tried this scheme and it works well.
samy
Posts: 8
Joined: Wed Nov 29, 2006 12:36 am

Post by samy »

Ok, that sounds good. Part of my confusion stems from the following which is actually generated by your collision detection code from the 06 Box2D:

Image

Is that result incorrect or do I still not understand the clipping process described in the slides?

If you could explain how that result is generated, it would probably give me some insight into the whole process. Thanks for all the help!!

-Sam
Erin Catto
Posts: 316
Joined: Fri Jul 01, 2005 5:29 am
Location: Irvine

Post by Erin Catto »

Ah yes. So you would think the contact point would be at the lowest vertex of the upper box. Well that should be the contact point. I will explain.

As the last step of point generation, the code slides the contact point along the normal onto the reference face. This is mainly useful in 3D where you get up to 8 clip points in a box-box collision and you want to reduce the number of points. It is easier to do that reduction if all the points lie in the plane of the reference face. For 2D this adjustment is unnecessary because you get a maximum of 2 points, and they should not be redundant.

You should be able to find the line of code that slides the point onto the reference face and remove it. It _should_ have little effect on the simulation.
samy
Posts: 8
Joined: Wed Nov 29, 2006 12:36 am

Post by samy »

Ok, that clears up my confusion. Thanks for the help Erin! I'll post some videos when I'm done with my little project here :)