Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 22 additions & 4 deletions src/libslic3r/PrintObjectSlice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4428,8 +4428,16 @@ static inline void apply_mm_segmentation(PrintObject &print_object, std::vector<
continue;

auto preserve_parent_region = [&by_region, &parent_layer_region, &parent_print_region]() {
if (!parent_layer_region.slices.empty())
by_region[parent_print_region.print_object_region_id()].surfaces = parent_layer_region.slices;
if (parent_layer_region.slices.empty())
return;

ByRegion &dst = by_region[parent_print_region.print_object_region_id()];
if (dst.surfaces.empty()) {
dst.surfaces = parent_layer_region.slices;
} else {
dst.surfaces.append(parent_layer_region.slices);
dst.needs_merge = true;
}
};

if (it_painted_region_begin == layer_range.painted_regions.cend()) {
Expand Down Expand Up @@ -4467,7 +4475,7 @@ static inline void apply_mm_segmentation(PrintObject &print_object, std::vector<
if (const int cfg_wall = parent_print_region.config().wall_filament.value;
cfg_wall >= 1 && cfg_wall <= int(by_extruder.size()))
self_extruder_id = cfg_wall;
if (default_bbox.defined && parent_layer_region_bbox.overlap(default_bbox))
if (clamp_parent_to_geometry && default_bbox.defined && parent_layer_region_bbox.overlap(default_bbox))
default_self_expolygons = intersection_ex(parent_layer_region.slices.surfaces, default_segmentation);
std::vector<bool> assigned_extruder(by_extruder.size(), false);
std::vector<int> alias_to_self_extruders;
Expand All @@ -4491,12 +4499,14 @@ static inline void apply_mm_segmentation(PrintObject &print_object, std::vector<
// Update the beginning PaintedRegion iterator for the next iteration.
it_painted_region_begin = it_target_region;

// FIXME: Don't trim by self, it is not reliable.
if (it_target_region->region == &parent_print_region) {
if (self_extruder_id < 0)
self_extruder_id = extruder_id;
if (extruder_id != self_extruder_id)
alias_to_self_extruders.emplace_back(extruder_id);
if (!clamp_parent_to_geometry)
continue;

ExPolygons self_segmented = intersection_ex(parent_layer_region.slices.surfaces, segmented.expolygons);
if (!self_segmented.empty()) {
if (explicit_self_expolygons.empty())
Expand Down Expand Up @@ -4526,6 +4536,14 @@ static inline void apply_mm_segmentation(PrintObject &print_object, std::vector<
}
}

const bool has_foreign_assigned_region =
std::any_of(assigned_extruder.begin(), assigned_extruder.end(),
[](bool assigned) { return assigned; });
if (!has_foreign_assigned_region) {
preserve_parent_region();
continue;
}

// Trim slices of this LayerRegion with all the MM regions.
// Mixed bias can intentionally shrink a painted layer's true silhouette.
// Clamp the parent region to the post-bias segmentation union so the
Expand Down