Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2010-12-07 04:56:32 +0300
committerCampbell Barton <ideasman42@gmail.com>2010-12-07 04:56:32 +0300
commit48614fbc2af024d613845b03d632e544f8127261 (patch)
tree41442fc6f5fe2b4ccef4f627429f740774abcdf9 /source/blender/editors/armature
parentfe0f78a66978f52eac94199baffc577cbf7c1123 (diff)
Added an assert() check for normalized quats which exposed a number of bugs where normalized quat was incorrectly assumed.
This would have made bug #25003 very simple to find. - Objects had their quats normalized when calculating their matrix, this is inconstant with pose bones and isn't useful for animation. Also it wasn't normalizing the delta rotation so these would give bad rotations. - Converting between rotation modes BKE_rotMode_change_values() assumed normal length quat. changing quat to euler rotation for eg could change the bone. - Clear rotation and transform were not normalizing the quat when 4d loc was disabled on quat rotation, corrected and also made it so the quat scale is restored after conversion so animations curves dont jump. There is 1 case in mat3_to_quat_is_ok() where quat_to_mat3 on an unnormalized quat is needed, for this I had to add an ugly static function quat_to_mat3_no_assert(), but overall its worthwhile IMHO to be able to find incorrect use of rotation conversion.
Diffstat (limited to 'source/blender/editors/armature')
-rw-r--r--source/blender/editors/armature/editarmature.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/source/blender/editors/armature/editarmature.c b/source/blender/editors/armature/editarmature.c
index 2e251a67a34..36544bcb086 100644
--- a/source/blender/editors/armature/editarmature.c
+++ b/source/blender/editors/armature/editarmature.c
@@ -5026,10 +5026,11 @@ static int pose_clear_rot_exec(bContext *C, wmOperator *UNUSED(op))
else {
/* perform clamping using euler form (3-components) */
float eul[3], oldeul[3], quat1[4] = {0};
+ float qlen;
if (pchan->rotmode == ROT_MODE_QUAT) {
- copy_qt_qt(quat1, pchan->quat);
- quat_to_eul( oldeul,pchan->quat);
+ qlen= normalize_qt_qt(quat1, pchan->quat);
+ quat_to_eul(oldeul, quat1);
}
else if (pchan->rotmode == ROT_MODE_AXISANGLE) {
axis_angle_to_eulO( oldeul, EULER_ORDER_DEFAULT,pchan->rotAxis, pchan->rotAngle);
@@ -5048,7 +5049,11 @@ static int pose_clear_rot_exec(bContext *C, wmOperator *UNUSED(op))
eul[2]= oldeul[2];
if (pchan->rotmode == ROT_MODE_QUAT) {
- eul_to_quat( pchan->quat,eul);
+ eul_to_quat(pchan->quat, eul);
+
+ /* restore original quat size */
+ mul_qt_fl(pchan->quat, qlen);
+
/* quaternions flip w sign to accumulate rotations correctly */
if ((quat1[0]<0.0f && pchan->quat[0]>0.0f) || (quat1[0]>0.0f && pchan->quat[0]<0.0f)) {
mul_qt_fl(pchan->quat, -1.0f);
@@ -5064,8 +5069,7 @@ static int pose_clear_rot_exec(bContext *C, wmOperator *UNUSED(op))
} // Duplicated in source/blender/editors/object/object_transform.c
else {
if (pchan->rotmode == ROT_MODE_QUAT) {
- pchan->quat[1]=pchan->quat[2]=pchan->quat[3]= 0.0f;
- pchan->quat[0]= 1.0f;
+ unit_qt(pchan->quat);
}
else if (pchan->rotmode == ROT_MODE_AXISANGLE) {
/* by default, make rotation of 0 radians around y-axis (roll) */