diff --git a/src/libslic3r/GCode/AvoidCrossingPerimeters.cpp b/src/libslic3r/GCode/AvoidCrossingPerimeters.cpp index 1f538862b..d29f7216a 100644 --- a/src/libslic3r/GCode/AvoidCrossingPerimeters.cpp +++ b/src/libslic3r/GCode/AvoidCrossingPerimeters.cpp @@ -254,7 +254,7 @@ static std::vector extend_for_closest_lines(const std::vector new_intersections = intersections; - if (!intersections.empty() && !start_lines.empty()) { + if (!new_intersections.empty() && !start_lines.empty()) { size_t cl_start_idx = get_closer(start_lines, new_intersections.front(), start); if (cl_start_idx != std::numeric_limits::max()) { // If there is any ClosestLine around the start point closer to the Intersection, then replace this Intersection with ClosestLine. @@ -265,11 +265,13 @@ static std::vector extend_for_closest_lines(const std::vector::max()) ? start_lines[start_closest_lines_idx] : start_lines.front(); new_intersections.insert(new_intersections.begin(),{cl_start.border_idx, cl_start.line_idx, cl_start.point, compute_distance(cl_start)}); } - } else if (!intersections.empty() && !end_lines.empty()) { + } + + if (!new_intersections.empty() && !end_lines.empty()) { size_t cl_end_idx = get_closer(end_lines, new_intersections.back(), end); if (cl_end_idx != std::numeric_limits::max()) { // If there is any ClosestLine around the end point closer to the Intersection, then replace this Intersection with ClosestLine. @@ -280,7 +282,7 @@ static std::vector extend_for_closest_lines(const std::vector::max()) ? end_lines[end_closest_lines_idx] : end_lines.front(); new_intersections.push_back({cl_end.border_idx, cl_end.line_idx, cl_end.point, compute_distance(cl_end)}); }