From a57e2a22f6f6e5035f75205c06596d6151af76ca Mon Sep 17 00:00:00 2001 From: Pavel Mikus Date: Tue, 13 Dec 2022 12:41:21 +0100 Subject: [PATCH] fixed bug with instancing --- src/libslic3r/Print.hpp | 9 +++++++-- src/libslic3r/PrintObject.cpp | 10 ++++++---- src/slic3r/GUI/Gizmos/GLGizmoFdmSupports.cpp | 8 ++++++-- 3 files changed, 19 insertions(+), 8 deletions(-) diff --git a/src/libslic3r/Print.hpp b/src/libslic3r/Print.hpp index dcec6c618..4e8eaa63b 100644 --- a/src/libslic3r/Print.hpp +++ b/src/libslic3r/Print.hpp @@ -202,6 +202,11 @@ public: } }; + struct GeneratedSupportPoints{ + Transform3d object_transform; // for frontend object mapping + SupportSpotsGenerator::SupportPoints support_points; + }; + std::vector> all_regions; std::vector layer_ranges; // Transformation of this ModelObject into one of the associated PrintObjects (all PrintObjects derived from a single modelObject differ by a Z rotation only). @@ -209,7 +214,7 @@ public: Transform3d trafo_bboxes; std::vector cached_volume_ids; - SupportSpotsGenerator::SupportPoints generated_support_points; + std::optional generated_support_points; void ref_cnt_inc() { ++ m_ref_cnt; } void ref_cnt_dec() { if (-- m_ref_cnt == 0) delete this; } @@ -217,7 +222,7 @@ public: all_regions.clear(); layer_ranges.clear(); cached_volume_ids.clear(); - generated_support_points.clear(); + generated_support_points.reset(); } private: diff --git a/src/libslic3r/PrintObject.cpp b/src/libslic3r/PrintObject.cpp index 3a7dce2d0..07da05251 100644 --- a/src/libslic3r/PrintObject.cpp +++ b/src/libslic3r/PrintObject.cpp @@ -419,10 +419,12 @@ void PrintObject::generate_support_spots() if (this->set_started(posSupportSpotsSearch)) { BOOST_LOG_TRIVIAL(debug) << "Searching support spots - start"; m_print->set_status(75, L("Searching support spots")); - SupportSpotsGenerator::Params params{this->print()->m_config.filament_type.values}; - SupportSpotsGenerator::SupportPoints supp_points = SupportSpotsGenerator::full_search(this, params); - this->m_shared_regions->generated_support_points = supp_points; - m_print->throw_if_canceled(); + if (!this->shared_regions()->generated_support_points.has_value()) { + SupportSpotsGenerator::Params params{this->print()->m_config.filament_type.values}; + SupportSpotsGenerator::SupportPoints supp_points = SupportSpotsGenerator::full_search(this, params); + this->m_shared_regions->generated_support_points = {this->trafo_centered(), supp_points}; + m_print->throw_if_canceled(); + } BOOST_LOG_TRIVIAL(debug) << "Searching support spots - end"; this->set_done(posSupportSpotsSearch); } diff --git a/src/slic3r/GUI/Gizmos/GLGizmoFdmSupports.cpp b/src/slic3r/GUI/Gizmos/GLGizmoFdmSupports.cpp index e57a6b31d..f13914715 100644 --- a/src/slic3r/GUI/Gizmos/GLGizmoFdmSupports.cpp +++ b/src/slic3r/GUI/Gizmos/GLGizmoFdmSupports.cpp @@ -405,13 +405,17 @@ void GLGizmoFdmSupports::apply_data_from_backend() if (!has_backend_supports()) return; ModelObject *mo = m_c->selection_info()->model_object(); + if (!mo) { + this->waiting_for_autogenerated_supports = false; + return; + } // find the respective PrintObject, we need a pointer to it for (const PrintObject *po : m_parent.fff_print()->objects()) { if (po->model_object()->id() == mo->id()) { std::unordered_map selectors; - SupportSpotsGenerator::SupportPoints support_points = po->shared_regions()->generated_support_points; - auto obj_transform = po->trafo_centered(); + SupportSpotsGenerator::SupportPoints support_points = po->shared_regions()->generated_support_points->support_points; + auto obj_transform = po->shared_regions()->generated_support_points->object_transform; for (ModelVolume *model_volume : po->model_object()->volumes) { if (model_volume->is_model_part()) { Transform3d mesh_transformation = obj_transform * model_volume->get_matrix();