Skip to content
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

Don't discard unused vertices #9

Closed
jfirebaugh opened this issue Oct 5, 2015 · 2 comments
Closed

Don't discard unused vertices #9

jfirebaugh opened this issue Oct 5, 2015 · 2 comments

Comments

@jfirebaugh
Copy link
Contributor

Discarding unused vertices makes earcut.hpp output unworkable for mapbox-gl-native due to the following:

  • Fill outlines use GL_LINES with indexed vertices
  • This requires knowing which vertex indexes correspond to which polygon rings
  • We want to share the same vertex indices with fill triangles
  • Therefore the indexes used by earcut need to correspond to the input vertex order -- no removal of vertices unused by triangulation
  • Once that's the case, then we are able to loop through the vertices in input order, add them to the buffer, and add the indices of ring vertices to the line elements buffer

The JS implementation does not remove unused vertices.

cc @mourner @kkaefer to double check my logic.

@mourner
Copy link
Member

mourner commented Oct 5, 2015

Yes, after I switched the JS implementation to indexed output, the output indices now reference the original input array. Unused vertices are a rare occurrence anyway, and reusing the input array makes performance better.

@jfirebaugh
Copy link
Contributor Author

Fixed by #10.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants