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
This commit is contained in:
Philipp Oeser
2025-06-06 08:09:32 +02:00
committed by Philipp Oeser
parent 3a35b26005
commit ac3afae380
2 changed files with 8 additions and 1 deletions

View File

@@ -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);
}

View File

@@ -494,7 +494,7 @@ void curve_populate_trans_data_structs(const TransInfo &t,
const float3x3 smtx_base = math::pseudo_invert(mtx_base);
const OffsetIndices<int> points_by_curve = curves.points_by_curve();
Array<float3> mean_center_point_per_curve(curves.curves_num());
Array<float3> 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);