patch [#28032] swapped matrix multiplication order, reverse it back, tested with...
authorCampbell Barton <ideasman42@gmail.com>
Wed, 20 Jul 2011 06:41:51 +0000 (06:41 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Wed, 20 Jul 2011 06:41:51 +0000 (06:41 +0000)
source/blender/python/mathutils/mathutils_Matrix.c

index 39d0784b287f9eca1df3fdbd7cf03920c5e55013..a7ed63776a573ebff3b79ddaf8f719001d356a4b 100644 (file)
@@ -1587,7 +1587,7 @@ static PyObject *Matrix_mul(PyObject *m1, PyObject *m2)
 
        if(mat1 && mat2) {
                /*MATRIX * MATRIX*/
-               if(mat1->row_size != mat2->col_size){
+               if(mat2->row_size != mat1->col_size){
                        PyErr_SetString(PyExc_ValueError,
                                        "Matrix multiplication: "
                                        "matrix A rowsize must equal matrix B colsize");
@@ -1597,15 +1597,15 @@ static PyObject *Matrix_mul(PyObject *m1, PyObject *m2)
                        float mat[16]= {0.0f};
                        int x, y, z;
 
-                       for(x = 0; x < mat1->row_size; x++) {
-                               for(y = 0; y < mat2->col_size; y++) {
-                                       for(z = 0; z < mat2->row_size; z++) {
-                                               mat[x * mat1->col_size + y] += (mat1->matrix[x][z] * mat2->matrix[z][y]);
+                       for(x = 0; x < mat2->row_size; x++) {
+                               for(y = 0; y < mat1->col_size; y++) {
+                                       for(z = 0; z < mat1->row_size; z++) {
+                                               mat[x * mat2->col_size + y] += (mat2->matrix[x][z] * mat1->matrix[z][y]);
                                        }
                                }
                        }
 
-                       return newMatrixObject(mat, mat2->row_size, mat1->col_size, Py_NEW, Py_TYPE(mat1));
+                       return newMatrixObject(mat, mat1->row_size, mat2->col_size, Py_NEW, Py_TYPE(mat1));
                }
        }
        else if(mat2) {