From 845f4cebadc8d15b6407e2e863fce2de6230266b Mon Sep 17 00:00:00 2001 From: Germano Cavalcante Date: Wed, 16 Jun 2021 16:47:34 -0300 Subject: Fix T88342: 'To Sphere' and 'Push/Pull' not working in Pose mode Some modes don't take into account that `TransData` may be in data space. --- .../editors/transform/transform_mode_push_pull.c | 5 +++ .../editors/transform/transform_mode_tosphere.c | 43 ++++++++++++++++++---- 2 files changed, 41 insertions(+), 7 deletions(-) diff --git a/source/blender/editors/transform/transform_mode_push_pull.c b/source/blender/editors/transform/transform_mode_push_pull.c index 8a92978f33f..b08e479a3d0 100644 --- a/source/blender/editors/transform/transform_mode_push_pull.c +++ b/source/blender/editors/transform/transform_mode_push_pull.c @@ -77,6 +77,8 @@ static void applyPushPull(TransInfo *t, const int UNUSED(mval[2])) t->con.applyRot(t, NULL, NULL, axis_global, NULL); } + const bool is_data_space = (t->options & CTX_POSE_BONE) != 0; + FOREACH_TRANS_DATA_CONTAINER (t, tc) { TransData *td = tc->data; for (i = 0; i < tc->data_len; i++, td++) { @@ -101,6 +103,9 @@ static void applyPushPull(TransInfo *t, const int UNUSED(mval[2])) } } normalize_v3_length(vec, distance * td->factor); + if (is_data_space) { + mul_m3_v3(td->smtx, vec); + } add_v3_v3v3(td->loc, td->iloc, vec); } diff --git a/source/blender/editors/transform/transform_mode_tosphere.c b/source/blender/editors/transform/transform_mode_tosphere.c index 15906f2c90c..9bca9b2e9e6 100644 --- a/source/blender/editors/transform/transform_mode_tosphere.c +++ b/source/blender/editors/transform/transform_mode_tosphere.c @@ -55,8 +55,10 @@ static void to_sphere_radius_update(TransInfo *t) { struct ToSphereInfo *data = t->custom.mode.data; float radius = 0.0f; + float vec[3]; const bool is_local_center = transdata_check_local_center(t, t->around); + const bool is_data_space = (t->options & CTX_POSE_BONE) != 0; if (t->flag & T_PROP_EDIT_ALL) { int factor_accum = 0.0f; @@ -67,7 +69,15 @@ static void to_sphere_radius_update(TransInfo *t) continue; } const float *center = is_local_center ? td->center : tc->center_local; - radius += td->factor * len_v3v3(center, td->iloc); + if (is_data_space) { + copy_v3_v3(vec, td->center); + } + else { + copy_v3_v3(vec, td->iloc); + } + + sub_v3_v3(vec, center); + radius += td->factor * len_v3(vec); factor_accum += td->factor; } } @@ -80,7 +90,15 @@ static void to_sphere_radius_update(TransInfo *t) TransData *td = tc->data; for (int i = 0; i < tc->data_len; i++, td++) { const float *center = is_local_center ? td->center : tc->center_local; - radius += len_v3v3(center, td->iloc); + if (is_data_space) { + copy_v3_v3(vec, td->center); + } + else { + copy_v3_v3(vec, td->iloc); + } + + sub_v3_v3(vec, center); + radius += len_v3(vec); } } radius /= (float)t->data_len_all; @@ -99,6 +117,7 @@ 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); + const bool is_data_space = (t->options & CTX_POSE_BONE) != 0; float vec[3]; float ratio, radius; @@ -142,16 +161,26 @@ static void applyToSphere(TransInfo *t, const int UNUSED(mval[2])) } const float *center = is_local_center ? td->center : tc->center_local; + if (is_data_space) { + copy_v3_v3(vec, td->center); + } + else { + copy_v3_v3(vec, td->iloc); + } - sub_v3_v3v3(vec, td->iloc, center); - + sub_v3_v3(vec, center); radius = normalize_v3(vec); - tratio = ratio * td->factor; - mul_v3_fl(vec, radius * (1.0f - tratio) + data->radius * tratio); + add_v3_v3(vec, center); + + if (is_data_space) { + sub_v3_v3(vec, td->center); + mul_m3_v3(td->smtx, vec); + add_v3_v3(vec, td->iloc); + } - add_v3_v3v3(td->loc, center, vec); + copy_v3_v3(td->loc, vec); } } -- cgit v1.2.3