diff --git a/README.markdown b/README.markdown index 43bf64017..f335450a8 100644 --- a/README.markdown +++ b/README.markdown @@ -189,7 +189,8 @@ The author of the Silk icon set is Mark James. Support material options: --support-material Generate support material for overhangs --support-material-threshold - Overhang threshold angle (range: 0-90, default: 45) + Overhang threshold angle (range: 0-90, set 0 for automatic detection, + default: 0) --support-material-pattern Pattern to use for support material (default: rectilinear) --support-material-spacing diff --git a/lib/Slic3r/Config.pm b/lib/Slic3r/Config.pm index c9594cac3..90f981364 100644 --- a/lib/Slic3r/Config.pm +++ b/lib/Slic3r/Config.pm @@ -536,11 +536,11 @@ our $Options = { }, 'support_material_threshold' => { label => 'Overhang threshold', - tooltip => 'Support material will not generated for overhangs whose slope angle is above the given threshold.', + tooltip => 'Support material will not generated for overhangs whose slope angle is above the given threshold. Set to zero for automatic detection.', sidetext => '°', cli => 'support-material-threshold=i', type => 'i', - default => 45, + default => 0, }, 'support_material_pattern' => { label => 'Pattern', diff --git a/lib/Slic3r/Print/Object.pm b/lib/Slic3r/Print/Object.pm index 86cebb675..bf4f77aa0 100644 --- a/lib/Slic3r/Print/Object.pm +++ b/lib/Slic3r/Print/Object.pm @@ -2,7 +2,7 @@ package Slic3r::Print::Object; use Moo; use Slic3r::ExtrusionPath ':roles'; -use Slic3r::Geometry qw(Z scale unscale deg2rad scaled_epsilon); +use Slic3r::Geometry qw(Z PI scale unscale deg2rad rad2deg scaled_epsilon); use Slic3r::Geometry::Clipper qw(diff_ex intersection_ex union_ex); use Slic3r::Surface ':types'; @@ -531,8 +531,12 @@ sub combine_infill { sub generate_support_material { my $self = shift; + my $threshold_rad = $Slic3r::Config->support_material_threshold + ? deg2rad($Slic3r::Config->support_material_threshold + 1) # +1 makes the threshold inclusive + : PI/2 - atan2($self->layers->[1]->regions->[0]->perimeter_flow->width/$Slic3r::Config->layer_height/2, 1); + Slic3r::debugf "Threshold angle = %d°\n", rad2deg($threshold_rad); + my $flow = $self->print->support_material_flow; - my $threshold_rad = deg2rad($Slic3r::Config->support_material_threshold + 1); # +1 makes the threshold inclusive my $overhang_width = $threshold_rad == 0 ? undef : scale $Slic3r::Config->layer_height * ((cos $threshold_rad) / (sin $threshold_rad)); my $distance_from_object = 1.5 * $flow->scaled_width; my $pattern_spacing = ($Slic3r::Config->support_material_spacing > $flow->spacing) diff --git a/slic3r.pl b/slic3r.pl index 51a58271d..bafd98749 100755 --- a/slic3r.pl +++ b/slic3r.pl @@ -237,7 +237,8 @@ $j Support material options: --support-material Generate support material for overhangs --support-material-threshold - Overhang threshold angle (range: 0-90, default: $config->{support_material_threshold}) + Overhang threshold angle (range: 0-90, set 0 for automatic detection, + default: $config->{support_material_threshold}) --support-material-pattern Pattern to use for support material (default: $config->{support_material_pattern}) --support-material-spacing