-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
[WIP] viewport label placement #4972
Conversation
So far I've switched CollisionTile to use viewport units and I've made it possible to switch the tile-specific parts of CollisionTile (matrix, collisionBoxArray). Right now I'm just trying to get to a hacky version of global viewport label placement so that we can unblock other work. I think steps are:
I'll work on:
|
and do placement every frame
…ecessary as long as we keep this all synchronous)
- Doesn't account for edges - Doesn't account for labels that rotate with the map - Shaders are still trying to account for perspective (needs to be removed) - Use of the collision grid got much simpler: we just put in projected coordinates and test for collisions... no more looking up the bounding boxes and calculating collision scales. - Collision grid dimensions/column count pretty much chosen at random - Get rid of no-longer-necessary placementThrottler - Get rid of (some) of "avoidEdges" logic (it doesn't play well with global collision detection) - Get rid of unused serialization code
…ion detection now works in pitched views.
Performance improvement: don't recalculate matrices for each layer
8119c71
to
161c018
Compare
… anchor point and perspective ratio.
… non-negligible cost in the profiler)
…-output (not used).
…every frame (but continue to do opacity updates on every frame).
…sed for a label even if we already know that the label is blocked.
…r labels that aren't anchored to a line.
…ce mathematical operations in circle/rect comparisons.
…eded (during collision detection)
Reload tiles when debug collision boxes are turned on so that buffers get generated.
Incidentally fixes issue #4897.
35e4424
to
36fd1b2
Compare
… fully faded out.
…ol_index, with opacities stored in the symbolInstances). Base fadeChange shader uniform on the last time the opacities for a bucket were updated.
…target opacity" for a symbol. Previous approximation was to just render for 300ms whenever there was a move event, but that could leave some fade animations incomplete until the next move (for instance, on a new tile load).
…the same way as freshly loaded tiles.
…ys become strings under the hood. (This would cause traversal of tile index in incorrect order, breaking label duplication assumptions)
- clone opacityState when we copy it -- otherwise, different tiles end up sharing the same opacity state object with undefined results - Don't copy opacityState from parent to child if the parent is the one being added to the index - TileCoord.isChildOf() needs sourceMaxZoom - Remove 'assert(symbolInstance.isDuplicate !== false)' on blockLabels. This assertion was saying that a child should only have to block one parent (because the others should already be blocked). But this wasn't true. Consider a label at zoom 10 blocking a label at zoom 9. If the same label is then added at zoom 8, the zoom 10 label will "block" a second parent (the one at zoom 8). - Remove 'assert(parentSymbolInstance.isDuplicate !== false)' on unblockLabels. The assumption here is that any duplicates we find on unblocking should have already been marked as duplicate. While it is the hoped-for behavior, it's not currently guaranteed, because it's possible for multiple symbols in one tile to show up as duplicate for the same symbol in a different tile. Added comment explaining the case.
…symbol duplication is causing targetOpacity to be set to 0).
ee51684
to
677b052
Compare
…00ms and 0ms providing instant collisions. Use 0ms/instant collisions for test suite. Also, fix bug in logic that tries to avoid line placement if a label is fully faded -- we need to make sure the label is fully faded (opacity == 0) AND we want the label to stay faded (targetOpacity == 0).
See distance_ratio comment in symbol_sdf: collision boxes are laid out in viewport space. Previous code looked like it inverted both terms, but: 1/(.5 + .5 * x/y) != .5 + .5 * y/x
Update Chinese tests to use new collision algorithm (not behavior preserving)
From discussion with @nickidlugash, our current plan is to continue supporting |
Here are the current known caveats for cross-tile symbol fading:
When the logic fails, you should just see a label fade out and then fade back in. I think it’s starting to look pretty acceptable… but we can definitely still improve. All of the above caveats can be fixed or at least mitigated (but at the cost of adding code complexity and some computation cost), although ultimately it’s not going to be 100% because “same label text and same anchor point” is just a heuristic. I'm not at all certain that the four points above account for all of the remaining flicker. My debugging approach so far has been to try to keep an internal data structure logging every cross-tile opacity update operation (keyed by label text), and then when I see flicker for a given label, looking it up in the data structure to see how it arrived at the flickering state. |
Switching from tiled label placement to global viewport label placement. #4704 WIP.
This PR dramatically changes our approach to collision detection. Instead of trying to pre-calculate collisions across a range of zooms in the background, we now calculate collisions synchronously in the foreground. Fade animations are no longer tied to zoom level, but instead based on time elapsed since collision occurred. This approach helps solve many problems:
The main structural changes are:
CollisionTile
is now a global object that lives only in the foreground. Insertions/queries into the collision index are now done entirely in viewport coordinates instead of tile coordinates.CrossTileSymbolIndex
.TODO:
symbol-avoid-edges
support (?)CollisionTile
), remove dead codeCrossTileSymbolIndex
grid_index_experimental
(adds support for circle geometry queries; removes support for cross-thread serialization): either update https://github.com/mapbox/grid-index, make a new library, or just continue to include the code directly.gl-native
api-gl
This PR will enable further changes that we're not tackling yet: