Segment shape collisions

Official forum for the Chipmunk2D Physics Library.
Post Reply
majicDave
Posts: 6
Joined: Thu May 21, 2009 5:44 pm
Contact:

Segment shape collisions

Post by majicDave »

Hi

I'm using Chipmunk 5.2.0, and having real issues with segment shapes not colliding at all with other shapes, particularly other segment shapes.

Has anyone else had issues with this or had segment shapes happily colliding with other segment shapes?

I found that the segment shapes will sometimes go straight through poly shapes but sometimes collide as they should. Segment shapes will never ever collide with other segment shapes. I've also found that varying the line radius makes no difference at all. Making one of the shapes static makes no difference. I am not using groups or layers at all. I have also tried replacing both segment shapes with poly shapes (boxes), and get reliably good results. I would rather avoid this as segment shapes would suffice if they actually worked and would no doubt be faster.

Cheers,
David
maximile
Posts: 157
Joined: Mon Aug 20, 2007 12:53 pm
Location: London, UK
Contact:

Re: Segment shape collisions

Post by maximile »

It's documented behaviour that segment shapes don't collide with each other. I usually use two circles and a rectangle when I need a segment on an active body.

Segment shapes should reliably collide with polys though. Maybe the winding is wrong?
User avatar
slembcke
Site Admin
Posts: 4166
Joined: Tue Aug 14, 2007 7:13 pm
Contact:

Re: Segment shape collisions

Post by slembcke »

Maximile is correct. It is in the docs, but is pretty easy to miss.

The problem is that it's somewhat hairy to get good collisions and normals for two segment shapes colliding. I haven't really found a satisfactory way to do it yet. As a workaround, it works perfectly fine to create degenerate 2 point polygons instead of line segments. Stick to using rounded segments for terrain or static geometry as it avoids the "cracks" that objects can catch on. On moving bodies though, using line polygons like that works just fine and are fairly cheap due to having only 2 points.
Can't sleep... Chipmunks will eat me...
Check out our latest projects! -> http://howlingmoonsoftware.com/wordpress/
majicDave
Posts: 6
Joined: Thu May 21, 2009 5:44 pm
Contact:

Re: Segment shape collisions

Post by majicDave »

Thanks guys, I must have missed that. Great to know that a 2 point poly is a workable solution, will give it a try.

Thanks!
Post Reply

Who is online

Users browsing this forum: No registered users and 9 guests