forked from bartvdbraak/blender
2.5 - Rotation work (axis angle bugfixes + cleanups)
* Made transform work better with axis-angle * Corrected the rotation-type handling code in a few places
This commit is contained in:
parent
d5009eb142
commit
baf12d3d17
@ -4856,9 +4856,13 @@ static int pose_clear_rot_exec(bContext *C, wmOperator *op)
|
||||
QUATCOPY(quat1, pchan->quat);
|
||||
QuatToEul(pchan->quat, oldeul);
|
||||
}
|
||||
else if (pchan->rotmode == PCHAN_ROT_AXISANGLE) {
|
||||
continue; // XXX
|
||||
}
|
||||
else {
|
||||
VECCOPY(oldeul, pchan->eul);
|
||||
}
|
||||
|
||||
eul[0]= eul[1]= eul[2]= 0.0f;
|
||||
|
||||
if (pchan->protectflag & OB_LOCK_ROTX)
|
||||
@ -4875,6 +4879,9 @@ static int pose_clear_rot_exec(bContext *C, wmOperator *op)
|
||||
QuatMulf(pchan->quat, -1.0f);
|
||||
}
|
||||
}
|
||||
else if (pchan->rotmode == PCHAN_ROT_AXISANGLE) {
|
||||
// TODO...
|
||||
}
|
||||
else {
|
||||
VECCOPY(pchan->eul, eul);
|
||||
}
|
||||
@ -4884,6 +4891,11 @@ static int pose_clear_rot_exec(bContext *C, wmOperator *op)
|
||||
pchan->quat[1]=pchan->quat[2]=pchan->quat[3]= 0.0f;
|
||||
pchan->quat[0]= 1.0f;
|
||||
}
|
||||
else if (pchan->rotmode == PCHAN_ROT_AXISANGLE) {
|
||||
/* by default, make rotation of 0 radians around y-axis (roll) */
|
||||
pchan->quat[0]=pchan->quat[1]=pchan->quat[3]= 0.0f;
|
||||
pchan->quat[2]= 1.0f;
|
||||
}
|
||||
else {
|
||||
pchan->eul[0]= pchan->eul[1]= pchan->eul[2]= 0.0f;
|
||||
}
|
||||
|
@ -278,8 +278,7 @@ void poselib_validate_act (bAction *act)
|
||||
/* ************************************************************* */
|
||||
|
||||
/* Pointers to the builtin KeyingSets that we want to use */
|
||||
static KeyingSet *poselib_ks_locrotscale = NULL; /* quaternion rotations */
|
||||
static KeyingSet *poselib_ks_locrotscale2 = NULL; /* euler rotations */ // XXX FIXME...
|
||||
static KeyingSet *poselib_ks_locrotscale = NULL; /* the only keyingset we'll need*/
|
||||
static short poselib_ks_need_init= 1; /* have the above been obtained yet? */
|
||||
|
||||
/* Make sure the builtin KeyingSets are initialised properly
|
||||
@ -290,13 +289,9 @@ static void poselib_get_builtin_keyingsets (void)
|
||||
/* only if we haven't got these yet */
|
||||
// FIXME: this assumes that we will always get the builtin sets...
|
||||
if (poselib_ks_need_init) {
|
||||
/* LocRotScale (quaternions) */
|
||||
/* LocRotScale (quaternions or eulers depending on context) */
|
||||
poselib_ks_locrotscale= ANIM_builtin_keyingset_get_named(NULL, "LocRotScale");
|
||||
|
||||
/* LocRotScale (euler) */
|
||||
//ks_locrotscale2= ANIM_builtin_keyingset_get_named(ks_locrotscale, "LocRotScale");
|
||||
poselib_ks_locrotscale2= poselib_ks_locrotscale; // FIXME: for now, just use the same one...
|
||||
|
||||
/* clear flag requesting init */
|
||||
poselib_ks_need_init= 0;
|
||||
}
|
||||
@ -410,10 +405,7 @@ static int poselib_add_exec (bContext *C, wmOperator *op)
|
||||
/* init cks for this PoseChannel, then use the relative KeyingSets to keyframe it */
|
||||
cks.pchan= pchan;
|
||||
|
||||
/* KeyingSet to use depends on rotation mode */
|
||||
if (pchan->rotmode)
|
||||
modify_keyframes(C, &dsources, act, poselib_ks_locrotscale2, MODIFYKEY_MODE_INSERT, (float)frame);
|
||||
else
|
||||
/* KeyingSet to use depends on rotation mode (but that's handled by the templates code) */
|
||||
modify_keyframes(C, &dsources, act, poselib_ks_locrotscale, MODIFYKEY_MODE_INSERT, (float)frame);
|
||||
}
|
||||
}
|
||||
|
@ -812,10 +812,17 @@ void pose_copy_menu(Scene *scene)
|
||||
|
||||
armature_mat_pose_to_bone(pchan, pchanact->pose_mat, delta_mat);
|
||||
|
||||
if (pchan->rotmode > 0)
|
||||
Mat4ToEulO(delta_mat, pchan->eul, pchan->rotmode);
|
||||
else
|
||||
if (pchan->rotmode == PCHAN_ROT_AXISANGLE) {
|
||||
float tmp_quat[4];
|
||||
|
||||
/* need to convert to quat first (in temp var)... */
|
||||
Mat4ToQuat(delta_mat, tmp_quat);
|
||||
QuatToAxisAngle(tmp_quat, &pchan->quat[1], &pchan->quat[0]);
|
||||
}
|
||||
else if (pchan->rotmode == PCHAN_ROT_QUAT)
|
||||
Mat4ToQuat(delta_mat, pchan->quat);
|
||||
else
|
||||
Mat4ToEulO(delta_mat, pchan->eul, pchan->rotmode);
|
||||
}
|
||||
break;
|
||||
case 11: /* Visual Size */
|
||||
@ -991,6 +998,7 @@ static int pose_paste_exec (bContext *C, wmOperator *op)
|
||||
pchan->flag= chan->flag;
|
||||
|
||||
/* check if rotation modes are compatible (i.e. do they need any conversions) */
|
||||
// FIXME: add axis-angle here too...
|
||||
if (pchan->rotmode == chan->rotmode) {
|
||||
/* copy the type of rotation in use */
|
||||
if (pchan->rotmode > 0) {
|
||||
|
@ -512,7 +512,16 @@ static void v3d_posearmature_buts(uiBlock *block, View3D *v3d, Object *ob, float
|
||||
uiButSetFunc(but, validate_bonebutton_cb, bone, NULL);
|
||||
uiButSetCompleteFunc(but, autocomplete_bone, (void *)ob);
|
||||
|
||||
QuatToEulO(pchan->quat, tfp->ob_eul, pchan->rotmode); // XXX?
|
||||
if (pchan->rotmode == PCHAN_ROT_AXISANGLE) {
|
||||
float quat[4];
|
||||
/* convert to euler, passing through quats... */
|
||||
AxisAngleToQuat(quat, &pchan->quat[1], pchan->quat[0]);
|
||||
QuatToEul(quat, tfp->ob_eul);
|
||||
}
|
||||
else if (pchan->rotmode == PCHAN_ROT_QUAT)
|
||||
QuatToEul(pchan->quat, tfp->ob_eul);
|
||||
else
|
||||
VecCopyf(tfp->ob_eul, pchan->eul);
|
||||
tfp->ob_eul[0]*= 180.0/M_PI;
|
||||
tfp->ob_eul[1]*= 180.0/M_PI;
|
||||
tfp->ob_eul[2]*= 180.0/M_PI;
|
||||
@ -841,7 +850,18 @@ static void do_view3d_region_buttons(bContext *C, void *arg, int event)
|
||||
eul[0]= M_PI*tfp->ob_eul[0]/180.0;
|
||||
eul[1]= M_PI*tfp->ob_eul[1]/180.0;
|
||||
eul[2]= M_PI*tfp->ob_eul[2]/180.0;
|
||||
EulOToQuat(eul, pchan->rotmode, pchan->quat); // xxx?
|
||||
|
||||
if (pchan->rotmode == PCHAN_ROT_AXISANGLE) {
|
||||
float quat[4];
|
||||
/* convert to axis-angle, passing through quats */
|
||||
EulToQuat(eul, quat);
|
||||
QuatToAxisAngle(quat, &pchan->quat[1], &pchan->quat[0]);
|
||||
}
|
||||
else if (pchan->rotmode == PCHAN_ROT_QUAT)
|
||||
EulToQuat(eul, pchan->quat);
|
||||
else
|
||||
VecCopyf(pchan->eul, eul);
|
||||
|
||||
}
|
||||
/* no break, pass on */
|
||||
case B_ARMATUREPANEL2:
|
||||
|
@ -2673,15 +2673,26 @@ static void ElementRotation(TransInfo *t, TransData *td, float mat[3][3], short
|
||||
/* this function works on end result */
|
||||
protectedQuaternionBits(td->protectflag, td->ext->quat, td->ext->iquat);
|
||||
|
||||
/* if axis-angle, we now convert the quat representation to axis-angle again
|
||||
* - this means that the math above is not totally correct, but it works well enough so far...
|
||||
*/
|
||||
if (td->rotOrder == PCHAN_ROT_AXISANGLE) {
|
||||
}
|
||||
else if (td->rotOrder == PCHAN_ROT_AXISANGLE) {
|
||||
/* calculate effect based on quats */
|
||||
float iquat[4];
|
||||
|
||||
/* td->ext->(i)quat is in axis-angle form, not quats! */
|
||||
AxisAngleToQuat(iquat, &td->ext->iquat[1], td->ext->iquat[0]);
|
||||
|
||||
Mat3MulSerie(fmat, td->mtx, mat, td->smtx, 0, 0, 0, 0, 0);
|
||||
Mat3ToQuat(fmat, quat); // Actual transform
|
||||
|
||||
QuatMul(td->ext->quat, quat, iquat);
|
||||
|
||||
/* this function works on end result */
|
||||
protectedQuaternionBits(td->protectflag, td->ext->quat, td->ext->iquat);
|
||||
|
||||
/* make temp copy (since stored in same place) */
|
||||
QuatCopy(quat, td->ext->quat);
|
||||
QuatToAxisAngle(quat, &td->ext->quat[1], &td->ext->quat[0]);
|
||||
}
|
||||
}
|
||||
else {
|
||||
float eulmat[3][3];
|
||||
|
||||
|
@ -552,9 +552,8 @@ static void add_pose_transdata(TransInfo *t, bPoseChannel *pchan, Object *ob, Tr
|
||||
|
||||
td->ob = ob;
|
||||
td->flag = TD_SELECTED;
|
||||
if ((pchan->rotmode == PCHAN_ROT_QUAT) || (pchan->rotmode == PCHAN_ROT_AXISANGLE))
|
||||
if (pchan->rotmode == PCHAN_ROT_QUAT)
|
||||
{
|
||||
// XXX: for now, axis-angle will be treated like for quats (the only difference is the normalisation)
|
||||
td->flag |= TD_USEQUAT;
|
||||
}
|
||||
if (bone->flag & BONE_HINGE_CHILD_TRANSFORM)
|
||||
|
Loading…
Reference in New Issue
Block a user