Unusual polygon collisions

Discuss any Chipmunk bugs here.
Post Reply
kezeali
Posts: 2
Joined: Thu Oct 25, 2007 9:32 pm
Contact:

Unusual polygon collisions

Post 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?
User avatar
slembcke
Site Admin
Posts: 4166
Joined: Tue Aug 14, 2007 7:13 pm
Contact:

Re: Unusual polygon collisions

Post 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.
Can't sleep... Chipmunks will eat me...
Check out our latest projects! -> http://howlingmoonsoftware.com/wordpress/
kezeali
Posts: 2
Joined: Thu Oct 25, 2007 9:32 pm
Contact:

Re: Unusual polygon collisions

Post by kezeali »

Yeah, it's a square with a bit sticking out - so it isn't convex. Thanks for clearing that up :D
Post Reply

Who is online

Users browsing this forum: No registered users and 6 guests