From 148732281d1b0cef815972f578e4035ec275eccd Mon Sep 17 00:00:00 2001 From: enricoturri1966 Date: Tue, 28 Feb 2023 11:47:46 +0100 Subject: [PATCH] Fixed rotation of mirrored objects in Object Coordinates --- src/slic3r/GUI/Selection.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/slic3r/GUI/Selection.cpp b/src/slic3r/GUI/Selection.cpp index 4e9ac43ea8..e45f214673 100644 --- a/src/slic3r/GUI/Selection.cpp +++ b/src/slic3r/GUI/Selection.cpp @@ -1006,9 +1006,17 @@ void Selection::rotate(const Vec3d& rotation, TransformationType transformation_ if (m_mode == Instance && !is_wipe_tower()) { assert(is_from_fully_selected_instance(i)); if (transformation_type.instance()) { - // ensure that the instance rotates as a rigid body + // ensure that the instance rotates as a rigid body + Transform3d inst_rotation_matrix = inst_trafo.get_rotation_matrix(); + if (inst_trafo.is_left_handed()) { + Geometry::TransformationSVD inst_svd(inst_trafo); + inst_rotation_matrix = inst_svd.u * inst_svd.v.transpose(); + // ensure the rotation has the proper direction + if (!rotation.normalized().cwiseAbs().isApprox(Vec3d::UnitX())) + rotation_matrix = rotation_matrix.inverse(); + } + const Transform3d inst_matrix_no_offset = inst_trafo.get_matrix_no_offset(); - const Transform3d inst_rotation_matrix = inst_trafo.get_rotation_matrix(); rotation_matrix = inst_matrix_no_offset.inverse() * inst_rotation_matrix * rotation_matrix * inst_rotation_matrix.inverse() * inst_matrix_no_offset; // rotate around selection center