Skip to content

Commit

Permalink
Fix wrong retraction settings being used (#2191)
Browse files Browse the repository at this point in the history
  • Loading branch information
HellAholic authored Jan 10, 2025
2 parents 39de950 + 9ac0329 commit 5438caa
Showing 1 changed file with 19 additions and 3 deletions.
22 changes: 19 additions & 3 deletions src/LayerPlan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2512,8 +2512,24 @@ void LayerPlan::writeGCode(GCodeExport& gcode)
{
ExtruderPlan& extruder_plan = extruder_plans_[extruder_plan_idx];

const RetractionAndWipeConfig* retraction_config
= current_mesh ? &current_mesh->retraction_wipe_config : &storage_.retraction_wipe_config_per_extruder[extruder_plan.extruder_nr_];
auto get_retraction_config = [&extruder_nr, this](std::shared_ptr<const SliceMeshStorage>& mesh) -> std::optional<const RetractionAndWipeConfig*>
{
if (mesh)
{
if (extruder_nr == mesh->settings.get<size_t>("extruder_nr")) [[likely]]
{
return &mesh->retraction_wipe_config;
}

// We are printing a part of a mesh with a different extruder, use this extruder settings instead (mesh-specific settings will be ignored)
return &storage_.retraction_wipe_config_per_extruder[extruder_nr];
}

// We have no mesh yet, a more global config should be used
return std::nullopt;
};

const RetractionAndWipeConfig* retraction_config = get_retraction_config(current_mesh).value_or(&storage_.retraction_wipe_config_per_extruder[extruder_plan.extruder_nr_]);
coord_t z_hop_height = retraction_config->retraction_config.zHop;

if (extruder_nr != extruder_plan.extruder_nr_)
Expand Down Expand Up @@ -2697,7 +2713,7 @@ void LayerPlan::writeGCode(GCodeExport& gcode)

if (path.retract)
{
retraction_config = path.mesh ? &path.mesh->retraction_wipe_config : retraction_config;
retraction_config = get_retraction_config(path.mesh).value_or(retraction_config);
gcode.writeRetraction(retraction_config->retraction_config);
if (path.retract_for_nozzle_switch)
{
Expand Down

0 comments on commit 5438caa

Please sign in to comment.