From 49531f6f7834d5b00a27fd91cfeccc57286e87cd Mon Sep 17 00:00:00 2001 From: Alessandro Ranellucci Date: Fri, 31 May 2013 19:41:31 +0200 Subject: [PATCH] Fixed regression causing rotation from plater to also translate the resulting G-code. #1191 --- lib/Slic3r/GUI/Plater.pm | 3 +-- lib/Slic3r/Model.pm | 2 +- lib/Slic3r/Print.pm | 2 +- lib/Slic3r/TriangleMesh.pm | 4 ++-- 4 files changed, 5 insertions(+), 6 deletions(-) diff --git a/lib/Slic3r/GUI/Plater.pm b/lib/Slic3r/GUI/Plater.pm index e70414a3c..1e229a78b 100644 --- a/lib/Slic3r/GUI/Plater.pm +++ b/lib/Slic3r/GUI/Plater.pm @@ -718,7 +718,7 @@ sub make_model { } $new_model_object->scale($plater_object->scale); $new_model_object->add_instance( - rotation => $plater_object->rotate, + rotation => $plater_object->rotate, # around center point offset => [ @$_ ], ) for @{$plater_object->instances}; $new_model_object->align_to_origin; @@ -1128,7 +1128,6 @@ sub instances_count { sub make_thumbnail { my $self = shift; - my @points = map [ @$_[X,Y] ], @{$self->model_object->mesh->vertices}; my $mesh = $self->model_object->mesh; my $thumbnail = Slic3r::ExPolygon::Collection->new( expolygons => (@{$mesh->facets} <= 5000) diff --git a/lib/Slic3r/Model.pm b/lib/Slic3r/Model.pm index cb740ab74..708247265 100644 --- a/lib/Slic3r/Model.pm +++ b/lib/Slic3r/Model.pm @@ -390,7 +390,7 @@ package Slic3r::Model::Instance; use Moo; has 'object' => (is => 'ro', weak_ref => 1, required => 1); -has 'rotation' => (is => 'rw', default => sub { 0 }); +has 'rotation' => (is => 'rw', default => sub { 0 }); # around mesh center point has 'offset' => (is => 'rw'); 1; diff --git a/lib/Slic3r/Print.pm b/lib/Slic3r/Print.pm index 0e4182da5..ae2992484 100644 --- a/lib/Slic3r/Print.pm +++ b/lib/Slic3r/Print.pm @@ -122,7 +122,7 @@ sub add_model { # we ignore the per-instance rotation currently and only # consider the first one - $mesh->rotate($object->instances->[0]->rotation); + $mesh->rotate($object->instances->[0]->rotation, $mesh->center); $mesh->scale(1 / &Slic3r::SCALING_FACTOR); } diff --git a/lib/Slic3r/TriangleMesh.pm b/lib/Slic3r/TriangleMesh.pm index 0968f7354..f6146d540 100644 --- a/lib/Slic3r/TriangleMesh.pm +++ b/lib/Slic3r/TriangleMesh.pm @@ -324,14 +324,14 @@ sub make_loops { sub rotate { my $self = shift; - my ($deg) = @_; + my ($deg, $center) = @_; return if $deg == 0; my $rad = Slic3r::Geometry::deg2rad($deg); # transform vertex coordinates foreach my $vertex (@{$self->vertices}) { - @$vertex = (@{ +(Slic3r::Geometry::rotate_points($rad, undef, [ $vertex->[X], $vertex->[Y] ]))[0] }, $vertex->[Z]); + @$vertex = (@{ +(Slic3r::Geometry::rotate_points($rad, $center, [ $vertex->[X], $vertex->[Y] ]))[0] }, $vertex->[Z]); } }