patch [#28032] Python Mathutils: Matrix Multiplication Error
authorCampbell Barton <ideasman42@gmail.com>
Wed, 20 Jul 2011 05:57:38 +0000 (05:57 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Wed, 20 Jul 2011 05:57:38 +0000 (05:57 +0000)
from Scott Giese (sgiese)

source/blender/python/mathutils/mathutils_Matrix.c

index b0187c1ef2558c6f24c47fa93e54b713df1932d6..39d0784b287f9eca1df3fdbd7cf03920c5e55013 100644 (file)
@@ -1594,20 +1594,14 @@ static PyObject *Matrix_mul(PyObject *m1, PyObject *m2)
                        return NULL;
                }
                else {
-                       float mat[16]= {0.0f, 0.0f, 0.0f, 0.0f,
-                                                       0.0f, 0.0f, 0.0f, 0.0f,
-                                                       0.0f, 0.0f, 0.0f, 0.0f,
-                                                       0.0f, 0.0f, 0.0f, 1.0f};
-                       double dot = 0.0f;
+                       float mat[16]= {0.0f};
                        int x, y, z;
 
-                       for(x = 0; x < mat2->row_size; x++) {
-                               for(y = 0; y < mat1->col_size; y++) {
-                                       for(z = 0; z < mat1->row_size; z++) {
-                                               dot += (mat1->matrix[z][y] * mat2->matrix[x][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]);
                                        }
-                                       mat[((x * mat1->col_size) + y)] = (float)dot;
-                                       dot = 0.0f;
                                }
                        }