diff options
author | Bastien Montagne <montagne29@wanadoo.fr> | 2018-05-15 17:29:19 +0300 |
---|---|---|
committer | Bastien Montagne <montagne29@wanadoo.fr> | 2018-05-15 17:30:02 +0300 |
commit | a95d417db0fe4ff18e22e833951a08805c7a91e7 (patch) | |
tree | 5de8be45651ecee8cbcb1561754ebdd67bb765c1 /source/blender/editors/transform | |
parent | 10fe8ec68f8db3f9b2e0f4423e5ff1d50da79d85 (diff) |
Fix broken PoseMode editing when CoW is enabled.
We need to get data from evaluated object/posechannel too, then...
Diffstat (limited to 'source/blender/editors/transform')
-rw-r--r-- | source/blender/editors/transform/transform_conversions.c | 34 |
1 files changed, 21 insertions, 13 deletions
diff --git a/source/blender/editors/transform/transform_conversions.c b/source/blender/editors/transform/transform_conversions.c index 49da143f2f3..3c026f71769 100644 --- a/source/blender/editors/transform/transform_conversions.c +++ b/source/blender/editors/transform/transform_conversions.c @@ -537,14 +537,17 @@ static short apply_targetless_ik(Object *ob) return apply; } -static void add_pose_transdata(TransInfo *t, bPoseChannel *pchan, Object *ob, TransDataContainer *tc, TransData *td) +static void add_pose_transdata( + TransInfo *t, Object *ob, bPoseChannel *pchan, + Object *ob_eval, bPoseChannel *pchan_eval, + TransDataContainer *tc, TransData *td) { - Bone *bone = pchan->bone; + Bone *bone = pchan_eval->bone; float pmat[3][3], omat[3][3]; float cmat[3][3], tmat[3][3]; float vec[3]; - copy_v3_v3(vec, pchan->pose_mat[3]); + copy_v3_v3(vec, pchan_eval->pose_mat[3]); copy_v3_v3(td->center, vec); td->ob = ob; @@ -595,14 +598,14 @@ static void add_pose_transdata(TransInfo *t, bPoseChannel *pchan, Object *ob, Tr /* proper way to get parent transform + own transform + constraints transform */ - copy_m3_m4(omat, ob->obmat); + copy_m3_m4(omat, ob_eval->obmat); /* New code, using "generic" BKE_pchan_to_pose_mat(). */ { float rotscale_mat[4][4], loc_mat[4][4]; float rpmat[3][3]; - BKE_pchan_to_pose_mat(pchan, rotscale_mat, loc_mat); + BKE_pchan_to_pose_mat(pchan_eval, rotscale_mat, loc_mat); if (t->mode == TFM_TRANSLATION) copy_m3_m4(pmat, loc_mat); else @@ -615,7 +618,7 @@ static void add_pose_transdata(TransInfo *t, bPoseChannel *pchan, Object *ob, Tr copy_m3_m4(rpmat, rotscale_mat); if (constraints_list_needinv(t, &pchan->constraints)) { - copy_m3_m4(tmat, pchan->constinv); + copy_m3_m4(tmat, pchan_eval->constinv); invert_m3_m3(cmat, tmat); mul_m3_series(td->mtx, cmat, omat, pmat); mul_m3_series(td->ext->r_mtx, cmat, omat, rpmat); @@ -635,7 +638,7 @@ static void add_pose_transdata(TransInfo *t, bPoseChannel *pchan, Object *ob, Tr if (pchan->parent) { /* same as td->smtx but without pchan->bone->bone_mat */ td->flag |= TD_PBONE_LOCAL_MTX_C; - mul_m3_m3m3(td->ext->l_smtx, pchan->bone->bone_mat, td->smtx); + mul_m3_m3m3(td->ext->l_smtx, pchan_eval->bone->bone_mat, td->smtx); } else { td->flag |= TD_PBONE_LOCAL_MTX_P; @@ -643,7 +646,7 @@ static void add_pose_transdata(TransInfo *t, bPoseChannel *pchan, Object *ob, Tr } /* for axismat we use bone's own transform */ - copy_m3_m4(pmat, pchan->pose_mat); + copy_m3_m4(pmat, pchan_eval->pose_mat); mul_m3_m3m3(td->axismtx, omat, pmat); normalize_m3(td->axismtx); @@ -668,10 +671,10 @@ static void add_pose_transdata(TransInfo *t, bPoseChannel *pchan, Object *ob, Tr bKinematicConstraint *data = has_targetless_ik(pchan); if (data) { if (data->flag & CONSTRAINT_IK_TIP) { - copy_v3_v3(data->grabtarget, pchan->pose_tail); + copy_v3_v3(data->grabtarget, pchan_eval->pose_tail); } else { - copy_v3_v3(data->grabtarget, pchan->pose_head); + copy_v3_v3(data->grabtarget, pchan_eval->pose_head); } td->loc = data->grabtarget; copy_v3_v3(td->iloc, td->loc); @@ -1087,7 +1090,6 @@ static void createTransPose(TransInfo *t, Object **objects, uint objects_len) Object *ob = tc->poseobj; bArmature *arm; - bPoseChannel *pchan; TransData *td; TransDataExtension *tdx; short ik_on = 0; @@ -1132,9 +1134,15 @@ static void createTransPose(TransInfo *t, Object **objects, uint objects_len) /* use pose channels to fill trans data */ td = tc->data; - for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) { + Object *ob_eval = DEG_get_evaluated_object(CTX_data_depsgraph(t->context), ob); + bPoseChannel *pchan, *pchan_eval; + for (pchan = ob->pose->chanbase.first, pchan_eval = ob_eval->pose->chanbase.first; + pchan && pchan_eval; + pchan = pchan->next, pchan_eval = pchan_eval->next) + { + BLI_assert(pchan == pchan_eval || STREQ(pchan->bone->name, pchan_eval->bone->name)); if (pchan->bone->flag & BONE_TRANSFORM) { - add_pose_transdata(t, pchan, ob, tc, td); + add_pose_transdata(t, ob, pchan, ob_eval, pchan_eval, tc, td); td++; } } |