mirror of
https://codeberg.org/comaps/comaps
synced 2026-01-09 05:44:34 +00:00
[drape] Add FollowAndRotateRoute mode
This adds a new mode to rotate the camera towards the route while driving. This is done by looking ahead X number of seconds along the current route, up to the next turn, and calculating the angle between the current position and then. Squashed commits: [drape] Add bearing calculation via route lookahead while navigating [drape] Extract NavigationContext from OnLocationUpdate params [drape] Increase rotation animation duration during navigation [drape] Seperate route and compass rotation into two modes [drape] Reduce route lookahead maximum to 25 seconds [drape] Fix case where rotation was incorrectly considered invalid [drape] Make FollowAndRotateRoute mode only available during driving navigation [drape] Rewrite FollowedPolyline::GetLookaheadPoint [drape] Cleanup Signed-off-by: Leonardo Bishop <me@leonardobishop.net>
This commit is contained in:
committed by
Konstantin Pastbin
parent
0d01076c0f
commit
515cf98cef
@@ -7,6 +7,7 @@
|
||||
|
||||
#include "drape/pointers.hpp"
|
||||
|
||||
#include "routing/base/followed_polyline.hpp"
|
||||
#include "shaders/program_manager.hpp"
|
||||
|
||||
#include "platform/location.hpp"
|
||||
@@ -24,6 +25,24 @@ using TAnimationCreator = std::function<drape_ptr<Animation>(ref_ptr<Animation>)
|
||||
|
||||
class DrapeNotifier;
|
||||
|
||||
struct NavigationContext
|
||||
{
|
||||
bool m_isNavigable = false;
|
||||
double m_distanceToNextTurn = 0.0;
|
||||
double m_speedLimit = 0.0;
|
||||
routing::FollowedPolyline const * m_followedPolyline = nullptr;
|
||||
|
||||
NavigationContext() = default;
|
||||
|
||||
NavigationContext(bool navigable, double distanceToTurn, double speedLimit,
|
||||
routing::FollowedPolyline const & followedPolyline)
|
||||
: m_isNavigable(navigable)
|
||||
, m_distanceToNextTurn(distanceToTurn)
|
||||
, m_speedLimit(speedLimit)
|
||||
, m_followedPolyline(&followedPolyline)
|
||||
{}
|
||||
};
|
||||
|
||||
class MyPositionController
|
||||
{
|
||||
public:
|
||||
@@ -102,7 +121,7 @@ public:
|
||||
drape_ptr<MyPosition> && shape, Arrow3d::PreloadedData && preloadedData);
|
||||
void ResetRenderShape();
|
||||
|
||||
void ActivateRouting(int zoomLevel, bool enableAutoZoom, bool isArrowGlued);
|
||||
void ActivateRouting(int zoomLevel, bool enableAutoZoom, bool isArrowGlued, bool allowRouteRotation);
|
||||
void DeactivateRouting();
|
||||
|
||||
void EnablePerspectiveInRouting(bool enablePerspective);
|
||||
@@ -117,14 +136,15 @@ public:
|
||||
void OnEnterBackground();
|
||||
|
||||
void OnCompassTapped();
|
||||
void OnLocationUpdate(location::GpsInfo const & info, bool isNavigable, double distanceToNextTurn, double speedLimit,
|
||||
void OnLocationUpdate(location::GpsInfo const & info, df::NavigationContext const & navigationContext,
|
||||
ScreenBase const & screen);
|
||||
void OnCompassUpdate(location::CompassInfo const & info, ScreenBase const & screen);
|
||||
|
||||
void Render(ref_ptr<dp::GraphicsContext> context, ref_ptr<gpu::ProgramManager> mng, ScreenBase const & screen,
|
||||
int zoomLevel, FrameValues const & frameValues);
|
||||
|
||||
bool IsRotationAvailable() const { return m_isDirectionAssigned; }
|
||||
bool IsArrowRotationAvailable() const { return m_isArrowDirectionAssigned; }
|
||||
bool IsRouteRotationAvailable() const { return m_isRouteDirectionAssigned; }
|
||||
bool IsInRouting() const { return m_isInRouting; }
|
||||
bool IsRouteFollowingActive() const;
|
||||
bool IsModeChangeViewport() const;
|
||||
@@ -135,7 +155,8 @@ public:
|
||||
|
||||
private:
|
||||
void ChangeMode(location::EMyPositionMode newMode);
|
||||
void SetDirection(double bearing);
|
||||
void SetRouteDirection(double bearing);
|
||||
void SetArrowDirection(double bearing);
|
||||
|
||||
void ChangeModelView(m2::PointD const & center, int zoomLevel);
|
||||
void ChangeModelView(double azimuth);
|
||||
@@ -178,12 +199,15 @@ private:
|
||||
double m_errorRadius; // error radius in mercator.
|
||||
double m_horizontalAccuracy;
|
||||
m2::PointD m_position; // position in mercator.
|
||||
double m_drawDirection;
|
||||
double m_direction;
|
||||
double m_routeDirection;
|
||||
double m_arrowDirection;
|
||||
m2::PointD m_oldPosition; // position in mercator.
|
||||
double m_oldDrawDirection;
|
||||
double m_oldArrowDirection;
|
||||
|
||||
bool m_enablePerspectiveInRouting;
|
||||
bool m_enableAutoZoomInRouting;
|
||||
bool m_allowRouteRotationInRouting;
|
||||
double m_autoScale2d;
|
||||
double m_autoScale3d;
|
||||
|
||||
@@ -205,7 +229,8 @@ private:
|
||||
TAnimationCreator m_animCreator;
|
||||
|
||||
bool m_isPositionAssigned;
|
||||
bool m_isDirectionAssigned;
|
||||
bool m_isArrowDirectionAssigned;
|
||||
bool m_isRouteDirectionAssigned;
|
||||
bool m_isCompassAvailable;
|
||||
|
||||
bool m_positionIsObsolete;
|
||||
|
||||
Reference in New Issue
Block a user