diff --git a/Build.PL b/Build.PL index b09e9e879..d7d4d8e8a 100644 --- a/Build.PL +++ b/Build.PL @@ -19,6 +19,7 @@ my $build = Module::Build->new( 'Moo' => '0.091009', 'perl' => '5.10.0', 'Scalar::Util' => '0', + 'Storable' => '0', 'Time::HiRes' => '0', }, build_requires => { diff --git a/lib/Slic3r/GUI/Plater.pm b/lib/Slic3r/GUI/Plater.pm index 36e0186e5..ae66ba8e7 100644 --- a/lib/Slic3r/GUI/Plater.pm +++ b/lib/Slic3r/GUI/Plater.pm @@ -692,6 +692,12 @@ sub make_model { my $model = Slic3r::Model->new; foreach my $plater_object (@{$self->{objects}}) { my $model_object = $plater_object->get_model_object; + + # if we need to alter the mesh, clone it first + if ($plater_object->scale != 1) { + $model_object = $model_object->clone; + } + my $new_model_object = $model->add_object( vertices => $model_object->vertices, input_file => $plater_object->input_file, @@ -1091,7 +1097,7 @@ sub free_model_object { my $self = shift; # only delete mesh from memory if we can retrieve it from the original file - return unless $self->input_file && $self->input_file_object_id; + return unless $self->input_file && defined $self->input_file_object_id; $self->model_object(undef); } diff --git a/lib/Slic3r/Model.pm b/lib/Slic3r/Model.pm index fef1f8346..58473fa9f 100644 --- a/lib/Slic3r/Model.pm +++ b/lib/Slic3r/Model.pm @@ -75,6 +75,7 @@ use Moo; use List::Util qw(first); use Slic3r::Geometry qw(X Y Z); +use Storable qw(dclone); has 'input_file' => (is => 'rw'); has 'model' => (is => 'ro', weak_ref => 1, required => 1); @@ -145,6 +146,8 @@ sub check_manifoldness { return (first { !$_->mesh->check_manifoldness } @{$self->volumes}) ? 0 : 1; } +sub clone { dclone($_[0]) } + package Slic3r::Model::Volume; use Moo;