cpPolyShape collision issues

Official forum for the Chipmunk2D Physics Library.
Post Reply
DetectiveCakes
Posts: 5
Joined: Wed Jul 29, 2009 6:12 pm
Contact:

cpPolyShape collision issues

Post by DetectiveCakes »

Has anyone else had weirdness in dealing with collisions between cpPolyShapes and other shapes?

My situation is this: I have some static cpPolyShapes hooked up to a body with infinite mass. I have some cpCirclesShapes that are user controllable. If the user pushes one of the circle shapes against a poly, initially it behaves as expected and bounces away. But if the user keeps pushing it, eventually it sort of "squeezes" through the poly shape and pops out the other side.

A few notes:
-My cpPolyShapes are convex
-The vertices of my cpPolyShapes have been defined in a clockwise direction, in order
-I'm using cpBodySlew to push stuff around. Maybe a problem?
-I don't have this problem with cpCircleShapes hitting other cpCircleShapes or cpSegmentShapes
-Seems to happen most often at/near vertices of a cpPolyShape, and in places where two cpPolyShapes touch/overlap
-I'm not dealing with particularly high velocities or particularly small shapes

Any ideas? Anyone had similar issues, even if you didn't find a solution (just so I know I'm not losing my mind)?

Thanks
User avatar
slembcke
Site Admin
Posts: 4166
Joined: Tue Aug 14, 2007 7:13 pm
Contact:

Re: cpPolyShape collision issues

Post by slembcke »

I've noticed a possibly similar issue. On the planet demo in trunk, it's possible to pull the little boxes right into the surface of the planet. You shouldn't be able to. I haven't figured out yet why this happens or how to fix it yet.

Best thing I can come up with is that the collision detection isn't returning consistent contact points when transitioning from a edge collision to a vertex collision.
Can't sleep... Chipmunks will eat me...
Check out our latest projects! -> http://howlingmoonsoftware.com/wordpress/
DetectiveCakes
Posts: 5
Joined: Wed Jul 29, 2009 6:12 pm
Contact:

Re: cpPolyShape collision issues

Post by DetectiveCakes »

Thanks for the reply!

This was cross-posted to the cocos-2d iphone forum, had a couple people report a similar issue there. I worked on a 3d physics engine too many years ago, I'll take a peak around... if I come up with anything useful I'll submit a patch (no promises though : ).
ShiftZ
Posts: 114
Joined: Sat Mar 07, 2009 7:23 am
Contact:

Re: cpPolyShape collision issues

Post by ShiftZ »

Just catched trouble with poly shape. I have bullets flying as poly shapes as suggested in coresponding thread. My level map bounded by 4 segment shapes (walls), and somehow bullets can only break through my walls exactly on corner of map, where segment shapes overlaps eachother. Collision massage not even generated. I have tried to increase wall thickness but with no success. I can capture it by Screen Recorder and post somewhere if need.
DetectiveCakes
Posts: 5
Joined: Wed Jul 29, 2009 6:12 pm
Contact:

Re: cpPolyShape collision issues

Post by DetectiveCakes »

Shiftz: My silly workaround here was to create a circle shape near each vertex, which sticks outside of the poly just a little bit. It's not ideal, but it works. I'd imagine this could be used in your situation as well.

Problems with this approach:
-It's some more overhead. I didn't notice any substantial performance hit (circles seem to be quite efficient), but if you've got a lot going on could be an issue.
-Once in a while the moving body still gets through. I'd say it happens about 10% as often as it used to. Usually seems now that it gets through the intersection of the poly and circle.
-Shapes are naturally just slightly 'lumpy'.

So... that mostly works, sort of.
reklis
Posts: 9
Joined: Mon Mar 08, 2010 3:13 pm
Contact:

Re: cpPolyShape collision issues

Post by reklis »

I have been debugging and searching the forums for a week now, and I think this may be exactly what is happening with my poly shapes.

Is there another workaround besides the circle shapes suggested by @DetectiveCakes? Any new thoughts or suggestions on how to deal with this?
User avatar
slembcke
Site Admin
Posts: 4166
Joined: Tue Aug 14, 2007 7:13 pm
Contact:

Re: cpPolyShape collision issues

Post by slembcke »

I guess I'm not quite sure what the issue is exactly. Though it sounds likely that you want to use raycast bullets.
Can't sleep... Chipmunks will eat me...
Check out our latest projects! -> http://howlingmoonsoftware.com/wordpress/
reklis
Posts: 9
Joined: Mon Mar 08, 2010 3:13 pm
Contact:

Re: cpPolyShape collision issues

Post by reklis »

Is there perhaps some crafty hackery we can do with surface_v at runtime on the collision events to repel the circle from the poly so that it does not "penetrate" the perimeter?
User avatar
slembcke
Site Admin
Posts: 4166
Joined: Tue Aug 14, 2007 7:13 pm
Contact:

Re: cpPolyShape collision issues

Post by slembcke »

Surface velocities only affect friction calculations. So that wouldn't help.

Are you sure the issue here isn't the lack of swept collisions?
Can't sleep... Chipmunks will eat me...
Check out our latest projects! -> http://howlingmoonsoftware.com/wordpress/
reklis
Posts: 9
Joined: Mon Mar 08, 2010 3:13 pm
Contact:

Re: cpPolyShape collision issues

Post by reklis »

slembcke wrote:Are you sure the issue here isn't the lack of swept collisions?
No, I'm not sure. I am doing more testing to find the root cause and will report back with my findings.
Post Reply

Who is online

Users browsing this forum: No registered users and 20 guests