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:
Diffstat (limited to 'source/blender/python/mathutils')
-rw-r--r--source/blender/python/mathutils/mathutils.c2
-rw-r--r--source/blender/python/mathutils/mathutils_Matrix.c28
-rw-r--r--source/blender/python/mathutils/mathutils_Quaternion.c1
-rw-r--r--source/blender/python/mathutils/mathutils_bvhtree.c10
-rw-r--r--source/blender/python/mathutils/mathutils_geometry.c2
-rw-r--r--source/blender/python/mathutils/mathutils_interpolate.c2
-rw-r--r--source/blender/python/mathutils/mathutils_kdtree.c2
-rw-r--r--source/blender/python/mathutils/mathutils_noise.c2
8 files changed, 35 insertions, 14 deletions
diff --git a/source/blender/python/mathutils/mathutils.c b/source/blender/python/mathutils/mathutils.c
index 1aa2cec861c..dcb6d7f3bc6 100644
--- a/source/blender/python/mathutils/mathutils.c
+++ b/source/blender/python/mathutils/mathutils.c
@@ -724,7 +724,7 @@ static struct PyModuleDef M_Mathutils_module_def = {
M_Mathutils_doc, /* m_doc */
0, /* m_size */
M_Mathutils_methods, /* m_methods */
- NULL, /* m_reload */
+ NULL, /* m_slots */
NULL, /* m_traverse */
NULL, /* m_clear */
NULL, /* m_free */
diff --git a/source/blender/python/mathutils/mathutils_Matrix.c b/source/blender/python/mathutils/mathutils_Matrix.c
index 8cd7a5c7d87..8405b966a4e 100644
--- a/source/blender/python/mathutils/mathutils_Matrix.c
+++ b/source/blender/python/mathutils/mathutils_Matrix.c
@@ -290,6 +290,18 @@ static PyObject *matrix__apply_to_copy(PyObject *(*matrix_func)(MatrixObject *),
return NULL;
}
+static bool matrix_is_identity(MatrixObject *self)
+{
+ for (int row = 0; row < self->row_num; row++) {
+ for (int col = 0; col < self->col_num; col++) {
+ if (MATRIX_ITEM(self, row, col) != ((row != col) ? 0.0f : 1.0f)) {
+ return false;
+ }
+ }
+ }
+ return true;
+}
+
/** \} */
/* -------------------------------------------------------------------- */
@@ -1232,12 +1244,11 @@ static PyObject *Matrix_to_quaternion(MatrixObject *self)
return NULL;
}
if (self->row_num == 3) {
- mat3_to_quat(quat, (float(*)[3])self->matrix);
+ mat3_to_quat(quat, (const float(*)[3])self->matrix);
}
else {
mat4_to_quat(quat, (const float(*)[4])self->matrix);
}
-
return Quaternion_CreatePyObject(quat, NULL);
}
@@ -1876,7 +1887,7 @@ static PyObject *Matrix_decompose(MatrixObject *self)
}
mat4_to_loc_rot_size(loc, rot, size, (const float(*)[4])self->matrix);
- mat3_to_quat(quat, rot);
+ mat3_normalized_to_quat_fast(quat, rot);
ret = PyTuple_New(3);
PyTuple_SET_ITEMS(ret,
@@ -3104,6 +3115,16 @@ static PyObject *Matrix_median_scale_get(MatrixObject *self, void *UNUSED(closur
return PyFloat_FromDouble(mat3_to_scale(mat));
}
+PyDoc_STRVAR(Matrix_is_identity_doc,
+ "True if this is an identity matrix (read-only).\n\n:type: bool");
+static PyObject *Matrix_is_identity_get(MatrixObject *self, void *UNUSED(closure))
+{
+ if (BaseMath_ReadCallback(self) == -1) {
+ return NULL;
+ }
+ return PyBool_FromLong(matrix_is_identity(self));
+}
+
PyDoc_STRVAR(Matrix_is_negative_doc,
"True if this matrix results in a negative scale, 3x3 and 4x4 only, "
"(read-only).\n\n:type: bool");
@@ -3187,6 +3208,7 @@ static PyGetSetDef Matrix_getseters[] = {
NULL},
{"row", (getter)Matrix_row_get, (setter)NULL, Matrix_row_doc, NULL},
{"col", (getter)Matrix_col_get, (setter)NULL, Matrix_col_doc, NULL},
+ {"is_identity", (getter)Matrix_is_identity_get, (setter)NULL, Matrix_is_identity_doc, NULL},
{"is_negative", (getter)Matrix_is_negative_get, (setter)NULL, Matrix_is_negative_doc, NULL},
{"is_orthogonal",
(getter)Matrix_is_orthogonal_get,
diff --git a/source/blender/python/mathutils/mathutils_Quaternion.c b/source/blender/python/mathutils/mathutils_Quaternion.c
index 6994a313237..a5ea09bef48 100644
--- a/source/blender/python/mathutils/mathutils_Quaternion.c
+++ b/source/blender/python/mathutils/mathutils_Quaternion.c
@@ -543,7 +543,6 @@ static PyObject *Quaternion_rotate(QuaternionObject *self, PyObject *value)
length = normalize_qt_qt(tquat, self->quat);
quat_to_mat3(self_rmat, tquat);
mul_m3_m3m3(rmat, other_rmat, self_rmat);
-
mat3_to_quat(self->quat, rmat);
mul_qt_fl(self->quat, length); /* maintain length after rotating */
diff --git a/source/blender/python/mathutils/mathutils_bvhtree.c b/source/blender/python/mathutils/mathutils_bvhtree.c
index ead255a6716..4bdb1adcdde 100644
--- a/source/blender/python/mathutils/mathutils_bvhtree.c
+++ b/source/blender/python/mathutils/mathutils_bvhtree.c
@@ -1148,12 +1148,12 @@ static PyObject *C_BVHTree_FromObject(PyObject *UNUSED(cls), PyObject *args, PyO
coords = MEM_mallocN(sizeof(*coords) * (size_t)coords_len, __func__);
tris = MEM_mallocN(sizeof(*tris) * (size_t)tris_len, __func__);
- MVert *mv = mesh->mvert;
- for (int i = 0; i < mesh->totvert; i++, mv++) {
- copy_v3_v3(coords[i], mv->co);
+ const MVert *verts = BKE_mesh_verts(mesh);
+ for (int i = 0; i < mesh->totvert; i++) {
+ copy_v3_v3(coords[i], verts[i].co);
}
- mloop = mesh->mloop;
+ mloop = BKE_mesh_loops(mesh);
}
{
@@ -1294,7 +1294,7 @@ static struct PyModuleDef bvhtree_moduledef = {
py_bvhtree_doc, /* m_doc */
0, /* m_size */
NULL, /* m_methods */
- NULL, /* m_reload */
+ NULL, /* m_slots */
NULL, /* m_traverse */
NULL, /* m_clear */
NULL, /* m_free */
diff --git a/source/blender/python/mathutils/mathutils_geometry.c b/source/blender/python/mathutils/mathutils_geometry.c
index 1e492574903..28deebcf5ac 100644
--- a/source/blender/python/mathutils/mathutils_geometry.c
+++ b/source/blender/python/mathutils/mathutils_geometry.c
@@ -1790,7 +1790,7 @@ static struct PyModuleDef M_Geometry_module_def = {
M_Geometry_doc, /* m_doc */
0, /* m_size */
M_Geometry_methods, /* m_methods */
- NULL, /* m_reload */
+ NULL, /* m_slots */
NULL, /* m_traverse */
NULL, /* m_clear */
NULL, /* m_free */
diff --git a/source/blender/python/mathutils/mathutils_interpolate.c b/source/blender/python/mathutils/mathutils_interpolate.c
index 6523b3f7259..10f42d9b070 100644
--- a/source/blender/python/mathutils/mathutils_interpolate.c
+++ b/source/blender/python/mathutils/mathutils_interpolate.c
@@ -93,7 +93,7 @@ static struct PyModuleDef M_Interpolate_module_def = {
M_Interpolate_doc, /* m_doc */
0, /* m_size */
M_Interpolate_methods, /* m_methods */
- NULL, /* m_reload */
+ NULL, /* m_slots */
NULL, /* m_traverse */
NULL, /* m_clear */
NULL, /* m_free */
diff --git a/source/blender/python/mathutils/mathutils_kdtree.c b/source/blender/python/mathutils/mathutils_kdtree.c
index 66c48697b6b..f5a27c6f90f 100644
--- a/source/blender/python/mathutils/mathutils_kdtree.c
+++ b/source/blender/python/mathutils/mathutils_kdtree.c
@@ -428,7 +428,7 @@ static struct PyModuleDef kdtree_moduledef = {
py_kdtree_doc, /* m_doc */
0, /* m_size */
NULL, /* m_methods */
- NULL, /* m_reload */
+ NULL, /* m_slots */
NULL, /* m_traverse */
NULL, /* m_clear */
NULL, /* m_free */
diff --git a/source/blender/python/mathutils/mathutils_noise.c b/source/blender/python/mathutils/mathutils_noise.c
index e1282e90c48..3a3297f27f7 100644
--- a/source/blender/python/mathutils/mathutils_noise.c
+++ b/source/blender/python/mathutils/mathutils_noise.c
@@ -1089,7 +1089,7 @@ static struct PyModuleDef M_Noise_module_def = {
M_Noise_doc, /* m_doc */
0, /* m_size */
M_Noise_methods, /* m_methods */
- NULL, /* m_reload */
+ NULL, /* m_slots */
NULL, /* m_traverse */
NULL, /* m_clear */
NULL, /* m_free */