From 5ec84adb14a9c19f0af64feefa4da79f655b4c23 Mon Sep 17 00:00:00 2001 From: YuSanka Date: Wed, 17 Aug 2022 09:58:20 +0200 Subject: [PATCH] Cut WIP: Add only needed modifiers --- src/libslic3r/Model.cpp | 14 +++++++------- src/slic3r/GUI/GUI_ObjectList.cpp | 3 ++- src/slic3r/GUI/Gizmos/GLGizmoCut.hpp | 2 +- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/src/libslic3r/Model.cpp b/src/libslic3r/Model.cpp index ffa74f79c..293d31eae 100644 --- a/src/libslic3r/Model.cpp +++ b/src/libslic3r/Model.cpp @@ -1380,10 +1380,6 @@ indexed_triangle_set ModelObject::get_connector_mesh(CutConnectorAttributes conn void ModelObject::apply_cut_connectors(const std::string& name) { - // discard old connector markers for volumes - for (ModelVolume* volume : volumes) - volume->cut_info.discard(); - if (cut_connectors.empty()) return; @@ -1517,6 +1513,8 @@ ModelObjectPtrs ModelObject::cut(size_t instance, const Vec3d& cut_center, const if (!volume->is_model_part()) { if (volume->cut_info.is_connector) { + volume->cut_info.discard(); + // ! Don't apply instance transformation for the conntectors. // This transformation is already there if (attributes.has(ModelObjectCutAttribute::KeepUpper)) { @@ -1559,10 +1557,12 @@ ModelObjectPtrs ModelObject::cut(size_t instance, const Vec3d& cut_center, const // to the modifier volume transformation to preserve their shape properly. volume->set_transformation(Geometry::Transformation(instance_matrix * volume_matrix)); - // #ysFIXME - add logic for the negative volumes/connectors - if (attributes.has(ModelObjectCutAttribute::KeepUpper)) + // Some logic for the negative volumes/connectors. Add only needed modifiers + auto bb = volume->mesh().transformed_bounding_box(cut_matrix * volume->get_matrix()); + bool is_crossed_by_cut = bb.min[Z] <= 0 && bb.max[Z] >= 0; + if (attributes.has(ModelObjectCutAttribute::KeepUpper) && (bb.min[Z] >= 0 || is_crossed_by_cut)) upper->add_volume(*volume); - if (attributes.has(ModelObjectCutAttribute::KeepLower)) + if (attributes.has(ModelObjectCutAttribute::KeepLower) && (bb.max[Z] <= 0 || is_crossed_by_cut)) lower->add_volume(*volume); } } diff --git a/src/slic3r/GUI/GUI_ObjectList.cpp b/src/slic3r/GUI/GUI_ObjectList.cpp index cc6954665..769b038fa 100644 --- a/src/slic3r/GUI/GUI_ObjectList.cpp +++ b/src/slic3r/GUI/GUI_ObjectList.cpp @@ -2918,6 +2918,7 @@ bool ObjectList::delete_from_model_and_list(const ItemType type, const int obj_i update_lock_icons_for_model(); return true; } + return false; } else if (del_subobject_from_object(obj_idx, sub_obj_idx, type)) { type == itVolume ? delete_volume_from_list(obj_idx, sub_obj_idx) : @@ -2942,7 +2943,7 @@ bool ObjectList::delete_from_model_and_list(const std::vector& it if (item->type&itObject) { bool was_cut = object(item->obj_idx)->is_cut(); if (!del_object(item->obj_idx)) - continue; + return false;// continue; m_objects_model->Delete(m_objects_model->GetItemById(item->obj_idx)); if (was_cut) update_lock_icons_for_model(); diff --git a/src/slic3r/GUI/Gizmos/GLGizmoCut.hpp b/src/slic3r/GUI/Gizmos/GLGizmoCut.hpp index 1665b8549..f8f788138 100644 --- a/src/slic3r/GUI/Gizmos/GLGizmoCut.hpp +++ b/src/slic3r/GUI/Gizmos/GLGizmoCut.hpp @@ -77,7 +77,7 @@ class GLGizmoCut3D : public GLGizmoBase bool m_keep_upper{ true }; bool m_keep_lower{ true }; bool m_place_on_cut_upper{ true }; - bool m_place_on_cut_lower{ true }; + bool m_place_on_cut_lower{ false }; bool m_rotate_upper{ false }; bool m_rotate_lower{ false };