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/python/mathutils
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/python/mathutils')
-rw-r--r--source/blender/python/mathutils/mathutils_Matrix.c18
-rw-r--r--source/blender/python/mathutils/mathutils_Quaternion.c4
2 files changed, 11 insertions, 11 deletions
diff --git a/source/blender/python/mathutils/mathutils_Matrix.c b/source/blender/python/mathutils/mathutils_Matrix.c
index 41baa9b089f..7ad20d41bf1 100644
--- a/source/blender/python/mathutils/mathutils_Matrix.c
+++ b/source/blender/python/mathutils/mathutils_Matrix.c
@@ -1120,8 +1120,7 @@ static PyObject *Matrix_to_euler(MatrixObject *self, PyObject *args)
float eul[3], eul_compatf[3];
EulerObject *eul_compat = NULL;
- float tmat[3][3];
- float (*mat)[3];
+ float mat[3][3];
if (BaseMath_ReadCallback(self) == -1)
return NULL;
@@ -1138,11 +1137,10 @@ static PyObject *Matrix_to_euler(MatrixObject *self, PyObject *args)
/*must be 3-4 cols, 3-4 rows, square matrix */
if (self->num_row == 3 && self->num_col == 3) {
- mat = (float (*)[3])self->matrix;
+ copy_m3_m3(mat, (float (*)[3])self->matrix);
}
else if (self->num_row == 4 && self->num_col == 4) {
- copy_m3_m4(tmat, (float (*)[4])self->matrix);
- mat = tmat;
+ copy_m3_m4(mat, (float (*)[4])self->matrix);
}
else {
PyErr_SetString(PyExc_ValueError,
@@ -1158,13 +1156,15 @@ static PyObject *Matrix_to_euler(MatrixObject *self, PyObject *args)
return NULL;
}
+ normalize_m3(mat);
+
if (eul_compat) {
- if (order == 1) mat3_to_compatible_eul(eul, eul_compatf, mat);
- else mat3_to_compatible_eulO(eul, eul_compatf, order, mat);
+ if (order == 1) mat3_normalized_to_compatible_eul(eul, eul_compatf, mat);
+ else mat3_normalized_to_compatible_eulO(eul, eul_compatf, order, mat);
}
else {
- if (order == 1) mat3_to_eul(eul, mat);
- else mat3_to_eulO(eul, order, mat);
+ if (order == 1) mat3_normalized_to_eul(eul, mat);
+ else mat3_normalized_to_eulO(eul, order, mat);
}
return Euler_CreatePyObject(eul, order, NULL);
diff --git a/source/blender/python/mathutils/mathutils_Quaternion.c b/source/blender/python/mathutils/mathutils_Quaternion.c
index 1752be6e306..898a002cf09 100644
--- a/source/blender/python/mathutils/mathutils_Quaternion.c
+++ b/source/blender/python/mathutils/mathutils_Quaternion.c
@@ -115,8 +115,8 @@ static PyObject *Quaternion_to_euler(QuaternionObject *self, PyObject *args)
quat_to_mat3(mat, tquat);
- if (order == EULER_ORDER_XYZ) mat3_to_compatible_eul(eul, eul_compat->eul, mat);
- else mat3_to_compatible_eulO(eul, eul_compat->eul, order, mat);
+ if (order == EULER_ORDER_XYZ) mat3_normalized_to_compatible_eul(eul, eul_compat->eul, mat);
+ else mat3_normalized_to_compatible_eulO(eul, eul_compat->eul, order, mat);
}
else {
if (order == EULER_ORDER_XYZ) quat_to_eul(eul, tquat);