Weird collision bug?

Discuss any Chipmunk bugs here.

Weird collision bug?

Postby bugmang » Mon Feb 04, 2013 8:38 pm

I have a simple simulation where I have a ball (with a sphere shape) moving around that "can" collide with multiple obstacles (each is a square and are static with infinite mass so they don't move when the ball collides with it). I simply assign the ball a velocity and let it bounce wherever infinitely. Simple right?

The attached image illustrates the problem I'm having. The red line indicates the ball's current trajectory and the blue line indicates the trajectory after collision. The top part of the image illustrates the expected behavior (which I get most of the time... or at least what appears to happen). The bottom part of the image shows the odd behavior that occurs sometimes (and it's visually surprising). In other words, It reverses direction entirely rather than simply reversing the y velocity. I read that I could combine these two objects into one body but sometimes they are combined as part of a non-convex shape (like a "C"). Is there a simple fix that I'm overlooking? I'm new to chipmunk... Thanks!

collision.png
Expected behavior shown at top, odd behavior shown at bottom.
collision.png (13.54 KiB) Viewed 3280 times
bugmang
 
Posts: 1
Joined: Mon Feb 04, 2013 8:07 pm

Re: Weird collision bug?

Postby slembcke » Tue Feb 05, 2013 3:08 pm

So one issue with the way collisions are handled in Chipmunk is that you can hit the "cracks" between shapes even if they are perfectly flush. What's happening is that your ball is hitting the corner of the block on the right, and that collision is being handled before the flat edge of the one on the left.

Using smaller timesteps will help, but the best way to fix it is to join your collision shapes together to avoid the cracks.
Can't sleep... Chipmunks will eat me...
Check out our latest projects! -> http://howlingmoonsoftware.com/wordpress/
User avatar
slembcke
Site Admin
 
Posts: 4164
Joined: Tue Aug 14, 2007 7:13 pm


Return to Bugs

Who is online

Users browsing this forum: No registered users and 1 guest

cron