Fixed regression causing rotation from plater to also translate the resulting G-code. #1191

This commit is contained in:
Alessandro Ranellucci 2013-05-31 19:41:31 +02:00
parent c62b49d1af
commit 49531f6f78
4 changed files with 5 additions and 6 deletions

View File

@ -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)

View File

@ -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;

View File

@ -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);
}

View File

@ -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]);
}
}