Hi,
I am having some weird results when trying to get the point count of a collision between a polygon (4 sided) and an edge (just a line). Maybe Im not understanding what a definition of a point is in a collision...
I have tried with the stable release as well as the most recent release (as of today) r206
// box2d 2.1.2
//b2CollidePolygons(&manifold, box_, *boxTransform_, poly2Region_, *poly2Transform_);
// box2d r206
b2CollideEdgeAndPolygon(&manifold, poly2Region_, *poly2Transform_,box_, *boxTransform_ );
points = manifold.pointCount;
Please provide the coordinates for the shapes and bodies.
Hi Erin - Thank you for your quick response!
I tried with many similar shapes and got same results, but this is the one from the images.
#define PTM_RATIO 32
// EDGE LINE
b2Vec2(10.f/PTM_RATIO,10.f/PTM_RATIO),b2Vec2(-40.f/PTM_RATIO,40.f/PTM_RATIO);
// POLYGON
b2Vec2 vertices[4];
vertices[0] = b2Vec2(-19.0/PTM_RATIO,-8.0/PTM_RATIO);
vertices[1] = b2Vec2(13.0/PTM_RATIO,-20.0/PTM_RATIO);
vertices[2] = b2Vec2(20.0/PTM_RATIO,57.0/PTM_RATIO);
vertices[3] = b2Vec2(5.0/PTM_RATIO,57.0/PTM_RATIO);
// this is another polygon I used that is more pronounced - seems like it only registered 2 points when near the top and bottom, but not in the middle.
/*
vertices[0] = b2Vec2(30.0/PTM_RATIO,40.0/PTM_RATIO);
vertices[1] = b2Vec2(-10.0/PTM_RATIO,40.0/PTM_RATIO);
vertices[2] = b2Vec2(0.0/PTM_RATIO,-40.0/PTM_RATIO);
vertices[3] = b2Vec2(15.0/PTM_RATIO,-40.0/PTM_RATIO);
*/
Hi - yes that scenario always shows one contact point for me, the issue I have is if I move the polygon so it makes 2 contacts in the middle of the polygon, in some positions it only return 1 contact point when it should be returning 2, can you move the poly with a mouse and display the contact points to see what i mean?
Try placing the polygon so that the left and right sides of it intersect the edge in the middle of the poly like in my screen shot.
thanks for your help.
edit: I added a movie to show what I mean.. thanks again for your time!!
Yeah, this is how the separating axis test works. Since that edge is short relative to the height of the polygon, there are some configurations where a sideways motion gives a shorter route to separation.