Repository navigation
Search with equal priority in both z-order directions - #93
Merged
Merged
Conversation
Contributor
Author
|
I also tried searching in order of increasing z-distance from the current point -- i.e. advance only one of |
mourner
approved these changes
Jan 3, 2018
mourner
left a comment
Member
There was a problem hiding this comment.
This is great!
Can we eliminate the “remainder” loops by changing the conditions in the main one?
Contributor
Author
|
Adding additional branches to the loop seems to negate the performance improvement. E.g.: var p = ear.prevZ,
n = ear.nextZ,
hasPrev = p && p.z >= minZ,
hasNext = n && n.z <= maxZ;
// look for points inside the triangle in both directions
while (hasPrev || hasNext) {
if (hasPrev) {
if (p !== ear.prev && p !== ear.next &&
pointInTriangle(a.x, a.y, b.x, b.y, c.x, c.y, p.x, p.y) &&
area(p.prev, p, p.next) >= 0) return false;
p = p.prevZ;
hasPrev = p && p.z >= minZ;
}
if (hasNext) {
if (n !== ear.prev && n !== ear.next &&
pointInTriangle(a.x, a.y, b.x, b.y, c.x, c.y, n.x, n.y) &&
area(n.prev, n, n.next) >= 0) return false;
n = n.nextZ;
hasNext = n && n.z <= maxZ;
}
} |
3 of 5 tasks
Member
|
Published as v2.1.3. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This gives a slight speedup for more complex polygons.
Before:
After:
Results in gl-js:
https://bl.ocks.org/anonymous/raw/c415471d58758dd81650dec97d35b2f8/