-
Notifications
You must be signed in to change notification settings - Fork 130
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
Use Node pointers plus object pool, eliminate separate vertices array #10
Conversation
Interesting! So you suggest storing Why would this be faster? Better memory access, or shorter path to data? |
Yeah, I don't know for sure that it would be faster, but intuitively, since you usually already have a |
I would like to eliminate the Lines 761 to 762 in bfbe17d
@mourner @kkaefer Is it somehow possible to reuse the existing Nodes in |
@jfirebaugh I believe not since new nodes have different prev/next/prevZ/nextZ pointers. However, polygon split is a relatively rare occurrence — once for each hole and a few more times in case of bad data, so maybe you could do some manual dynamic allocation magic specifically for these. |
👍 for merging, @kkaefer said 👍 in Slack too. |
This brings the code closer to the JS implementation, and ensures that it is usable by mapbox-gl-native per #9.
It turned out that discarding unused vertices was not the only way that the indices generated by earcut.hpp were out of sync with input order indices. There were two other sources of desynchronization:
linkedList
(fixed in c18fa5c)@mourner This implements an optimization I think we should try for the JS implementation: f4b0a71.
Before
After
So the degenerate results are slower, but they are super fast anyway. Real-world cases are a wash.
cc @kkaefer