skapunch/box2d

Polygon jumps to other side of chain shape

Opened this issue · 3 comments

There seem to be some rare cases where a polygon shape can move through a chain 
shape segment.

1. Run attached test
2. Use mouse to pull the box to the left a little as in the images below

Keep the grab position low down and toward the right side of the box to avoid 
toppling it over completely, but a little above the top of the vertical edge so 
that it is able to rotate a bit.

It looks like the box suddenly decides it should be on the other side of the 
vertical edge. The problem goes away when any one of these is done:
- the box is made shorter
- the box is made wider
- the vertical edge is made higher

The problem only seems to occur when the box is touching both edge segments. It 
does not matter whether the edges are at the ends of their chain or not, or 
that the edges are at perfect right angles to each other, or whether the two 
edges are consecutive in the chain or not.

Video: http://youtu.be/d_-0oM2uVVM

Original issue reported on code.google.com by iforc...@gmail.com on 21 Jun 2012 at 10:10

Attachments:

See also: http://www.box2d.org/forum/viewtopic.php?f=4&t=8867

Original comment by iforc...@gmail.com on 5 Oct 2012 at 6:33

Simple solution seems to be not to use ghost vertices where the angle between 
consecutive edge segments is <= 90 degrees.

Original comment by iforc...@gmail.com on 16 Mar 2013 at 5:32

This is a limitation of the current algorithm. It tries to provide smooth 
double-sided collision. This means you must bury isolated vertices. The pop 
occurs when the centroid of the polygon goes behind the chain.

Possible fix: apply the collision algorithm twice, once for each side. Then 
pick the result with the greatest separation. Yes, two partial polygons should 
work.

Original comment by erinca...@gmail.com on 23 Oct 2013 at 5:46

  • Changed state: Accepted