diff options
author | Joshua Leung <aligorith@gmail.com> | 2007-02-05 04:28:14 +0300 |
---|---|---|
committer | Joshua Leung <aligorith@gmail.com> | 2007-02-05 04:28:14 +0300 |
commit | 4d5bd6872b9ee27fd8d8a5ac62e2128b7b554e21 (patch) | |
tree | 607df9db8e5f5d16cddae6f149cefe80743b6c1e /source/blender | |
parent | 461e4786c80b748e0b541edf3930dcdd80182049 (diff) |
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.
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/blenkernel/BKE_armature.h | 1 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/armature.c | 18 | ||||
-rwxr-xr-x | source/blender/src/transform.c | 10 | ||||
-rwxr-xr-x | source/blender/src/transform_generics.c | 22 |
4 files changed, 46 insertions, 5 deletions
diff --git a/source/blender/blenkernel/BKE_armature.h b/source/blender/blenkernel/BKE_armature.h index cefaaf24eb6..31f6201f35b 100644 --- a/source/blender/blenkernel/BKE_armature.h +++ b/source/blender/blenkernel/BKE_armature.h @@ -97,6 +97,7 @@ void mat3_to_vec_roll(float mat[][3], float *vec, float *roll); /* Common Conversions Between Co-ordinate Spaces */ void armature_mat_world_to_pose(struct Object *ob, float inmat[][4], float outmat[][4]); +void armature_loc_world_to_pose(struct Object *ob, float *inloc, float *outloc); void armature_mat_pose_to_bone(struct bPoseChannel *pchan, float inmat[][4], float outmat[][4]); void armature_loc_pose_to_bone(struct bPoseChannel *pchan, float *inloc, float *outloc); void armature_mat_pose_to_delta(float delta_mat[][4], float pose_mat[][4], float arm_mat[][4]); diff --git a/source/blender/blenkernel/intern/armature.c b/source/blender/blenkernel/intern/armature.c index fb9ffb5b2e8..2d6c3f58352 100644 --- a/source/blender/blenkernel/intern/armature.c +++ b/source/blender/blenkernel/intern/armature.c @@ -838,6 +838,24 @@ void armature_mat_world_to_pose(Object *ob, float inmat[][4], float outmat[][4]) Mat4MulMat4(outmat, obmat, inmat); } +/* Convert Wolrd-Space Location to Pose-Space Location + * NOTE: this cannot be used to convert to pose-space location of the supplied + * pose-channel into its local space (i.e. 'visual'-keyframing) + */ +void armature_loc_world_to_pose(Object *ob, float *inloc, float *outloc) +{ + float xLocMat[4][4]; + float nLocMat[4][4]; + + /* build matrix for location */ + Mat4One(xLocMat); + VECCOPY(xLocMat[3], inloc); + + /* get bone-space cursor matrix and extract location */ + armature_mat_world_to_pose(ob, xLocMat, nLocMat); + VECCOPY(outloc, nLocMat[3]); +} + /* Convert Pose-Space Matrix to Bone-Space Matrix * NOTE: this cannot be used to convert to pose-space transforms of the supplied * pose-channel into its local space (i.e. 'visual'-keyframing) diff --git a/source/blender/src/transform.c b/source/blender/src/transform.c index 68f877928e5..323d155342f 100755 --- a/source/blender/src/transform.c +++ b/source/blender/src/transform.c @@ -122,7 +122,15 @@ static void helpline(TransInfo *t, float *vec) } else if(t->flag & T_POSE) { Object *ob=t->poseobj; - if(ob) Mat4MulVecfl(ob->obmat, vecrot); + float tmat[4][4]; + + Mat4One(tmat); + VECCOPY(tmat[3], vecrot); + + if(ob) { + Mat4MulMat4(tmat, ob->obmat, tmat); + VECCOPY(vecrot, tmat[3]); + } } getmouseco_areawin(mval); 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); } |