diff --git a/xs/src/libslic3r/Format/3mf.cpp b/xs/src/libslic3r/Format/3mf.cpp index b838f65c1..4dc40bd3c 100644 --- a/xs/src/libslic3r/Format/3mf.cpp +++ b/xs/src/libslic3r/Format/3mf.cpp @@ -1738,10 +1738,7 @@ namespace Slic3r { stream << " \n"; } - Transform3d t = Transform3d::Identity(); - t.translate(Vec3d(instance->offset(0), instance->offset(1), 0.0)); - t.rotate(Eigen::AngleAxisd(instance->rotation, Vec3d::UnitZ())); - t.scale(instance->scaling_factor); + Transform3d t = instance->world_matrix(); build_items.emplace_back(instance_id, t); stream << " \n"; diff --git a/xs/src/slic3r/GUI/GLCanvas3D.cpp b/xs/src/slic3r/GUI/GLCanvas3D.cpp index 73966a7f5..36f664f34 100644 --- a/xs/src/slic3r/GUI/GLCanvas3D.cpp +++ b/xs/src/slic3r/GUI/GLCanvas3D.cpp @@ -2999,9 +2999,9 @@ void GLCanvas3D::on_mouse(wxMouseEvent& evt) if (m_gizmos.get_current_type() == Gizmos::Flatten) { // Rotate the object so the normal points downward: Vec3d normal = m_gizmos.get_flattening_normal(); - if (normal != Vec3d::Zero()) { - Vec3d axis = normal(2) > 0.999f ? Vec3d::UnitX() : normal.cross(-Vec3d::UnitZ()); - float angle = acos(-normal(2)); + if (normal(0) != 0.0 || normal(1) != 0.0 || normal(2) != 0.0) { + Vec3d axis = normal(2) > 0.999 ? Vec3d::UnitX() : normal.cross(-Vec3d::UnitZ()).normalized(); + float angle = acos(clamp(-1.0, 1.0, -normal(2))); m_on_gizmo_rotate_callback.call(angle, (float)axis(0), (float)axis(1), (float)axis(2)); } } diff --git a/xs/src/slic3r/GUI/GLGizmo.cpp b/xs/src/slic3r/GUI/GLGizmo.cpp index a35165db4..aa4152c85 100644 --- a/xs/src/slic3r/GUI/GLGizmo.cpp +++ b/xs/src/slic3r/GUI/GLGizmo.cpp @@ -1282,7 +1282,7 @@ bool GLGizmoFlatten::is_plane_update_necessary() const Vec3d GLGizmoFlatten::get_flattening_normal() const { Vec3d normal = m_model_object->instances.front()->world_matrix().matrix().block(0, 0, 3, 3) * m_normal; m_normal = Vec3d::Zero(); - return normal; + return normal.normalized(); } } // namespace GUI