From 1dc11c4fdff477cfd55255e37d3d407d666815ad Mon Sep 17 00:00:00 2001 From: Joshua Leung Date: Mon, 7 Feb 2011 10:50:35 +0000 Subject: [PATCH] Bugfix [#25934] "Apply Visual Transform as Pose" not working? Simplified the code for Apply Visual Transform as Pose. This makes it work for IK chains now, since there aren't any recalculations of the pose involved now, which were contributing to the pose getting incorrect as the applying process went on, since the IK chain was getting calculated differently with each successive change to the chain. --- .../blender/editors/armature/editarmature.c | 24 +++++++------------ 1 file changed, 9 insertions(+), 15 deletions(-) diff --git a/source/blender/editors/armature/editarmature.c b/source/blender/editors/armature/editarmature.c index 4fc5064cef0..2cdb2c9a062 100644 --- a/source/blender/editors/armature/editarmature.c +++ b/source/blender/editors/armature/editarmature.c @@ -729,24 +729,18 @@ static int pose_visual_transform_apply_exec (bContext *C, wmOperator *UNUSED(op) * at once are to be predictable*/ CTX_DATA_BEGIN(C, bPoseChannel *, pchan, selected_pose_bones) { - float delta_mat[4][4], imat[4][4], mat[4][4]; - - where_is_pose_bone(scene, ob, pchan, CFRA, 1); - - copy_m4_m4(mat, pchan->pose_mat); - - /* calculate pchan->pose_mat without loc/size/rot & constraints applied */ - where_is_pose_bone(scene, ob, pchan, CFRA, 0); - invert_m4_m4(imat, pchan->pose_mat); - mul_m4_m4m4(delta_mat, mat, imat); - + float delta_mat[4][4]; + + /* chan_mat already contains the delta transform from rest pose to pose-mode pose + * as that is baked into there so that B-Bones will work. Once we've set this as the + * new raw-transform components, don't recalc the poses yet, otherwise IK result will + * change, thus changing the result we may be trying to record. + */ + copy_m4_m4(delta_mat, pchan->chan_mat); pchan_apply_mat4(pchan, delta_mat, TRUE); - - where_is_pose_bone(scene, ob, pchan, CFRA, 1); } CTX_DATA_END; - - // ob->pose->flag |= (POSE_LOCKED|POSE_DO_UNLOCK); + DAG_id_tag_update(&ob->id, OB_RECALC_DATA); /* note, notifier might evolve */