## overlapping static bodies causing jittering to other bodies

Discuss any Chipmunk bugs here.

### Re: overlapping static bodies causing jittering to other bod

Yeah, will need more details. How exactly are you making it static? Adding joints to hold it in place or swapping the body out for a static one? If you are using joints that have to fight with each other or collisions that will cause the body's velocity to be pretty angry as it's being asked to solve something unsolvable. If you have a body with a non-zero velocity that will also cause issues.
Can't sleep... Chipmunks will eat me...
Check out our latest projects! -> http://howlingmoonsoftware.com/wordpress/

slembcke

Posts: 4164
Joined: Tue Aug 14, 2007 7:13 pm

### Re: overlapping static bodies causing jittering to other bod

It looks to me like your static body has a non-zero velocity set on it. Looking at your code below, you set the velocity to zero, so my next best bet is that it's the bias velocity. The bias velocity is what is used to correct the positions of overlapping objects and is normally set to zero when the position is integrated in cpBodyUpdatePosition(). Try setting v_bias and w_bias to zero as well. Really though I wouldn't do this. Read on!

So it's fine (and common) for a rogue body to have an infinite mass and moment of inertia. I'm not sure what you'd do with one that had a reasonable finite mass. It's velocity would get modified due to collisions and you'd have to handle that. You've sort of sidestepped that by making it very massive so it's velocity change from collisions is very small, but the issue is still there. The only catch is that the math chokes when trying to solve a collision between two infinite mass objects. In the latest version of Chipmunk, such collisions are now silently ignored, but in previous versions would trigger an assertion.

The biggest reason for static bodies/shapes to exist is optimization. You can have thousands of static shapes without increasing the collision detection cost very much. Most of the work is done when the shapes are created, and then never again. Since rogue bodies might move at any time, Chipmunk recalculates their shapes' collision properties every frame.

I'm guessing your worst case will be a few dozen rogue bodies at a time. In which case I wouldn't worry about it. Use infinite mass rogue bodies, and either filter out the collisions (groups, layers, or callbacks, whichever works best) or use the latest Chipmunk which does it for you.
Can't sleep... Chipmunks will eat me...
Check out our latest projects! -> http://howlingmoonsoftware.com/wordpress/

slembcke