-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Fix rotation edge cases and compass overspinning #1829
Conversation
👍 Want to port the wrap change to gl-js too? |
It's still possible to trigger #1558 by doing a sharp-rotate across 180º, but only going right-to-left. |
Also, when tapping to reset to north, the compass does a strange little jaunt in the opposite direction before correcting to north. |
Sure, once I’m reasonably confident about this change.
Does 2ccb4e94f4936b6be1ffefb6c6ef0de48a6a1664 do the trick?
Happens in master too. Turn on Slow Animations (⌘T) in the Simulator to see it. |
4936f8637e12967a3046a7716aa3c598e966b968 fixes the compass overspinning. |
As I pointed out in #1582 (comment), we need to be careful about updating Cocoa-side state in response to model/mbgl changes. Something like 4936f8637e12967a3046a7716aa3c598e966b968 will be required for #1582 as well. |
Nope, though the behavior has changed. Sharply rotating over 180º from either direction will get the compass stuck on the screen upon tapping, but doing it again the reverse direction will unstick it. 😁 I'll fiddle around with this over the long weekend. |
Look good to you, @friedbunny? |
Fixed a bug in which -[MGLMapView direction] could return 360 instead of 0. Switched to mbgl::util::wrap() for clarity. -updateCompass now relies on -direction to avoid code duplication.
Rely on mbgl to drive compass rotation for simplicity. Eliminated fall-through from mbgl::MapChangeRegionIsChanging to mbgl::MapChangeRegionDidChange, because is-changing should not cause did-change to be fired.
Wrap the angle on each interpolated step instead of when normalizing.
|
This PR addresses some edge cases around bearing, obsoleting #1558:
mbgl::util::wrap()
is now min-inclusive, max-exclusive. It is the responsibility of the caller to handle the case in whichmin
is returned. Previously,wrap(360, 0, 360)
would return 360 butwrap(720, 0, 360)
would return 0. This is how mapbox-gl-js behaves, but I believe the max-exclusive behavior is more predictable.-[MGLMapView direction]
now returns a value in the range [0, 360) instead of [0, 360]./cc @mourner @friedbunny @kkaefer