From 36f4f77640c94d17a4b372dde0a3d680f470c47d Mon Sep 17 00:00:00 2001 From: Eric Fischer Date: Mon, 2 Nov 2015 11:43:44 -0800 Subject: [PATCH] Another polygon fix: if the outer ring was dropped, drop its inner rings too --- geometry.cc | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/geometry.cc b/geometry.cc index 3e3ada6f..586bfa46 100644 --- a/geometry.cc +++ b/geometry.cc @@ -344,6 +344,7 @@ drawvec reduce_tiny_poly(drawvec &geom, int z, int detail, bool *reduced, double long long pixel = (1 << (32 - detail - z)) * 2; *reduced = true; + bool included_last_outer = false; for (unsigned i = 0; i < geom.size(); i++) { if (geom[i].op == VT_MOVETO) { @@ -361,7 +362,7 @@ drawvec reduce_tiny_poly(drawvec &geom, int z, int detail, bool *reduced, double } area = area / 2; - if (fabs(area) <= pixel * pixel) { + if (fabs(area) <= pixel * pixel || (area < 0 && !included_last_outer)) { // printf("area is only %f vs %lld so using square\n", area, pixel * pixel); *accum_area += area; @@ -376,6 +377,10 @@ drawvec reduce_tiny_poly(drawvec &geom, int z, int detail, bool *reduced, double *accum_area -= pixel * pixel; } + + if (area >= 0) { + included_last_outer = false; + } } else { // printf("area is %f so keeping instead of %lld\n", area, pixel * pixel); @@ -384,6 +389,10 @@ drawvec reduce_tiny_poly(drawvec &geom, int z, int detail, bool *reduced, double } *reduced = false; + + if (area >= 0) { + included_last_outer = true; + } } i = j - 1;