diff --git a/lib/Slic3r/GCode.pm b/lib/Slic3r/GCode.pm index f45b671fa..ec0d6d929 100644 --- a/lib/Slic3r/GCode.pm +++ b/lib/Slic3r/GCode.pm @@ -135,8 +135,12 @@ sub extrude_path { # retract if distance from previous position is greater or equal to the one # specified by the user { - my $travel = Slic3r::Line->new($self->last_pos, $path->points->[0]); + my $travel = Slic3r::Line->new($self->last_pos->clone, $path->points->[0]->clone); if ($travel->length >= scale $self->extruder->retract_before_travel) { + # move travel back to original layer coordinates. + # note that we're only considering the current object's islands, while we should + # build a more complete configuration space + $travel->translate(-$self->shift_x, -$self->shift_y); if (!$Slic3r::Config->only_retract_when_crossing_perimeters || $path->role != EXTR_ROLE_FILL || !first { $_->encloses_line($travel, scaled_epsilon) } @{$self->layer->slices}) { if ($self->last_path && $self->last_path->role == &EXTR_ROLE_EXTERNAL_PERIMETER) { my @lines = $self->last_path->lines; diff --git a/lib/Slic3r/Line.pm b/lib/Slic3r/Line.pm index 4979189c9..58c9479d3 100644 --- a/lib/Slic3r/Line.pm +++ b/lib/Slic3r/Line.pm @@ -67,4 +67,12 @@ sub reverse { @$self = reverse @$self; } +sub translate { + my $self = shift; + my ($x, $y) = @_; + @$self = Slic3r::Geometry::move_points([$x, $y], @$self); + bless $_, 'Slic3r::Point' for @$self; + return $self; +} + 1;