From e0678d3a383ac7d67b4dca106cb32358534795a0 Mon Sep 17 00:00:00 2001 From: Alessandro Ranellucci Date: Sun, 24 May 2015 15:47:07 +0200 Subject: [PATCH] Bugfix: skirt was floating in 3D preview when raft layers were enabled. #2843 --- lib/Slic3r/GUI/3DScene.pm | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/lib/Slic3r/GUI/3DScene.pm b/lib/Slic3r/GUI/3DScene.pm index 1537fdf6e..7628a6c54 100644 --- a/lib/Slic3r/GUI/3DScene.pm +++ b/lib/Slic3r/GUI/3DScene.pm @@ -1096,9 +1096,18 @@ sub load_print_toolpaths { } else { $skirt_height = min($print->config->skirt_height, $print->total_layer_count); } - foreach my $i (0..max(0, $skirt_height-1)) { - my $layer = $print->get_object(0)->get_layer($i); - my $top_z = $layer->print_z; + $skirt_height ||= 1 if $print->config->brim_width > 0; + + # get first $skirt_height layers (maybe this should be moved to a PrintObject method?) + my $object0 = $print->get_object(0); + my @layers = (); + push @layers, map $object0->get_layer($_-1), 1..min($skirt_height, $object0->layer_count); + push @layers, map $object0->get_support_layer($_-1), 1..min($skirt_height, $object0->support_layer_count); + @layers = sort { $a->print_z <=> $b->print_z } @layers; + @layers = @layers[0..($skirt_height-1)]; + + foreach my $i (0..($skirt_height-1)) { + my $top_z = $layers[$i]->print_z; $offsets{$top_z} = [$qverts->size, $tverts->size]; if ($i == 0) {