From 21de9d23eceb0ba32acfe356a986b90eb32ed360 Mon Sep 17 00:00:00 2001 From: Lukas Matena Date: Thu, 28 May 2020 16:14:05 +0200 Subject: [PATCH] Bugfix: Cut gizmo ignored SLA elevation and the cut ended up shifted It is still possible to set the plane into the space under an object, but at least it always cuts where indicated. --- src/slic3r/GUI/Gizmos/GLGizmoCut.cpp | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/slic3r/GUI/Gizmos/GLGizmoCut.cpp b/src/slic3r/GUI/Gizmos/GLGizmoCut.cpp index 17c10f4858..4c00f8f2fd 100644 --- a/src/slic3r/GUI/Gizmos/GLGizmoCut.cpp +++ b/src/slic3r/GUI/Gizmos/GLGizmoCut.cpp @@ -198,12 +198,20 @@ void GLGizmoCut::set_cut_z(double cut_z) const void GLGizmoCut::perform_cut(const Selection& selection) { - const auto instance_idx = selection.get_instance_idx(); - const auto object_idx = selection.get_object_idx(); + const int instance_idx = selection.get_instance_idx(); + const int object_idx = selection.get_object_idx(); wxCHECK_RET(instance_idx >= 0 && object_idx >= 0, "GLGizmoCut: Invalid object selection"); - wxGetApp().plater()->cut(object_idx, instance_idx, m_cut_z, m_keep_upper, m_keep_lower, m_rotate_lower); + // m_cut_z is the distance from the bed. Subtract possible SLA elevation. + const GLVolume* first_glvolume = selection.get_volume(*selection.get_volume_idxs().begin()); + coordf_t object_cut_z = m_cut_z - first_glvolume->get_sla_shift_z(); + + if (object_cut_z > 0.) + wxGetApp().plater()->cut(object_idx, instance_idx, object_cut_z, m_keep_upper, m_keep_lower, m_rotate_lower); + else { + // the object is SLA-elevated and the plane is under it. + } } double GLGizmoCut::calc_projection(const Linef3& mouse_ray) const