Falling objects 'sink' into the floor?

Official forum for the Chipmunk2D Physics Library.
Post Reply
doeke
Posts: 4
Joined: Tue Aug 17, 2010 1:23 pm
Contact:

Falling objects 'sink' into the floor?

Post by doeke »

Let's say I have a space with some gravity and a static floor, and I drop objects on it from some height. Instead of bouncing or coming to rest immediately, the shapes will sink into the floor, then float up quickly before coming to a rest, as if the floor was made from pillows. The same happens when one non-static object falls on another, and it never last longer than half a second or so (still enough to be very noticable).

I tried setting different numbers of (elastic) iterations, but that does not seem to have any effect on the issue I'm having.

This might just be a problem with the python wrapper (pymunk) I am using, as it seems to be there in all the examples included with pymunk too. So does anyone know if there is something I'm doing wrong, or if there is likely a bug in pymunk, and if so, where would the problem most likely be (so I could try to fix it)?
User avatar
slembcke
Site Admin
Posts: 4166
Joined: Tue Aug 14, 2007 7:13 pm
Contact:

Re: Falling objects 'sink' into the floor?

Post by slembcke »

Not a bug. That is how Chipmunk (and most other physics engines including Box2D) resolve overlapping collisions when not performing swept collisions.

In the C API, you can change the cp_bias_coef to cause it to resolve the overlap faster at the cost of stability.
Can't sleep... Chipmunks will eat me...
Check out our latest projects! -> http://howlingmoonsoftware.com/wordpress/
doeke
Posts: 4
Joined: Tue Aug 17, 2010 1:23 pm
Contact:

Re: Falling objects 'sink' into the floor?

Post by doeke »

I just assumed something was wrong because the overlap seemed larger and resolving it slower then what I'm used to from box2d and what I saw in the chipmunk demo movie.

Luckily I'll be using chipmunk for a platformer-like game, so as long as I avoid stacks of multiple objects, setting cp_bias_coef to a higher value shouldn't be problem. Would setting cp_collision_slop to a lower value also be a solution, or does that result in worse stability/realism issues?

Also, thanks for the quick answer.
User avatar
slembcke
Site Admin
Posts: 4166
Joined: Tue Aug 14, 2007 7:13 pm
Contact:

Re: Falling objects 'sink' into the floor?

Post by slembcke »

Changing cp_bias_coef is a pretty safe thing to experiment with. 0.1 simply seemed like a good default value as it's nearly impossible to notice in games with slower moving objects. Most people never even seem to notice it.

cp_collision_slop allows objects to overlap slightly all the time. This is because Chipmunk remembers the collision solutions from the last few frames. By allowing them to overlap slightly, you prevent contacts from jittering and disappearing every other frame. Normally, you'd simply set this value to be slightly less than a pixel so that you don't notice the effect of it.
Can't sleep... Chipmunks will eat me...
Check out our latest projects! -> http://howlingmoonsoftware.com/wordpress/
Post Reply

Who is online

Users browsing this forum: No registered users and 7 guests