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
symbol sorting for viewport labelling #5298
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall looks good to me (pending tests passing).
src/gl/index_buffer.js
Outdated
} | ||
|
||
bind() { | ||
this.gl.bindBuffer(this.gl.ELEMENT_ARRAY_BUFFER, this.buffer); | ||
} | ||
|
||
updateData(array: TriangleIndexArray | LineIndexArray) { | ||
this.bind(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does it make sense to assert here that it's in dynamicDraw
mode?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yep!
src/data/bucket/symbol_bucket.js
Outdated
const symbolInstance = this.symbolInstances[i]; | ||
|
||
for (const placedTextSymbolIndex of symbolInstance.placedTextSymbolIndices) { | ||
const placedSymbol = this.placedGlyphArray.get(placedTextSymbolIndex); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Am I right in reading this as "we sort symbols within a segment, but symbols can't reorder between segments"? And if that's the case, aren't we basically giving up on sorting when there are multiple segments? That seems OK since this is an edge case, but if we're going to give up, why not just early-exit the entire sorting process?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, it's kind of giving up. I hadn't thought about an early-exit but that's probably cleaner. This approach sorts them so that they look mostly right, but is more complicated and probably error-prone. I'll switch to an early exit!
Oh also as part of these changes we should un-ignore the tests tagged 5150 in |
Err, another concern: doesn't this break the debug collision boxes/circles for sorted symbols? Their index arrays will need the same re-sorting... |
Nope, this leaves collision box rendering unchanged. Their boxes are rendered un an unsorted order, but that seems ok to consider it's just a debug view and these symbols are all allowed to overlap. |
🤦♂️ I didn't think that through all the way -- forgot you're not changing the sort of the |
41a2181
to
019fb57
Compare
cc18560
to
07acec3
Compare
019fb57
to
41a2181
Compare
which was previously used to sort symbols before buffer creation.
07acec3
to
57d6963
Compare
Previously the symbols were sorted in the y direction before running them through the collision code. Now only the rendering is sorted and the collision order depends on the original data order. I think this is the right approach because: - we should respect data order so that it can be used for label importance - data order is consistent, while y order changes with rotation
Looks great to me, let's merge it into We can do it on either branch, but we should be able to remove these three ignores now:
We'll have to update the expected results, but the new results should be unambiguously better. 😃 |
This sorts symbols that may overlap based on their vertical position. The sorting happens at the end of symbol placement within
commitPlacement
.The sorting happens in each tile independently. This means there might be incorrect sorting near tile edges but I think that fixing that minor drawback would be not worth the added complexity. Unless we switch back to the clipping approach we used before.
@ChrisLoer