From 38c1656624a067e73f9c6585549b4779fbba4fbe Mon Sep 17 00:00:00 2001 From: Laurynas Duburas Date: Mon, 25 Aug 2025 11:03:37 +0200 Subject: [PATCH] Fix #143635: Grease Pencil: Use only editable points in `use_connected_only` In function `curve_populate_trans_data_structs` only editable points are copied to `TransDataContainer`. The code handling proportional connected editing was expecting all data from `CurvesGeometry` to be there. Additional offset index array was added for editable points per curves. Pull Request: https://projects.blender.org/blender/blender/pulls/144655 --- .../editors/transform/transform_convert_curves.cc | 13 +++++++++++-- .../transform/transform_convert_grease_pencil.cc | 8 +++++--- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/source/blender/editors/transform/transform_convert_curves.cc b/source/blender/editors/transform/transform_convert_curves.cc index bbc8789c506..c92a32db337 100644 --- a/source/blender/editors/transform/transform_convert_curves.cc +++ b/source/blender/editors/transform/transform_convert_curves.cc @@ -681,6 +681,14 @@ void curve_populate_trans_data_structs(const TransInfo &t, } if (use_connected_only) { + Array curves_offsets_in_td_buffer(curves.curves_num() + 1, 0); + affected_curves.foreach_index(GrainSize(512), [&](const int64_t curve) { + curves_offsets_in_td_buffer[curve] = + points_to_transform_per_attr[0].slice_content(points_by_curve[curve]).size(); + }); + offset_indices::accumulate_counts_to_offsets(curves_offsets_in_td_buffer); + const OffsetIndices curves_offsets_in_td(curves_offsets_in_td_buffer); + Array bezier_offsets_in_td(curves.curves_num() + 1, 0); offset_indices::copy_group_sizes(points_by_curve, bezier_curves, bezier_offsets_in_td); offset_indices::accumulate_counts_to_offsets(bezier_offsets_in_td); @@ -693,14 +701,15 @@ void curve_populate_trans_data_structs(const TransInfo &t, for (const int curve_i : segment) { const int selection_attrs_num = curve_types[curve_i] == CURVE_TYPE_BEZIER ? 3 : 1; const IndexRange curve_points = points_by_curve[curve_i]; - const int total_curve_points = selection_attrs_num * curve_points.size(); + const IndexRange editable_curve_points = curves_offsets_in_td[curve_i]; + const int total_curve_points = selection_attrs_num * editable_curve_points.size(); map.reinitialize(total_curve_points); closest_distances.reinitialize(total_curve_points); closest_distances.fill(std::numeric_limits::max()); mapped_curve_positions.reinitialize(total_curve_points); fill_map(CurveType(curve_types[curve_i]), - curve_points, + editable_curve_points, position_offsets_in_td, bezier_offsets_in_td[curve_i], map); diff --git a/source/blender/editors/transform/transform_convert_grease_pencil.cc b/source/blender/editors/transform/transform_convert_grease_pencil.cc index 9826ba2f0a7..e8189cb0273 100644 --- a/source/blender/editors/transform/transform_convert_grease_pencil.cc +++ b/source/blender/editors/transform/transform_convert_grease_pencil.cc @@ -134,12 +134,14 @@ static void createTransGreasePencilVerts(bContext *C, TransInfo *t) } if (use_proportional_edit) { - tc.data_len += editable_points.size() + 2 * bezier_points.size(); + const IndexMask editable_bezier_points = IndexMask::from_intersection( + editable_points, bezier_points, curves_transform_data->memory); + tc.data_len += editable_points.size() + 2 * editable_bezier_points.size(); points_to_transform_per_attribute[layer_offset].append(editable_points); if (selection_attribute_names.size() > 1) { - points_to_transform_per_attribute[layer_offset].append(bezier_points); - points_to_transform_per_attribute[layer_offset].append(bezier_points); + points_to_transform_per_attribute[layer_offset].append(editable_bezier_points); + points_to_transform_per_attribute[layer_offset].append(editable_bezier_points); } } else {