Commit Graph

4 Commits

Author SHA1 Message Date
Matthias Richter
97ae2d8928 Fix commit adfe9a9a breaking EPA. 2013-09-03 17:13:27 +02:00
Matthias Richter
adfe9a9a5d Issue #25 (2): Collision detection sometimes hangs.
Sometimes the expanding polytype algorithm takes a long time to
terminate, e.g. in situations like this:

 .-.
: +-:-+
 '-'  |
  |   |
  +---+

The issue here is that the EPA adds vertices very close to each other,
which makes the separation distance change very slowly. If this is the
case, consider the current separation distance as approximately correct
and continue.
2013-08-13 15:34:58 +02:00
Matthias Richter
0dc1e6c719 Issue #25: Division by 0 in CircleShape:support().
support(A,B, 1,0) returns 0,0 when A and B are touching in a vertex of
both A and B AND this vertex is on the right of A's center (in direction
(1,0)), e.g. this situation:

    .---.
 .-.| B |
: A x---'
 '-'

Then: support(A,B, 1,0) = A:support(1,0) - B:support(-1,0) = x - x = 0

Since CircleShape:support(dx,dy) normalizes dx,dy this will result in a
division by 0 error in the subsequent execution of the GJK algorithm.

An early out with result 'not colliding' (in accordance to the other
edge cases) prevents this error.
2013-08-13 15:13:25 +02:00
Matthias Richter
ce4b8011da Collision detection using GJK/EPA instead of SAT.
The Gilbert–Johnson–Keerthi collision detection algorithm is
significantly faster than collision detection using the separating axis
theorem. GJK can only determine whether two shapes collide, but not the
penetration vector. The expanding polytype algorithm can use information
from GJK to quickly find the required vector.
2012-05-20 16:50:35 +02:00