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:
authorMichel Selten <michel@mselten.demon.nl>2003-07-11 00:00:51 +0400
committerMichel Selten <michel@mselten.demon.nl>2003-07-11 00:00:51 +0400
commitf999426daaf98c3abdb65ae6b78a9463ebcad0dd (patch)
tree95ed54d0c681ab04fc79f4cb4fee81807420e61b /source/blender/python/api2_2x/matrix.c
parent66e2bf39d975fe289b60f918f7e23157f22db1f6 (diff)
* Object_getInverseMatrix now returns a correct matrix.
The problem was that the memory was allocated at the stack, but after the Python object was created, the pointer to the memory goes invalid. Thanks to Kester Maddoc for providing a patch - almost 2 weeks ago. Ouch, I should read my mail a little bit better.
Diffstat (limited to 'source/blender/python/api2_2x/matrix.c')
-rw-r--r--source/blender/python/api2_2x/matrix.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/source/blender/python/api2_2x/matrix.c b/source/blender/python/api2_2x/matrix.c
index 6694ae8adab..76d4409dbad 100644
--- a/source/blender/python/api2_2x/matrix.c
+++ b/source/blender/python/api2_2x/matrix.c
@@ -39,6 +39,8 @@ static void Matrix_dealloc (MatrixObject *self)
Py_DECREF (self->rows[2]);
Py_DECREF (self->rows[3]);
+ if (self->mem)
+ PyMem_Free (self->mem);
PyMem_DEL (self);
}
@@ -130,8 +132,16 @@ PyObject * newMatrixObject (float mat[][4])
MatrixObject * self;
self = PyObject_NEW (MatrixObject, &Matrix_Type);
- self->mat = mat;
-
+ if (mat)
+ {
+ self->mem = NULL;
+ self->mat = mat;
+ }
+ else
+ {
+ self->mem = PyMem_Malloc (4*4*sizeof (float));
+ self->mat = self->mem;
+ }
self->rows[0] = newVectorObject ((float *)(self->mat[0]), 4);
self->rows[1] = newVectorObject ((float *)(self->mat[1]), 4);
self->rows[2] = newVectorObject ((float *)(self->mat[2]), 4);