Bugfix: use the external motion planner when extruding skirt and brim. #2412
This commit is contained in:
parent
a200498eef
commit
99deffef62
2 changed files with 20 additions and 15 deletions
|
@ -349,17 +349,19 @@ sub travel_to {
|
|||
) {
|
||||
# Just perform a straight travel move without any retraction.
|
||||
$gcode .= $self->writer->travel_to_xy($self->point_to_gcode($point), $comment);
|
||||
} elsif ($self->config->avoid_crossing_perimeters && !$self->avoid_crossing_perimeters->straight_once) {
|
||||
} elsif ($self->config->avoid_crossing_perimeters && !$self->avoid_crossing_perimeters->disable_once) {
|
||||
# If avoid_crossing_perimeters is enabled and the disable_once flag is not set
|
||||
# we need to plan a multi-segment travel move inside the configuration space.
|
||||
$gcode .= $self->avoid_crossing_perimeters->travel_to($self, $point, $comment);
|
||||
} else {
|
||||
# If avoid_crossing_perimeters is disabled or the straight_once flag is set,
|
||||
# If avoid_crossing_perimeters is disabled or the disable_once flag is set,
|
||||
# perform a straight move with a retraction.
|
||||
$gcode .= $self->retract;
|
||||
$gcode .= $self->writer->travel_to_xy($self->point_to_gcode($point), $comment || '');
|
||||
}
|
||||
|
||||
# Re-allow avoid_crossing_perimeters for the next travel moves
|
||||
$self->avoid_crossing_perimeters->straight_once(0);
|
||||
$self->avoid_crossing_perimeters->disable_once(0);
|
||||
|
||||
return $gcode;
|
||||
}
|
||||
|
@ -554,10 +556,11 @@ sub wipe {
|
|||
package Slic3r::GCode::AvoidCrossingPerimeters;
|
||||
use Moo;
|
||||
|
||||
has '_external_mp' => (is => 'rw');
|
||||
has '_layer_mp' => (is => 'rw');
|
||||
has 'new_object' => (is => 'rw', default => sub {0}); # this flag triggers the use of the external configuration space for avoid_crossing_perimeters for the next travel move
|
||||
has 'straight_once' => (is => 'rw', default => sub {1}); # this flag disables avoid_crossing_perimeters just for the next travel move
|
||||
has '_external_mp' => (is => 'rw');
|
||||
has '_layer_mp' => (is => 'rw');
|
||||
has 'use_external_mp' => (is => 'rw', default => sub {0});
|
||||
has 'use_external_mp_once' => (is => 'rw', default => sub {0}); # this flag triggers the use of the external configuration space for avoid_crossing_perimeters for the next travel move
|
||||
has 'disable_once' => (is => 'rw', default => sub {1}); # this flag disables avoid_crossing_perimeters just for the next travel move
|
||||
|
||||
use Slic3r::Geometry qw(scale);
|
||||
|
||||
|
@ -576,11 +579,8 @@ sub travel_to {
|
|||
|
||||
my $gcode = "";
|
||||
|
||||
# If avoid_crossing_perimeters is enabled and the straight_once flag is not set
|
||||
# we need to plan a multi-segment travel move inside the configuration space.
|
||||
if ($self->new_object) {
|
||||
# If we're moving to a new object we need to use the external configuration space.
|
||||
$self->new_object(0);
|
||||
if ($self->use_external_mp || $self->use_external_mp_once) {
|
||||
$self->use_external_mp_once(0);
|
||||
|
||||
# represent $point in G-code coordinates
|
||||
$point = $point->clone;
|
||||
|
|
|
@ -309,6 +309,7 @@ sub process_layer {
|
|||
if (((values %{$self->_skirt_done}) < $self->print->config->skirt_height || $self->print->config->skirt_height == -1)
|
||||
&& !$self->_skirt_done->{$layer->print_z}) {
|
||||
$self->_gcodegen->set_origin(Slic3r::Pointf->new(0,0));
|
||||
$self->_gcodegen->avoid_crossing_perimeters->use_external_mp(1);
|
||||
my @extruder_ids = map { $_->id } @{$self->_gcodegen->writer->extruders};
|
||||
$gcode .= $self->_gcodegen->set_extruder($extruder_ids[0]);
|
||||
# skip skirt if we have a large brim
|
||||
|
@ -326,21 +327,25 @@ sub process_layer {
|
|||
}
|
||||
}
|
||||
$self->_skirt_done->{$layer->print_z} = 1;
|
||||
$self->_gcodegen->avoid_crossing_perimeters->straight_once(1);
|
||||
$self->_gcodegen->avoid_crossing_perimeters->use_external_mp(0);
|
||||
$self->_gcodegen->avoid_crossing_perimeters->disable_once(1);
|
||||
}
|
||||
|
||||
# extrude brim
|
||||
if (!$self->_brim_done) {
|
||||
$gcode .= $self->_gcodegen->set_extruder($self->print->objects->[0]->config->support_material_extruder-1);
|
||||
$self->_gcodegen->set_origin(Slic3r::Pointf->new(0,0));
|
||||
$self->_gcodegen->avoid_crossing_perimeters->use_external_mp(1);
|
||||
$gcode .= $self->_gcodegen->extrude_loop($_, 'brim', $object->config->support_material_speed)
|
||||
for @{$self->print->brim};
|
||||
$self->_brim_done(1);
|
||||
$self->_gcodegen->avoid_crossing_perimeters->straight_once(1);
|
||||
$self->_gcodegen->avoid_crossing_perimeters->use_external_mp(0);
|
||||
$self->_gcodegen->avoid_crossing_perimeters->disable_once(1);
|
||||
}
|
||||
|
||||
for my $copy (@$object_copies) {
|
||||
$self->_gcodegen->avoid_crossing_perimeters->new_object(1) if ($self->_last_obj_copy // '') ne "$copy";
|
||||
# when starting a new object, use the external motion planner for the first travel move
|
||||
$self->_gcodegen->avoid_crossing_perimeters->use_external_mp_once(1) if ($self->_last_obj_copy // '') ne "$copy";
|
||||
$self->_last_obj_copy("$copy");
|
||||
|
||||
$self->_gcodegen->set_origin(Slic3r::Pointf->new(map unscale $copy->[$_], X,Y));
|
||||
|
|
Loading…
Reference in a new issue