From 2594ed7f1d7f5fb4307adae3c42b3fdc75e3a1f2 Mon Sep 17 00:00:00 2001 From: Erica Fischer Date: Thu, 27 Jul 2023 14:59:31 -0700 Subject: [PATCH] Also makes no difference... --- geometry.cpp | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/geometry.cpp b/geometry.cpp index 48526a031..7ee2035b1 100644 --- a/geometry.cpp +++ b/geometry.cpp @@ -104,11 +104,14 @@ drawvec from_tile_scale(drawvec const &geom, int z, int detail) { drawvec remove_noop(drawvec geom, int type, int shift) { // first pass: remove empty linetos - long long x = 0, y = 0; + long long ox = 0, oy = 0; drawvec out; for (size_t i = 0; i < geom.size(); i++) { - if (geom[i].op == VT_LINETO && std::round((double) geom[i].x / (1LL << shift)) == x && std::round((double) geom[i].y / (1LL << shift)) == y) { + long long nx = std::round((double) geom[i].x / (1LL << shift)); + long long ny = std::round((double) geom[i].y / (1LL << shift)); + + if (geom[i].op == VT_LINETO && nx == ox && ny == oy) { continue; } @@ -116,8 +119,8 @@ drawvec remove_noop(drawvec geom, int type, int shift) { out.push_back(geom[i]); } else { /* moveto or lineto */ out.push_back(geom[i]); - x = std::round((double) geom[i].x / (1LL << shift)); - y = std::round((double) geom[i].y / (1LL << shift)); + ox = nx; + oy = ny; } } @@ -130,14 +133,17 @@ drawvec remove_noop(drawvec geom, int type, int shift) { for (size_t i = 0; i < geom.size(); i++) { if (geom[i].op == VT_MOVETO) { if (i + 1 >= geom.size()) { + // followed by end-of-geometry: not needed continue; } if (geom[i + 1].op == VT_MOVETO) { + // followed by another moveto: not needed continue; } if (geom[i + 1].op == VT_CLOSEPATH) { + // followed by closepath: not possible fprintf(stderr, "Shouldn't happen\n"); i++; // also remove unused closepath continue; @@ -155,8 +161,10 @@ drawvec remove_noop(drawvec geom, int type, int shift) { out.resize(0); for (size_t i = 0; i < geom.size(); i++) { - if (geom[i].op == VT_MOVETO) { - if (i > 0 && geom[i - 1].op == VT_LINETO && std::round((double) geom[i - 1].x / (1LL << shift)) == std::round((double) geom[i].x / (1LL << shift)) && std::round((double) geom[i - 1].y / (1LL << shift)) == std::round((double) geom[i].y / (1LL << shift))) { + if (i > 1 && geom[i].op == VT_MOVETO) { + if (geom[i - 1].op == VT_LINETO && + std::round((double) geom[i - 1].x / (1LL << shift)) == std::round((double) geom[i].x / (1LL << shift)) && + std::round((double) geom[i - 1].y / (1LL << shift)) == std::round((double) geom[i].y / (1LL << shift))) { continue; } }