diff --git a/src/libslic3r/PerimeterGenerator.cpp b/src/libslic3r/PerimeterGenerator.cpp index 7236f66ff4..89add59783 100644 --- a/src/libslic3r/PerimeterGenerator.cpp +++ b/src/libslic3r/PerimeterGenerator.cpp @@ -1033,6 +1033,18 @@ std::tuple, Polygons> generate_extra_perimeters_over }; if (!first_overhang_is_closed_and_anchored) { std::reverse(overhang_region.begin(), overhang_region.end()); + } else { + size_t min_dist_idx = 0; + double min_dist = std::numeric_limits::max(); + for (size_t i = 0; i < overhang_region.front().polyline.size(); i++) { + Point p = overhang_region.front().polyline[i]; + if (double d = lower_layer_aabb_tree.distance_from_lines(p) < min_dist) { + min_dist = d; + min_dist_idx = i; + } + } + std::rotate(overhang_region.front().polyline.begin(), overhang_region.front().polyline.begin() + min_dist_idx, + overhang_region.front().polyline.end()); } auto first_unanchored = std::stable_partition(overhang_region.begin(), overhang_region.end(), is_anchored); int index_of_first_unanchored = first_unanchored - overhang_region.begin(); diff --git a/src/libslic3r/SLAPrintSteps.cpp b/src/libslic3r/SLAPrintSteps.cpp index 3565f193a0..0e505dfc20 100644 --- a/src/libslic3r/SLAPrintSteps.cpp +++ b/src/libslic3r/SLAPrintSteps.cpp @@ -31,7 +31,7 @@ #include "I18N.hpp" #include - +#include "format.hpp" namespace Slic3r {