diff --git a/lib/Slic3r/Print/Object.pm b/lib/Slic3r/Print/Object.pm index 3e9f38d22..368a23406 100644 --- a/lib/Slic3r/Print/Object.pm +++ b/lib/Slic3r/Print/Object.pm @@ -155,12 +155,18 @@ sub detect_surfaces_type { sub prepare_infill { my ($self) = @_; - # prerequisites - $self->make_perimeters; # do we need them? TODO: check - $self->detect_surfaces_type; - return if $self->step_done(STEP_PREPARE_INFILL); $self->set_step_started(STEP_PREPARE_INFILL); + + # This prepare_infill() is not really idempotent. + # TODO: It should clear and regenerate fill_surfaces at every run + # instead of modifying it in place. + $self->invalidate_step(STEP_PERIMETERS); + $self->make_perimeters; + + # prerequisites + $self->detect_surfaces_type; + $self->print->status_cb->(30, "Preparing infill"); # decide what surfaces are to be filled diff --git a/xs/src/libslic3r/LayerRegion.cpp b/xs/src/libslic3r/LayerRegion.cpp index 148dd843c..5b4a6cc5c 100644 --- a/xs/src/libslic3r/LayerRegion.cpp +++ b/xs/src/libslic3r/LayerRegion.cpp @@ -66,7 +66,7 @@ LayerRegion::make_perimeters(const SurfaceCollection &slices, SurfaceCollection* g.process(); } -// This function reads layer->slices andlower_layer->slices +// This function reads layer->slices and lower_layer->slices // and writes this->bridged and this->fill_surfaces, so it's thread-safe. void LayerRegion::process_external_surfaces() @@ -106,7 +106,6 @@ LayerRegion::process_external_surfaces() } SurfaceCollection bottom; - Polygons removed_holes; for (const Surface &surface : surfaces) { if (!surface.is_bottom()) continue; diff --git a/xs/src/libslic3r/PrintRegion.cpp b/xs/src/libslic3r/PrintRegion.cpp index cb4e7fa2e..c5a1c948e 100644 --- a/xs/src/libslic3r/PrintRegion.cpp +++ b/xs/src/libslic3r/PrintRegion.cpp @@ -85,11 +85,19 @@ PrintRegion::invalidate_state_by_config(const PrintConfigBase &config) steps.insert(posPerimeters); } else if (opt_key == "first_layer_extrusion_width") { steps.insert(posSupportMaterial); + } else if (opt_key == "solid_infill_below_area") { + const float &cur_value = config.opt(opt_key)->value; + const float &new_value = this->config.solid_infill_below_area.value; + if (new_value >= cur_value) { + steps.insert(posPrepareInfill); + } else { + // prepare_infill is not idempotent when solid_infill_below_area is reduced + steps.insert(posPerimeters); + } } else if (opt_key == "infill_every_layers" || opt_key == "solid_infill_every_layers" || opt_key == "bottom_solid_layers" || opt_key == "top_solid_layers" - || opt_key == "solid_infill_below_area" || opt_key == "infill_extruder" || opt_key == "solid_infill_extruder" || opt_key == "infill_extrusion_width") { @@ -108,10 +116,10 @@ PrintRegion::invalidate_state_by_config(const PrintConfigBase &config) } else if (opt_key == "fill_density") { const float &cur_value = config.opt("fill_density")->value; const float &new_value = this->config.fill_density.value; - if ((cur_value == 0) != (new_value == 0)) + if ((cur_value == 0) != (new_value == 0) || (cur_value == 100) != (new_value == 100)) steps.insert(posPerimeters); - steps.insert(posPrepareInfill); + steps.insert(posInfill); } else if (opt_key == "external_perimeter_extrusion_width" || opt_key == "perimeter_extruder") { steps.insert(posPerimeters);