From 76562d1e75a3c23cfdfa760dc92e6663427e0c29 Mon Sep 17 00:00:00 2001 From: enricoturri1966 Date: Fri, 15 Jul 2022 14:55:13 +0200 Subject: [PATCH] SPE-1252 - Fixed update of contours in Cut Gizmo when modifying the orientation or the scale of a part of a multipart object --- src/slic3r/GUI/Gizmos/GLGizmoCut.cpp | 12 ++++++++++-- src/slic3r/GUI/Gizmos/GLGizmoCut.hpp | 1 + 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/slic3r/GUI/Gizmos/GLGizmoCut.cpp b/src/slic3r/GUI/Gizmos/GLGizmoCut.cpp index bbf1623d0..f77c007fe 100644 --- a/src/slic3r/GUI/Gizmos/GLGizmoCut.cpp +++ b/src/slic3r/GUI/Gizmos/GLGizmoCut.cpp @@ -278,16 +278,23 @@ void GLGizmoCut::update_contours() const ModelObject* model_object = wxGetApp().model().objects[selection.get_object_idx()]; const int instance_idx = selection.get_instance_idx(); std::vector volumes_idxs = std::vector(model_object->volumes.size()); + std::vector volumes_trafos = std::vector(model_object->volumes.size()); for (size_t i = 0; i < model_object->volumes.size(); ++i) { volumes_idxs[i] = model_object->volumes[i]->id(); + volumes_trafos[i] = model_object->volumes[i]->get_matrix(); } + bool trafos_match = std::equal(volumes_trafos.begin(), volumes_trafos.end(), + m_cut_contours.volumes_trafos.begin(), m_cut_contours.volumes_trafos.end(), + [](const Transform3d& a, const Transform3d& b) { return a.isApprox(b); }); + if (0.0 < m_cut_z && m_cut_z < m_max_z) { if (m_cut_contours.cut_z != m_cut_z || m_cut_contours.object_id != model_object->id() || - m_cut_contours.instance_idx != instance_idx || m_cut_contours.volumes_idxs != volumes_idxs) { + m_cut_contours.instance_idx != instance_idx || m_cut_contours.volumes_idxs != volumes_idxs || + !trafos_match) { m_cut_contours.cut_z = m_cut_z; - if (m_cut_contours.object_id != model_object->id() || m_cut_contours.volumes_idxs != volumes_idxs) + if (m_cut_contours.object_id != model_object->id() || m_cut_contours.volumes_idxs != volumes_idxs || !trafos_match) m_cut_contours.mesh = model_object->raw_mesh(); m_cut_contours.position = box.center(); @@ -295,6 +302,7 @@ void GLGizmoCut::update_contours() m_cut_contours.object_id = model_object->id(); m_cut_contours.instance_idx = instance_idx; m_cut_contours.volumes_idxs = volumes_idxs; + m_cut_contours.volumes_trafos = volumes_trafos; m_cut_contours.contours.reset(); MeshSlicingParams slicing_params; diff --git a/src/slic3r/GUI/Gizmos/GLGizmoCut.hpp b/src/slic3r/GUI/Gizmos/GLGizmoCut.hpp index 4113632c0..6af0223bf 100644 --- a/src/slic3r/GUI/Gizmos/GLGizmoCut.hpp +++ b/src/slic3r/GUI/Gizmos/GLGizmoCut.hpp @@ -34,6 +34,7 @@ class GLGizmoCut : public GLGizmoBase ObjectID object_id; int instance_idx{ -1 }; std::vector volumes_idxs; + std::vector volumes_trafos; }; CutContours m_cut_contours;