From 5813ec08c92c1a9bce3e5ef2b7e539b20cb8c829 Mon Sep 17 00:00:00 2001 From: Lukas Matena Date: Wed, 28 Nov 2018 11:37:17 +0100 Subject: [PATCH] Place on bed planes recalculation after individual volumes are manipulated --- src/slic3r/GUI/GLGizmo.cpp | 20 ++++++-------------- src/slic3r/GUI/GLGizmo.hpp | 6 +----- 2 files changed, 7 insertions(+), 19 deletions(-) diff --git a/src/slic3r/GUI/GLGizmo.cpp b/src/slic3r/GUI/GLGizmo.cpp index 8d22baac5..7119fb367 100644 --- a/src/slic3r/GUI/GLGizmo.cpp +++ b/src/slic3r/GUI/GLGizmo.cpp @@ -1559,11 +1559,9 @@ void GLGizmoFlatten::update_planes() m_planes.resize(std::min((int)m_planes.size(), 254)); // Planes are finished - let's save what we calculated it from: - m_source_data.bounding_boxes.clear(); - for (const auto& vol : m_model_object->volumes) - m_source_data.bounding_boxes.push_back(vol->get_convex_hull().bounding_box()); - const float* first_vertex = m_model_object->volumes.front()->get_convex_hull().first_vertex(); - m_source_data.mesh_first_point = Vec3d((double)first_vertex[0], (double)first_vertex[1], (double)first_vertex[2]); + m_volumes_matrices.clear(); + for (const ModelVolume* vol : m_model_object->volumes) + m_volumes_matrices.push_back(vol->get_matrix()); } // Check if the bounding boxes of each volume's convex hull is the same as before @@ -1573,19 +1571,13 @@ bool GLGizmoFlatten::is_plane_update_necessary() const if (m_state != On || !m_model_object || m_model_object->instances.empty()) return false; - if (m_model_object->volumes.size() != m_source_data.bounding_boxes.size()) + if (m_model_object->volumes.size() != m_volumes_matrices.size()) return true; - // now compare the bounding boxes: - for (unsigned int i=0; ivolumes.size(); ++i) - if (m_model_object->volumes[i]->get_convex_hull().bounding_box() != m_source_data.bounding_boxes[i]) + for (unsigned int i=0; i < m_model_object->volumes.size(); ++i) + if (! m_model_object->volumes[i]->get_matrix().isApprox(m_volumes_matrices[i])) return true; - const float* first_vertex = m_model_object->volumes.front()->get_convex_hull().first_vertex(); - Vec3d first_point((double)first_vertex[0], (double)first_vertex[1], (double)first_vertex[2]); - if (first_point != m_source_data.mesh_first_point) - return true; - return false; } diff --git a/src/slic3r/GUI/GLGizmo.hpp b/src/slic3r/GUI/GLGizmo.hpp index a229e44c7..e06cfa4bd 100644 --- a/src/slic3r/GUI/GLGizmo.hpp +++ b/src/slic3r/GUI/GLGizmo.hpp @@ -414,13 +414,9 @@ private: Vec3d normal; float area; }; - struct SourceDataSummary { - std::vector bounding_boxes; // bounding boxes of convex hulls of individual volumes - Vec3d mesh_first_point; - }; // This holds information to decide whether recalculation is necessary: - SourceDataSummary m_source_data; + std::vector m_volumes_matrices; std::vector m_planes; mutable Vec3d m_starting_center;