How can I get the normal for a surface being collided with?

Aug 27, 2009 at 5:46 PM
Edited Aug 27, 2009 at 5:46 PM

I have a moving circle geom colliding with another rectangle geom. How can I get the normal for the rectangle geom for the surface being collided with?

I noticed the OnCollision() event manager has a contactList parameter, and a Contact has a Normal field that can be accessed. However, when I pause the code in OnCollision() event for the circle geometry I see there is more than one item in contactList. I thought there would be only one item in the list, the geom the circle geom is colliding with. But I guess it doesn't work that way, so the Normal field from each contact in contactList probably is of no help (because there is more than one contact in the list - which Normal would I choose?). Do items in contactList correspond to vertices of the circle geom contacting the rectangle geom?

Does Farseer provide a way to get the Normal of a surface being collided with?

 

Coordinator
Aug 27, 2009 at 6:11 PM
gameboy wrote:

Does Farseer provide a way to get the Normal of a surface being collided with?

Yes, and you already found it.

The contactlist contains all the contacts between the two geometries. They are the places where the two geometries touch each other. The normal of those contacts are used to separate the two geometries and the normal points from geom A towards geom B. Geom A is the geometry you registered the OnCollision event at.

Sep 1, 2009 at 4:24 PM

If you're using SAT (as opposed to DistanceGrid), you'll find that the normals of each Contact is the same for any collision. With DistanceGrid, I believe the first Contact in the list will have greatest penetration, so I would either base the normal off of the first Contact, or an average of all of the Contact normals.