diff --git a/lib/Slic3r/GCode.pm b/lib/Slic3r/GCode.pm index 5f75905dc..b895a1d99 100644 --- a/lib/Slic3r/GCode.pm +++ b/lib/Slic3r/GCode.pm @@ -188,6 +188,10 @@ sub extrude { sub extrude_loop { my ($self, $loop, $description) = @_; + # make a copy; don't modify the orientation of the original loop object otherwise + # next copies (if any) would not detect the correct orientation + $loop = $loop->clone; + # extrude all loops ccw my $was_clockwise = $loop->make_counter_clockwise; my $polygon = $loop->polygon; diff --git a/t/perimeters.t b/t/perimeters.t index 0805d1b42..526c7a5b9 100644 --- a/t/perimeters.t +++ b/t/perimeters.t @@ -43,7 +43,11 @@ use Slic3r::Test; { $config->set('external_perimeter_speed', 68); - my $print = Slic3r::Test::init_print('cube_with_hole', config => $config); + my $print = Slic3r::Test::init_print( + 'cube_with_hole', + config => $config, + duplicate => 2, # we test two copies to make sure ExtrusionLoop objects are not modified in-place (the second object would not detect cw loops and thus would calculate wrong inwards moves) + ); my $has_cw_loops = my $has_outwards_move = 0; my $cur_loop; my %external_loops = (); # print_z => count of external loops @@ -58,6 +62,11 @@ use Slic3r::Test; $has_cw_loops = 1 if Slic3r::Polygon->new_scale(@$cur_loop)->is_clockwise; if ($self->F == $config->external_perimeter_speed*60) { my $move_dest = Slic3r::Point->new_scale(@$info{qw(new_X new_Y)}); + + # reset counter for second object + $external_loops{$self->Z} = 0 + if defined($external_loops{$self->Z}) && $external_loops{$self->Z} == 2; + $external_loops{$self->Z}++; my $loop_contains_point = Slic3r::Polygon->new_scale(@$cur_loop)->contains_point($move_dest); $has_outwards_move = 1