From 4e5f7d74ff6d90a00a50a190c0cffd48e86cfbaa Mon Sep 17 00:00:00 2001 From: Alessandro Ranellucci Date: Sun, 25 May 2014 23:17:00 +0200 Subject: [PATCH] Bugfix: wrong handling of large number of raft layers. #2041 --- lib/Slic3r/Print/Object.pm | 9 ++++----- t/support.t | 6 +++--- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/lib/Slic3r/Print/Object.pm b/lib/Slic3r/Print/Object.pm index 61b3da837..127bf5a82 100644 --- a/lib/Slic3r/Print/Object.pm +++ b/lib/Slic3r/Print/Object.pm @@ -308,11 +308,10 @@ sub slice { } # remove empty layers from bottom - my $first_object_layer_id = $self->config->raft_layers; - while (@{$self->layers} && !@{$self->layers->[$first_object_layer_id]->slices}) { - splice @{$self->layers}, $first_object_layer_id, 1; - for (my $i = $first_object_layer_id; $i <= $#{$self->layers}; $i++) { - $self->layers->[$i]->id($i); + while (@{$self->layers} && !@{$self->layers->[0]->slices}) { + shift @{$self->layers}; + for (my $i = 0; $i <= $#{$self->layers}; $i++) { + $self->layers->[$i]->id( $self->layers->[$i]->id-1 ); } } diff --git a/t/support.t b/t/support.t index 8186ec691..8939848bb 100644 --- a/t/support.t +++ b/t/support.t @@ -1,4 +1,4 @@ -use Test::More tests => 15; +use Test::More tests => 16; use strict; use warnings; @@ -130,10 +130,10 @@ use Slic3r::Test; 'first object layer is completely supported by raft'; } -{ +foreach my $raft_layers (2, 70) { my $config = Slic3r::Config->new_from_defaults; $config->set('skirts', 0); - $config->set('raft_layers', 2); + $config->set('raft_layers', $raft_layers); $config->set('layer_height', 0.35); $config->set('first_layer_height', 0.3); $config->set('nozzle_diameter', [0.5]);