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.
This commit is contained in:
Martin Šach 2024-11-22 11:32:33 +01:00 committed by Lukas Matena
parent c7d9e55808
commit 9aed420c33

View File

@ -2583,8 +2583,14 @@ LayerResult GCodeGenerator::process_layer(
*layers[instance_to_print.object_layer_to_print_id].layer()); *layers[instance_to_print.object_layer_to_print_id].layer());
this->set_origin(unscale(first_instance->shift)); this->set_origin(unscale(first_instance->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; 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 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
m_layer = &layer; m_layer = &layer;
@ -2677,12 +2683,23 @@ LayerResult GCodeGenerator::process_layer(
} }
if (!this->m_moved_to_first_layer_point) { 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) { if (m_writer.multiple_extruders) {
return std::string{""}; return std::string{""};
} }
return m_label_objects.maybe_change_instance(m_writer); return m_label_objects.maybe_change_instance(m_writer);
}); });
this->set_origin({0, 0});
} }
if (!extruder_extrusions.skirt.empty()) { if (!extruder_extrusions.skirt.empty()) {