mirror of
				https://github.com/SoftFever/OrcaSlicer.git
				synced 2025-10-31 04:31:15 -06:00 
			
		
		
		
	More work on incremental slicing
This commit is contained in:
		
							parent
							
								
									d2ca4c1b13
								
							
						
					
					
						commit
						7ccfd2f024
					
				
					 4 changed files with 70 additions and 7 deletions
				
			
		|  | @ -447,6 +447,10 @@ sub _fill_gaps { | |||
| sub prepare_fill_surfaces { | ||||
|     my $self = shift; | ||||
|      | ||||
|     # Note: in order to make the psPrepareInfill step idempotent, we should never | ||||
|     # alter fill_surfaces boundaries on which our idempotency relies since that's | ||||
|     # the only meaningful information returned by psPerimeters. | ||||
|      | ||||
|     # if no solid layers are requested, turn top/bottom surfaces to internal | ||||
|     if ($self->config->top_solid_layers == 0) { | ||||
|         $_->surface_type(S_TYPE_INTERNAL) for @{$self->fill_surfaces->filter_by_type(S_TYPE_TOP)}; | ||||
|  |  | |||
|  | @ -80,7 +80,10 @@ sub apply_config { | |||
|     # All regions now have distinct settings. | ||||
|     # Check whether applying the new region config defaults we'd get different regions. | ||||
|     my $rearrange_regions = 0; | ||||
|     my @other_region_configs = (); | ||||
|     REGION: foreach my $region_id (0..($self->region_count - 1)) { | ||||
|         my $region = $self->regions->[$region_id]; | ||||
|         my @this_region_configs = (); | ||||
|         foreach my $object (@{$self->objects}) { | ||||
|             foreach my $volume_id (@{ $object->get_region_volumes($region_id) }) { | ||||
|                 my $volume = $object->model_object->volumes->[$volume_id]; | ||||
|  | @ -96,17 +99,40 @@ sub apply_config { | |||
|                     $material_config->normalize; | ||||
|                     $new->apply_dynamic($material_config); | ||||
|                 } | ||||
|                 if (!$new->equals($self->regions->[$region_id]->config)) { | ||||
|                 if (defined first { !$_->equals($new) } @this_region_configs) { | ||||
|                     # if the new config for this volume differs from the other | ||||
|                     # volume configs currently associated to this region, it means | ||||
|                     # the region subdivision does not make sense anymore | ||||
|                     $rearrange_regions = 1; | ||||
|                     last REGION; | ||||
|                 } | ||||
|                 push @this_region_configs, $new; | ||||
|                  | ||||
|                 if (defined first { $_->equals($new) } @other_region_configs) { | ||||
|                     # if the new config for this volume equals any of the other | ||||
|                     # volume configs that are not currently associated to this | ||||
|                     # region, it means the region subdivision does not make | ||||
|                     # sense anymore | ||||
|                     $rearrange_regions = 1; | ||||
|                     last REGION; | ||||
|                 } | ||||
|                  | ||||
|                 # if we're here and the new region config is different from the old | ||||
|                 # one, we need to apply the new config and invalidate all objects | ||||
|                 # (possible optimization: only invalidate objects using this region) | ||||
|                 my $region_config_diff = $region->config->diff($new); | ||||
|                 if (@$region_config_diff) { | ||||
|                     $region->config->apply($new); | ||||
|                     foreach my $o (@{$self->objects}) { | ||||
|                         $o->invalidate_all_steps | ||||
|                             if !$o->invalidate_state_by_config_options($region_config_diff); | ||||
|                     } | ||||
|                 } | ||||
|             } | ||||
|         } | ||||
|         push @other_region_configs, @this_region_configs; | ||||
|     } | ||||
|      | ||||
|     # Some optimization is possible: if the volumes-regions mappings don't change | ||||
|     # but still region configs are changed somehow, we could just apply the diff | ||||
|     # and invalidate the affected steps. | ||||
|     if ($rearrange_regions) { | ||||
|         # the current subdivision of regions does not make sense anymore. | ||||
|         # we need to remove all objects and re-add them | ||||
|  | @ -442,12 +468,14 @@ sub process { | |||
|                 while (defined (my $obj_layer = $q->dequeue)) { | ||||
|                     my ($i, $region_id) = @$obj_layer; | ||||
|                     my $layerm = $object->layers->[$i]->regions->[$region_id]; | ||||
|                     $layerm->fills->clear; | ||||
|                     $layerm->fills->append( $object->fill_maker->make_fill($layerm) ); | ||||
|                 } | ||||
|             }, | ||||
|             collect_cb => sub {}, | ||||
|             no_threads_cb => sub { | ||||
|                 foreach my $layerm (map @{$_->regions}, @{$object->layers}) { | ||||
|                     $layerm->fills->clear; | ||||
|                     $layerm->fills->append($object->fill_maker->make_fill($layerm)); | ||||
|                 } | ||||
|             }, | ||||
|  |  | |||
|  | @ -580,6 +580,10 @@ sub detect_surfaces_type { | |||
|         # clip surfaces to the fill boundaries | ||||
|         foreach my $layer (@{$self->layers}) { | ||||
|             my $layerm = $layer->regions->[$region_id]; | ||||
|              | ||||
|             # Note: this method should be idempotent, but fill_surfaces gets modified  | ||||
|             # in place. However we're now only using its boundaries (which are invariant) | ||||
|             # so we're safe | ||||
|             my $fill_boundaries = [ map $_->clone->p, @{$layerm->fill_surfaces} ]; | ||||
|             $layerm->fill_surfaces->clear; | ||||
|             foreach my $surface (@{$layerm->slices}) { | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Alessandro Ranellucci
						Alessandro Ranellucci