From cdc709111430ea693d31817693ad6d1f1b2fa993 Mon Sep 17 00:00:00 2001 From: Alessandro Ranellucci Date: Thu, 25 Jul 2013 22:32:03 +0200 Subject: [PATCH] Implement --support-material-enforce-layers --- lib/Slic3r/Print/Object.pm | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/lib/Slic3r/Print/Object.pm b/lib/Slic3r/Print/Object.pm index 16146491..b20e7f37 100644 --- a/lib/Slic3r/Print/Object.pm +++ b/lib/Slic3r/Print/Object.pm @@ -842,16 +842,24 @@ sub generate_support_material { my $diff; # If a threshold angle was specified, use a different logic for detecting overhangs. - if (defined $threshold_rad) { - my $d = scale $lower_layer->height * ((cos $threshold_rad) / (sin $threshold_rad)); + if (defined $threshold_rad || $layer_id <= $Slic3r::Config->support_material_enforce_layers) { + my $d = defined $threshold_rad + ? scale $lower_layer->height * ((cos $threshold_rad) / (sin $threshold_rad)) + : 0; + $diff = diff( [ offset([ map $_->p, @{$layerm->slices} ], -$d) ], [ map @$_, @{$lower_layer->slices} ], ); + + # only enforce spacing from the object ($fw/2) if the threshold angle + # is not too high: in that case, $d will be very small (as we need to catch + # very short overhangs), and such contact area would be eaten by the + # enforced spacing, resulting in high threshold angles to be almost ignored $diff = diff( [ offset($diff, $d - $fw/2) ], [ map @$_, @{$lower_layer->slices} ], - ); + ) if $d > $fw/2; } else { $diff = diff( [ offset([ map $_->p, @{$layerm->slices} ], -$fw/2) ],