Page 1 of 1

Objects Overlap on Low Speeds

Posted: Fri Jun 20, 2008 10:36 am
by cmuser
Hi all,

First of all, let me point out how I love the chipmunk lib! :)

I need to create some kind of a billiard game.
Instead of billiard balls I'm using square polygons.
I have created 8 identical polygons and a space (the "table") with no gravitation, but with damping=0.5 to emulate the friction of the billiard table.
I set an initial speed vector to a polygon and watch the polygons collide.

Direct collisions work well, especially at high speed.
But when a polygon is spinning at low speed (when it's about to stop), sometimes its corner can overlap an other polygon without generating a collision.

I've been playing with different chipmunk parameters for several days, but still haven't eliminated the overlap completely, which happens from time to time.

Could anybody advise me what parameter to play with, please?

Please, help.

Re: Objects Overlap on Low Speeds

Posted: Fri Jun 20, 2008 11:23 am
by maximile
Have you set cp_collision_slop to 0? If that's not it, then I guess it could be this (from the docs): "Pointy or thin polygons aren’t handled well. Collision points are generated at the poly’s vertexes. I haven’t decided what to do about this yet."

Re: Objects Overlap on Low Speeds

Posted: Fri Jun 20, 2008 4:31 pm
by slembcke
cmuser: Could you be more specific? How much do they overlap? Are you sure it isn't a drawing issue?

maximile: That's describing when two polygons overlap, but neither contains vertexes from the other poly (like a David's Star for example).

Re: Objects Overlap on Low Speeds

Posted: Mon Jun 23, 2008 3:17 am
by cmuser
to maximile & slembcke:
thank you very much for your advices!

Sorry, it was really a bug in drawing! Used wrong angle in rotation. :oops:

One more question:
I'm moving objects on a table (top view).
The objects are moving in zero-gravity in the space (= table surface), to substitute the friction of the table I use the space damping parameter.
Is there a better way to represent the table friction (in order not to use space damping)?

Re: Objects Overlap on Low Speeds

Posted: Mon Jun 23, 2008 12:19 pm
by Michael Buckley
You could probably stop the apply a small force opposing the object each frame. When the speed of the object gets too slow in a direction, you'll want to stop the object and stop applying the force.