Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/transform/transform_mode.c
| Show First 20 Lines • Show All 542 Lines • ▼ Show 20 Lines | |||||
| */ | */ | ||||
| void ElementRotation_ex(TransInfo *t, | void ElementRotation_ex(TransInfo *t, | ||||
| TransDataContainer *tc, | TransDataContainer *tc, | ||||
| TransData *td, | TransData *td, | ||||
| const float mat[3][3], | const float mat[3][3], | ||||
| const float *center) | const float *center) | ||||
| { | { | ||||
| float vec[3], totmat[3][3], smat[3][3]; | float vec[3], totmat[3][3], smat[3][3]; | ||||
| float eul[3], fmat[3][3], quat[4]; | float eul[3], fmat[3][3], quat[4], iquat[4]; | ||||
| if (td->ext && td->ext->iquat) { | |||||
| copy_qt_qt(iquat, td->ext->iquat); | |||||
| if (is_zero_qt(iquat)) { | |||||
| /* Undefined value. */ | |||||
| unit_qt(iquat); | |||||
| } | |||||
| } | |||||
| if (t->flag & T_POINTS) { | if (t->flag & T_POINTS) { | ||||
| 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); | ||||
| /* apply gpencil falloff */ | /* apply gpencil falloff */ | ||||
| if (t->options & CTX_GPENCIL_STROKES) { | if (t->options & CTX_GPENCIL_STROKES) { | ||||
| bGPDstroke *gps = (bGPDstroke *)td->extra; | bGPDstroke *gps = (bGPDstroke *)td->extra; | ||||
| Show All 17 Lines | if (t->flag & T_POINTS) { | ||||
| protectedTransBits(td->protectflag, vec); | protectedTransBits(td->protectflag, vec); | ||||
| add_v3_v3v3(td->loc, td->iloc, vec); | add_v3_v3v3(td->loc, td->iloc, vec); | ||||
| if (td->flag & TD_USEQUAT) { | if (td->flag & TD_USEQUAT) { | ||||
| mul_m3_series(fmat, td->smtx, mat, td->mtx); | mul_m3_series(fmat, td->smtx, mat, td->mtx); | ||||
| mat3_to_quat(quat, fmat); // Actual transform | mat3_to_quat(quat, fmat); // Actual transform | ||||
| if (td->ext->quat) { | if (td->ext->quat) { | ||||
| mul_qt_qtqt(td->ext->quat, quat, td->ext->iquat); | mul_qt_qtqt(td->ext->quat, quat, iquat); | ||||
| /* is there a reason not to have this here? -jahka */ | /* is there a reason not to have this here? -jahka */ | ||||
| protectedQuaternionBits(td->protectflag, td->ext->quat, td->ext->iquat); | protectedQuaternionBits(td->protectflag, td->ext->quat, iquat); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| /** | /** | ||||
| * HACK WARNING | * HACK WARNING | ||||
| * | * | ||||
| * This is some VERY ugly special case to deal with pose mode. | * This is some VERY ugly special case to deal with pose mode. | ||||
| * | * | ||||
| ▲ Show 20 Lines • Show All 46 Lines • ▼ Show 20 Lines | else if (t->flag & T_POSE) { | ||||
| * So no other way than storing it in some dedicated members of td->ext! */ | * So no other way than storing it in some dedicated members of td->ext! */ | ||||
| if ((t->flag & T_V3D_ALIGN) == 0) { /* align mode doesn't rotate objects itself */ | if ((t->flag & T_V3D_ALIGN) == 0) { /* align mode doesn't rotate objects itself */ | ||||
| /* euler or quaternion/axis-angle? */ | /* euler or quaternion/axis-angle? */ | ||||
| if (td->ext->rotOrder == ROT_MODE_QUAT) { | if (td->ext->rotOrder == ROT_MODE_QUAT) { | ||||
| mul_m3_series(fmat, td->ext->r_smtx, mat, td->ext->r_mtx); | mul_m3_series(fmat, td->ext->r_smtx, mat, td->ext->r_mtx); | ||||
| mat3_to_quat(quat, fmat); /* Actual transform */ | mat3_to_quat(quat, fmat); /* Actual transform */ | ||||
| mul_qt_qtqt(td->ext->quat, quat, td->ext->iquat); | mul_qt_qtqt(td->ext->quat, quat, 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, iquat); | ||||
| } | } | ||||
| else if (td->ext->rotOrder == ROT_MODE_AXISANGLE) { | else if (td->ext->rotOrder == ROT_MODE_AXISANGLE) { | ||||
| /* calculate effect based on quats */ | /* calculate effect based on quats */ | ||||
| float iquat[4], tquat[4]; | float tquat[4]; | ||||
| axis_angle_to_quat(iquat, td->ext->irotAxis, td->ext->irotAngle); | axis_angle_to_quat(iquat, td->ext->irotAxis, td->ext->irotAngle); | ||||
| mul_m3_series(fmat, td->ext->r_smtx, mat, td->ext->r_mtx); | mul_m3_series(fmat, td->ext->r_smtx, mat, td->ext->r_mtx); | ||||
| mat3_to_quat(quat, fmat); /* Actual transform */ | mat3_to_quat(quat, fmat); /* Actual transform */ | ||||
| mul_qt_qtqt(tquat, quat, iquat); | mul_qt_qtqt(tquat, quat, iquat); | ||||
| quat_to_axis_angle(td->ext->rotAxis, td->ext->rotAngle, tquat); | quat_to_axis_angle(td->ext->rotAxis, td->ext->rotAngle, tquat); | ||||
| ▲ Show 20 Lines • Show All 49 Lines • ▼ Show 20 Lines | else { | ||||
| if ((t->flag & T_V3D_ALIGN) == 0) { // align mode doesn't rotate objects itself | if ((t->flag & T_V3D_ALIGN) == 0) { // align mode doesn't rotate objects itself | ||||
| /* euler or quaternion? */ | /* euler or quaternion? */ | ||||
| if ((td->ext->rotOrder == ROT_MODE_QUAT) || (td->flag & TD_USEQUAT)) { | if ((td->ext->rotOrder == ROT_MODE_QUAT) || (td->flag & TD_USEQUAT)) { | ||||
| /* 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); | ||||
| mat3_to_quat(quat, fmat); // Actual transform | mat3_to_quat(quat, fmat); // Actual transform | ||||
| mul_qt_qtqt(td->ext->quat, quat, td->ext->iquat); | mul_qt_qtqt(td->ext->quat, quat, 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, iquat); | ||||
| } | } | ||||
| } | } | ||||
| else if (td->ext->rotOrder == ROT_MODE_AXISANGLE) { | else if (td->ext->rotOrder == ROT_MODE_AXISANGLE) { | ||||
| /* calculate effect based on quats */ | /* calculate effect based on quats */ | ||||
| float iquat[4], tquat[4]; | float tquat[4]; | ||||
| axis_angle_to_quat(iquat, td->ext->irotAxis, td->ext->irotAngle); | axis_angle_to_quat(iquat, td->ext->irotAxis, td->ext->irotAngle); | ||||
| mul_m3_series(fmat, td->smtx, mat, td->mtx); | mul_m3_series(fmat, td->smtx, mat, td->mtx); | ||||
| mat3_to_quat(quat, fmat); // Actual transform | mat3_to_quat(quat, fmat); // Actual transform | ||||
| mul_qt_qtqt(tquat, quat, iquat); | mul_qt_qtqt(tquat, quat, iquat); | ||||
| quat_to_axis_angle(td->ext->rotAxis, td->ext->rotAngle, tquat); | quat_to_axis_angle(td->ext->rotAxis, td->ext->rotAngle, tquat); | ||||
| ▲ Show 20 Lines • Show All 526 Lines • Show Last 20 Lines | |||||