diff --git a/core/nodeslicer/nodes.py b/core/nodeslicer/nodes.py index 1ee75d8..83b6b67 100644 --- a/core/nodeslicer/nodes.py +++ b/core/nodeslicer/nodes.py @@ -487,23 +487,39 @@ class SLICENODE_BufferShellsMultiple(SliceNode): else: prepared_paths = paths - all_res_paths = [] - all_res_groups = [] + all_buffers: list[SlicePaths] = [] for i in range(count): dist = base_distance + (i * width_step) res_paths, res_groups = slice.buffer_slice(prepared_paths, dist, miter=self.shape_option) - all_res_paths.extend(res_paths) - all_res_groups.extend(res_groups) + all_buffers.append(SlicePaths(res_paths, res_groups)) + + # Zip Logic: Interleave paths by group (Z-layer) + all_groups = set() + grouped_inputs = [] + for p_list in all_buffers: + d = {} + for i, g in enumerate(p_list.groups): + all_groups.add(g) + d.setdefault(g, []).append(p_list[i]) + grouped_inputs.append(d) + + sorted_groups = sorted(list(all_groups)) + + merged = SlicePaths() + for g in sorted_groups: + for d in grouped_inputs: + group_paths = d.get(g, []) + for p in group_paths: + merged.append_with_group(p, g) if any(rotation): mat_inv = Euler(rotation).to_matrix() mat_inv_np = np.array(mat_inv) - final_paths = [s @ mat_inv_np.T for s in all_res_paths] - else: - final_paths = all_res_paths + final_paths = [s @ mat_inv_np.T for s in merged] + return SlicePaths(final_paths, merged.groups) - return SlicePaths(final_paths, all_res_groups) + return merged @register_class class SLICENODE_Infill(SliceNode):