mirror of
				https://github.com/SoftFever/OrcaSlicer.git
				synced 2025-10-31 04:31:15 -06:00 
			
		
		
		
	Generate multiple vertex lists rather than requesting a single huge
memory block.
This commit is contained in:
		
							parent
							
								
									2a5095a1ea
								
							
						
					
					
						commit
						a53bd3dfe9
					
				
					 1 changed files with 88 additions and 30 deletions
				
			
		|  | @ -1249,6 +1249,21 @@ sub load_print_object_toolpaths { | ||||||
|     my @layers = sort { $a->print_z <=> $b->print_z } |     my @layers = sort { $a->print_z <=> $b->print_z } | ||||||
|         @{$object->layers}, @{$object->support_layers}; |         @{$object->layers}, @{$object->support_layers}; | ||||||
|      |      | ||||||
|  |     # Bounding box of the object and its copies. | ||||||
|  |     my $bb = Slic3r::Geometry::BoundingBoxf3->new; | ||||||
|  |     { | ||||||
|  |         my $obb = $object->bounding_box; | ||||||
|  |         foreach my $copy (@{ $object->_shifted_copies }) { | ||||||
|  |             my $cbb = $obb->clone; | ||||||
|  |             $cbb->translate(@$copy); | ||||||
|  |             $bb->merge_point(Slic3r::Pointf3->new_unscale(@{$cbb->min_point}, 0)); | ||||||
|  |             $bb->merge_point(Slic3r::Pointf3->new_unscale(@{$cbb->max_point}, $object->size->z)); | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     # Maximum size of an allocation block: 32MB / sizeof(float) | ||||||
|  |     my $alloc_size_max = 32 * 1048576 / 4; | ||||||
|  |      | ||||||
|     foreach my $layer (@layers) { |     foreach my $layer (@layers) { | ||||||
|         my $top_z = $layer->print_z; |         my $top_z = $layer->print_z; | ||||||
|          |          | ||||||
|  | @ -1256,9 +1271,13 @@ sub load_print_object_toolpaths { | ||||||
|             $perim_offsets{$top_z} = [ |             $perim_offsets{$top_z} = [ | ||||||
|                 $perim_qverts->size, $perim_tverts->size, |                 $perim_qverts->size, $perim_tverts->size, | ||||||
|             ]; |             ]; | ||||||
|  |         } | ||||||
|  |         if (!exists $infill_offsets{$top_z}) { | ||||||
|             $infill_offsets{$top_z} = [ |             $infill_offsets{$top_z} = [ | ||||||
|                 $infill_qverts->size, $infill_tverts->size, |                 $infill_qverts->size, $infill_tverts->size, | ||||||
|             ]; |             ]; | ||||||
|  |         } | ||||||
|  |         if (!exists $support_offsets{$top_z}) { | ||||||
|             $support_offsets{$top_z} = [ |             $support_offsets{$top_z} = [ | ||||||
|                 $support_qverts->size, $support_tverts->size, |                 $support_qverts->size, $support_tverts->size, | ||||||
|             ]; |             ]; | ||||||
|  | @ -1285,17 +1304,9 @@ sub load_print_object_toolpaths { | ||||||
|                     $support_qverts, $support_tverts); |                     $support_qverts, $support_tverts); | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
|     } |  | ||||||
|      |  | ||||||
|     my $obb = $object->bounding_box; |  | ||||||
|     my $bb = Slic3r::Geometry::BoundingBoxf3->new; |  | ||||||
|     foreach my $copy (@{ $object->_shifted_copies }) { |  | ||||||
|         my $cbb = $obb->clone; |  | ||||||
|         $cbb->translate(@$copy); |  | ||||||
|         $bb->merge_point(Slic3r::Pointf3->new_unscale(@{$cbb->min_point}, 0)); |  | ||||||
|         $bb->merge_point(Slic3r::Pointf3->new_unscale(@{$cbb->max_point}, $object->size->z)); |  | ||||||
|     } |  | ||||||
| 
 | 
 | ||||||
|  |         if ($perim_qverts->size() > $alloc_size_max || $perim_tverts->size() > $alloc_size_max) { | ||||||
|  |             # Store the vertex arrays and restart their containers. | ||||||
|             push @{$self->volumes}, Slic3r::GUI::3DScene::Volume->new( |             push @{$self->volumes}, Slic3r::GUI::3DScene::Volume->new( | ||||||
|                 bounding_box    => $bb, |                 bounding_box    => $bb, | ||||||
|                 color           => COLORS->[0], |                 color           => COLORS->[0], | ||||||
|  | @ -1303,7 +1314,13 @@ sub load_print_object_toolpaths { | ||||||
|                 tverts          => $perim_tverts, |                 tverts          => $perim_tverts, | ||||||
|                 offsets         => { %perim_offsets }, |                 offsets         => { %perim_offsets }, | ||||||
|             ); |             ); | ||||||
|  |             $perim_qverts   = Slic3r::GUI::_3DScene::GLVertexArray->new; | ||||||
|  |             $perim_tverts   = Slic3r::GUI::_3DScene::GLVertexArray->new; | ||||||
|  |             %perim_offsets  = (); | ||||||
|  |         } | ||||||
| 
 | 
 | ||||||
|  |         if ($infill_qverts->size() > $alloc_size_max || $infill_tverts->size() > $alloc_size_max) { | ||||||
|  |             # Store the vertex arrays and restart their containers. | ||||||
|             push @{$self->volumes}, Slic3r::GUI::3DScene::Volume->new( |             push @{$self->volumes}, Slic3r::GUI::3DScene::Volume->new( | ||||||
|                 bounding_box    => $bb, |                 bounding_box    => $bb, | ||||||
|                 color           => COLORS->[1], |                 color           => COLORS->[1], | ||||||
|  | @ -1311,7 +1328,13 @@ sub load_print_object_toolpaths { | ||||||
|                 tverts          => $infill_tverts, |                 tverts          => $infill_tverts, | ||||||
|                 offsets         => { %infill_offsets }, |                 offsets         => { %infill_offsets }, | ||||||
|             ); |             ); | ||||||
|  |             $infill_qverts   = Slic3r::GUI::_3DScene::GLVertexArray->new; | ||||||
|  |             $infill_tverts   = Slic3r::GUI::_3DScene::GLVertexArray->new; | ||||||
|  |             %infill_offsets  = (); | ||||||
|  |         } | ||||||
| 
 | 
 | ||||||
|  |         if ($support_qverts->size() > $alloc_size_max || $support_tverts->size() > $alloc_size_max) { | ||||||
|  |             # Store the vertex arrays and restart their containers. | ||||||
|             push @{$self->volumes}, Slic3r::GUI::3DScene::Volume->new( |             push @{$self->volumes}, Slic3r::GUI::3DScene::Volume->new( | ||||||
|                 bounding_box    => $bb, |                 bounding_box    => $bb, | ||||||
|                 color           => COLORS->[2], |                 color           => COLORS->[2], | ||||||
|  | @ -1319,6 +1342,41 @@ sub load_print_object_toolpaths { | ||||||
|                 tverts          => $support_tverts, |                 tverts          => $support_tverts, | ||||||
|                 offsets         => { %support_offsets }, |                 offsets         => { %support_offsets }, | ||||||
|             ); |             ); | ||||||
|  |             $support_qverts   = Slic3r::GUI::_3DScene::GLVertexArray->new; | ||||||
|  |             $support_tverts   = Slic3r::GUI::_3DScene::GLVertexArray->new; | ||||||
|  |             %support_offsets  = (); | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     if ($perim_qverts->size() > 0 || $perim_tverts->size() > 0) { | ||||||
|  |         push @{$self->volumes}, Slic3r::GUI::3DScene::Volume->new( | ||||||
|  |             bounding_box    => $bb, | ||||||
|  |             color           => COLORS->[0], | ||||||
|  |             qverts          => $perim_qverts, | ||||||
|  |             tverts          => $perim_tverts, | ||||||
|  |             offsets         => { %perim_offsets }, | ||||||
|  |         ); | ||||||
|  |     } | ||||||
|  |      | ||||||
|  |     if ($infill_qverts->size() > 0 || $infill_tverts->size() > 0) { | ||||||
|  |         push @{$self->volumes}, Slic3r::GUI::3DScene::Volume->new( | ||||||
|  |             bounding_box    => $bb, | ||||||
|  |             color           => COLORS->[1], | ||||||
|  |             qverts          => $infill_qverts, | ||||||
|  |             tverts          => $infill_tverts, | ||||||
|  |             offsets         => { %infill_offsets }, | ||||||
|  |         ); | ||||||
|  |     } | ||||||
|  |      | ||||||
|  |     if ($support_qverts->size() > 0 || $support_tverts->size() > 0) { | ||||||
|  |         push @{$self->volumes}, Slic3r::GUI::3DScene::Volume->new( | ||||||
|  |             bounding_box    => $bb, | ||||||
|  |             color           => COLORS->[2], | ||||||
|  |             qverts          => $support_qverts, | ||||||
|  |             tverts          => $support_tverts, | ||||||
|  |             offsets         => { %support_offsets }, | ||||||
|  |         ); | ||||||
|  |     } | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| sub set_toolpaths_range { | sub set_toolpaths_range { | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 bubnikv
						bubnikv