From d47e12f05c10dcbc5e66721f37498d1c292860af Mon Sep 17 00:00:00 2001 From: Alessandro Ranellucci Date: Wed, 24 Dec 2014 00:10:31 +0100 Subject: [PATCH] Bugfix: a wrong optimization caused some top-level perimeters not to be sorted using the nearest-neighbor search. #2322 --- lib/Slic3r/Layer/Region.pm | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/lib/Slic3r/Layer/Region.pm b/lib/Slic3r/Layer/Region.pm index 6ce755b7b..f48282ee3 100644 --- a/lib/Slic3r/Layer/Region.pm +++ b/lib/Slic3r/Layer/Region.pm @@ -350,16 +350,12 @@ sub make_perimeters { # use a nearest neighbor search to order these children # TODO: supply second argument to chained_path() too? - # Optimization: since islands are going to be sorted by slice anyway in the - # G-code export process, we skip chained_path here - my ($sorted_collection, @orig_indices); - if ($is_contour && $depth == 0) { - $sorted_collection = $collection; - @orig_indices = (0..$#$sorted_collection); - } else { - $sorted_collection = $collection->chained_path_indices(0); - @orig_indices = @{$sorted_collection->orig_indices}; - } + # (We used to skip this chiained_path() when $is_contour && + # $depth == 0 because slices are ordered at G_code export + # time, but multiple top-level perimeters might belong to + # the same slice actually, so that was a broken optimization.) + my $sorted_collection = $collection->chained_path_indices(0); + my @orig_indices = @{$sorted_collection->orig_indices}; my @loops = (); foreach my $loop (@$sorted_collection) {