Bugfix: only_retract_when_crossing_perimeters was almost not working. #680

This commit is contained in:
Alessandro Ranellucci 2012-09-12 15:19:47 +02:00
parent e61055774f
commit 87912cb3b0
2 changed files with 4 additions and 2 deletions

View File

@ -3,7 +3,7 @@ use Moo;
use List::Util qw(first);
use Slic3r::ExtrusionPath ':roles';
use Slic3r::Geometry qw(scale unscale points_coincide PI X Y);
use Slic3r::Geometry qw(scale unscale scaled_epsilon points_coincide PI X Y);
has 'layer' => (is => 'rw');
has 'shift_x' => (is => 'rw', default => sub {0} );
@ -135,7 +135,7 @@ sub extrude_path {
{
my $travel = Slic3r::Line->new($self->last_pos, $path->points->[0]);
if ($travel->length >= scale $self->extruder->retract_before_travel) {
if (!$Slic3r::Config->only_retract_when_crossing_perimeters || $path->role != EXTR_ROLE_FILL || !first { $_->expolygon->encloses_line($travel) } @{$self->layer->slices}) {
if (!$Slic3r::Config->only_retract_when_crossing_perimeters || $path->role != EXTR_ROLE_FILL || !first { $_->expolygon->encloses_line($travel, scaled_epsilon) } @{$self->layer->slices}) {
$gcode .= $self->retract(travel_to => $path->points->[0]);
}
}

View File

@ -20,6 +20,7 @@ our @EXPORT_OK = qw(
shortest_path collinear scale unscale merge_collinear_lines
rad2deg_dir bounding_box_center line_intersects_any douglas_peucker
polyline_remove_short_segments normal triangle_normal polygon_is_convex
scaled_epsilon
);
@ -38,6 +39,7 @@ use constant MAX => 1;
our $parallel_degrees_limit = abs(deg2rad(3));
sub epsilon () { 1E-4 }
sub scaled_epsilon () { epsilon / &Slic3r::SCALING_FACTOR }
sub scale ($) { $_[0] / &Slic3r::SCALING_FACTOR }
sub unscale ($) { $_[0] * &Slic3r::SCALING_FACTOR }