mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-08-07 22:14:00 -06:00
CLIPPER_OFFSET_SCALE was made a power of two, the scaling functions
inside ClipperUtils are now using bit shifts instead of multiplication by doubles, which makes the scaling precise. Removed the scale parameter from all offset functions. Modified the safety offset to calculate offset per polygon instead of over all polygons at once. The old way was not safe and very slow, sometimes this meant a kiss of death for supports for example.
This commit is contained in:
parent
e93253e270
commit
695c92fb00
14 changed files with 214 additions and 152 deletions
|
@ -173,7 +173,7 @@ sub repaint {
|
|||
|
||||
# if sequential printing is enabled and we have more than one object, draw clearance area
|
||||
if ($self->{config}->complete_objects && (map @{$_->instances}, @{$self->{model}->objects}) > 1) {
|
||||
my ($clearance) = @{offset([$thumbnail->convex_hull], (scale($self->{config}->extruder_clearance_radius) / 2), 1, JT_ROUND, scale(0.1))};
|
||||
my ($clearance) = @{offset([$thumbnail->convex_hull], (scale($self->{config}->extruder_clearance_radius) / 2), JT_ROUND, scale(0.1))};
|
||||
$dc->SetPen($self->{clearance_pen});
|
||||
$dc->SetBrush($self->{transparent_brush});
|
||||
$dc->DrawPolygon($self->scaled_points_to_pixel($clearance, 1), 0, 0);
|
||||
|
@ -185,7 +185,7 @@ sub repaint {
|
|||
if (@{$self->{objects}} && $self->{config}->skirts) {
|
||||
my @points = map @{$_->contour}, map @$_, map @{$_->instance_thumbnails}, @{$self->{objects}};
|
||||
if (@points >= 3) {
|
||||
my ($convex_hull) = @{offset([convex_hull(\@points)], scale max($self->{config}->brim_width + $self->{config}->skirt_distance), 1, JT_ROUND, scale(0.1))};
|
||||
my ($convex_hull) = @{offset([convex_hull(\@points)], scale max($self->{config}->brim_width + $self->{config}->skirt_distance), JT_ROUND, scale(0.1))};
|
||||
$dc->SetPen($self->{skirt_pen});
|
||||
$dc->SetBrush($self->{transparent_brush});
|
||||
$dc->DrawPolygon($self->scaled_points_to_pixel($convex_hull, 1), 0, 0);
|
||||
|
|
|
@ -7,7 +7,7 @@ our @ISA = qw(Exporter);
|
|||
our @EXPORT_OK = qw(offset offset_ex
|
||||
diff_ex diff union_ex intersection_ex xor_ex JT_ROUND JT_MITER
|
||||
JT_SQUARE is_counter_clockwise union_pt offset2 offset2_ex
|
||||
intersection intersection_pl diff_pl union CLIPPER_OFFSET_SCALE
|
||||
intersection intersection_pl diff_pl union
|
||||
union_pt_chained diff_ppl intersection_ppl);
|
||||
|
||||
1;
|
||||
|
|
|
@ -276,7 +276,7 @@ sub make_skirt {
|
|||
my $distance = scale max($self->config->skirt_distance, $self->config->brim_width);
|
||||
for (my $i = $skirts; $i > 0; $i--) {
|
||||
$distance += scale $spacing;
|
||||
my $loop = offset([$convex_hull], $distance, 1, JT_ROUND, scale(0.1))->[0];
|
||||
my $loop = offset([$convex_hull], $distance, JT_ROUND, scale(0.1))->[0];
|
||||
my $eloop = Slic3r::ExtrusionLoop->new_from_paths(
|
||||
Slic3r::ExtrusionPath->new(
|
||||
polyline => Slic3r::Polygon->new(@$loop)->split_at_first_point,
|
||||
|
@ -369,7 +369,7 @@ sub make_brim {
|
|||
# -0.5 because islands are not represented by their centerlines
|
||||
# (first offset more, then step back - reverse order than the one used for
|
||||
# perimeters because here we're offsetting outwards)
|
||||
push @loops, @{offset2(\@islands, ($i + 0.5) * $flow->scaled_spacing, -1.0 * $flow->scaled_spacing, 100000, JT_SQUARE)};
|
||||
push @loops, @{offset2(\@islands, ($i + 0.5) * $flow->scaled_spacing, -1.0 * $flow->scaled_spacing, JT_SQUARE)};
|
||||
}
|
||||
|
||||
$self->brim->append(map Slic3r::ExtrusionLoop->new_from_paths(
|
||||
|
|
|
@ -7,7 +7,7 @@ use List::Util qw(min max sum first);
|
|||
use Slic3r::Flow ':roles';
|
||||
use Slic3r::Geometry qw(X Y Z PI scale unscale chained_path epsilon);
|
||||
use Slic3r::Geometry::Clipper qw(diff diff_ex intersection intersection_ex union union_ex
|
||||
offset offset_ex offset2 offset2_ex intersection_ppl CLIPPER_OFFSET_SCALE JT_MITER);
|
||||
offset offset_ex offset2 offset2_ex intersection_ppl JT_MITER);
|
||||
use Slic3r::Print::State ':steps';
|
||||
use Slic3r::Surface ':types';
|
||||
|
||||
|
@ -863,7 +863,7 @@ sub discover_horizontal_shells {
|
|||
# and it's not wanted in a hollow print even if it would make sense when
|
||||
# obeying the solid shell count option strictly (DWIM!)
|
||||
my $margin = $neighbor_layerm->flow(FLOW_ROLE_EXTERNAL_PERIMETER)->scaled_width;
|
||||
my $regularized = offset2($new_internal_solid, -$margin, +$margin, CLIPPER_OFFSET_SCALE, JT_MITER, 5);
|
||||
my $regularized = offset2($new_internal_solid, -$margin, +$margin, JT_MITER, 5);
|
||||
my $too_narrow = diff(
|
||||
$new_internal_solid,
|
||||
$regularized,
|
||||
|
@ -893,7 +893,7 @@ sub discover_horizontal_shells {
|
|||
# have the same angle, so the next shell would be grown even more and so on.
|
||||
my $too_narrow = diff(
|
||||
$new_internal_solid,
|
||||
offset2($new_internal_solid, -$margin, +$margin, CLIPPER_OFFSET_SCALE, JT_MITER, 5),
|
||||
offset2($new_internal_solid, -$margin, +$margin, JT_MITER, 5),
|
||||
1,
|
||||
);
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@ use Slic3r::ExtrusionPath ':roles';
|
|||
use Slic3r::Flow ':roles';
|
||||
use Slic3r::Geometry qw(epsilon scale scaled_epsilon PI rad2deg deg2rad convex_hull);
|
||||
use Slic3r::Geometry::Clipper qw(offset diff union union_ex intersection offset_ex offset2
|
||||
intersection_pl offset2_ex diff_pl CLIPPER_OFFSET_SCALE JT_MITER JT_ROUND);
|
||||
intersection_pl offset2_ex diff_pl JT_MITER JT_ROUND);
|
||||
use Slic3r::Surface ':types';
|
||||
|
||||
has 'print_config' => (is => 'rw', required => 1);
|
||||
|
@ -299,9 +299,8 @@ sub contact_area {
|
|||
offset(
|
||||
$diff,
|
||||
$_,
|
||||
CLIPPER_OFFSET_SCALE,
|
||||
JT_ROUND,
|
||||
scale(0.05)*CLIPPER_OFFSET_SCALE),
|
||||
scale(0.05)),
|
||||
$slices_margin
|
||||
);
|
||||
}
|
||||
|
@ -584,9 +583,8 @@ sub generate_base_layers {
|
|||
$fillet_radius_scaled,
|
||||
-$fillet_radius_scaled,
|
||||
# Use a geometric offsetting for filleting.
|
||||
CLIPPER_OFFSET_SCALE,
|
||||
JT_ROUND,
|
||||
0.2*$fillet_radius_scaled*CLIPPER_OFFSET_SCALE),
|
||||
0.2*$fillet_radius_scaled),
|
||||
$trim_polygons,
|
||||
0); # don't apply the safety offset.
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue