-
Notifications
You must be signed in to change notification settings - Fork 208
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Hole connection bug #52
Comments
Not sure if this is the solution or just removes the trigger:
This still finds the same bridge-node in the outer ring, so I guess the problem lies somewhere in not filtering enough points after the split. |
Interesting, I didn't think it would be related to filtering. |
@hjanetzek filtering was there earlier, the reason it was dropped recently is discussed in #41. Do you think we should bring it back? Or could we fix it with a more targeted filtering, like in the split routine? https://github.com/mapbox/earcut/blob/master/src/earcut.js#L238-L240 |
@mourner in my opinion it would be better to filter out duplicate points and colinear segments in advance and have an extra mode to skip filtering. One way to fix this triangulation is to ensure that
|
@hjanetzek interesting! The I tried your suggestion to not consider duplicate vertices in Should we do one of these, revert the point filtering change, or try to figure out a more sophisticated fix? I'm not sure. |
@mourner reflex is said to be required by Eberly and seems to make sense for a valid connection. I guess checking But the zero area case in locallyInside should certainly be avoided :) |
@hjanetzek want to show the proposed fix (reflex angle check + locallyInside fix) in a PR? |
BTW, if we bring back duplicate/collinear point filtering prior to hole elimination and trinagulation, together with the reflex check, the touching holes case still fails hard. Or is this related to an edge locallyInside case? |
@mourner I'm not sure what the best solution for this issue is. That touching-holes fails with filtering in advance is rather a problem in splitEarcut: It causes to pick a split that cannot be successful. You can test it by dumping the rings after the split
|
@hjanetzek it's hard to choose which option is the best fix because we can't make a decision based on one failing test (which can be affected by a lot of things). So I made three branches |
@hjanetzek we ran some samples on 4 branches and looks like we have a winner here — https://gist.github.com/jakepruitt/5d8a834e6054d5f4265e While exploring the results, I suddenly discovered a bug in the current earcut master — it doesn't filter out the last point if it's equal to the first one when making an initial linked list. Fixing it fixes the issue above too. |
Test case:
It looks like this happens when a hole connects to outer polygon, then another hole connects to that hole through the same vertice, but since there are two vertices after eliminating the hole, one of the two connections leads to a broken outline. Should be fixable with some more checks in the
findHoleBridge
routine.cc @flippmoke @hjanetzek @jakepruitt
The text was updated successfully, but these errors were encountered: