Page 1 of 1

Circle shape body penetrations

Posted: Thu Sep 05, 2013 5:49 pm
by ensomniac
Hey Guys,
Another quick question. I have a bunch of circle shapes with ChipmunkBodys attached. When the objects collide, they occasionally penetrate with each other. What is the best method for avoiding this without killing performance?

Thanks
Ryan

Re: Circle shape body penetrations

Posted: Thu Sep 05, 2013 5:56 pm
by compass3
I think increase the fixed update rate may help

Re: Circle shape body penetrations

Posted: Sat Sep 07, 2013 12:36 pm
by ensomniac
Unfortunately increasing or decreasing the fixed timestep doesn't help completely. Decreasing it helps a little bit, but not enough. I have to decrease it so low that the motion no longer looks natural. Surely there's a better way to handle shape penetrations? To be fair, I had the same exact problem using physX...

Re: Circle shape body penetrations

Posted: Mon Sep 09, 2013 12:06 pm
by slembcke
Decreasing the fixed timestep shouldn't make anything look unnatural. Are you making it so small that it's actually slowing down the whole simulation?

As for the issue, Chipmunk doesn't support swept collisions. This means that it moves objects to their new positions and then checks for overlaps. PhysX does support swept collisions, but it's off by default because it's *very* expensive. You have to turn it on for individual objects and you can really only do it for a few in the scene without killing your performance. There is also some very specific rules about which objects can have swept collisions against others.

If decreasing the timestep isn't an option, the next best thing you can do is to cap your object's velocity. Alternatively, you can change the Chipmunk.collisionBias value to make the overlap disappear more quickly.