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/object.c
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/object.c')
-rw-r--r--source/blender/blenkernel/intern/object.c14
1 files changed, 7 insertions, 7 deletions
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;
}
}