diff options
author | r.kuznetsov <r.kuznetsov@corp.mail.ru> | 2015-06-08 17:32:44 +0300 |
---|---|---|
committer | r.kuznetsov <r.kuznetsov@corp.mail.ru> | 2015-11-30 16:08:34 +0300 |
commit | afe8f28d0c4f4d28f2448e214476ebea7b2a397d (patch) | |
tree | f386d4dd8ca823727f50b400e5b7f95a0fded3de /drape_frontend/line_shape_helper.cpp | |
parent | 843f3c3c7838aa0f1e6c39e736af51967f50bf94 (diff) |
Added route clipping
Diffstat (limited to 'drape_frontend/line_shape_helper.cpp')
-rw-r--r-- | drape_frontend/line_shape_helper.cpp | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/drape_frontend/line_shape_helper.cpp b/drape_frontend/line_shape_helper.cpp index b60e47b7da..afa3e574ef 100644 --- a/drape_frontend/line_shape_helper.cpp +++ b/drape_frontend/line_shape_helper.cpp @@ -217,4 +217,15 @@ glsl::vec2 GetNormal(LineSegment const & segment, bool isLeft, ENormalType norma segment.m_rightWidthScalar[index].x * segment.m_rightNormals[index]; } +float GetProjectionLength(glsl::vec2 const & newPoint, glsl::vec2 const & startPoint, + glsl::vec2 const & endPoint) +{ + glsl::vec2 const v1 = endPoint - startPoint; + glsl::vec2 const v2 = newPoint - startPoint; + float const squareLen = glsl::dot(v1, v1); + float const proj = glsl::dot(v1, v2) / squareLen; + return sqrt(squareLen) * my::clamp(proj, 0.0f, 1.0f); +} + } // namespace df + |