Fix plater slowness after the introduction of the vertical projection
This commit is contained in:
parent
93310a6a81
commit
b495e15d7f
2 changed files with 10 additions and 8 deletions
|
@ -1119,20 +1119,21 @@ sub make_thumbnail {
|
||||||
my @points = map [ @$_[X,Y] ], @{$self->model_object->mesh->vertices};
|
my @points = map [ @$_[X,Y] ], @{$self->model_object->mesh->vertices};
|
||||||
my $mesh = $self->model_object->mesh;
|
my $mesh = $self->model_object->mesh;
|
||||||
my $thumbnail = Slic3r::ExPolygon::Collection->new(
|
my $thumbnail = Slic3r::ExPolygon::Collection->new(
|
||||||
expolygons => (@{$mesh->facets} <= 2000)
|
expolygons => (@{$mesh->facets} <= 5000)
|
||||||
? $mesh->horizontal_projection
|
? $mesh->horizontal_projection
|
||||||
: [ Slic3r::ExPolygon->new(convex_hull($mesh->vertices)) ],
|
: [ Slic3r::ExPolygon->new(convex_hull($mesh->vertices)) ],
|
||||||
);
|
);
|
||||||
for (map @$_, map @$_, @{$thumbnail->expolygons}) {
|
for (map @$_, map @$_, @{$thumbnail->expolygons}) {
|
||||||
@$_ = map $_ * $self->thumbnail_scaling_factor, @$_;
|
@$_ = map $_ * $self->thumbnail_scaling_factor, @$_;
|
||||||
}
|
}
|
||||||
for (@{$thumbnail->expolygons}) {
|
foreach my $expolygon (@{$thumbnail->expolygons}) {
|
||||||
$_->simplify(0.3);
|
@$expolygon = grep $_->area >= 1, @$expolygon;
|
||||||
$_->rotate(Slic3r::Geometry::deg2rad($self->rotate));
|
$expolygon->simplify(0.5);
|
||||||
$_->scale($self->scale);
|
$expolygon->rotate(Slic3r::Geometry::deg2rad($self->rotate));
|
||||||
|
$expolygon->scale($self->scale);
|
||||||
}
|
}
|
||||||
|
@{$thumbnail->expolygons} = grep @$_, @{$thumbnail->expolygons};
|
||||||
$thumbnail->align_to_origin;
|
$thumbnail->align_to_origin;
|
||||||
|
|
||||||
$self->thumbnail($thumbnail); # ignored in multi-threaded environments
|
$self->thumbnail($thumbnail); # ignored in multi-threaded environments
|
||||||
$self->free_model_object;
|
$self->free_model_object;
|
||||||
|
|
||||||
|
|
|
@ -584,11 +584,12 @@ sub horizontal_projection {
|
||||||
|
|
||||||
my @f = ();
|
my @f = ();
|
||||||
foreach my $facet (@{$self->facets}) {
|
foreach my $facet (@{$self->facets}) {
|
||||||
push @f, [ map [ @{$self->vertices->[$_]}[X,Y] ], @$facet ];
|
push @f, Slic3r::Polygon->new([ map [ @{$self->vertices->[$_]}[X,Y] ], @$facet ]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$_->make_counter_clockwise for @f;
|
||||||
my $scale_vector = Math::Clipper::integerize_coordinate_sets({ bits => 32 }, @f);
|
my $scale_vector = Math::Clipper::integerize_coordinate_sets({ bits => 32 }, @f);
|
||||||
my $union = union_ex([ Slic3r::Geometry::Clipper::offset(\@f, 1) ]);
|
my $union = union_ex([ Slic3r::Geometry::Clipper::offset(\@f, 10000) ]);
|
||||||
Math::Clipper::unscale_coordinate_sets($scale_vector, $_) for @$union;
|
Math::Clipper::unscale_coordinate_sets($scale_vector, $_) for @$union;
|
||||||
return $union;
|
return $union;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue