diff --git a/lib/Slic3r/GUI/Plater.pm b/lib/Slic3r/GUI/Plater.pm index 951a4f30b0..f49856b6d5 100644 --- a/lib/Slic3r/GUI/Plater.pm +++ b/lib/Slic3r/GUI/Plater.pm @@ -659,6 +659,9 @@ sub rotate { $_->set_rotation(0) for @{ $model_object->instances }; } $model_object->rotate(deg2rad($angle), $axis); + + # realign object to Z = 0 + $model_object->center_around_origin; $self->make_thumbnail($obj_idx); } @@ -688,6 +691,9 @@ sub flip { $model_object->flip($axis); $model_object->update_bounding_box; + + # realign object to Z = 0 + $model_object->center_around_origin; $self->make_thumbnail($obj_idx); # update print and start background processing @@ -725,6 +731,7 @@ sub changescale { my $versor = [1,1,1]; $versor->[$axis] = $scale/100; $model_object->scale_xyz(Slic3r::Pointf3->new(@$versor)); + # object was already aligned to Z = 0, so no need to realign it $self->make_thumbnail($obj_idx); } else { # max scale factor should be above 2540 to allow importing files exported in inches diff --git a/lib/Slic3r/GUI/PreviewCanvas.pm b/lib/Slic3r/GUI/PreviewCanvas.pm index 6872af9898..9bba47cc30 100644 --- a/lib/Slic3r/GUI/PreviewCanvas.pm +++ b/lib/Slic3r/GUI/PreviewCanvas.pm @@ -351,8 +351,6 @@ sub set_bed_shape { sub load_object { my ($self, $object, $all_instances) = @_; - my $z_min = $object->raw_bounding_box->z_min; - # color mesh(es) by material my @materials = (); @@ -381,7 +379,6 @@ sub load_object { instance_idx => $instance_idx, mesh => $mesh, color => $color, - origin => Slic3r::Pointf3->new(0,0,-$z_min), ); push @volumes_idx, $#{$self->volumes}; diff --git a/lib/Slic3r/Model.pm b/lib/Slic3r/Model.pm index d3bbae030c..a7a3009ae7 100644 --- a/lib/Slic3r/Model.pm +++ b/lib/Slic3r/Model.pm @@ -272,6 +272,7 @@ sub rotate { } elsif ($axis == Z) { $_->mesh->rotate_z($angle) for @{$self->volumes}; } + $self->set_origin_translation(Slic3r::Pointf3->new(0,0,0)); $self->invalidate_bounding_box; } @@ -285,6 +286,7 @@ sub flip { } elsif ($axis == Z) { $_->mesh->flip_z for @{$self->volumes}; } + $self->set_origin_translation(Slic3r::Pointf3->new(0,0,0)); $self->invalidate_bounding_box; } diff --git a/xs/src/libslic3r/Model.cpp b/xs/src/libslic3r/Model.cpp index 40926eb93c..224ad67a79 100644 --- a/xs/src/libslic3r/Model.cpp +++ b/xs/src/libslic3r/Model.cpp @@ -520,6 +520,9 @@ ModelObject::scale(const Pointf3 &versor) for (ModelVolumePtrs::const_iterator v = this->volumes.begin(); v != this->volumes.end(); ++v) { (*v)->mesh.scale(versor); } + + // reset origin translation since it doesn't make sense anymore + this->origin_translation = Pointf3(0,0,0); this->invalidate_bounding_box(); } diff --git a/xs/src/libslic3r/Model.hpp b/xs/src/libslic3r/Model.hpp index 62bb38bfc5..56700d7a33 100644 --- a/xs/src/libslic3r/Model.hpp +++ b/xs/src/libslic3r/Model.hpp @@ -97,7 +97,7 @@ class ModelObject /* This vector accumulates the total translation applied to the object by the center_around_origin() method. Callers might want to apply the same translation - to new volumes before adding them to this object in order to preset alignment + to new volumes before adding them to this object in order to preserve alignment when user expects that. */ Pointf3 origin_translation;