Fix #143534: Grease Pencil: Grid snapping problem with bezier points or proportional editing
When the median was being calculated, the division was by the total number of transform data, rather than the selected number of transform data. Under most circumstances this would be the same, but when transforming bezier control points without the handles selected, or when having proportional editing on. This the median calculation would return a wrong result. Note: This problem could occur almost every object type not just Grease Pencil. Resolves: #143534 Pull Request: https://projects.blender.org/blender/blender/pulls/144245
This commit is contained in:
committed by
Falk David
parent
a459556ebd
commit
eb651bb243
@@ -1402,14 +1402,18 @@ void tranform_snap_target_median_calc(const TransInfo *t, float r_median[3])
|
||||
float v[3];
|
||||
zero_v3(v);
|
||||
|
||||
tc->foreach_index_selected([&](const int i) { add_v3_v3(v, tc->data[i].center); });
|
||||
int num_selected = 0;
|
||||
tc->foreach_index_selected([&](const int i) {
|
||||
add_v3_v3(v, tc->data[i].center);
|
||||
num_selected++;
|
||||
});
|
||||
|
||||
if (tc->data_len == 0) {
|
||||
if (num_selected == 0) {
|
||||
/* Is this possible? */
|
||||
continue;
|
||||
}
|
||||
|
||||
mul_v3_fl(v, 1.0 / tc->data_len);
|
||||
mul_v3_fl(v, 1.0 / num_selected);
|
||||
|
||||
if (tc->use_local_mat) {
|
||||
mul_m4_v3(tc->mat, v);
|
||||
|
||||
Reference in New Issue
Block a user