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

make symbol sorting more deterministic #2023

Merged
merged 1 commit into from
Jan 30, 2016
Merged

make symbol sorting more deterministic #2023

merged 1 commit into from
Jan 30, 2016

Conversation

ansis
Copy link
Contributor

@ansis ansis commented Jan 29, 2016

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

@@ -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;
Copy link
Contributor

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SymbolInstances 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.

Copy link
Contributor

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.

Copy link
Contributor Author

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!

@lucaswoj
Copy link
Contributor

Why subsort by index instead of x coordinate?

@ansis
Copy link
Contributor Author

ansis commented Jan 29, 2016

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.

@lucaswoj
Copy link
Contributor

I'm :shipit: once #2023 (comment) is merged in.

@ansis ansis force-pushed the sort-order-symbols branch from 45a731a to 7213285 Compare January 30, 2016 01:07
@ansis ansis merged commit 7213285 into master Jan 30, 2016
@ansis ansis removed the in progress label Jan 30, 2016
@ansis ansis deleted the sort-order-symbols branch January 30, 2016 01:14
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

Successfully merging this pull request may close these issues.

2 participants