mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-11-30 08:55:26 -05:00
Travel back from a lift at the lifted height, then descend (#16933)
* Travel back from a lift at the lifted height, then descend After a tool change on the Bambu Lab prime tower, the nozzle is lifted at the tower and then travels to the next object. That travel is forced to set the layer Z, which sent it down the final branch of travel_to_xyz(): it cancelled the lift and emitted one combined XYZ move, so the nozzle sank over the print and left color streaks. When the nozzle is lifted and the target is lower, move in XY first and descend at the target, as the branch already does after a filament change. Fixes #14968 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Keep a lifted nozzle up over every travel that descends to the print A multi-point avoid-crossing or exclusion-volume travel now stays at the lifted height and descends only at its last point. The split descent also covers printers with an axis remap, takes its Z move from the target position, and is skipped when X and Y do not change. The test parses with GCodeReader and runs with arc fitting both off and on. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Check exclusion volumes from the height a lifted nozzle travels at Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Merge the lifted and multi-point travel branches into one loop The 2-point travel, the lifted detour and the avoid-crossing detour now share one loop; a detour only moves to the layer height at its first point when the nozzle is not staying lifted. A new test lifts at each layer change of a concave part with avoid crossing walls on, so lifted detours of more than two points are checked for a nozzle that comes down before the end. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Keep an exclusion-volume detour lifted when its lift is still pending A retraction leaves its lift pending until the first leg of the travel. The interpolated-Z detour only checked for a lift already made, so it lifted on the first leg and then lowered at each later waypoint. A lift the first leg will make now skips the interpolation, so the detour stays lifted and descends at its last point. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: Kris Austin <kris.austin@gmail.com>
This commit is contained in:
3 files changed
+202
-35
No files matched your search
+22
-26
@@ -8089,7 +8089,7 @@ LayerResult GCode::process_layer(
|
||||
m_nominal_z = entry.sub_z;
|
||||
// Use the same lazy-Z mechanism as change_layer(): set the flag so travel_to
|
||||
// fires even when m_last_pos coincides with the first extrusion point,
|
||||
// ensuring Z reaches sub_z via the combined XY+Z move.
|
||||
// ensuring Z reaches sub_z on the travel to it.
|
||||
m_need_change_layer_lift_z = true;
|
||||
|
||||
for (ObjectByExtruder::Island &island : instance_to_print.object_by_extruder.islands) {
|
||||
@@ -10521,9 +10521,6 @@ std::string GCode::travel_to(const Point& point, ExtrusionRole role, std::string
|
||||
result.append(to_local_point(gcode_point));
|
||||
return result;
|
||||
};
|
||||
const auto nominal_writer_z = [this]() {
|
||||
return m_writer.get_position().z() - m_writer.get_zhop();
|
||||
};
|
||||
const auto route_around_exclusion_volumes = [&](
|
||||
Polyline &path,
|
||||
const std::optional<double> &start_z_override,
|
||||
@@ -10532,7 +10529,8 @@ std::string GCode::travel_to(const Point& point, ExtrusionRole role, std::string
|
||||
return false;
|
||||
|
||||
const double target_z = z == DBL_MAX ? m_nominal_z : z;
|
||||
double route_start_z = start_z_override.value_or(nominal_writer_z());
|
||||
// A lifted nozzle travels at its lifted height, so the route is checked from there.
|
||||
double route_start_z = start_z_override.value_or(m_writer.get_position().z());
|
||||
double route_end_z = target_z;
|
||||
if (include_planned_lift) {
|
||||
const Vec2d destination_xy = this->point_to_gcode(path.back());
|
||||
@@ -10681,13 +10679,15 @@ std::string GCode::travel_to(const Point& point, ExtrusionRole role, std::string
|
||||
gcode += m_writer.travel_to_xy(this->point_to_gcode(travel.points[i]), comment);
|
||||
}
|
||||
} else {
|
||||
if (travel.size() == 2) {
|
||||
// No extra movements emitted by avoid_crossing_perimeters, simply move to the end point with z change
|
||||
const auto& dest2d = this->point_to_gcode(travel.points.back());
|
||||
Vec3d dest3d(dest2d(0), dest2d(1), z == DBL_MAX ? m_nominal_z : z);
|
||||
gcode += m_writer.travel_to_xyz(dest3d, comment, m_need_change_layer_lift_z);
|
||||
m_need_change_layer_lift_z = false;
|
||||
} else if (exclusion_volume_travel_rerouted && z != DBL_MAX) {
|
||||
const double target_z = z == DBL_MAX ? m_nominal_z : z;
|
||||
// A lifted nozzle keeps its height over the whole detour and descends only at the last
|
||||
// point, so it never sinks over the print.
|
||||
const bool stay_lifted = m_writer.get_zhop() > EPSILON && m_writer.get_position().z() > target_z + EPSILON;
|
||||
// A lift left pending by the retraction happens on the first leg, so that detour is lifted too.
|
||||
const Vec2d first2d = this->point_to_gcode(travel.points[1]);
|
||||
const bool lift_pending =
|
||||
m_writer.planned_travel_z(Vec3d(first2d.x(), first2d.y(), target_z), m_need_change_layer_lift_z).second > target_z + EPSILON;
|
||||
if (exclusion_volume_travel_rerouted && z != DBL_MAX && !stay_lifted && !lift_pending) {
|
||||
// Preserve the original sloped-Z move over the longer detour.
|
||||
// The router activates every volume touched by the complete Z
|
||||
// range, so this interpolation remains conservative.
|
||||
@@ -10706,23 +10706,19 @@ std::string GCode::travel_to(const Point& point, ExtrusionRole role, std::string
|
||||
m_need_change_layer_lift_z = false;
|
||||
}
|
||||
} else {
|
||||
// Extra movements emitted by avoid_crossing_perimeters, lift the z to normal height at the beginning, then apply the z
|
||||
// ratio at the last point
|
||||
// Extra movements emitted by avoid_crossing_perimeters move to the layer height at the first point,
|
||||
// unless the nozzle stays lifted. The target Z is applied at the last point.
|
||||
const bool layer_z_first = travel.size() > 2 && !stay_lifted;
|
||||
for (size_t i = 1; i < travel.size(); ++i) {
|
||||
if (i == 1) {
|
||||
// Lift to normal z at beginning
|
||||
Vec2d dest2d = this->point_to_gcode(travel.points[i]);
|
||||
Vec3d dest3d(dest2d(0), dest2d(1), m_nominal_z);
|
||||
gcode += m_writer.travel_to_xyz(dest3d, comment, m_need_change_layer_lift_z);
|
||||
const Vec2d dest2d = this->point_to_gcode(travel.points[i]);
|
||||
if (i == 1 && layer_z_first) {
|
||||
gcode += m_writer.travel_to_xyz(Vec3d(dest2d.x(), dest2d.y(), m_nominal_z), comment, m_need_change_layer_lift_z);
|
||||
m_need_change_layer_lift_z = false;
|
||||
} else if (i == travel.size() - 1 && (z != DBL_MAX || !layer_z_first)) {
|
||||
gcode += m_writer.travel_to_xyz(Vec3d(dest2d.x(), dest2d.y(), target_z), comment, m_need_change_layer_lift_z);
|
||||
m_need_change_layer_lift_z = false;
|
||||
} else if (z != DBL_MAX && i == travel.size() - 1) {
|
||||
// Apply z_ratio for the very last point
|
||||
Vec2d dest2d = this->point_to_gcode(travel.points[i]);
|
||||
Vec3d dest3d(dest2d(0), dest2d(1), z);
|
||||
gcode += m_writer.travel_to_xyz(dest3d, comment);
|
||||
} else {
|
||||
// For all points in between, no z change
|
||||
gcode += m_writer.travel_to_xy(this->point_to_gcode(travel.points[i]), comment);
|
||||
gcode += m_writer.travel_to_xy(dest2d, comment);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user