diff --git a/src/slic3r/GUI/GCodeViewer.cpp b/src/slic3r/GUI/GCodeViewer.cpp index 4e58e68ec..0585ce58c 100644 --- a/src/slic3r/GUI/GCodeViewer.cpp +++ b/src/slic3r/GUI/GCodeViewer.cpp @@ -2354,13 +2354,23 @@ void GCodeViewer::refresh_render_paths(bool keep_sequential_current_first, bool size_t last = path_id; // check adjacent paths - while (first > 0 && path.sub_paths.front().first.position.isApprox(buffer.paths[first - 1].sub_paths.back().last.position)) { + while (first > 0) { + const Path& ref_path = buffer.paths[first - 1]; + if (!path.sub_paths.front().first.position.isApprox(ref_path.sub_paths.back().last.position) || + path.role != ref_path.role) + break; + + path.sub_paths.front().first = ref_path.sub_paths.front().first; --first; - path.sub_paths.front().first = buffer.paths[first].sub_paths.front().first; } - while (last < buffer.paths.size() - 1 && path.sub_paths.back().last.position.isApprox(buffer.paths[last + 1].sub_paths.front().first.position)) { + while (last < buffer.paths.size() - 1) { + const Path& ref_path = buffer.paths[last + 1]; + if (!path.sub_paths.back().last.position.isApprox(ref_path.sub_paths.front().first.position) || + path.role != ref_path.role) + break; + + path.sub_paths.back().last = ref_path.sub_paths.back().last; ++last; - path.sub_paths.back().last = buffer.paths[last].sub_paths.back().last; } const size_t min_s_id = m_layers.get_range_at(min_id).first;