From 9aed420c33eddc3c33d9e7606a21c26b821b1c53 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20=C5=A0ach?= Date: Fri, 22 Nov 2024 11:32:33 +0100 Subject: [PATCH] SPE-2578: Fix avoid crossing perimeters (#13445, #13478, #12432, #13669): - Turn off external motion planner when the instance is the same for layer change. - Properly set the instance shift for travel_to_first_position. Affects simple rectangular layer change. --- src/libslic3r/GCode.cpp | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/src/libslic3r/GCode.cpp b/src/libslic3r/GCode.cpp index 111ff6c6654..3ba85b5bd41 100644 --- a/src/libslic3r/GCode.cpp +++ b/src/libslic3r/GCode.cpp @@ -2583,7 +2583,13 @@ LayerResult GCodeGenerator::process_layer( *layers[instance_to_print.object_layer_to_print_id].layer()); this->set_origin(unscale(first_instance->shift)); - m_avoid_crossing_perimeters.use_external_mp_once = true; + const GCode::PrintObjectInstance next_instance{ + &instances_to_print.front().print_object, + int(instances_to_print.front().instance_id) + }; + if (m_current_instance != next_instance) { + m_avoid_crossing_perimeters.use_external_mp_once = true; + } } gcode += this->change_layer(previous_layer_z, print_z, result.spiral_vase_enable, first_point.head<2>(), first_layer); // this will increase m_layer_index @@ -2677,12 +2683,23 @@ LayerResult GCodeGenerator::process_layer( } if (!this->m_moved_to_first_layer_point) { - gcode += this->travel_to_first_position(first_point, print_z, ExtrusionRole::Mixed, [this]() { + const Point shift{first_instance->shift}; + this->set_origin(unscale(shift)); + + const GCode::PrintObjectInstance next_instance{ + &instances_to_print.front().print_object, + int(instances_to_print.front().instance_id) + }; + if (m_current_instance != next_instance) { + m_avoid_crossing_perimeters.use_external_mp_once = true; + } + gcode += this->travel_to_first_position(first_point - to_3d(shift, 0), print_z, ExtrusionRole::Mixed, [this]() { if (m_writer.multiple_extruders) { return std::string{""}; } return m_label_objects.maybe_change_instance(m_writer); }); + this->set_origin({0, 0}); } if (!extruder_extrusions.skirt.empty()) {