diff --git a/lib/Slic3r/GUI/Plater.pm b/lib/Slic3r/GUI/Plater.pm index 3a024f938..66b40b277 100644 --- a/lib/Slic3r/GUI/Plater.pm +++ b/lib/Slic3r/GUI/Plater.pm @@ -1158,6 +1158,8 @@ sub split_object { $self->resume_background_process; return; } + + $_->center_around_origin for (@model_objects); $self->remove($obj_idx); $current_object = $obj_idx = undef; diff --git a/xs/src/libslic3r/Model.cpp b/xs/src/libslic3r/Model.cpp index 6714966e7..0cc15f81f 100644 --- a/xs/src/libslic3r/Model.cpp +++ b/xs/src/libslic3r/Model.cpp @@ -496,7 +496,7 @@ void ModelObject::center_around_origin() // apply rotation and scaling to vector as well before translating instance, // in order to leave final position unaltered Vectorf3 v = vector.negative(); - v.rotate(i->rotation, i->offset); + v.rotate(i->rotation); v.scale(i->scaling_factor); i->offset.translate(v.x, v.y); } @@ -639,19 +639,22 @@ void ModelObject::split(ModelObjectPtrs* new_objects) ModelVolume* volume = this->volumes.front(); TriangleMeshPtrs meshptrs = volume->mesh.split(); - for (TriangleMeshPtrs::iterator mesh = meshptrs.begin(); mesh != meshptrs.end(); ++mesh) { - (*mesh)->repair(); + for (TriangleMesh *mesh : meshptrs) { + // Snap the mesh to Z=0. + float z0 = FLT_MAX; + + mesh->repair(); ModelObject* new_object = m_model->add_object(*this, false); new_object->input_file = ""; - ModelVolume* new_volume = new_object->add_volume(**mesh); + ModelVolume* new_volume = new_object->add_volume(*mesh); new_volume->name = volume->name; new_volume->config = volume->config; new_volume->modifier = volume->modifier; new_volume->material_id(volume->material_id()); new_objects->push_back(new_object); - delete *mesh; + delete mesh; } return;