From ac3afae3802dc8d6b80e0ae249cf219d07c8b4d9 Mon Sep 17 00:00:00 2001 From: Philipp Oeser Date: Fri, 6 Jun 2025 08:09:32 +0200 Subject: [PATCH] Fix: uninitialized TransData center for Curves proportional editing When proportional editing around individual origins is used, we would end up with uninitialized TransData center for points in curves which have nothing selected. This is more or less harmless since the center is not even used in that case (instead the center of the closest point found is used, see logic in #set_prop_dist /#prop_dist_loc_get). Still nicer to be clear about this, added some code comments which hopefully make the situation clearer. Ref. 1d0c11987f Ref. #139101 Pull Request: https://projects.blender.org/blender/blender/pulls/139849 --- source/blender/editors/transform/transform_convert.cc | 4 ++++ source/blender/editors/transform/transform_convert_curves.cc | 5 ++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/source/blender/editors/transform/transform_convert.cc b/source/blender/editors/transform/transform_convert.cc index 15f546c50a7..47eb0e7f184 100644 --- a/source/blender/editors/transform/transform_convert.cc +++ b/source/blender/editors/transform/transform_convert.cc @@ -205,6 +205,9 @@ static float3 prop_dist_loc_get(const TransDataContainer *tc, /** * Distance calculated from not-selected vertex to nearest selected vertex. + * If the #transdata_check_local_islands() check succeeds, this will also change + * the TransData center and axismtx of unselected points to the center and axismtx of the closest + * point found (for proportional editing around individual origins). */ static void set_prop_dist(TransInfo *t, const bool with_dist) { @@ -284,6 +287,7 @@ static void set_prop_dist(TransInfo *t, const bool with_dist) if (td_index != -1) { td->rdist = nearest.dist; if (use_island) { + /* Use center and axismtx of closest point found. */ copy_v3_v3(td->center, td_table[td_index]->center); copy_m3_m3(td->axismtx, td_table[td_index]->axismtx); } diff --git a/source/blender/editors/transform/transform_convert_curves.cc b/source/blender/editors/transform/transform_convert_curves.cc index e0ed0751577..2700b2a8627 100644 --- a/source/blender/editors/transform/transform_convert_curves.cc +++ b/source/blender/editors/transform/transform_convert_curves.cc @@ -494,7 +494,7 @@ void curve_populate_trans_data_structs(const TransInfo &t, const float3x3 smtx_base = math::pseudo_invert(mtx_base); const OffsetIndices points_by_curve = curves.points_by_curve(); - Array mean_center_point_per_curve(curves.curves_num()); + Array mean_center_point_per_curve(curves.curves_num(), float3(0)); if (use_individual_origin) { affected_curves.foreach_index(GrainSize(512), [&](const int64_t curve_i) { const IndexRange points = points_by_curve[curve_i]; @@ -502,6 +502,9 @@ void curve_populate_trans_data_structs(const TransInfo &t, const IndexMask selection = IndexMask::from_bools(point_selection, memory).slice_content(points); if (selection.is_empty()) { + /* For proportional editing around individual origins, unselected points will not use the + * TransData center (instead the closest point found is used, see logic in #set_prop_dist / + * #prop_dist_loc_get). */ return; } float3 center(0.0f);