Fix T38393: bone roll not restored properly after cancelling rotation of bones.

This commit is contained in:
Brecht Van Lommel 2014-01-29 16:11:34 +01:00
parent 41ee052a45
commit 1e0654f162
Notes: blender-bot 2023-02-14 11:16:54 +01:00
Referenced by issue #38393, Bone roll is not reset after escape from a rotation
2 changed files with 21 additions and 12 deletions

View File

@ -1197,6 +1197,7 @@ static void createTransArmatureVerts(TransInfo *t)
if ((ebo->flag & BONE_ROOTSEL) == 0) {
td->extra = ebo;
td->ival = ebo->roll;
}
td->ext = NULL;
@ -1219,6 +1220,7 @@ static void createTransArmatureVerts(TransInfo *t)
ED_armature_ebone_to_mat3(ebo, td->axismtx);
td->extra = ebo; /* to fix roll */
td->ival = ebo->roll;
td->ext = NULL;
td->val = NULL;

View File

@ -806,21 +806,28 @@ static void recalcData_view3d(TransInfo *t)
float roll;
ebo = td->extra;
copy_v3_v3(up_axis, td->axismtx[2]);
if (t->mode != TFM_ROTATION) {
sub_v3_v3v3(vec, ebo->tail, ebo->head);
normalize_v3(vec);
rotation_between_vecs_to_quat(qrot, td->axismtx[1], vec);
mul_qt_v3(qrot, up_axis);
if (t->state == TRANS_CANCEL) {
/* restore roll */
ebo->roll = td->ival;
}
else {
mul_m3_v3(t->mat, up_axis);
copy_v3_v3(up_axis, td->axismtx[2]);
if (t->mode != TFM_ROTATION) {
sub_v3_v3v3(vec, ebo->tail, ebo->head);
normalize_v3(vec);
rotation_between_vecs_to_quat(qrot, td->axismtx[1], vec);
mul_qt_v3(qrot, up_axis);
}
else {
mul_m3_v3(t->mat, up_axis);
}
/* roll has a tendency to flip in certain orientations - [#34283], [#33974] */
roll = ED_rollBoneToVector(ebo, up_axis, false);
ebo->roll = angle_compat_rad(roll, ebo->roll);
}
/* roll has a tendency to flip in certain orientations - [#34283], [#33974] */
roll = ED_rollBoneToVector(ebo, up_axis, false);
ebo->roll = angle_compat_rad(roll, ebo->roll);
}
}
}