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
path: root/source
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2014-12-28 07:13:01 +0300
committerCampbell Barton <ideasman42@gmail.com>2014-12-28 07:13:01 +0300
commite182d43d3e695a5086e8167b1ed4fc04ef43dbec (patch)
tree0c4284790a400eb75d173d5b00aae9f6c55e67d1 /source
parentb11a2f707535a9a8a26c667be246db02986c9817 (diff)
cleanup: avoid ref-counting None for a new matrix
Diffstat (limited to 'source')
-rw-r--r--source/blender/python/mathutils/mathutils_Matrix.c29
1 files changed, 18 insertions, 11 deletions
diff --git a/source/blender/python/mathutils/mathutils_Matrix.c b/source/blender/python/mathutils/mathutils_Matrix.c
index b773d603e16..23e83050c88 100644
--- a/source/blender/python/mathutils/mathutils_Matrix.c
+++ b/source/blender/python/mathutils/mathutils_Matrix.c
@@ -1846,8 +1846,24 @@ static PyObject *Matrix_zero(MatrixObject *self)
return NULL;
Py_RETURN_NONE;
+
}
/*---------------------------matrix.identity(() ------------------*/
+static void matrix_identity_internal(MatrixObject *self)
+{
+ BLI_assert((self->num_col == self->num_row) && (self->num_row <= 4));
+
+ if (self->num_col == 2) {
+ unit_m2((float (*)[2])self->matrix);
+ }
+ else if (self->num_col == 3) {
+ unit_m3((float (*)[3])self->matrix);
+ }
+ else {
+ unit_m4((float (*)[4])self->matrix);
+ }
+}
+
PyDoc_STRVAR(Matrix_identity_doc,
".. method:: identity()\n"
"\n"
@@ -1870,15 +1886,7 @@ static PyObject *Matrix_identity(MatrixObject *self)
return NULL;
}
- if (self->num_col == 2) {
- unit_m2((float (*)[2])self->matrix);
- }
- else if (self->num_col == 3) {
- unit_m3((float (*)[3])self->matrix);
- }
- else {
- unit_m4((float (*)[4])self->matrix);
- }
+ matrix_identity_internal(self);
if (BaseMath_WriteCallback(self) == -1)
return NULL;
@@ -2808,8 +2816,7 @@ PyObject *Matrix_CreatePyObject(float *mat,
}
else if (num_col == num_row) {
/* or if no arguments are passed return identity matrix for square matrices */
- PyObject *ret_dummy = Matrix_identity(self);
- Py_DECREF(ret_dummy);
+ matrix_identity_internal(self);
}
else {
/* otherwise zero everything */