diff options
author | Joseph Gilbert <ascotan@gmail.com> | 2004-03-15 03:43:38 +0300 |
---|---|---|
committer | Joseph Gilbert <ascotan@gmail.com> | 2004-03-15 03:43:38 +0300 |
commit | 127e57d983dcc2b3403f68443fd7f76ce1413a6a (patch) | |
tree | b880817345f94c4a1d3d0597c459d3f774a16e1b /source/blender | |
parent | 6c650c586d22a0dc17f4ae9695b0b956713092d9 (diff) |
-bug fix: matrix_item callback now returns rows from a matrix as in previous API implementation (exmple: ob.getMatrix()[0])
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/python/api2_2x/matrix.c | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/source/blender/python/api2_2x/matrix.c b/source/blender/python/api2_2x/matrix.c index fcabc1c1c48..cfd7a6604df 100644 --- a/source/blender/python/api2_2x/matrix.c +++ b/source/blender/python/api2_2x/matrix.c @@ -479,19 +479,23 @@ static PyObject * Matrix_repr (MatrixObject *self) } //no support for matrix[x][y] so have to return by sequence index +//will return a row from the matrix to support previous API +//compatability static PyObject * Matrix_item (MatrixObject *self, int i) { - int maxsize, x, y; + float *vec; + int x; - maxsize = self->colSize * self->rowSize; - if(i < 0 || i >= maxsize) + if(i < 0 || i >= self->rowSize) return EXPP_ReturnPyObjError(PyExc_IndexError, - "array index out of range\n"); + "matrix row index out of range\n"); - x = (int)floor((double)(i / self->colSize)); - y = i % self->colSize; - - return PyFloat_FromDouble(self->matrix[x][y]); + vec = PyMem_Malloc (self->colSize *sizeof (float)); + for(x = 0; x < self->colSize; x++){ + vec[x] = self->matrix[i][x]; + } + + return (PyObject*)newVectorObject(vec, self->colSize); } static PyObject *Matrix_slice(MatrixObject *self, int begin, int end) |