Bugfix: duplicate options did not work correctly for copies > 2. #113

This commit is contained in:
Alessandro Ranellucci 2011-12-12 17:32:45 +01:00
parent 9a610395ce
commit 3c2b2cfef2
2 changed files with 9 additions and 14 deletions

View file

@ -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

View file

@ -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;
foreach my $shift (@shifts) {
push @new_facets, [ $normal ];
foreach my $vertex (@vertices) {
push @{$new_facets[-1]}, [ map $vertex->[$_] + ($shift[$_] || 0), (X,Y,Z) ];
push @{$new_facets[-1]}, [ map $vertex->[$_] + ($shift->[$_] || 0), (X,Y,Z) ];
}
}
}
push @{$self->facets}, @new_facets;