Fix seam dents caused by skipped retraction after outer wall (#16982)

Co-authored-by: Ioannis Giannakas <59056762+igiannakas@users.noreply.github.com>
This commit is contained in:
Damir GaleevandIoannis Giannakas authored and GitHub committed 2026-11-14 11:30:49 -03:00
1 parent 87cf1429ca
commit 82135af6ff
11 files changed
+278 -7

No files matched your search

+36 -3
View File
@@ -3425,6 +3425,7 @@ void GCode::_do_export(Print& print, GCodeOutputStream &file, ThumbnailsGenerato
case CalibMode::Calib_Auto_PA_Line:
case CalibMode::Calib_Retraction_tower:
m_calib_config.set_key_value("wipe_inward", new ConfigOptionBool(false));
m_calib_config.set_key_value("retract_after_outer_wall", new ConfigOptionBool(false));
break;
default:
break;
@@ -7589,8 +7590,10 @@ LayerResult GCode::process_layer(
gcode += std::move(gcode_toolchange);
// let analyzer tag generator aware of a role type change
if (layer_tools.has_wipe_tower && m_wipe_tower)
if (layer_tools.has_wipe_tower && m_wipe_tower) {
m_last_processor_extrusion_role = erWipeTower;
m_retract_after_last_path = false;
}
// Belt printers: now that this pass's tool is selected, lay down any ordinary-layer
// apron band whose brim filament is this extruder, before the object extrusion at
@@ -8929,6 +8932,23 @@ std::string GCode::extrude_path(const ExtrusionPath& path, const std::string& de
return gcode;
}
// Orca: overhanging segments share one role on every wall, so the wall index decides where it is set.
// Without it (classic thin walls, extra perimeters on overhangs) an external path decides. Unlike
// !is_inner_wall(), extra perimeters are not an outer wall, and every path counts, not just the first.
static bool is_outer_wall(const ExtrusionEntity &wall)
{
if (wall.inset_idx >= 0)
return wall.inset_idx == 0;
const ExtrusionPaths *paths = nullptr;
if (const auto *loop = dynamic_cast<const ExtrusionLoop *>(&wall))
paths = &loop->paths;
else if (const auto *multipath = dynamic_cast<const ExtrusionMultiPath *>(&wall))
paths = &multipath->paths;
if (paths == nullptr)
return wall.role() == erExternalPerimeter;
return std::any_of(paths->begin(), paths->end(), [](const ExtrusionPath &path) { return path.role() == erExternalPerimeter; });
}
// Extrude perimeters: Decide where to put seams (hide or align seams).
std::string GCode::extrude_perimeters(const Print &print, const std::vector<ObjectByExtruder::Island::Region> &by_region, bool is_first_layer, bool is_infill_first, bool unsupported_loops_only)
{
@@ -8979,8 +8999,14 @@ std::string GCode::extrude_perimeters(const Print &print, const std::vector<Obje
for (const ExtrusionEntity* ee : region.perimeters) {
if (defer_unsupported && waits_for_infill(ee) != unsupported_loops_only)
continue;
const size_t size_before = gcode.size();
gcode += this->extrude_entity(*ee, "perimeter", -1., region.perimeters,
wipe_support ? &*wipe_support : nullptr);
// Orca: set once the whole wall is down, so a gap between its paths is not a travel off it.
// A loop shorter than the seam gap prints nothing and leaves the flag alone. m_config still
// holds the wall's own region and the calibration overrides.
if (gcode.size() != size_before)
m_retract_after_last_path = m_config.retract_after_outer_wall.value && is_outer_wall(*ee);
if (wipe_support)
wipe_support->append(*ee);
}
@@ -9400,6 +9426,8 @@ std::string GCode::_extrude_piece(const ExtrusionPath &path, const std::string &
}
m_need_change_layer_lift_z = false;
}
// Orca: the travel off the last wall is done; extrude_perimeters() sets this again after an outer wall.
m_retract_after_last_path = false;
if (path.z_contoured && !path.polyline.lines().empty()) {
double current_z = m_writer.get_position().z();
@@ -10733,7 +10761,10 @@ LiftType GCode::to_lift_type(ZHopType z_hop_types) {
bool GCode::needs_retraction(const Polyline &travel, ExtrusionRole role, LiftType& lift_type)
{
if (travel.length() < scale_(FILAMENT_CONFIG(retraction_minimum_travel))) {
const bool leaving_external_perimeter = is_perimeter(m_last_processor_extrusion_role) && m_last_processor_extrusion_role != erPerimeter;
// Orca: a short travel off the outer wall drags its hot end inward; retract_after_outer_wall ignores the threshold there.
const bool force_after_outer_wall = m_retract_after_last_path && travel.length() > SCALED_EPSILON;
if (!force_after_outer_wall && travel.length() < scale_(FILAMENT_CONFIG(retraction_minimum_travel))) {
// skip retraction if the move is shorter than the configured threshold
return false;
}
@@ -10811,7 +10842,7 @@ bool GCode::needs_retraction(const Polyline &travel, ExtrusionRole role, LiftTyp
//BBS: force to retract when leave from external perimeter for a long travel
//Better way is judging whether the travel move direction is same with last extrusion move.
if (is_perimeter(m_last_processor_extrusion_role) && m_last_processor_extrusion_role != erPerimeter) {
if (leaving_external_perimeter) {
if (ZHopType(FILAMENT_CONFIG(z_hop_types)) == ZHopType::zhtAuto) {
lift_type = is_through_overhang(clipped_travel) ? LiftType::SpiralLift : LiftType::SlopeLift;
}
@@ -11012,6 +11043,8 @@ std::string GCode::set_extruder(unsigned int new_filament_id, double print_z, bo
int new_extruder_id = get_extruder_id(new_filament_id);
if (!m_writer.need_toolchange(new_filament_id))
return "";
// Orca: the tool that printed the outer wall retracts for the tool change; the next tool did not print it.
m_retract_after_last_path = false;
const std::optional<ToolchangePositionState> position_before_toolchange =
this->capture_toolchange_position();