Commit Graph

59 Commits

Author SHA1 Message Date
Minh Nguyễn
d26b956a48 [core] Cleaned up Transform
Eliminated many redundant methods on Transform. Minimized usage of TransformState::x and TransformState::y. Added convenient constructors for AnimationOptions. When scaling, passing in view’s origin as the anchor no longer anchors the scaling operation at the view’s center. To specify no anchor, use NaN.

Increased precision of worldSize(), now that it’s used much more heavily in transform methods.
2016-01-14 00:39:18 -08:00
Minh Nguyễn
27b308a234 [core] Separated AnimationOptions from CameraOptions 2016-01-14 00:39:12 -08:00
Minh Nguyễn
63820d1b4f [core] Always constrain width for zoom level
Even if the map supports wrapping the world, it isn’t necessary to show more than one full revolution of the world at a time. Removed a redundant zoom level clamp.
2015-12-24 16:24:45 -08:00
Minh Nguyễn
d668c0fa84 [ios, osx] Better zoom level–altitude conversion
Greatly simplified conversions between zoom level and altitude. Adjusted field of view to more closely match MapKit. Conversions are now well within the same order of magnitude as MapKit at all latitudes.

Fixes #2266.
2015-12-20 03:57:28 -08:00
Minh Nguyễn
a5230f3e11 [core] Clamp pitch in easeTo(), flyTo()
Also factored out the maximum pitch into a constant.
2015-12-19 23:14:01 -08:00
Minh Nguyễn
0a9b6a82e4 [core] Reformulated flyTo options
The speed and curve fields in CameraOptions have been replaced with velocity and minZoom fields, which expressed in screen units. Scaling and easing make it difficult to derive options that are expressed in physical units.
2015-12-19 20:33:18 -08:00
Minh Nguyễn
97c143a338 [core] Fly across the meridian or antemeridian, whichever is shorter
ref mapbox/mapbox-gl-js#1853
2015-12-19 20:33:18 -08:00
Minh Nguyễn
af9de6c0ac [core] Refined and commented flyTo
Rewrote the flyTo implementation to more closely match GL JS’s implementation and the paper on which it is based.

Rewrote CameraOptions documentation. Only document units for generic types like double. The semantics of LatLng and Duration are already baked into the types; one just needs to look up the types’ definitions. Also, the […) is set notation, so the braces are supposed to be mismatched.

Fixes #3296.
2015-12-19 20:31:40 -08:00
Brad Leege
925687ab06 [android] #3244 - Removing debug log statements 2015-12-18 14:39:02 -06:00
Brad Leege
f7d1a40350 [android] Camera API 2015-12-18 11:33:40 -08:00
Minh Nguyễn
986e0ae39e [core] Added special case for atomic flyTo()
startTransition isn’t well-suited to atomic transitions, which are expected to be synchronous and end up at the final state.
2015-12-17 10:24:58 -08:00
Minh Nguyễn
e1854f0f26 [core] Corrected flying trajectory; pitched flight
Corrected some fairly opaque code that was incorrectly ported from GL JS the first time around in #3171, causing the trajectory to extend far into the Earth’s orbit. Also transition pitch while flying, call transition frame/finish callback functions, and recognize the same “speed” and “curve” parameters that GL JS does.

Fixes #3296, fixes #3297.
2015-12-15 12:52:13 -08:00
Konstantin Käfer
4fc8226838 [core] allow changing the orientation
You can now change the orientation of north to be to the right, bottom, left in addition to the default of top
2015-12-15 11:41:58 -08:00
Thiago Marcos P. Santos
9af7594d61 [core] Use global namespace on some <cmath> functions
Improves compatibility as some old std libs don't have them
on the std:: namespace.
2015-12-11 17:12:31 -08:00
Adam Hunter
095a8be300 Implementation of flyTo. 2015-12-09 17:14:22 -08:00
Minh Nguyễn
2de0a351a0 [core] [iOS] Completion handlers for animated methods
Added transition frame and finish functions to CameraOptions. Added Objective-C equivalents to the three main entry points to easeTo() in MGLMapView.

Fixes #1581.
2015-11-25 15:20:25 -08:00
Bruno de Oliveira Abinader
adfac6f061 [core] Added ConstrainMode::{HeightOnly,WidthAndHeight}
ConstrainMode gives flexibility to our engine to choose between
constraining both vertically and horizontally, or just vertically
(default behavior).

Constrain in both axis means we can no longer pan the map beyond the map
boundaries. This fixes an issue where e.g. annotations disappear upon
crossing the map boundaries.
2015-11-18 09:37:27 +02:00
Bruno de Oliveira Abinader
711d41f91b [core] Avoid extra copy of TransformState in Painter::render
In MapContext thread, TransformState gets updated from main thread to
MapContext and Painter can safely reference MapContext's TransformState
instead of copying it upon each Painter::render call.
2015-11-18 09:37:27 +02:00
Bruno de Oliveira Abinader
fc2fa73363 [core] Cleanup Transform::rotateBy
Make use of PrecisionPoint's operator functionalities inherited from
vec2<> and reduced overhead eg. offset_y is always 0 so no need to add
this to calculation inside the if.
2015-11-12 10:46:50 -08:00
Bruno de Oliveira Abinader
8b76f00d8c [core] PrecisionPoint is now a vec2<double>
We could reuse all the operators defined in vec2<>, including operator
bool() that checks if the contained values are !NaN.
2015-11-12 10:46:50 -08:00
Minh Nguyễn
aae7f90e37 [core] Fixed Transform::_setScale()
Corrected Transform::_setScale() after the refactoring in 5a24ac605b for #2994. This change also addresses two dead store warnings from the static analyzer.
2015-11-12 10:46:43 -08:00
Bruno de Oliveira Abinader
cd0266f25c [core] Added more NaN checks in Transform 2015-11-11 16:59:49 +02:00
Bruno de Oliveira Abinader
5a24ac605b [core] Use PrecisionPoint in zoom and angle functions 2015-11-11 16:59:49 +02:00
Bruno de Oliveira Abinader
99ac8d8720 [core] Use pass-by-ref in CameraOptions
Pass-by-const-ref is not always possible because CameraOptions gets its
members modified along the way.

Also fixes a case in Map::jumpTo where Update::Zoom should be called if
zoom is affected.
2015-11-11 16:59:49 +02:00
Bruno de Oliveira Abinader
c78e769635 [core] Use PrecisionPoint in coordinate functions 2015-11-11 16:59:49 +02:00
Bruno de Oliveira Abinader
e2052ea3e4 [core] Added PrecisionPoint to represent pixel points 2015-11-11 16:59:49 +02:00
Bruno de Oliveira Abinader
e5c460f2db [core] Added isValid to geo helper structs 2015-11-11 16:59:49 +02:00
Minh Nguyễn
17451418cc [core] Update after final frame of transition
The final frame is self-destructing – it destroys the frame and finish functions – so technically we’re no longer inTransition(). Yet there still needs to be an update after that final frame.

Also, avoid a redundant change notification on the last frame. (It would come too late, after the DidChange notification, anyhow.)

Fixes #2946.
2015-11-06 11:06:53 -08:00
Ansis Brammanis
750c72f324 improve gestures in perspective view
The location under your finger stays under your finger as you pan.
The location you double tap to zoom stays at the same point.
The location at the center of a pinch zoom stays at the center.
The location at the center of a rotation stays at the center.
2015-10-26 12:48:03 -07:00
Minh Nguyễn
0a172a21fd CameraOptions
Plumbed camera options all the way through to MGLMapView. Added a method that lets you specify a direction in addition to center point and zoom level.

Added Map::jumpTo() for parity with mapbox-gl-js. Replaced usage of Map::setLatLng() and Map::setLatLngZoom() with Map::jumpTo() or Map::easeTo() within MGLMapView. Replaced MGLMapView.pitch with MGLMapCamera for setting all supported degrees of freedom simultaneously. Simultaneously move and rotate with course.

Support customizable timing functions on iOS.

iosapp now persists an archived MGLMapCamera instead of separate viewpoint properties and also synchronizes user defaults on termination. This change implements persistence entirely in Objective-C, eliminating the use of the Objective-C++ implementation.

Fixes #1643, fixes #1834. Ref #1581.
2015-09-07 09:22:52 -07:00
Bruno de Oliveira Abinader
0b501e0566 Substitute nudgeTransitions with async view invalidation 2015-09-02 23:20:46 +03:00
Ansis Brammanis
14dee43a71 add map.setPitch(pitch) and map.getPitch() 2015-08-24 18:41:51 -04:00
Bruno de Oliveira Abinader
5ff855bb00 Fix Update flags in mbgl::Transform
Transform::{_moveBy,_setAngle} were returning Update::Nothing, causing
the render to not repaint. Replacing with Update::Repaint fixes the
issue.

Fixes #2036.
2015-08-13 10:17:08 +03:00
Bruno de Oliveira Abinader
ac9d5886f0 Added operator implementations for mbgl::Update enum class 2015-08-13 10:12:48 +03:00
Bruno de Oliveira Abinader
58357b7964 Removed Transform::needsTransition()
Transform::updateTransitions() already checks if there is a callback to
update transitions.
2015-08-05 15:19:00 +03:00
Konstantin Käfer
78ec33320f don't use certain STL functions
some functions defined in <cmath>, as well as std::to_string aren't available on GNU's STL for some platforms, e.g. Android
2015-08-04 14:08:19 +02:00
Bruno de Oliveira Abinader
2aad2f4e14 Pass {Duration,TimePoint} by const ref if possible 2015-07-14 16:48:34 +03:00
Konstantin Käfer
675ddddee7 Make pixelRatio constant across a Map object lifetime
also moves framebuffer size out of TransformState into its own object
2015-07-08 10:40:05 +02:00
Minh Nguyễn
08acb65b1c Eliminated map overrotation on drift pan
Wrap the angle on each interpolated step instead of when normalizing.
2015-07-06 13:08:59 -07:00
Minh Nguyễn
46a6173bd7 [wrap)
If (wrap] is desired, it is the responsibility of the caller to handle the case in which min is returned.
2015-07-06 13:07:34 -07:00
John Firebaugh
95351dd906 Send MapChangeRegionIsChanging notifications 2015-06-26 10:32:07 -07:00
John Firebaugh
d193083513 Remove duration argument from View::notifyMapChange
Fixes #1026
2015-06-26 10:32:07 -07:00
John Firebaugh
e6a576f6eb currentState() ⇢ getState() 2015-06-26 10:32:07 -07:00
John Firebaugh
07a6d2ef64 Move Transform from MapData to Map
Pass current state to MapContext where needed. Remove mutex from
Transform.
2015-06-26 10:32:07 -07:00
John Firebaugh
e87a36444f Move getMin/MaxZoom to TransformState 2015-06-26 10:32:07 -07:00
John Firebaugh
4ba78b6bcf Transform needs only a single TransformState 2015-06-24 13:08:36 -07:00
Konstantin Käfer
f4707f72e0 Replace mbgl::util::make_unique<> with std::make_unique<> 2015-05-26 17:57:38 +02:00
Minh Nguyễn
b6765a2eb1 Merge pull request #1453 from mapbox/1ec5-whee-2
Prevent full-circle spin during animated rotation
2015-05-19 16:18:26 -07:00
Konstantin Käfer
24ea920810 ignore Transform changes with NaN parameters 2015-05-08 20:25:47 +02:00
Minh Nguyễn
d876274ad1 Prevent full-circle spin during animated rotation
#1295 made #1199 a lot less common, but it was still possible for the map to do a full 180° when drift-rotating past due-south. With this change, the map is atomically rotated to a bearing in the same cycle as the final bearing.

/cc @friedbunny
2015-05-06 16:38:59 -07:00