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>2015-10-23 23:02:51 +0300
committerCampbell Barton <ideasman42@gmail.com>2015-10-23 23:02:51 +0300
commitfbca69c69afb370ddc5a0b52e10d9db61c025752 (patch)
tree8dde2bedbc44a98af31d06bf2fa80a1fb04432e7 /source/blender/blenkernel/intern
parent3a98426ed6d37a204b1d55834e0590dcb7990b47 (diff)
BLI_math: add mat3_normalized_to_* functions
Many uses of matrices for rotation keep them normalized, so no need to normalize each time.
Diffstat (limited to 'source/blender/blenkernel/intern')
-rw-r--r--source/blender/blenkernel/intern/armature.c10
-rw-r--r--source/blender/blenkernel/intern/constraint.c2
-rw-r--r--source/blender/blenkernel/intern/object.c14
3 files changed, 14 insertions, 12 deletions
diff --git a/source/blender/blenkernel/intern/armature.c b/source/blender/blenkernel/intern/armature.c
index 6afe7f1abe9..fde25784c22 100644
--- a/source/blender/blenkernel/intern/armature.c
+++ b/source/blender/blenkernel/intern/armature.c
@@ -1325,18 +1325,20 @@ void BKE_armature_mat_pose_to_bone_ex(Object *ob, bPoseChannel *pchan, float inm
/* same as BKE_object_mat3_to_rot() */
void BKE_pchan_mat3_to_rot(bPoseChannel *pchan, float mat[3][3], bool use_compat)
{
+ BLI_ASSERT_UNIT_M3(mat);
+
switch (pchan->rotmode) {
case ROT_MODE_QUAT:
- mat3_to_quat(pchan->quat, mat);
+ mat3_normalized_to_quat(pchan->quat, mat);
break;
case ROT_MODE_AXISANGLE:
- mat3_to_axis_angle(pchan->rotAxis, &pchan->rotAngle, mat);
+ mat3_normalized_to_axis_angle(pchan->rotAxis, &pchan->rotAngle, mat);
break;
default: /* euler */
if (use_compat)
- mat3_to_compatible_eulO(pchan->eul, pchan->eul, pchan->rotmode, mat);
+ mat3_normalized_to_compatible_eulO(pchan->eul, pchan->eul, pchan->rotmode, mat);
else
- mat3_to_eulO(pchan->eul, pchan->rotmode, mat);
+ mat3_normalized_to_eulO(pchan->eul, pchan->rotmode, mat);
break;
}
}
diff --git a/source/blender/blenkernel/intern/constraint.c b/source/blender/blenkernel/intern/constraint.c
index 03406c6c2a0..906a9e4e484 100644
--- a/source/blender/blenkernel/intern/constraint.c
+++ b/source/blender/blenkernel/intern/constraint.c
@@ -3863,7 +3863,7 @@ static void pivotcon_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *ta
/* correct the pivot by the rotation axis otherwise the pivot translates when it shouldnt */
- mat3_to_axis_angle(axis, &angle, rotMat);
+ mat3_normalized_to_axis_angle(axis, &angle, rotMat);
if (angle) {
float dvec[3];
sub_v3_v3v3(vec, pivot, cob->matrix[3]);
diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c
index 61c4073a2fd..4ec41373116 100644
--- a/source/blender/blenkernel/intern/object.c
+++ b/source/blender/blenkernel/intern/object.c
@@ -1945,11 +1945,13 @@ void BKE_object_rot_to_mat3(Object *ob, float mat[3][3], bool use_drot)
void BKE_object_mat3_to_rot(Object *ob, float mat[3][3], bool use_compat)
{
+ BLI_ASSERT_UNIT_M3(mat);
+
switch (ob->rotmode) {
case ROT_MODE_QUAT:
{
float dquat[4];
- mat3_to_quat(ob->quat, mat);
+ mat3_normalized_to_quat(ob->quat, mat);
normalize_qt_qt(dquat, ob->dquat);
invert_qt_normalized(dquat);
mul_qt_qtqt(ob->quat, dquat, ob->quat);
@@ -1961,7 +1963,7 @@ void BKE_object_mat3_to_rot(Object *ob, float mat[3][3], bool use_compat)
float dquat[4];
/* without drot we could apply 'mat' directly */
- mat3_to_quat(quat, mat);
+ mat3_normalized_to_quat(quat, mat);
axis_angle_to_quat(dquat, ob->drotAxis, ob->drotAngle);
invert_qt_normalized(dquat);
mul_qt_qtqt(quat, dquat, quat);
@@ -1972,18 +1974,16 @@ void BKE_object_mat3_to_rot(Object *ob, float mat[3][3], bool use_compat)
{
float quat[4];
float dquat[4];
- float tmat[3][3];
/* without drot we could apply 'mat' directly */
- mat3_to_quat(quat, mat);
+ mat3_normalized_to_quat(quat, mat);
eulO_to_quat(dquat, ob->drot, ob->rotmode);
invert_qt_normalized(dquat);
mul_qt_qtqt(quat, dquat, quat);
- quat_to_mat3(tmat, quat);
/* end drot correction */
- if (use_compat) mat3_to_compatible_eulO(ob->rot, ob->rot, ob->rotmode, tmat);
- else mat3_to_eulO(ob->rot, ob->rotmode, tmat);
+ if (use_compat) quat_to_compatible_eulO(ob->rot, ob->rot, ob->rotmode, quat);
+ else quat_to_eulO(ob->rot, ob->rotmode, quat);
break;
}
}