Skip to content

Commit

Permalink
Fix one more race condition, close #34
Browse files Browse the repository at this point in the history
  • Loading branch information
mourner committed Oct 8, 2015
1 parent 8b52731 commit 5313848
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/earcut.js
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,8 @@ function findHoleBridge(data, holeNode, outerNode) {

if (t >= 0 && A * sign - s - t >= 0) {
tan = Math.abs(py - my) / amx; // tangential
if (tan < tanMin && locallyInside(data, node, holeNode)) {
if ((tan < tanMin || (tan === tanMin && mx > bx)) &&
locallyInside(data, node, holeNode)) {
mNode = node;
tanMin = tan;
}
Expand Down
10 changes: 10 additions & 0 deletions test/fixtures/issue34.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[
[[1500,0],[0,0],[0,1000],[1500,1000],[1500,0]],
[[804,642],[814,644],[818,676],[850,690],[838,728],[806,728],[772,752],[748,746],[764,724],[728,726],[710,708],[738,656],[764,668],[784,700],[806,702],[792,666],[804,642]],
[[1176,214],[1254,216],[1292,242],[1324,242],[1332,268],[1352,278],[1352,298],[1290,348],[1290,358],[1312,350],[1314,362],[1266,416],[1240,474],[1182,500],[1200,510],[1200,520],[1186,520],[1200,544],[1186,580],[1160,584],[1162,606],[1146,620],[1162,650],[1136,672],[1124,658],[1076,668],[1022,658],[1036,698],[1066,706],[1118,688],[1144,708],[1132,746],[1064,748],[1004,740],[990,668],[966,670],[946,648],[948,632],[962,628],[992,650],[1016,648],[1054,622],[1044,592],[1054,584],[1078,606],[1076,576],[1052,570],[1056,540],[1038,568],[1004,570],[976,526],[996,502],[958,496],[948,454],[962,454],[952,436],[964,390],[986,382],[974,368],[1004,376],[1018,420],[1052,434],[1060,482],[1078,490],[1062,472],[1062,442],[1104,450],[1104,436],[1142,422],[1154,402],[1110,424],[1046,416],[1022,388],[1022,344],[1002,344],[1018,318],[1060,308],[1076,272],[1104,288],[1122,246],[1140,230],[1168,234],[1176,214]],
[[974,698],[986,738],[964,740],[952,714],[974,698]],
[[842,596],[860,626],[848,622],[842,596]],
[[798,572],[792,606],[768,614],[740,580],[758,586],[798,572]],
[[892,584],[894,594],[882,588],[892,584]],
[[870,500],[912,538],[922,586],[908,590],[894,568],[864,564],[854,550],[868,538],[846,520],[854,500],[870,500]]
]
1 change: 1 addition & 0 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ areaTest('issue16', 12);
areaTest('issue17', 11);
areaTest('steiner', 9);
areaTest('issue29', 40);
areaTest('issue34', 139);
areaTest('self-touching', 124, 3.4e-14);
areaTest('outside-ring', 64);
areaTest('simplified-us-border', 120);
Expand Down

0 comments on commit 5313848

Please sign in to comment.