From 556c212f9d0e64d365a96f51666e75f479190a89 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luk=C3=A1=C5=A1=20Hejl?= Date: Tue, 13 Oct 2020 22:29:36 +0200 Subject: [PATCH] Fixed crossing perimeters when option "Wipe while retracting" is enabled --- src/libslic3r/GCode.cpp | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/libslic3r/GCode.cpp b/src/libslic3r/GCode.cpp index ae8e3cfda..b047d748b 100644 --- a/src/libslic3r/GCode.cpp +++ b/src/libslic3r/GCode.cpp @@ -3076,9 +3076,18 @@ std::string GCode::travel_to(const Point &point, ExtrusionRole role, std::string // generate G-code for the travel move std::string gcode; - if (needs_retraction) + if (needs_retraction) { + Point last_post_before_retract = this->last_pos(); gcode += this->retract(); - else + // When "Wipe while retracting" is enabled, then extruder moves to another position, and travel from this position can cross perimeters. + // Because of it, it is necessary to call avoid crossing perimeters for the path between previous last_post and last_post after calling retraction() + if (last_post_before_retract != this->last_pos() && m_config.avoid_crossing_perimeters && !m_avoid_crossing_perimeters.disable_once) { + Polyline retract_travel = m_avoid_crossing_perimeters.travel_to(*this, last_post_before_retract); + retract_travel.points.reserve(retract_travel.points.size() + travel.points.size()); + append(retract_travel.points, travel.points); + travel = std::move(retract_travel); + } + } else // Reset the wipe path when traveling, so one would not wipe along an old path. m_wipe.reset_path();