Collision callback returns extra contacts (pymunk)

Discuss any Chipmunk bugs here.

Collision callback returns extra contacts (pymunk)

Postby chmille3 » Wed Apr 07, 2010 5:47 pm

Hello all, I want to have geometric shapes stick to each other if two or more points of contact occur between any two shapes. However, when a corner of one of the shapes hits the side of another, more than one contact point is registered and the extra contact point is in a different spot.

Examples are in the attached files where a triangle corner is colliding with either a square or another triangle. The small red dots are the collision points registered in the callback and the red dot on the triangle in the 2nd file is the position of my mouse. This only seems to happen with a triangle is hitting a square or another triangle, and even then only occurs about 50 percent of the time.

I perform a point query using the two points returned and both points say they are hitting the triangle when clearly only one is.
I tried this with pymunk version 0.8.4 and 1.0.0 and have the same problem. It seems to be a bug in pymunk(chipmunk) but wasn't sure. Any help/feedback is appreciated, thanks.
Posts: 3
Joined: Thu Apr 30, 2009 3:34 pm

Re: Collision callback returns extra contacts (pymunk)

Postby slembcke » Thu Apr 08, 2010 8:10 am

I think I noticed this before actually, it's probably a precision issue in the poly to poly collision detection code. I'll have to look into it.

edit: Oh! No, I know what's causing that. I changed poly to poly collisions to use a partial convex hull when checking if a vertex is inside the other polygon. This fixes the problem where you detect that two poly's are overlapping but neither contains vertexes of the other. This happens with polygon that have long and thin or pointy parts on them. I guess a more correct thing to do would be to do the degenerate collision point search after a degenerate collision is found.

I committed the fix to trunk. You'll have to build pymunk from scratch with the trunk Chipmunk source to get the change though. (or poke viblio)
Can't sleep... Chipmunks will eat me...
Check out our latest projects! ->
User avatar
Site Admin
Posts: 4164
Joined: Tue Aug 14, 2007 7:13 pm

Return to Bugs

Who is online

Users browsing this forum: No registered users and 1 guest