Page 1 of 1

Unusual polygon collisions

Posted: Thu Oct 25, 2007 9:48 pm
by kezeali
I'm not sure if this is a bug or just stupidity on my part, but I can't get certain polygons to collide properly (with other polygons or segments). For example the marked edges of the following never collide:

Code: Select all

cpVect verts[] = {
		cpv(-15,-15),
		cpv(-15, 15),
		cpv( 15, 15),
		cpv( 15,-15),
// from here
		cpv( 9,-15),
		cpv( 5,-25),
		cpv( -5,-25),
		cpv( -9,-15),
// to here
	};
The problem seems similar to what would happen if the polygon winding was incorrect, but as far as I can tell it's fine.

Any ideas?

Re: Unusual polygon collisions

Posted: Fri Oct 26, 2007 1:24 am
by slembcke
From a quick sketch, it seems that is not convex. Is that correct? You can use concave collision shapes, but you need to decompose it into convex shapes and add them separately.

Also, if possible, give them a little bit of overlap so that you don't get "cracks" between the polys that a line segment could slip into.

Re: Unusual polygon collisions

Posted: Fri Oct 26, 2007 3:25 pm
by kezeali
Yeah, it's a square with a bit sticking out - so it isn't convex. Thanks for clearing that up :D