From 79ce094e3afcf5ded39cb203f8ffd01cdb1dd0e5 Mon Sep 17 00:00:00 2001 From: Alessandro Ranellucci Date: Sun, 3 May 2015 18:28:39 +0200 Subject: [PATCH] Bugfix: splitting a rotated object resulted in wrong positions. #2772 --- xs/src/libslic3r/Model.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/xs/src/libslic3r/Model.cpp b/xs/src/libslic3r/Model.cpp index 6fafe9bf0..fc9f39b3f 100644 --- a/xs/src/libslic3r/Model.cpp +++ b/xs/src/libslic3r/Model.cpp @@ -482,7 +482,12 @@ ModelObject::center_around_origin() if (!this->instances.empty()) { for (ModelInstancePtrs::const_iterator i = this->instances.begin(); i != this->instances.end(); ++i) { - (*i)->offset.translate(-vector.x, -vector.y); + // apply rotation and scaling to vector as well before translating instance, + // in order to leave final position unaltered + Vectorf3 v = vector.negative(); + v.rotate(Slic3r::Geometry::deg2rad((*i)->rotation), (*i)->offset); + v.scale((*i)->scaling_factor); + (*i)->offset.translate(v.x, v.y); } this->update_bounding_box(); }