forked from organicmaps/organicmaps
Fixed scaling in 3d for follow-and-rotate mode.
Conflicts: drape_frontend/frontend_renderer.cpp map/framework.cpp
This commit is contained in:
parent
6dff719947
commit
7d3027c5b5
7 changed files with 32 additions and 10 deletions
|
@ -510,7 +510,7 @@ void FrontendRenderer::OnResize(ScreenBase const & screen)
|
|||
{
|
||||
m2::RectD const viewportRect = screen.isPerspective() ? screen.PixelRectIn3d() : screen.PixelRect();
|
||||
|
||||
m_myPositionController->SetPixelRect(screen.PixelRect());
|
||||
m_myPositionController->SetPixelRect(viewportRect);
|
||||
m_viewport.SetViewport(0, 0, screen.GetWidth(), screen.GetHeight());
|
||||
m_contextFactory->getDrawContext()->resize(viewportRect.SizeX(), viewportRect.SizeY());
|
||||
RefreshProjection();
|
||||
|
@ -1251,6 +1251,9 @@ void FrontendRenderer::UpdateScene(ScreenBase const & modelView)
|
|||
TTilesCollection tiles;
|
||||
ResolveTileKeys(modelView, tiles);
|
||||
|
||||
m_myPositionController->UpdatePixelPosition(modelView);
|
||||
|
||||
m_overlayTree->ForceUpdate();
|
||||
auto removePredicate = [this](drape_ptr<RenderGroup> const & group)
|
||||
{
|
||||
return group->IsOverlay() && group->GetTileKey().m_styleZoomLevel > GetCurrentZoomLevel();
|
||||
|
|
|
@ -113,6 +113,11 @@ void MyPositionController::SetPixelRect(m2::RectD const & pixelRect)
|
|||
Follow();
|
||||
}
|
||||
|
||||
void MyPositionController::UpdatePixelPosition(ScreenBase const & screen)
|
||||
{
|
||||
m_pixelPosition = screen.P3dToP(GetCurrentPixelBinding());
|
||||
}
|
||||
|
||||
void MyPositionController::SetListener(ref_ptr<MyPositionController::Listener> listener)
|
||||
{
|
||||
m_listener = listener;
|
||||
|
@ -508,13 +513,17 @@ void MyPositionController::Follow(int preferredZoomLevel)
|
|||
if (currentMode == location::MODE_FOLLOW)
|
||||
ChangeModelView(m_position);
|
||||
else if (currentMode == location::MODE_ROTATE_AND_FOLLOW)
|
||||
ChangeModelView(m_position, m_drawDirection, GetRaFPixelBinding(), preferredZoomLevel);
|
||||
{
|
||||
ChangeModelView(m_position, m_drawDirection,
|
||||
m_pixelPosition,
|
||||
preferredZoomLevel);
|
||||
}
|
||||
}
|
||||
|
||||
m2::PointD MyPositionController::GetRaFPixelBinding() const
|
||||
{
|
||||
return m2::PointD (m_pixelRect.Center().x,
|
||||
m_pixelRect.maxY() - POSITION_Y_OFFSET * VisualParams::Instance().GetVisualScale());
|
||||
return m2::PointD(m_pixelRect.Center().x,
|
||||
m_pixelRect.maxY() - POSITION_Y_OFFSET * VisualParams::Instance().GetVisualScale());
|
||||
}
|
||||
|
||||
m2::PointD MyPositionController::GetCurrentPixelBinding() const
|
||||
|
|
|
@ -44,6 +44,7 @@ public:
|
|||
~MyPositionController();
|
||||
|
||||
void SetPixelRect(m2::RectD const & pixelRect);
|
||||
void UpdatePixelPosition(ScreenBase const & screen);
|
||||
void SetListener(ref_ptr<Listener> listener);
|
||||
|
||||
m2::PointD const & Position() const;
|
||||
|
@ -143,6 +144,7 @@ private:
|
|||
my::HighResTimer m_lastGPSBearing;
|
||||
|
||||
m2::RectD m_pixelRect;
|
||||
m2::PointD m_pixelPosition;
|
||||
|
||||
bool m_isVisible;
|
||||
bool m_isDirtyViewport;
|
||||
|
|
|
@ -138,6 +138,11 @@ m2::PointD Navigator::PtoG(m2::PointD const & pt) const
|
|||
return m_Screen.PtoG(pt);
|
||||
}
|
||||
|
||||
m2::PointD Navigator::P3dtoP(m2::PointD const & pt) const
|
||||
{
|
||||
return m_Screen.P3dToP(pt);
|
||||
}
|
||||
|
||||
bool Navigator::CanShrinkInto(ScreenBase const & screen, m2::RectD const & boundRect)
|
||||
{
|
||||
m2::RectD clipRect = screen.ClipRect();
|
||||
|
|
|
@ -32,6 +32,7 @@ public:
|
|||
|
||||
m2::PointD GtoP(m2::PointD const & pt) const;
|
||||
m2::PointD PtoG(m2::PointD const & pt) const;
|
||||
m2::PointD P3dtoP(m2::PointD const & pt) const;
|
||||
|
||||
void StartDrag(m2::PointD const & pt);
|
||||
void DoDrag(m2::PointD const & pt);
|
||||
|
|
|
@ -264,13 +264,11 @@ bool UserEventStream::SetScale(m2::PointD const & pxScaleCenter, double factor,
|
|||
// Reset current animation if there is any.
|
||||
ResetCurrentAnimation();
|
||||
|
||||
m2::PointD glbScaleCenter = m_navigator.PtoG(scaleCenter);
|
||||
m2::PointD glbScaleCenter = m_navigator.PtoG(m_navigator.P3dtoP(scaleCenter));
|
||||
if (m_listener)
|
||||
m_listener->CorrectGlobalScalePoint(glbScaleCenter);
|
||||
|
||||
ScreenBase screen = GetCurrentScreen();
|
||||
m_navigator.CalculateScale(scaleCenter, factor, screen);
|
||||
m2::PointD offset = GetCurrentScreen().PixelRect().Center() - scaleCenter;
|
||||
m2::PointD const offset = GetCurrentScreen().PixelRect().Center() - m_navigator.P3dtoP(scaleCenter);
|
||||
|
||||
auto const creator = [this, &glbScaleCenter, &offset](m2::AnyRectD const & startRect, m2::AnyRectD const & endRect,
|
||||
double aDuration, double mDuration, double sDuration)
|
||||
|
@ -279,6 +277,9 @@ bool UserEventStream::SetScale(m2::PointD const & pxScaleCenter, double factor,
|
|||
sDuration, glbScaleCenter, offset));
|
||||
};
|
||||
|
||||
ScreenBase screen = GetCurrentScreen();
|
||||
m_navigator.CalculateScale(scaleCenter, factor, screen);
|
||||
|
||||
return SetRect(screen.GlobalRect(), true, creator);
|
||||
}
|
||||
|
||||
|
|
|
@ -642,7 +642,8 @@ void Framework::ShowAll()
|
|||
|
||||
m2::PointD Framework::GetPixelCenter() const
|
||||
{
|
||||
return m_currentModelView.PixelRect().Center();
|
||||
return m_currentModelView.isPerspective() ? m_currentModelView.PixelRectIn3d().Center()
|
||||
: m_currentModelView.PixelRect().Center();
|
||||
}
|
||||
|
||||
m2::PointD const & Framework::GetViewportCenter() const
|
||||
|
@ -721,7 +722,7 @@ void Framework::Scale(Framework::EScaleMode mode, m2::PointD const & pxPoint, bo
|
|||
|
||||
void Framework::Scale(double factor, bool isAnim)
|
||||
{
|
||||
Scale(factor, m_currentModelView.PixelRect().Center(), isAnim);
|
||||
Scale(factor, GetPixelCenter(), isAnim);
|
||||
}
|
||||
|
||||
void Framework::Scale(double factor, m2::PointD const & pxPoint, bool isAnim)
|
||||
|
|
Loading…
Add table
Reference in a new issue