Don't accumulate tiny polygon holes as negative dust

This commit is contained in:
Erica Fischer
2022-11-07 16:03:59 -08:00
parent 31a90cbbbd
commit f5bd2a7522
5 changed files with 23 additions and 20 deletions
+6 -3
View File
@@ -632,12 +632,12 @@ drawvec reduce_tiny_poly(drawvec &geom, int z, int detail, bool *reduced, double
// inner rings must just have their area de-accumulated rather
// than being drawn since we don't really know where they are.
// i.e., this ring (inner or outer) is small enough that we are including it
// i.e., this outer ring is small enough that we are including it
// in a tiny polygon rather than letting it represent itself,
// OR it is an inner ring and we haven't output an outer ring for it to be
// cut out of, so we are just subtracting its area from the tiny polygon
// rather than trying to deal with it geometrically
if (std::fabs(area) <= pixel * pixel || (area < 0 && !included_last_outer)) {
if ((area > 0 && 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;
@@ -659,10 +659,13 @@ drawvec reduce_tiny_poly(drawvec &geom, int z, int detail, bool *reduced, double
}
}
// i.e., this ring is large enough that it gets to represent itself
// or it is a tiny hole out of a real polygon, which we are still treating
// as a real geometry because otherwise we can accumulate enough tiny holes
// that we will drop the next several outer rings getting back up to 0.
else {
// printf("area is %f so keeping instead of %lld\n", area, pixel * pixel);
for (size_t k = i; k <= j && k < geom.size(); k++) {
for (size_t k = i; k < j && k < geom.size(); k++) {
out.push_back(geom[k]);
}