mirror of
				https://github.com/SoftFever/OrcaSlicer.git
				synced 2025-10-31 04:31:15 -06:00 
			
		
		
		
	Bugfix: a move below z_offset was performed when retract_lift was enabled and lift amount was less than z_offset. Includes regression test. #2349
This commit is contained in:
		
							parent
							
								
									ee3fb7caa2
								
							
						
					
					
						commit
						6135a9fb8b
					
				
					 4 changed files with 45 additions and 2 deletions
				
			
		|  | @ -165,6 +165,7 @@ sub thread_cleanup { | ||||||
|     no warnings 'redefine'; |     no warnings 'redefine'; | ||||||
|     *Slic3r::Config::DESTROY                = sub {}; |     *Slic3r::Config::DESTROY                = sub {}; | ||||||
|     *Slic3r::Config::Full::DESTROY          = sub {}; |     *Slic3r::Config::Full::DESTROY          = sub {}; | ||||||
|  |     *Slic3r::Config::GCode::DESTROY         = sub {}; | ||||||
|     *Slic3r::Config::Print::DESTROY         = sub {}; |     *Slic3r::Config::Print::DESTROY         = sub {}; | ||||||
|     *Slic3r::Config::PrintObject::DESTROY   = sub {}; |     *Slic3r::Config::PrintObject::DESTROY   = sub {}; | ||||||
|     *Slic3r::Config::PrintRegion::DESTROY   = sub {}; |     *Slic3r::Config::PrintRegion::DESTROY   = sub {}; | ||||||
|  |  | ||||||
|  | @ -71,6 +71,20 @@ sub init_external_mp { | ||||||
|     $self->_external_mp(Slic3r::MotionPlanner->new($islands)); |     $self->_external_mp(Slic3r::MotionPlanner->new($islands)); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | sub preamble { | ||||||
|  |     my ($self) = @_; | ||||||
|  |      | ||||||
|  |     my $gcode = $self->writer->preamble; | ||||||
|  |      | ||||||
|  |     # Perform a *silent* move to z_offset: we need this to initialize the Z | ||||||
|  |     # position of our writer object so that any initial lift taking place | ||||||
|  |     # before the first layer change will raise the extruder from the correct | ||||||
|  |     # initial Z instead of 0. | ||||||
|  |     $self->writer->travel_to_z($self->config->z_offset, ''); | ||||||
|  |      | ||||||
|  |     return $gcode; | ||||||
|  | } | ||||||
|  | 
 | ||||||
| sub change_layer { | sub change_layer { | ||||||
|     my ($self, $layer) = @_; |     my ($self, $layer) = @_; | ||||||
|      |      | ||||||
|  |  | ||||||
|  | @ -546,7 +546,7 @@ sub write_gcode { | ||||||
|     $print_first_layer_temperature->(1); |     $print_first_layer_temperature->(1); | ||||||
|      |      | ||||||
|     # set other general things |     # set other general things | ||||||
|     print $fh $gcodegen->writer->preamble; |     print $fh $gcodegen->preamble; | ||||||
|      |      | ||||||
|     # initialize a motion planner for object-to-object travel moves |     # initialize a motion planner for object-to-object travel moves | ||||||
|     if ($self->config->avoid_crossing_perimeters) { |     if ($self->config->avoid_crossing_perimeters) { | ||||||
|  |  | ||||||
							
								
								
									
										30
									
								
								t/gcode.t
									
										
									
									
									
								
							
							
						
						
									
										30
									
								
								t/gcode.t
									
										
									
									
									
								
							|  | @ -1,4 +1,4 @@ | ||||||
| use Test::More tests => 16; | use Test::More tests => 19; | ||||||
| use strict; | use strict; | ||||||
| use warnings; | use warnings; | ||||||
| 
 | 
 | ||||||
|  | @ -41,6 +41,34 @@ use Slic3r::Test; | ||||||
|     ok !defined (first { abs($_ - $config->retract_speed->[0]*60) < 5 } @retract_speeds), 'wipe moves don\'t retract faster than configured speed'; |     ok !defined (first { abs($_ - $config->retract_speed->[0]*60) < 5 } @retract_speeds), 'wipe moves don\'t retract faster than configured speed'; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | { | ||||||
|  |     my $config = Slic3r::Config->new_from_defaults; | ||||||
|  |     $config->set('z_offset', 5); | ||||||
|  |     $config->set('start_gcode', ''); | ||||||
|  |      | ||||||
|  |     my $test = sub { | ||||||
|  |         my ($comment) = @_; | ||||||
|  |         my $print = Slic3r::Test::init_print('20mm_cube', config => $config); | ||||||
|  |         my $moves_below_z_offset = 0; | ||||||
|  |         Slic3r::GCode::Reader->new->parse(Slic3r::Test::gcode($print), sub { | ||||||
|  |             my ($self, $cmd, $args, $info) = @_; | ||||||
|  |              | ||||||
|  |             if ($info->{travel} && exists $args->{Z}) { | ||||||
|  |                 $moves_below_z_offset++ if $args->{Z} < $config->z_offset; | ||||||
|  |             } | ||||||
|  |         }); | ||||||
|  |         is $moves_below_z_offset, 0, "no Z moves below Z offset ($comment)"; | ||||||
|  |     }; | ||||||
|  |      | ||||||
|  |     $test->("no lift"); | ||||||
|  |      | ||||||
|  |     $config->set('retract_lift', [3]); | ||||||
|  |     $test->("lift < z_offset"); | ||||||
|  |      | ||||||
|  |     $config->set('retract_lift', [6]); | ||||||
|  |     $test->("lift > z_offset"); | ||||||
|  | } | ||||||
|  | 
 | ||||||
| { | { | ||||||
|     # This tests the following behavior: |     # This tests the following behavior: | ||||||
|     # - complete objects does not crash |     # - complete objects does not crash | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Alessandro Ranellucci
						Alessandro Ranellucci