From 17cbca5e064ad435de7fe46b6b1e88dc86789615 Mon Sep 17 00:00:00 2001 From: Alessandro Ranellucci <aar@cpan.org> Date: Sun, 10 Mar 2013 12:22:40 +0100 Subject: [PATCH] Factor out layer height in support material generation --- lib/Slic3r/Print/Object.pm | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/lib/Slic3r/Print/Object.pm b/lib/Slic3r/Print/Object.pm index e3dec9aa5..26fec8186 100644 --- a/lib/Slic3r/Print/Object.pm +++ b/lib/Slic3r/Print/Object.pm @@ -710,13 +710,10 @@ sub generate_support_material { my $self = shift; return if $self->layer_count < 2; - my $overhang_width; + my $threshold_rad; if ($Slic3r::Config->support_material_threshold) { - my $threshold_rad = deg2rad($Slic3r::Config->support_material_threshold + 1); # +1 makes the threshold inclusive + $threshold_rad = deg2rad($Slic3r::Config->support_material_threshold + 1); # +1 makes the threshold inclusive Slic3r::debugf "Threshold angle = %d°\n", rad2deg($threshold_rad); - $overhang_width = scale $Slic3r::Config->layer_height * ((cos $threshold_rad) / (sin $threshold_rad)); - } else { - $overhang_width = $self->layers->[1]->regions->[0]->overhang_width; } my $flow = $self->print->support_material_flow; my $distance_from_object = 1.5 * $flow->scaled_width; @@ -740,6 +737,11 @@ sub generate_support_material { my $layer = $self->layers->[$i]; my $lower_layer = $i > 0 ? $self->layers->[$i-1] : undef; + # overhang width must be computed on lower layer + my $overhang_width = $Slic3r::Config->support_material_threshold + ? scale $lower_layer->height * ((cos $threshold_rad) / (sin $threshold_rad)) + : $self->layers->[1]->regions->[0]->overhang_width; + my @current_layer_offsetted_slices = map $_->offset_ex($distance_from_object), @{$layer->slices}; # $upper_layers_overhangs[-1] contains the overhangs of the upper layer, regardless of any interface layers