Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaria Volvenkova <d.volvenkova@corp.mail.ru>2017-07-04 20:11:02 +0300
committerRoman Kuznetsov <r.kuznetsow@gmail.com>2017-07-05 11:55:38 +0300
commit9aadfb01e577437bd6dc18dae2e37357707d1841 (patch)
tree086bd382f2443124d509816b53d249ab053fb439 /drape_frontend/user_mark_shapes.cpp
parentc5441740bdbb0b915e2ebee090cb691311dc70d7 (diff)
User lines simplification.
Diffstat (limited to 'drape_frontend/user_mark_shapes.cpp')
-rw-r--r--drape_frontend/user_mark_shapes.cpp38
1 files changed, 35 insertions, 3 deletions
diff --git a/drape_frontend/user_mark_shapes.cpp b/drape_frontend/user_mark_shapes.cpp
index 13a5cfbb60..64a37be297 100644
--- a/drape_frontend/user_mark_shapes.cpp
+++ b/drape_frontend/user_mark_shapes.cpp
@@ -134,12 +134,44 @@ void CacheUserLines(TileKey const & tileKey, ref_ptr<dp::TextureManager> texture
dp::Batcher & batcher)
{
float const vs = static_cast<float>(df::VisualParams::Instance().GetVisualScale());
+ int const kLineSimplifyLevelStart = 15;
+ bool const simplify = tileKey.m_zoomLevel <= kLineSimplifyLevelStart;
+
+ double sqrScale;
+ if (simplify)
+ {
+ double const currentScaleGtoP = 1.0 / GetScale(tileKey.m_zoomLevel);
+ sqrScale = math::sqr(currentScaleGtoP);
+ }
+
for (auto lineIndex : indexes)
{
UserLineRenderParams & renderInfo = renderParams[lineIndex];
- auto const splines = m2::ClipSplineByRect(tileKey.GetGlobalRect(), renderInfo.m_spline);
- for (auto const & spline : splines)
+ m2::SharedSpline spline = renderInfo.m_spline;
+ if (simplify)
+ {
+ spline.Reset(new m2::Spline(renderInfo.m_spline->GetSize()));
+
+ static double minSegmentLength = math::sqr(4.0 * vs);
+ m2::PointD lastAddedPoint;
+ for (auto const & point : renderInfo.m_spline->GetPath())
+ {
+ if ((spline->GetSize() > 1 && point.SquareLength(lastAddedPoint) * sqrScale < minSegmentLength) ||
+ spline->IsPrelonging(point))
+ {
+ spline->ReplacePoint(point);
+ }
+ else
+ {
+ spline->AddPoint(point);
+ lastAddedPoint = point;
+ }
+ }
+ }
+
+ auto const clippedSplines = m2::ClipSplineByRect(tileKey.GetGlobalRect(), spline);
+ for (auto const & clippedSpline : clippedSplines)
{
for (auto const & layer : renderInfo.m_layers)
{
@@ -154,7 +186,7 @@ void CacheUserLines(TileKey const & tileKey, ref_ptr<dp::TextureManager> texture
params.m_minVisibleScale = 1;
params.m_rank = 0;
- LineShape(spline, params).Draw(make_ref(&batcher), textures);
+ LineShape(clippedSpline, params).Draw(make_ref(&batcher), textures);
}
}
}