Fix T89291: Objects with rotation deltas don't rotate in correct axes
Quaternion correction was not implemented and Euler values were being incorrectly combined.
This commit is contained in:
parent
41af27c582
commit
b665ad8621
|
@ -164,6 +164,9 @@ void compatible_eul(float eul[3], const float old[3]);
|
||||||
|
|
||||||
void rotate_eul(float eul[3], const char axis, const float angle);
|
void rotate_eul(float eul[3], const char axis, const float angle);
|
||||||
|
|
||||||
|
void add_eul_euleul(float r_eul[3], float a[3], float b[3], const short order);
|
||||||
|
void sub_eul_euleul(float r_eul[3], float a[3], float b[3], const short order);
|
||||||
|
|
||||||
/************************** Arbitrary Order Eulers ***************************/
|
/************************** Arbitrary Order Eulers ***************************/
|
||||||
|
|
||||||
/* warning: must match the eRotationModes in DNA_action_types.h
|
/* warning: must match the eRotationModes in DNA_action_types.h
|
||||||
|
|
|
@ -1924,6 +1924,31 @@ void eulO_to_gimbal_axis(float gmat[3][3], const float eul[3], const short order
|
||||||
gmat[R->axis[2]][R->axis[2]] = 1;
|
gmat[R->axis[2]][R->axis[2]] = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void add_eul_euleul(float r_eul[3], float a[3], float b[3], const short order)
|
||||||
|
{
|
||||||
|
float quat[4], quat_b[4];
|
||||||
|
|
||||||
|
eulO_to_quat(quat, a, order);
|
||||||
|
eulO_to_quat(quat_b, b, order);
|
||||||
|
|
||||||
|
mul_qt_qtqt(quat, quat_b, quat);
|
||||||
|
|
||||||
|
quat_to_eulO(r_eul, order, quat);
|
||||||
|
}
|
||||||
|
|
||||||
|
void sub_eul_euleul(float r_eul[3], float a[3], float b[3], const short order)
|
||||||
|
{
|
||||||
|
float quat[4], quat_b[4];
|
||||||
|
|
||||||
|
eulO_to_quat(quat, a, order);
|
||||||
|
eulO_to_quat(quat_b, b, order);
|
||||||
|
|
||||||
|
invert_qt_normalized(quat_b);
|
||||||
|
mul_qt_qtqt(quat, quat_b, quat);
|
||||||
|
|
||||||
|
quat_to_eulO(r_eul, order, quat);
|
||||||
|
}
|
||||||
|
|
||||||
/******************************* Dual Quaternions ****************************/
|
/******************************* Dual Quaternions ****************************/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -734,9 +734,25 @@ void ElementRotation_ex(TransInfo *t,
|
||||||
/* can be called for texture space translate for example, then opt out */
|
/* can be called for texture space translate for example, then opt out */
|
||||||
if (td->ext->quat) {
|
if (td->ext->quat) {
|
||||||
mul_m3_series(fmat, td->smtx, mat, td->mtx);
|
mul_m3_series(fmat, td->smtx, mat, td->mtx);
|
||||||
|
|
||||||
|
if (!is_zero_v3(td->ext->dquat)) {
|
||||||
|
/* Correct for delta quat */
|
||||||
|
float tmp_mat[3][3];
|
||||||
|
quat_to_mat3(tmp_mat, td->ext->dquat);
|
||||||
|
mul_m3_m3m3(fmat, fmat, tmp_mat);
|
||||||
|
}
|
||||||
|
|
||||||
mat3_to_quat(quat, fmat); /* Actual transform */
|
mat3_to_quat(quat, fmat); /* Actual transform */
|
||||||
|
|
||||||
|
if (!is_zero_v4(td->ext->dquat)) {
|
||||||
|
/* Correct back for delta quat. */
|
||||||
|
float idquat[4];
|
||||||
|
invert_qt_qt_normalized(idquat, td->ext->dquat);
|
||||||
|
mul_qt_qtqt(quat, idquat, quat);
|
||||||
|
}
|
||||||
|
|
||||||
mul_qt_qtqt(td->ext->quat, quat, td->ext->iquat);
|
mul_qt_qtqt(td->ext->quat, quat, td->ext->iquat);
|
||||||
|
|
||||||
/* this function works on end result */
|
/* this function works on end result */
|
||||||
protectedQuaternionBits(td->protectflag, td->ext->quat, td->ext->iquat);
|
protectedQuaternionBits(td->protectflag, td->ext->quat, td->ext->iquat);
|
||||||
}
|
}
|
||||||
|
@ -761,21 +777,28 @@ void ElementRotation_ex(TransInfo *t,
|
||||||
td->ext->irotAngle);
|
td->ext->irotAngle);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
/* Calculate the total rotation in eulers. */
|
||||||
float obmat[3][3];
|
float obmat[3][3];
|
||||||
|
|
||||||
mul_m3_m3m3(totmat, mat, td->mtx);
|
mul_m3_m3m3(totmat, mat, td->mtx);
|
||||||
mul_m3_m3m3(smat, td->smtx, totmat);
|
mul_m3_m3m3(smat, td->smtx, totmat);
|
||||||
|
|
||||||
/* Calculate the total rotation in eulers. */
|
if (!is_zero_v3(td->ext->drot)) {
|
||||||
add_v3_v3v3(eul, td->ext->irot, td->ext->drot); /* correct for delta rot */
|
/* Correct for delta rot */
|
||||||
eulO_to_mat3(obmat, eul, td->ext->rotOrder);
|
add_eul_euleul(eul, td->ext->irot, td->ext->drot, td->ext->rotOrder);
|
||||||
/* mat = transform, obmat = object rotation */
|
}
|
||||||
mul_m3_m3m3(fmat, smat, obmat);
|
else {
|
||||||
|
copy_v3_v3(eul, td->ext->irot);
|
||||||
|
}
|
||||||
|
|
||||||
|
eulO_to_mat3(obmat, eul, td->ext->rotOrder);
|
||||||
|
mul_m3_m3m3(fmat, smat, obmat);
|
||||||
mat3_to_compatible_eulO(eul, td->ext->rot, td->ext->rotOrder, fmat);
|
mat3_to_compatible_eulO(eul, td->ext->rot, td->ext->rotOrder, fmat);
|
||||||
|
|
||||||
/* correct back for delta rot */
|
if (!is_zero_v3(td->ext->drot)) {
|
||||||
sub_v3_v3v3(eul, eul, td->ext->drot);
|
/* Correct back for delta rot. */
|
||||||
|
sub_eul_euleul(eul, eul, td->ext->drot, td->ext->rotOrder);
|
||||||
|
}
|
||||||
|
|
||||||
/* and apply */
|
/* and apply */
|
||||||
protectedRotateBits(td->protectflag, eul, td->ext->irot);
|
protectedRotateBits(td->protectflag, eul, td->ext->irot);
|
||||||
|
|
Loading…
Reference in New Issue