From 3311164b24da61f2967f96d0ee27508a7e2e0267 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Fri, 16 Dec 2011 19:53:12 +0000 Subject: Math lib: matrix multiplication order fix for two functions that were inconsistent with similar functions & math notation: mul_m4_m4m4(R, B, A) => mult_m4_m4m4(R, A, B) mul_m3_m3m4(R, B, A) => mult_m3_m3m4(R, A, B) For branch maintainers, it should be relatively simple to fix things manually, it's also possible run this script after merging to do automatic replacement: http://www.pasteall.org/27459/python --- source/blender/ikplugin/intern/iksolver_plugin.c | 10 +++++----- source/blender/ikplugin/intern/itasc_plugin.cpp | 12 ++++++------ 2 files changed, 11 insertions(+), 11 deletions(-) (limited to 'source/blender/ikplugin') diff --git a/source/blender/ikplugin/intern/iksolver_plugin.c b/source/blender/ikplugin/intern/iksolver_plugin.c index eb3695ea217..34656daaa19 100644 --- a/source/blender/ikplugin/intern/iksolver_plugin.c +++ b/source/blender/ikplugin/intern/iksolver_plugin.c @@ -199,7 +199,7 @@ static void make_dmats(bPoseChannel *pchan) if (pchan->parent) { float iR_parmat[4][4]; invert_m4_m4(iR_parmat, pchan->parent->pose_mat); - mul_m4_m4m4(pchan->chan_mat, pchan->pose_mat, iR_parmat); // delta mat + mult_m4_m4m4(pchan->chan_mat, iR_parmat, pchan->pose_mat); // delta mat } else copy_m4_m4(pchan->chan_mat, pchan->pose_mat); } @@ -216,7 +216,7 @@ static void where_is_ik_bone(bPoseChannel *pchan, float ik_mat[][3]) // nr = t if (pchan->parent) mul_serie_m4(pchan->pose_mat, pchan->parent->pose_mat, pchan->chan_mat, ikmat, NULL, NULL, NULL, NULL, NULL); else - mul_m4_m4m4(pchan->pose_mat, ikmat, pchan->chan_mat); + mult_m4_m4m4(pchan->pose_mat, pchan->chan_mat, ikmat); /* calculate head */ copy_v3_v3(pchan->pose_head, pchan->pose_mat[3]); @@ -356,7 +356,7 @@ static void execute_posetree(struct Scene *scene, Object *ob, PoseTree *tree) unit_m4(rootmat); copy_v3_v3(rootmat[3], pchan->pose_head); - mul_m4_m4m4(imat, rootmat, ob->obmat); + mult_m4_m4m4(imat, ob->obmat, rootmat); invert_m4_m4(goalinv, imat); for (target=tree->targets.first; target; target=target->next) { @@ -371,7 +371,7 @@ static void execute_posetree(struct Scene *scene, Object *ob, PoseTree *tree) get_constraint_target_matrix(scene, target->con, 0, CONSTRAINT_OBTYPE_OBJECT, ob, rootmat, 1.0); /* and set and transform goal */ - mul_m4_m4m4(goal, rootmat, goalinv); + mult_m4_m4m4(goal, goalinv, rootmat); copy_v3_v3(goalpos, goal[3]); copy_m3_m4(goalrot, goal); @@ -385,7 +385,7 @@ static void execute_posetree(struct Scene *scene, Object *ob, PoseTree *tree) break; } else { - mul_m4_m4m4(goal, rootmat, goalinv); + mult_m4_m4m4(goal, goalinv, rootmat); copy_v3_v3(polepos, goal[3]); poleconstrain= 1; diff --git a/source/blender/ikplugin/intern/itasc_plugin.cpp b/source/blender/ikplugin/intern/itasc_plugin.cpp index f4720b7fc41..f605441282b 100644 --- a/source/blender/ikplugin/intern/itasc_plugin.cpp +++ b/source/blender/ikplugin/intern/itasc_plugin.cpp @@ -570,7 +570,7 @@ static bool target_callback(const iTaSC::Timestamp& timestamp, const iTaSC::Fram mul_serie_m4(restmat, target->owner->obmat, chanmat, target->eeRest, NULL, NULL, NULL, NULL, NULL); } else { - mul_m4_m4m4(restmat, target->eeRest, target->owner->obmat); + mult_m4_m4m4(restmat, target->owner->obmat, target->eeRest); } // blend the target blend_m4_m4m4(tarmat, restmat, tarmat, constraint->enforce); @@ -597,7 +597,7 @@ static bool base_callback(const iTaSC::Timestamp& timestamp, const iTaSC::Frame& // save the base as a frame too so that we can compute deformation // after simulation ikscene->baseFrame.setValue(&chanmat[0][0]); - mul_m4_m4m4(rootmat, chanmat, ikscene->blArmature->obmat); + mult_m4_m4m4(rootmat, ikscene->blArmature->obmat, chanmat); } else { copy_m4_m4(rootmat, ikscene->blArmature->obmat); @@ -622,11 +622,11 @@ static bool base_callback(const iTaSC::Timestamp& timestamp, const iTaSC::Frame& // get polar target matrix in world space get_constraint_target_matrix(ikscene->blscene, ikscene->polarConstraint, 1, CONSTRAINT_OBTYPE_OBJECT, ikscene->blArmature, mat, 1.0); // convert to armature space - mul_m4_m4m4(polemat, mat, imat); + mult_m4_m4m4(polemat, imat, mat); // get the target in world space (was computed before as target object are defined before base object) iktarget->target->getPose().getValue(mat[0]); // convert to armature space - mul_m4_m4m4(goalmat, mat, imat); + mult_m4_m4m4(goalmat, imat, mat); // take position of target, polar target, end effector, in armature space KDL::Vector goalpos(goalmat[3]); KDL::Vector polepos(polemat[3]); @@ -1003,7 +1003,7 @@ static void convert_pose(IK_Scene *ikscene) copy_m4_m4(bmat, bone->arm_mat); } invert_m4_m4(rmat, bmat); - mul_m4_m4m4(bmat, pchan->pose_mat, rmat); + mult_m4_m4m4(bmat, rmat, pchan->pose_mat); normalize_m4(bmat); boneRot.setValue(bmat[0]); GetJointRotation(boneRot, ikchan->jointType, rot); @@ -1419,7 +1419,7 @@ static IK_Scene* convert_tree(Scene *blscene, Object *ob, bPoseChannel *pchan) copy_m4_m4(mat, pchan->bone->arm_mat); copy_v3_v3(mat[3], pchan->bone->arm_tail); // get the rest pose relative to the armature base - mul_m4_m4m4(iktarget->eeRest, mat, invBaseFrame); + mult_m4_m4m4(iktarget->eeRest, invBaseFrame, mat); iktarget->eeBlend = (!ikscene->polarConstraint && condata->type==CONSTRAINT_IK_COPYPOSE) ? true : false; // use target_callback to make sure the initPose includes enforce coefficient target_callback(iTaSC::Timestamp(), iTaSC::F_identity, initPose, iktarget); -- cgit v1.2.3