From 4116320481e1e791ed48967dea71974e96f8effe Mon Sep 17 00:00:00 2001 From: Laurynas Duburas Date: Fri, 19 Apr 2024 14:20:18 +0300 Subject: [PATCH 1/6] copy data for transform to tc->custom.type.data --- .../transform/transform_convert_curves.cc | 74 ++++++++++++++++++- 1 file changed, 71 insertions(+), 3 deletions(-) diff --git a/source/blender/editors/transform/transform_convert_curves.cc b/source/blender/editors/transform/transform_convert_curves.cc index 06916da105b..20bd9919fda 100644 --- a/source/blender/editors/transform/transform_convert_curves.cc +++ b/source/blender/editors/transform/transform_convert_curves.cc @@ -62,6 +62,69 @@ static void calculate_curve_point_distances_for_proportional_editing( } } +static int64_t *custom_data_to_point_num(void *data) +{ + return static_cast(data); +} + +static int64_t *custom_data_to_range_num(void *data) +{ + return static_cast(data) + 1; +} + +static float3 *custom_data_to_positions(void *data) +{ + return reinterpret_cast(custom_data_to_range_num(data) + 1); +} + +static IndexRange *custom_data_to_ranges(void *data, int64_t points_num) +{ + return reinterpret_cast(custom_data_to_positions(data) + points_num); +} + +static void *selected_positions_to_custom_data(const bke::CurvesGeometry &curves, + const IndexMask &selection) +{ + const int64_t points_num = selection.size(); + const Vector ranges{selection.to_ranges()}; + + void *data = MEM_callocN(sizeof(int64_t) * 2 + sizeof(float3) * points_num + + sizeof(IndexRange) * ranges.size(), + __func__); + *custom_data_to_point_num(data) = points_num; + *custom_data_to_range_num(data) = ranges.size(); + MutableSpan ranges_dst{custom_data_to_ranges(data, points_num), ranges.size()}; + ranges_dst.copy_from(ranges); + + float3 *positions_data = custom_data_to_positions(data); + MutableSpan positions_dst{positions_data, points_num}; + Span positions = curves.positions(); + + int64_t offset_dst = 0; + for (const IndexRange &range : ranges) { + positions_dst.slice(offset_dst, range.size()).copy_from(positions.slice(range)); + offset_dst += range.size(); + } + return data; +} + +static void selected_positions_from_custom_data(bke::CurvesGeometry &curves, void *data) +{ + const int64_t points_num = *custom_data_to_point_num(data); + + Span ranges{custom_data_to_ranges(data, points_num), + *custom_data_to_range_num(data)}; + Span positions{custom_data_to_positions(data), points_num}; + + MutableSpan positions_dst = curves.positions_for_write(); + + int64_t offset_src = 0; + for (const IndexRange &range : ranges) { + positions_dst.slice(range).copy_from(positions.slice(offset_src, range.size())); + offset_src += range.size(); + } +} + static void createTransCurvesVerts(bContext * /*C*/, TransInfo *t) { MutableSpan trans_data_contrainers(t->data_container, t->data_container_len); @@ -77,6 +140,7 @@ static void createTransCurvesVerts(bContext * /*C*/, TransInfo *t) bke::CurvesGeometry &curves = curves_id->geometry.wrap(); if (use_proportional_edit) { + selection_per_object[i] = curves.points_range(); tc.data_len = curves.point_num; } else { @@ -86,6 +150,7 @@ static void createTransCurvesVerts(bContext * /*C*/, TransInfo *t) if (tc.data_len > 0) { tc.data = MEM_cnew_array(tc.data_len, __func__); + tc.custom.type.data = selected_positions_to_custom_data(curves, selection_per_object[i]); } } @@ -144,6 +209,7 @@ static void recalcData_curves(TransInfo *t) curves.tag_normals_changed(); } else { + selected_positions_from_custom_data(curves, tc.custom.type.data); curves.tag_positions_changed(); curves.calculate_bezier_auto_handles(); } @@ -168,8 +234,10 @@ void curve_populate_trans_data_structs(TransDataContainer &tc, float mtx[3][3], smtx[3][3]; copy_m3_m4(mtx, transform.ptr()); pseudoinverse_m3_m3(smtx, mtx, PSEUDOINVERSE_EPSILON); - - MutableSpan positions = curves.positions_for_write(); + int64_t position_num = *blender::ed::transform::curves::custom_data_to_point_num( + tc.custom.type.data); + MutableSpan positions{ + blender::ed::transform::curves::custom_data_to_positions(tc.custom.type.data), position_num}; if (use_proportional_edit) { const OffsetIndices points_by_curve = curves.points_by_curve(); const VArray selection = *curves.attributes().lookup_or_default( @@ -233,7 +301,7 @@ void curve_populate_trans_data_structs(TransDataContainer &tc, for (const int selection_i : range) { TransData *td = &tc.data[selection_i + trans_data_offset]; const int point_i = selected_indices[selection_i]; - float3 *elem = &positions[point_i]; + float3 *elem = &positions[selection_i]; copy_v3_v3(td->iloc, *elem); copy_v3_v3(td->center, td->iloc); -- 2.30.2 From dbf00e35794759a45a187d1b543ae539ad40a8cc Mon Sep 17 00:00:00 2001 From: Laurynas Duburas Date: Fri, 19 Apr 2024 19:02:30 +0300 Subject: [PATCH 2/6] struct TransformArrays added --- .../transform/transform_convert_curves.cc | 95 +++++++++---------- 1 file changed, 43 insertions(+), 52 deletions(-) diff --git a/source/blender/editors/transform/transform_convert_curves.cc b/source/blender/editors/transform/transform_convert_curves.cc index 20bd9919fda..2bb5e3030f8 100644 --- a/source/blender/editors/transform/transform_convert_curves.cc +++ b/source/blender/editors/transform/transform_convert_curves.cc @@ -62,66 +62,57 @@ static void calculate_curve_point_distances_for_proportional_editing( } } -static int64_t *custom_data_to_point_num(void *data) -{ - return static_cast(data); -} +struct TransformArrays { + Vector ranges; + Array offsets; + Array positions; +}; -static int64_t *custom_data_to_range_num(void *data) -{ - return static_cast(data) + 1; -} - -static float3 *custom_data_to_positions(void *data) -{ - return reinterpret_cast(custom_data_to_range_num(data) + 1); -} - -static IndexRange *custom_data_to_ranges(void *data, int64_t points_num) -{ - return reinterpret_cast(custom_data_to_positions(data) + points_num); -} - -static void *selected_positions_to_custom_data(const bke::CurvesGeometry &curves, - const IndexMask &selection) +static void selected_positions_to_custom_data(const bke::CurvesGeometry &curves, + const IndexMask &selection, + TransCustomData &custom_data) { const int64_t points_num = selection.size(); - const Vector ranges{selection.to_ranges()}; + Vector ranges(selection.to_ranges()); - void *data = MEM_callocN(sizeof(int64_t) * 2 + sizeof(float3) * points_num + - sizeof(IndexRange) * ranges.size(), - __func__); - *custom_data_to_point_num(data) = points_num; - *custom_data_to_range_num(data) = ranges.size(); - MutableSpan ranges_dst{custom_data_to_ranges(data, points_num), ranges.size()}; - ranges_dst.copy_from(ranges); - - float3 *positions_data = custom_data_to_positions(data); - MutableSpan positions_dst{positions_data, points_num}; + Array positions_dst(points_num); Span positions = curves.positions(); + Array offsets(ranges.size() + 1); - int64_t offset_dst = 0; - for (const IndexRange &range : ranges) { - positions_dst.slice(offset_dst, range.size()).copy_from(positions.slice(range)); - offset_dst += range.size(); + offsets[0] = 0; + for (const int i : ranges.index_range()) { + offsets[i + 1] = offsets[i] + ranges[i].size(); } - return data; + + OffsetIndices offset_indices(offsets); + for (const int i : ranges.index_range()) { + positions_dst.as_mutable_span().slice(offset_indices[i]).copy_from(positions.slice(ranges[i])); + } + + TransformArrays *transform_arrays = MEM_new(__func__); + transform_arrays->positions = std::move(positions_dst); + transform_arrays->ranges = std::move(ranges); + transform_arrays->offsets = std::move(offsets); + + custom_data.data = transform_arrays; + custom_data.free_cb = [](TransInfo *, TransDataContainer *, TransCustomData *custom_data) { + TransformArrays *data = static_cast(custom_data->data); + MEM_delete(data); + custom_data->data = nullptr; + }; } -static void selected_positions_from_custom_data(bke::CurvesGeometry &curves, void *data) +static void selected_positions_from_custom_data(bke::CurvesGeometry &curves, + const TransformArrays &transform_arrays) { - const int64_t points_num = *custom_data_to_point_num(data); - - Span ranges{custom_data_to_ranges(data, points_num), - *custom_data_to_range_num(data)}; - Span positions{custom_data_to_positions(data), points_num}; + Span ranges{transform_arrays.ranges}; + Span positions{transform_arrays.positions}; + OffsetIndices offset_indices(transform_arrays.offsets); MutableSpan positions_dst = curves.positions_for_write(); - int64_t offset_src = 0; - for (const IndexRange &range : ranges) { - positions_dst.slice(range).copy_from(positions.slice(offset_src, range.size())); - offset_src += range.size(); + for (const int i : ranges.index_range()) { + positions_dst.slice(ranges[i]).copy_from(positions.slice(offset_indices[i])); } } @@ -150,7 +141,7 @@ static void createTransCurvesVerts(bContext * /*C*/, TransInfo *t) if (tc.data_len > 0) { tc.data = MEM_cnew_array(tc.data_len, __func__); - tc.custom.type.data = selected_positions_to_custom_data(curves, selection_per_object[i]); + selected_positions_to_custom_data(curves, selection_per_object[i], tc.custom.type); } } @@ -209,7 +200,8 @@ static void recalcData_curves(TransInfo *t) curves.tag_normals_changed(); } else { - selected_positions_from_custom_data(curves, tc.custom.type.data); + selected_positions_from_custom_data(curves, + *static_cast(tc.custom.type.data)); curves.tag_positions_changed(); curves.calculate_bezier_auto_handles(); } @@ -234,10 +226,9 @@ void curve_populate_trans_data_structs(TransDataContainer &tc, float mtx[3][3], smtx[3][3]; copy_m3_m4(mtx, transform.ptr()); pseudoinverse_m3_m3(smtx, mtx, PSEUDOINVERSE_EPSILON); - int64_t position_num = *blender::ed::transform::curves::custom_data_to_point_num( - tc.custom.type.data); + MutableSpan positions{ - blender::ed::transform::curves::custom_data_to_positions(tc.custom.type.data), position_num}; + static_cast(tc.custom.type.data)->positions}; if (use_proportional_edit) { const OffsetIndices points_by_curve = curves.points_by_curve(); const VArray selection = *curves.attributes().lookup_or_default( -- 2.30.2 From 37186dbd70f57fcb35c6a41862dddfc65de022eb Mon Sep 17 00:00:00 2001 From: Laurynas Duburas Date: Sat, 20 Apr 2024 01:23:25 +0300 Subject: [PATCH 3/6] gather and scatter --- .../editors/transform/transform_convert.hh | 17 +++ .../transform/transform_convert_curves.cc | 108 +++++++++--------- .../transform_convert_grease_pencil.cc | 13 ++- 3 files changed, 77 insertions(+), 61 deletions(-) diff --git a/source/blender/editors/transform/transform_convert.hh b/source/blender/editors/transform/transform_convert.hh index 785a769bfa1..32bd776b6fc 100644 --- a/source/blender/editors/transform/transform_convert.hh +++ b/source/blender/editors/transform/transform_convert.hh @@ -80,6 +80,17 @@ struct TransDataVertSlideVert { } }; +/** + * Structure used for curves transform operation. + * Used for both curves and grease pencil objects. + */ +struct CurvesTransformData { + blender::IndexMaskMemory memory; + blender::Vector selection_by_layer; + blender::Vector layer_offsets; + blender::Array positions; +}; + /* `transform_convert.cc` */ /** @@ -161,6 +172,12 @@ void curve_populate_trans_data_structs(TransDataContainer &tc, bool use_connected_only, int trans_data_offset); +CurvesTransformData *create_curves_custom_data(TransCustomData &custom_data); + +void selected_positions_from_custom_data(const TransCustomData &custom_data, + const int layer, + blender::MutableSpan positions_dst); + /* `transform_convert_action.cc` */ extern TransConvertTypeInfo TransConvertType_Action; diff --git a/source/blender/editors/transform/transform_convert_curves.cc b/source/blender/editors/transform/transform_convert_curves.cc index 2bb5e3030f8..2685ce73cb4 100644 --- a/source/blender/editors/transform/transform_convert_curves.cc +++ b/source/blender/editors/transform/transform_convert_curves.cc @@ -9,6 +9,7 @@ #include #include "BLI_array.hh" +#include "BLI_array_utils.hh" #include "BLI_inplace_priority_queue.hh" #include "BLI_math_matrix.h" #include "BLI_span.hh" @@ -62,58 +63,18 @@ static void calculate_curve_point_distances_for_proportional_editing( } } -struct TransformArrays { - Vector ranges; - Array offsets; - Array positions; -}; - -static void selected_positions_to_custom_data(const bke::CurvesGeometry &curves, - const IndexMask &selection, - TransCustomData &custom_data) +static void append_positions_to_custom_data(const IndexMask selection, + Span positions, + TransCustomData &custom_data) { - const int64_t points_num = selection.size(); - Vector ranges(selection.to_ranges()); - - Array positions_dst(points_num); - Span positions = curves.positions(); - Array offsets(ranges.size() + 1); - - offsets[0] = 0; - for (const int i : ranges.index_range()) { - offsets[i + 1] = offsets[i] + ranges[i].size(); - } - - OffsetIndices offset_indices(offsets); - for (const int i : ranges.index_range()) { - positions_dst.as_mutable_span().slice(offset_indices[i]).copy_from(positions.slice(ranges[i])); - } - - TransformArrays *transform_arrays = MEM_new(__func__); - transform_arrays->positions = std::move(positions_dst); - transform_arrays->ranges = std::move(ranges); - transform_arrays->offsets = std::move(offsets); - - custom_data.data = transform_arrays; - custom_data.free_cb = [](TransInfo *, TransDataContainer *, TransCustomData *custom_data) { - TransformArrays *data = static_cast(custom_data->data); - MEM_delete(data); - custom_data->data = nullptr; - }; -} - -static void selected_positions_from_custom_data(bke::CurvesGeometry &curves, - const TransformArrays &transform_arrays) -{ - Span ranges{transform_arrays.ranges}; - Span positions{transform_arrays.positions}; - OffsetIndices offset_indices(transform_arrays.offsets); - - MutableSpan positions_dst = curves.positions_for_write(); - - for (const int i : ranges.index_range()) { - positions_dst.slice(ranges[i]).copy_from(positions.slice(offset_indices[i])); - } + CurvesTransformData &transform_data = *static_cast(custom_data.data); + transform_data.selection_by_layer.append(selection); + const int data_offset = transform_data.layer_offsets.last(); + transform_data.layer_offsets.append(data_offset + selection.size()); + array_utils::gather( + positions, + transform_data.selection_by_layer.last(), + transform_data.positions.as_mutable_span().slice(data_offset, selection.size())); } static void createTransCurvesVerts(bContext * /*C*/, TransInfo *t) @@ -130,18 +91,21 @@ static void createTransCurvesVerts(bContext * /*C*/, TransInfo *t) Curves *curves_id = static_cast(tc.obedit->data); bke::CurvesGeometry &curves = curves_id->geometry.wrap(); + CurvesTransformData *curves_transform_data = create_curves_custom_data(tc.custom.type); + if (use_proportional_edit) { selection_per_object[i] = curves.points_range(); tc.data_len = curves.point_num; } else { - selection_per_object[i] = ed::curves::retrieve_selected_points(curves, memory); + selection_per_object[i] = ed::curves::retrieve_selected_points( + curves, curves_transform_data->memory); tc.data_len = selection_per_object[i].size(); } if (tc.data_len > 0) { tc.data = MEM_cnew_array(tc.data_len, __func__); - selected_positions_to_custom_data(curves, selection_per_object[i], tc.custom.type); + curves_transform_data->positions.reinitialize(tc.data_len); } } @@ -200,8 +164,7 @@ static void recalcData_curves(TransInfo *t) curves.tag_normals_changed(); } else { - selected_positions_from_custom_data(curves, - *static_cast(tc.custom.type.data)); + selected_positions_from_custom_data(tc.custom.type, 0, curves.positions_for_write()); curves.tag_positions_changed(); curves.calculate_bezier_auto_handles(); } @@ -211,6 +174,33 @@ static void recalcData_curves(TransInfo *t) } // namespace blender::ed::transform::curves +CurvesTransformData *create_curves_custom_data(TransCustomData &custom_data) +{ + CurvesTransformData *transform_data = MEM_new(__func__); + transform_data->layer_offsets.append(0); + custom_data.data = transform_data; + custom_data.free_cb = [](TransInfo *, TransDataContainer *, TransCustomData *custom_data) { + CurvesTransformData *data = static_cast(custom_data->data); + MEM_delete(data); + custom_data->data = nullptr; + }; + return transform_data; +} + +void selected_positions_from_custom_data(const TransCustomData &custom_data, + const int layer, + blender::MutableSpan positions_dst) +{ + using namespace blender; + const CurvesTransformData &transform_data = *static_cast( + custom_data.data); + const IndexMask &selection = transform_data.selection_by_layer[layer]; + OffsetIndices offsets{transform_data.layer_offsets}; + Span positions = transform_data.positions.as_span().slice(offsets[layer]); + + array_utils::scatter(positions, selection, positions_dst); +} + void curve_populate_trans_data_structs(TransDataContainer &tc, blender::bke::CurvesGeometry &curves, const blender::float4x4 &transform, @@ -227,8 +217,12 @@ void curve_populate_trans_data_structs(TransDataContainer &tc, copy_m3_m4(mtx, transform.ptr()); pseudoinverse_m3_m3(smtx, mtx, PSEUDOINVERSE_EPSILON); - MutableSpan positions{ - static_cast(tc.custom.type.data)->positions}; + ed::transform::curves::append_positions_to_custom_data( + selected_indices, curves.positions(), tc.custom.type); + MutableSpan positions = static_cast(tc.custom.type.data) + ->positions.as_mutable_span() + .slice(trans_data_offset, selected_indices.size()); + if (use_proportional_edit) { const OffsetIndices points_by_curve = curves.points_by_curve(); const VArray selection = *curves.attributes().lookup_or_default( diff --git a/source/blender/editors/transform/transform_convert_grease_pencil.cc b/source/blender/editors/transform/transform_convert_grease_pencil.cc index 17c83baa0c8..e88d82db113 100644 --- a/source/blender/editors/transform/transform_convert_grease_pencil.cc +++ b/source/blender/editors/transform/transform_convert_grease_pencil.cc @@ -44,23 +44,24 @@ static void createTransGreasePencilVerts(bContext *C, TransInfo *t) } int layer_offset = 0; - IndexMaskMemory memory; Array points_per_layer_per_object(total_number_of_drawings); /* Count selected elements per layer per object and create TransData structs. */ for (const int i : trans_data_contrainers.index_range()) { TransDataContainer &tc = trans_data_contrainers[i]; + CurvesTransformData *curves_transform_data = create_curves_custom_data(tc.custom.type); const Vector drawings = all_drawings[i]; for (ed::greasepencil::MutableDrawingInfo info : drawings) { if (use_proportional_edit) { points_per_layer_per_object[layer_offset] = ed::greasepencil::retrieve_editable_points( - *object, info.drawing, memory); + *object, info.drawing, curves_transform_data->memory); tc.data_len += points_per_layer_per_object[layer_offset].size(); } else { points_per_layer_per_object[layer_offset] = - ed::greasepencil::retrieve_editable_and_selected_points(*object, info.drawing, memory); + ed::greasepencil::retrieve_editable_and_selected_points( + *object, info.drawing, curves_transform_data->memory); tc.data_len += points_per_layer_per_object[layer_offset].size(); } @@ -69,11 +70,13 @@ static void createTransGreasePencilVerts(bContext *C, TransInfo *t) if (tc.data_len > 0) { tc.data = MEM_cnew_array(tc.data_len, __func__); + curves_transform_data->positions.reinitialize(tc.data_len); } } /* Reuse the variable `layer_offset`. */ layer_offset = 0; + IndexMaskMemory memory; /* Populate TransData structs. */ for (const int i : trans_data_contrainers.index_range()) { @@ -145,8 +148,10 @@ static void recalcData_grease_pencil(TransInfo *t) const Vector drawings = ed::greasepencil::retrieve_editable_drawings(*scene, grease_pencil); - for (ed::greasepencil::MutableDrawingInfo info : drawings) { + for (const int64_t i : drawings.index_range()) { + ed::greasepencil::MutableDrawingInfo info = drawings[i]; bke::CurvesGeometry &curves = info.drawing.strokes_for_write(); + selected_positions_from_custom_data(tc.custom.type, i, curves.positions_for_write()); curves.calculate_bezier_auto_handles(); curves.tag_positions_changed(); -- 2.30.2 From 20f94e58658d0416cd656cd4d812be1ffc07cd4c Mon Sep 17 00:00:00 2001 From: Laurynas Duburas Date: Sat, 20 Apr 2024 10:06:32 +0300 Subject: [PATCH 4/6] cleanup --- .../transform_convert_grease_pencil.cc | 37 +++++++------------ 1 file changed, 13 insertions(+), 24 deletions(-) diff --git a/source/blender/editors/transform/transform_convert_grease_pencil.cc b/source/blender/editors/transform/transform_convert_grease_pencil.cc index e88d82db113..82e1b1287ab 100644 --- a/source/blender/editors/transform/transform_convert_grease_pencil.cc +++ b/source/blender/editors/transform/transform_convert_grease_pencil.cc @@ -106,30 +106,19 @@ static void createTransGreasePencilVerts(bContext *C, TransInfo *t) value_attribute = opacities; } - if (use_proportional_edit) { - const IndexMask affected_strokes = ed::greasepencil::retrieve_editable_strokes( - *object, info.drawing, memory); - curve_populate_trans_data_structs(tc, - curves, - layer_space_to_world_space, - value_attribute, - points, - true, - affected_strokes, - use_connected_only, - layer_points_offset); - } - else { - curve_populate_trans_data_structs(tc, - curves, - layer_space_to_world_space, - value_attribute, - points, - false, - {}, - use_connected_only, - layer_points_offset); - } + const IndexMask affected_strokes = use_proportional_edit ? + ed::greasepencil::retrieve_editable_strokes( + *object, info.drawing, memory) : + IndexMask(); + curve_populate_trans_data_structs(tc, + curves, + layer_space_to_world_space, + value_attribute, + points, + use_proportional_edit, + affected_strokes, + use_connected_only, + layer_points_offset); layer_points_offset += points.size(); layer_offset++; -- 2.30.2 From f2abc80fbad8adb0ca97af1bab94a280b4c3fb70 Mon Sep 17 00:00:00 2001 From: Laurynas Duburas Date: Mon, 22 Apr 2024 15:25:58 +0300 Subject: [PATCH 5/6] Comments added --- .../editors/transform/transform_convert.hh | 18 ++++++++++++++---- .../transform/transform_convert_curves.cc | 17 ++++++++++------- .../transform_convert_grease_pencil.cc | 6 ++++-- 3 files changed, 28 insertions(+), 13 deletions(-) diff --git a/source/blender/editors/transform/transform_convert.hh b/source/blender/editors/transform/transform_convert.hh index 32bd776b6fc..d1346f7124e 100644 --- a/source/blender/editors/transform/transform_convert.hh +++ b/source/blender/editors/transform/transform_convert.hh @@ -87,7 +87,16 @@ struct TransDataVertSlideVert { struct CurvesTransformData { blender::IndexMaskMemory memory; blender::Vector selection_by_layer; + + /** + * The offsets of every grease pencil layer into `positions` array. + * For curves only one layer is used. + */ blender::Vector layer_offsets; + + /** + * Copy of all positions being transformed. + */ blender::Array positions; }; @@ -172,11 +181,12 @@ void curve_populate_trans_data_structs(TransDataContainer &tc, bool use_connected_only, int trans_data_offset); -CurvesTransformData *create_curves_custom_data(TransCustomData &custom_data); +CurvesTransformData *create_curves_transform_custom_data(TransCustomData &custom_data); -void selected_positions_from_custom_data(const TransCustomData &custom_data, - const int layer, - blender::MutableSpan positions_dst); +void copy_positions_from_curves_transform_custom_data( + const TransCustomData &custom_data, + const int layer, + blender::MutableSpan positions_dst); /* `transform_convert_action.cc` */ diff --git a/source/blender/editors/transform/transform_convert_curves.cc b/source/blender/editors/transform/transform_convert_curves.cc index 2685ce73cb4..06dbab801f9 100644 --- a/source/blender/editors/transform/transform_convert_curves.cc +++ b/source/blender/editors/transform/transform_convert_curves.cc @@ -73,7 +73,7 @@ static void append_positions_to_custom_data(const IndexMask selection, transform_data.layer_offsets.append(data_offset + selection.size()); array_utils::gather( positions, - transform_data.selection_by_layer.last(), + selection, transform_data.positions.as_mutable_span().slice(data_offset, selection.size())); } @@ -91,7 +91,8 @@ static void createTransCurvesVerts(bContext * /*C*/, TransInfo *t) Curves *curves_id = static_cast(tc.obedit->data); bke::CurvesGeometry &curves = curves_id->geometry.wrap(); - CurvesTransformData *curves_transform_data = create_curves_custom_data(tc.custom.type); + CurvesTransformData *curves_transform_data = create_curves_transform_custom_data( + tc.custom.type); if (use_proportional_edit) { selection_per_object[i] = curves.points_range(); @@ -164,7 +165,8 @@ static void recalcData_curves(TransInfo *t) curves.tag_normals_changed(); } else { - selected_positions_from_custom_data(tc.custom.type, 0, curves.positions_for_write()); + copy_positions_from_curves_transform_custom_data( + tc.custom.type, 0, curves.positions_for_write()); curves.tag_positions_changed(); curves.calculate_bezier_auto_handles(); } @@ -174,7 +176,7 @@ static void recalcData_curves(TransInfo *t) } // namespace blender::ed::transform::curves -CurvesTransformData *create_curves_custom_data(TransCustomData &custom_data) +CurvesTransformData *create_curves_transform_custom_data(TransCustomData &custom_data) { CurvesTransformData *transform_data = MEM_new(__func__); transform_data->layer_offsets.append(0); @@ -187,9 +189,10 @@ CurvesTransformData *create_curves_custom_data(TransCustomData &custom_data) return transform_data; } -void selected_positions_from_custom_data(const TransCustomData &custom_data, - const int layer, - blender::MutableSpan positions_dst) +void copy_positions_from_curves_transform_custom_data( + const TransCustomData &custom_data, + const int layer, + blender::MutableSpan positions_dst) { using namespace blender; const CurvesTransformData &transform_data = *static_cast( diff --git a/source/blender/editors/transform/transform_convert_grease_pencil.cc b/source/blender/editors/transform/transform_convert_grease_pencil.cc index 82e1b1287ab..551a35ff1f9 100644 --- a/source/blender/editors/transform/transform_convert_grease_pencil.cc +++ b/source/blender/editors/transform/transform_convert_grease_pencil.cc @@ -49,7 +49,8 @@ static void createTransGreasePencilVerts(bContext *C, TransInfo *t) /* Count selected elements per layer per object and create TransData structs. */ for (const int i : trans_data_contrainers.index_range()) { TransDataContainer &tc = trans_data_contrainers[i]; - CurvesTransformData *curves_transform_data = create_curves_custom_data(tc.custom.type); + CurvesTransformData *curves_transform_data = create_curves_transform_custom_data( + tc.custom.type); const Vector drawings = all_drawings[i]; for (ed::greasepencil::MutableDrawingInfo info : drawings) { @@ -140,7 +141,8 @@ static void recalcData_grease_pencil(TransInfo *t) for (const int64_t i : drawings.index_range()) { ed::greasepencil::MutableDrawingInfo info = drawings[i]; bke::CurvesGeometry &curves = info.drawing.strokes_for_write(); - selected_positions_from_custom_data(tc.custom.type, i, curves.positions_for_write()); + copy_positions_from_curves_transform_custom_data( + tc.custom.type, i, curves.positions_for_write()); curves.calculate_bezier_auto_handles(); curves.tag_positions_changed(); -- 2.30.2 From be0895ac2236c05fb08d6441c804598e6236f505 Mon Sep 17 00:00:00 2001 From: Laurynas Duburas Date: Mon, 22 Apr 2024 16:12:42 +0300 Subject: [PATCH 6/6] cleanup --- source/blender/editors/transform/transform_convert_curves.cc | 1 - 1 file changed, 1 deletion(-) diff --git a/source/blender/editors/transform/transform_convert_curves.cc b/source/blender/editors/transform/transform_convert_curves.cc index 06dbab801f9..d8b7237fdfe 100644 --- a/source/blender/editors/transform/transform_convert_curves.cc +++ b/source/blender/editors/transform/transform_convert_curves.cc @@ -80,7 +80,6 @@ static void append_positions_to_custom_data(const IndexMask selection, static void createTransCurvesVerts(bContext * /*C*/, TransInfo *t) { MutableSpan trans_data_contrainers(t->data_container, t->data_container_len); - IndexMaskMemory memory; Array selection_per_object(t->data_container_len); const bool use_proportional_edit = (t->flag & T_PROP_EDIT_ALL) != 0; const bool use_connected_only = (t->flag & T_PROP_CONNECTED) != 0; -- 2.30.2