diff options
author | Ansis Brammanis <brammanis@gmail.com> | 2016-02-11 15:47:44 -0800 |
---|---|---|
committer | Ansis Brammanis <brammanis@gmail.com> | 2016-02-15 12:55:41 -0800 |
commit | cdab06306fb5d0f2e74d3264495b166bd440d4f8 (patch) | |
tree | 4e283ff57c6579684723ef204e0e2d8be68fc414 /src | |
parent | 9891d0eb794df7a6fa69afd5c56bc371101d41fc (diff) | |
download | qtlocation-mapboxgl-cdab06306fb5d0f2e74d3264495b166bd440d4f8.tar.gz |
[core] round points created by clipLines instead of truncating them
Diffstat (limited to 'src')
-rw-r--r-- | src/mbgl/util/clip_lines.cpp | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/src/mbgl/util/clip_lines.cpp b/src/mbgl/util/clip_lines.cpp index 3a909d674a..071e9d09bd 100644 --- a/src/mbgl/util/clip_lines.cpp +++ b/src/mbgl/util/clip_lines.cpp @@ -21,33 +21,33 @@ std::vector<std::vector<Coordinate>> clipLines(const std::vector<std::vector<Coo if (p0.x < x1 && p1.x < x1) { continue; } else if (p0.x < x1) { - p0 = { x1, static_cast<int16_t>(p0.y + (p1.y - p0.y) * ((float)(x1 - p0.x) / (p1.x - p0.x))) }; + p0 = { x1, static_cast<int16_t>(::round(p0.y + (p1.y - p0.y) * ((float)(x1 - p0.x) / (p1.x - p0.x)))) }; } else if (p1.x < x1) { - p1 = { x1, static_cast<int16_t>(p0.y + (p1.y - p0.y) * ((float)(x1 - p0.x) / (p1.x - p0.x))) }; + p1 = { x1, static_cast<int16_t>(::round(p0.y + (p1.y - p0.y) * ((float)(x1 - p0.x) / (p1.x - p0.x)))) }; } if (p0.y < y1 && p1.y < y1) { continue; } else if (p0.y < y1) { - p0 = { static_cast<int16_t>(p0.x + (p1.x - p0.x) * ((float)(y1 - p0.y) / (p1.y - p0.y))), y1 }; + p0 = { static_cast<int16_t>(::round(p0.x + (p1.x - p0.x) * ((float)(y1 - p0.y) / (p1.y - p0.y)))), y1 }; } else if (p1.y < y1) { - p1 = { static_cast<int16_t>(p0.x + (p1.x - p0.x) * ((float)(y1 - p0.y) / (p1.y - p0.y))), y1 }; + p1 = { static_cast<int16_t>(::round(p0.x + (p1.x - p0.x) * ((float)(y1 - p0.y) / (p1.y - p0.y)))), y1 }; } if (p0.x >= x2 && p1.x >= x2) { continue; } else if (p0.x >= x2) { - p0 = { x2, static_cast<int16_t>(p0.y + (p1.y - p0.y) * ((float)(x2 - p0.x) / (p1.x - p0.x))) }; + p0 = { x2, static_cast<int16_t>(::round(p0.y + (p1.y - p0.y) * ((float)(x2 - p0.x) / (p1.x - p0.x)))) }; } else if (p1.x >= x2) { - p1 = { x2, static_cast<int16_t>(p0.y + (p1.y - p0.y) * ((float)(x2 - p0.x) / (p1.x - p0.x))) }; + p1 = { x2, static_cast<int16_t>(::round(p0.y + (p1.y - p0.y) * ((float)(x2 - p0.x) / (p1.x - p0.x)))) }; } if (p0.y >= y2 && p1.y >= y2) { continue; } else if (p0.y >= y2) { - p0 = { static_cast<int16_t>(p0.x + (p1.x - p0.x) * ((float)(y2 - p0.y) / (p1.y - p0.y))), y2 }; + p0 = { static_cast<int16_t>(::round(p0.x + (p1.x - p0.x) * ((float)(y2 - p0.y) / (p1.y - p0.y)))), y2 }; } else if (p1.y >= y2) { - p1 = { static_cast<int16_t>(p0.x + (p1.x - p0.x) * ((float)(y2 - p0.y) / (p1.y - p0.y))), y2 }; + p1 = { static_cast<int16_t>(::round(p0.x + (p1.x - p0.x) * ((float)(y2 - p0.y) / (p1.y - p0.y)))), y2 }; } if (clippedLines.empty() || (!clippedLines.back().empty() && !(p0 == clippedLines.back().back()))) { |