-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
make symbol sorting more deterministic #2023
Conversation
@@ -40,6 +40,8 @@ function SymbolBucket(options) { | |||
|
|||
this.adjustedIconMaxSize = this.layer.getLayoutValue('icon-size', 18, zoomHistory); | |||
this.adjustedIconSize = this.layer.getLayoutValue('icon-size', this.zoom + 1, zoomHistory); | |||
|
|||
this.index = 0; |
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.
Could we get away with passing k
to addFeature
here instead? I'd prefer that to adding another class property.
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.
SymbolInstance
s for the same feature still need different values. We could do something like k * 10000 + j
but that seems a bit messier.
The value doesn't need to be an index, it just needs to be a unique value we can generate the same way in both -js and -native.
I thought generating it from the position, angle and style properties but that just seems way more complicated.
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.
My concern isn't using the index conceptually but adding additional state to the SymbolBucket
class. It's ok for the context of this PR but makes my future a little harder.
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.
this.symbolInstances.length
should work!
Why subsort by index instead of x coordinate? |
Two features could have the same position but have other properties be different. You'd also have to sort by the angle and per-feature properties like text-field, icon-name and all the data-driven ones eventually. It seemed simpler to just have a counter. It doesn't need to be an index, it just needs to be unique for each instance and consistently generatable. |
I'm |
45a731a
to
7213285
Compare
The order of symbols with the same y value (after rotation) was undefined, which was causing some rendering differences with -native.
test-suite changes:
mapbox/mapbox-gl-test-suite@7ebad04
I'll make the same change in -native.
👀 @lucaswoj