# Box2D Forums

 It is currently Sat May 25, 2013 12:34 am

 All times are UTC - 8 hours [ DST ]

 Page 1 of 1 [ 4 posts ]
 Print view Previous topic | Next topic
Author Message
 Post subject: Only 1 contact returned from b2CollidePolygonsPosted: Mon Aug 15, 2011 10:03 pm

Joined: Mon Nov 16, 2009 11:14 pm
Posts: 18
Hoping someone can explain why I'm getting a single collision point or offer an alternate solution to my problem.

I have a polygon composed of about 8 vertices that is roughly 40 pixels high and 200 pixels wide. When the user touch above this polygon, I'm trying to determine the point closest to the touch. My naive approach was to create a square that is 5 pixels wide and 80 pixels high (centered on the touch point) and applying b2CollidePolygons() to these two polygons. I expected to receive contacts at both the top and bottom of the platform.

I am getting contacts but only one.

Top

 Post subject: Re: Only 1 contact returned from b2CollidePolygonsPosted: Mon Aug 15, 2011 10:22 pm

Joined: Mon Nov 16, 2009 11:14 pm
Posts: 18
OK...slightly wrong. b2CollidePolygons is returning two contacts. My b2CollidePolygonAndCircle was returning only one contact.

Still the same problem though. I would expect b2CollidePolygons to return 4 contacts...and the same for b2CollidePolygonAndCircle. b2CollidePolygons is only returning two contacts that are on the same horizontal axes but not the additional contacts that should be above or below this pair.

Top

 Post subject: Re: Only 1 contact returned from b2CollidePolygonsPosted: Tue Aug 16, 2011 9:33 am

Joined: Mon Nov 16, 2009 11:14 pm
Posts: 18
Just so others know, the Box2D documentation (4.8 Contact Manifolds) says that circle-circle and circle-polygon collisions only return one contact. Seems to be a limitation of the collision algorithm.

Top

 Post subject: Re: Only 1 contact returned from b2CollidePolygonsPosted: Tue Aug 16, 2011 7:54 pm

Joined: Tue Jun 24, 2008 8:25 pm
Posts: 1517
Location: Tokyo
biosopher wrote:
I would expect b2CollidePolygons to return 4 contacts...and the same for b2CollidePolygonAndCircle.
I would like to see a diagram showing an example of two convex polygons and where these four contact points would be

As for your original question, I think you might be better off just doing a 'closest point on line to point' test for each edge of the 40x200 shape in your scene.
http://paulbourke.net/geometry/pointline/

Top

 Display posts from previous: All posts1 day7 days2 weeks1 month3 months6 months1 year Sort by AuthorPost timeSubject AscendingDescending
 Page 1 of 1 [ 4 posts ]

 All times are UTC - 8 hours [ DST ]

#### Who is online

Users browsing this forum: No registered users and 1 guest

 You cannot post new topics in this forumYou cannot reply to topics in this forumYou cannot edit your posts in this forumYou cannot delete your posts in this forumYou cannot post attachments in this forum

 Search for: