Box2D Forums

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

All times are UTC - 8 hours [ DST ]




Post new topic Reply to topic  [ 4 posts ] 
Author Message
PostPosted: Mon Aug 15, 2011 10:03 pm 
Offline

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
 Profile  
 
PostPosted: Mon Aug 15, 2011 10:22 pm 
Offline

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
 Profile  
 
PostPosted: Tue Aug 16, 2011 9:33 am 
Offline

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
 Profile  
 
PostPosted: Tue Aug 16, 2011 7:54 pm 
Offline

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
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 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 forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group