diff --git a/source/blender/nodes/geometry/nodes/node_geo_duplicate_elements.cc b/source/blender/nodes/geometry/nodes/node_geo_duplicate_elements.cc index 0440d4c87e8..da93dc67639 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_duplicate_elements.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_duplicate_elements.cc @@ -1116,16 +1116,16 @@ static void duplicate_instances(GeometrySet &geometry_set, std::unique_ptr dst_instances = std::make_unique(); dst_instances->resize(duplicates.total_size()); - for (const int i_selection : selection.index_range()) { - const IndexRange range = duplicates[i_selection]; + selection.foreach_index([&](const int i_src, const int i_dst) { + const IndexRange range = duplicates[i_dst]; if (range.is_empty()) { - continue; + return; } - const int old_handle = src_instances.reference_handles()[i_selection]; + const int old_handle = src_instances.reference_handles()[i_src]; const bke::InstanceReference reference = src_instances.references()[old_handle]; const int new_handle = dst_instances->add_reference(reference); dst_instances->reference_handles_for_write().slice(range).fill(new_handle); - } + }); bke::gather_attributes_to_groups( src_instances.attributes(),