diff --git a/lib/Slic3r/Print.pm b/lib/Slic3r/Print.pm index 81a5bcd19..667d1997c 100644 --- a/lib/Slic3r/Print.pm +++ b/lib/Slic3r/Print.pm @@ -42,16 +42,9 @@ sub new_from_mesh { # duplicate object { my @size = $mesh->size; - my @duplicate_offset = ( - ($size[X] + scale $Slic3r::duplicate_distance), - ($size[Y] + scale $Slic3r::duplicate_distance), - ); - for (my $i = 2; $i <= $Slic3r::duplicate_x; $i++) { - $mesh->duplicate($duplicate_offset[X] * ($i-1), 0); - } - for (my $i = 2; $i <= $Slic3r::duplicate_y; $i++) { - $mesh->duplicate(0, $duplicate_offset[Y] * ($i-1)); - } + my @duplicate_offset = map +($size[$_] + scale $Slic3r::duplicate_distance), (X,Y); + $mesh->duplicate(map [$duplicate_offset[X] * ($_-1), 0], 2..$Slic3r::duplicate_x); + $mesh->duplicate(map [0, $duplicate_offset[Y] * ($_-1)], 2..$Slic3r::duplicate_y); } # initialize print job diff --git a/lib/Slic3r/TriangleMesh.pm b/lib/Slic3r/TriangleMesh.pm index 5032fe25a..60e5a1158 100644 --- a/lib/Slic3r/TriangleMesh.pm +++ b/lib/Slic3r/TriangleMesh.pm @@ -279,15 +279,17 @@ sub move { sub duplicate { my $self = shift; - my (@shift) = @_; + my (@shifts) = @_; my @new_facets = (); foreach my $facet (@{$self->facets}) { # transform vertex coordinates my ($normal, @vertices) = @$facet; - push @new_facets, [ $normal ]; - foreach my $vertex (@vertices) { - push @{$new_facets[-1]}, [ map $vertex->[$_] + ($shift[$_] || 0), (X,Y,Z) ]; + foreach my $shift (@shifts) { + push @new_facets, [ $normal ]; + foreach my $vertex (@vertices) { + push @{$new_facets[-1]}, [ map $vertex->[$_] + ($shift->[$_] || 0), (X,Y,Z) ]; + } } } push @{$self->facets}, @new_facets;