Skip to content

Commit

Permalink
Fix hole bridge edge case, close #45
Browse files Browse the repository at this point in the history
  • Loading branch information
mourner committed Jan 19, 2016
1 parent 6f39883 commit 65c7da5
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/earcut.js
Expand Up @@ -310,6 +310,8 @@ function findHoleBridge(hole, outerNode) {

if (!m) return null;

if (hole.x === m.x) return m.prev; // hole touches outer segment; pick lower endpoint

// look for points inside the triangle of hole point, segment intersection and endpoint;
// if there are no points found, we have a valid connection;
// otherwise choose the point of the minimum angle with the ray as connection point
Expand Down
1 change: 1 addition & 0 deletions test/fixtures/issue45.json
@@ -0,0 +1 @@
[[[10,10], [25,10], [25,40], [10,40]], [[15,30], [20,35], [10,40]], [[15,15], [15,20], [20,15]]]
1 change: 1 addition & 0 deletions test/test.js
Expand Up @@ -29,6 +29,7 @@ areaTest('simplified-us-border', 120);
areaTest('touching-holes', 57);
areaTest('hole-touching-outer', 77);
areaTest('hilbert', 1023);
areaTest('issue45', 10);

test('indices-2d', function (t) {
var indices = earcut([10, 0, 0, 50, 60, 60, 70, 10]);
Expand Down

0 comments on commit 65c7da5

Please sign in to comment.