diff options
author | Campbell Barton <ideasman42@gmail.com> | 2020-11-05 07:41:35 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2020-11-05 07:45:48 +0300 |
commit | 52a2d5cbd269c4f7f84a866a3080ce821dce80d3 (patch) | |
tree | 74781b25ad13a90605e25812539f7f9cd3f1447a /source/blender/editors/transform | |
parent | 8d88d9fd339dc2296e17667ad51d6cd1090ede3d (diff) |
Transform: support individual origins for "To Sphere"
Diffstat (limited to 'source/blender/editors/transform')
-rw-r--r-- | source/blender/editors/transform/transform_mode_tosphere.c | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/source/blender/editors/transform/transform_mode_tosphere.c b/source/blender/editors/transform/transform_mode_tosphere.c index d50b26d3e5a..15906f2c90c 100644 --- a/source/blender/editors/transform/transform_mode_tosphere.c +++ b/source/blender/editors/transform/transform_mode_tosphere.c @@ -56,6 +56,8 @@ static void to_sphere_radius_update(TransInfo *t) struct ToSphereInfo *data = t->custom.mode.data; float radius = 0.0f; + const bool is_local_center = transdata_check_local_center(t, t->around); + if (t->flag & T_PROP_EDIT_ALL) { int factor_accum = 0.0f; FOREACH_TRANS_DATA_CONTAINER (t, tc) { @@ -64,7 +66,8 @@ static void to_sphere_radius_update(TransInfo *t) if (td->factor == 0.0f) { continue; } - radius += td->factor * len_v3v3(tc->center_local, td->iloc); + const float *center = is_local_center ? td->center : tc->center_local; + radius += td->factor * len_v3v3(center, td->iloc); factor_accum += td->factor; } } @@ -76,7 +79,8 @@ static void to_sphere_radius_update(TransInfo *t) FOREACH_TRANS_DATA_CONTAINER (t, tc) { TransData *td = tc->data; for (int i = 0; i < tc->data_len; i++, td++) { - radius += len_v3v3(tc->center_local, td->iloc); + const float *center = is_local_center ? td->center : tc->center_local; + radius += len_v3v3(center, td->iloc); } } radius /= (float)t->data_len_all; @@ -94,6 +98,8 @@ static void to_sphere_radius_update(TransInfo *t) static void applyToSphere(TransInfo *t, const int UNUSED(mval[2])) { + const bool is_local_center = transdata_check_local_center(t, t->around); + float vec[3]; float ratio, radius; int i; @@ -135,7 +141,9 @@ static void applyToSphere(TransInfo *t, const int UNUSED(mval[2])) continue; } - sub_v3_v3v3(vec, td->iloc, tc->center_local); + const float *center = is_local_center ? td->center : tc->center_local; + + sub_v3_v3v3(vec, td->iloc, center); radius = normalize_v3(vec); @@ -143,7 +151,7 @@ static void applyToSphere(TransInfo *t, const int UNUSED(mval[2])) mul_v3_fl(vec, radius * (1.0f - tratio) + data->radius * tratio); - add_v3_v3v3(td->loc, tc->center_local, vec); + add_v3_v3v3(td->loc, center, vec); } } |