From 4d5bd6872b9ee27fd8d8a5ac62e2128b7b554e21 Mon Sep 17 00:00:00 2001 From: Joshua Leung Date: Mon, 5 Feb 2007 01:28:14 +0000 Subject: Bugfix #5833: When rotating bones around the 3d-cursor in posemode with a rotated armature, rotation was around strange points other than the cursor. This bug has been around for quite a few releases now. Somehow, the maths used to convert the world/global space locations to local locations only worked on things in editmode, but not bones. --- source/blender/src/transform_generics.c | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) (limited to 'source/blender/src/transform_generics.c') diff --git a/source/blender/src/transform_generics.c b/source/blender/src/transform_generics.c index 5bf08c02255..18412e0ab37 100755 --- a/source/blender/src/transform_generics.c +++ b/source/blender/src/transform_generics.c @@ -640,14 +640,24 @@ void restoreTransObjects(TransInfo *t) void calculateCenter2D(TransInfo *t) { - if (t->flag & (T_EDIT|T_POSE)) { - Object *ob= G.obedit?G.obedit:t->poseobj; + if (t->flag & T_EDIT) { + Object *ob= G.obedit; float vec[3]; VECCOPY(vec, t->center); Mat4MulVecfl(ob->obmat, vec); projectIntView(t, vec, t->center2d); } + else if (t->flag & T_POSE) { + Object *ob= t->poseobj; + float mat[4][4]; + + Mat4One(mat); + VECCOPY(mat[3], t->center); + + Mat4MulMat4(mat, ob->obmat, mat); + projectIntView(t, mat[3], t->center2d); + } else { projectIntView(t, t->center, t->center2d); } @@ -661,8 +671,8 @@ void calculateCenterCursor(TransInfo *t) VECCOPY(t->center, cursor); /* If edit or pose mode, move cursor in local space */ - if(t->flag & (T_EDIT|T_POSE)) { - Object *ob= G.obedit?G.obedit:t->poseobj; + if (t->flag & T_EDIT) { + Object *ob= G.obedit; float mat[3][3], imat[3][3]; VecSubf(t->center, t->center, ob->obmat[3]); @@ -670,6 +680,10 @@ void calculateCenterCursor(TransInfo *t) Mat3Inv(imat, mat); Mat3MulVecfl(imat, t->center); } + else if (t->flag & T_POSE) { + Object *ob= t->poseobj; + armature_loc_world_to_pose(ob, cursor, t->center); + } calculateCenter2D(t); } -- cgit v1.2.3