diff --git a/src/libslic3r/BranchingTree/BranchingTree.cpp b/src/libslic3r/BranchingTree/BranchingTree.cpp index a7d9a1b4d..3102f213f 100644 --- a/src/libslic3r/BranchingTree/BranchingTree.cpp +++ b/src/libslic3r/BranchingTree/BranchingTree.cpp @@ -106,7 +106,11 @@ bool build_tree(PointCloud &nodes, Builder &builder) mergenode.right = closest_node_id; size_t new_idx = nodes.insert_junction(mergenode); ptsqueue.push(new_idx); - ptsqueue.remove(nodes.get_queue_idx(closest_node_id)); + size_t qid = nodes.get_queue_idx(closest_node_id); + + if (qid != PointCloud::Unqueued) + ptsqueue.remove(nodes.get_queue_idx(closest_node_id)); + nodes.mark_unreachable(closest_node_id); } } else if (closest_node.pos.z() < node.pos.z() && diff --git a/src/libslic3r/BranchingTree/PointCloud.cpp b/src/libslic3r/BranchingTree/PointCloud.cpp index 35498f4c1..11b500843 100644 --- a/src/libslic3r/BranchingTree/PointCloud.cpp +++ b/src/libslic3r/BranchingTree/PointCloud.cpp @@ -140,7 +140,7 @@ PointCloud::PointCloud(std::vector meshpts, , LEAFS_BEGIN{MESHPTS_BEGIN + m_meshpoints.size()} , JUNCTIONS_BEGIN{LEAFS_BEGIN + m_leafs.size()} , m_searchable_indices(JUNCTIONS_BEGIN + m_junctions.size(), true) - , m_queue_indices(JUNCTIONS_BEGIN + m_junctions.size(), UNQUEUED) + , m_queue_indices(JUNCTIONS_BEGIN + m_junctions.size(), Unqueued) , m_reachable_cnt{JUNCTIONS_BEGIN + m_junctions.size()} , m_ktree{CoordFn{this}, LEAFS_BEGIN} // Only for bed and mesh points { diff --git a/src/libslic3r/BranchingTree/PointCloud.hpp b/src/libslic3r/BranchingTree/PointCloud.hpp index d2072bee9..3c5e8a9a2 100644 --- a/src/libslic3r/BranchingTree/PointCloud.hpp +++ b/src/libslic3r/BranchingTree/PointCloud.hpp @@ -67,8 +67,6 @@ private: return dot_sq < D.squaredNorm() * cos2bridge_slope; } - static constexpr auto UNQUEUED = size_t(-1); - template static auto *get_node(PC &&pc, size_t id) { @@ -87,6 +85,8 @@ private: public: + static constexpr auto Unqueued = size_t(-1); + struct ZCompareFn { const PointCloud *self; @@ -155,7 +155,7 @@ public: m_junctions.emplace_back(p); m_junctions.back().id = int(new_id); m_searchable_indices.emplace_back(true); - m_queue_indices.emplace_back(UNQUEUED); + m_queue_indices.emplace_back(Unqueued); ++m_reachable_cnt; return new_id; @@ -172,7 +172,7 @@ public: assert(node_id < m_searchable_indices.size()); m_searchable_indices[node_id] = false; - m_queue_indices[node_id] = UNQUEUED; + m_queue_indices[node_id] = Unqueued; --m_reachable_cnt; }