Fix extrusion of some support layers at wrong Z height (#13327)

In some rare support edge cases, Orca could start extruding a new layer before moving to the correct Z height.

This happened when two support layers were generated back-to-back and the next layer started exactly where the previous one ended. In that situation, there was no movement that naturally updated the Z position first.

The code was clearing the “pending layer change” flag too early, so it lost track of the fact that a Z move was still required.

This change ensures that if a layer change is still pending, Orca will always move to the correct Z height before the first extrusion of that layer.

This guarantees that every layer starts at the correct height and fixes the missing / incorrect support layers seen in those edge cases.
This commit is contained in:
Kiss Lorand
2026-04-23 18:50:28 +03:00
committed by GitHub
parent 35b2b6212d
commit 95ce474c8d

View File

@@ -6199,11 +6199,13 @@ std::string GCode::_extrude(const ExtrusionPath &path, std::string description,
"move to first " + description + " point",
sloped == nullptr ? DBL_MAX : get_sloped_z(sloped->slope_begin.z_ratio)
);
m_need_change_layer_lift_z = false;
// Orca: ensure Z matches planned layer height
if (_last_pos_undefined && !slope_need_z_travel) {
gcode += this->writer().travel_to_z(m_nominal_z, "ensure Z matches planned layer height", true);
if (!slope_need_z_travel && (_last_pos_undefined || m_need_change_layer_lift_z)) {
const std::string z_sync_comment = _last_pos_undefined ?
"ensure Z matches planned layer height" : ""; // no comment for normal layer-Z lift
gcode += this->writer().travel_to_z(m_nominal_z, z_sync_comment, true);
}
m_need_change_layer_lift_z = false;
}