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:
authorBenoit Bolsee <benoit.bolsee@online.be>2009-12-23 02:38:09 +0300
committerBenoit Bolsee <benoit.bolsee@online.be>2009-12-23 02:38:09 +0300
commit81a7bf2db9beacf664588acddfe458ed216269f8 (patch)
treeee1e2ccd88bac50388197d60d731c68f471570ba /source/gameengine/Ketsji/KX_PyMath.h
parentc7a471c8c6ed85796f097019d28081f00c2b539a (diff)
BGE: fix more matrix transpose bugs in assignement to game object matrices.
Assignment to KX_GameObject localOrientation and worldOrientation matrices was assuming row-major matrix although reading these matrices was returning a column-major MathUtils object. The faulty function (PyMatTo) is fixed and all matrices in python are now assumed column-major. This function is also used in the following methods: BL_Shader.setUniformMatrix4() BL_Shader.setUniformMatrix3() (No change in scripts if you didn't specify the optional transpose parameter: the default value is changed so that column-major matrices are assumed as before.) KX_Camera.projection_matrix (assignement to this attribute now requires a column-major matrix and you must fix your script if you were setting a value to this attribute.)
Diffstat (limited to 'source/gameengine/Ketsji/KX_PyMath.h')
-rw-r--r--source/gameengine/Ketsji/KX_PyMath.h22
1 files changed, 11 insertions, 11 deletions
diff --git a/source/gameengine/Ketsji/KX_PyMath.h b/source/gameengine/Ketsji/KX_PyMath.h
index 0ad91799983..8e0cce7f4a4 100644
--- a/source/gameengine/Ketsji/KX_PyMath.h
+++ b/source/gameengine/Ketsji/KX_PyMath.h
@@ -56,7 +56,7 @@ inline unsigned int Size(const MT_Tuple3&) { return 3; }
inline unsigned int Size(const MT_Tuple4&) { return 4; }
/**
- * Converts the given python matrix to an MT class.
+ * Converts the given python matrix (column-major) to an MT class (row-major).
*/
template<class T>
bool PyMatTo(PyObject* pymat, T& mat)
@@ -65,30 +65,30 @@ bool PyMatTo(PyObject* pymat, T& mat)
mat.setIdentity();
if (PySequence_Check(pymat))
{
- unsigned int rows = PySequence_Size(pymat);
- if (rows != Size(mat))
+ unsigned int cols = PySequence_Size(pymat);
+ if (cols != Size(mat))
return false;
- for (unsigned int y = 0; noerror && y < Size(mat); y++)
+ for (unsigned int x = 0; noerror && x < cols; x++)
{
- PyObject *pyrow = PySequence_GetItem(pymat, y); /* new ref */
- if (!PyErr_Occurred() && PySequence_Check(pyrow))
+ PyObject *pycol = PySequence_GetItem(pymat, x); /* new ref */
+ if (!PyErr_Occurred() && PySequence_Check(pycol))
{
- unsigned int cols = PySequence_Size(pyrow);
- if (cols != Size(mat))
+ unsigned int rows = PySequence_Size(pycol);
+ if (rows != Size(mat))
noerror = false;
else
{
- for( unsigned int x = 0; x < Size(mat); x++)
+ for( unsigned int y = 0; y < rows; y++)
{
- PyObject *item = PySequence_GetItem(pyrow, x); /* new ref */
+ PyObject *item = PySequence_GetItem(pycol, y); /* new ref */
mat[y][x] = PyFloat_AsDouble(item);
Py_DECREF(item);
}
}
} else
noerror = false;
- Py_DECREF(pyrow);
+ Py_DECREF(pycol);
}
} else
noerror = false;