From 3713f09a8e461435d66cb375ddd41fb5f22bf7ef Mon Sep 17 00:00:00 2001 From: Vojtech Bubnik Date: Wed, 16 Nov 2022 18:41:48 +0100 Subject: [PATCH] Follow-up to 30fbdd123525e1ea04d4af7593efc20a4b223147 Fixed one more bug in Z chaining of layer islands. --- src/libslic3r/Layer.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/libslic3r/Layer.cpp b/src/libslic3r/Layer.cpp index c85194543..97c98a0e8 100644 --- a/src/libslic3r/Layer.cpp +++ b/src/libslic3r/Layer.cpp @@ -175,18 +175,22 @@ static void connect_layer_slices( if (lslice.bbox.contains(pt) && m_above.lslices[l].contains(pt)) { found = true; j = l; + assert(i >= 0 && i < m_below.lslices_ex.size()); + assert(j >= 0 && j < m_above.lslices_ex.size()); break; } } } else { // Index of an island above. Look-it up in the island below. assert(j < m_offset_end); - j -= m_offset_below; + j -= m_offset_above; for (int l = int(m_below.lslices_ex.size()) - 1; l >= 0; -- l) { LayerSlice &lslice = m_below.lslices_ex[l]; if (lslice.bbox.contains(pt) && m_below.lslices[l].contains(pt)) { found = true; i = l; + assert(i >= 0 && i < m_below.lslices_ex.size()); + assert(j >= 0 && j < m_above.lslices_ex.size()); break; } } @@ -197,6 +201,8 @@ static void connect_layer_slices( std::swap(i, j); i -= m_offset_below; j -= m_offset_above; + assert(i >= 0 && i < m_below.lslices_ex.size()); + assert(j >= 0 && j < m_above.lslices_ex.size()); found = true; } if (found) {