Fix issue #5248: don't redo placement for zoom changes of low-pitch m… #5284
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.
Fixes #5248.
aefb3ee introduced
redoPlacement
calls in response to any map move, since any movement could potentially affect collision detection with the new pitch-scaling behavior. To prevent incurring extra/unnecessary placement costs, I did a couple things:However, I forgot that the transform parameter
cameraToCenterDistance
would be changing with every zoom change, and that zoom changes didn't previously trigger placement. While zoom changes (and anything else that affectscameraToCenterDistance
, like changing the field of view) do affect collision detection, the effects are minimal at low pitch and can be safely ignored.When the cost of placement is relatively low, this is not a very substantial difference, because the throttling limits placement to once every 300ms anyway. When placement is significantly more expensive (as in #5208), the placement can end up running continuously during zoom operations, which is a waste (we should only have to re-do placement when we cross integer zoom levels).
This PR fixes the oversight and introduces one unit test to verify that
redoPlacement
is actually being suppressed.This will hopefully all be superseded soon by #5150.
bench results
The benchmarks don't really exercise the use case this PR addresses, so this is just a sanity check.
/cc @jfirebaugh @ansis