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:
authorBrecht Van Lommel <brechtvanlommel@pandora.be>2009-04-20 19:06:46 +0400
committerBrecht Van Lommel <brechtvanlommel@pandora.be>2009-04-20 19:06:46 +0400
commit874c29cea8e6f9bc411fccf2d6f4cb07e94328d0 (patch)
tree5971e577cf7c02e05a1e37b5ad058c71a6744877 /source/gameengine/Ketsji/KX_PyMath.cpp
parent7555bfa793a2b0fc187c6211c56986f35b2d7b09 (diff)
parentc5bc4e4fb1a33eda8c31f2ea02e91f32f74c8fa5 (diff)
2.50: svn merge https://svn.blender.org/svnroot/bf-blender/trunk/blender -r19323:HEAD
Notes: * blenderbuttons and ICON_SNAP_PEEL_OBJECT were not merged.
Diffstat (limited to 'source/gameengine/Ketsji/KX_PyMath.cpp')
-rw-r--r--source/gameengine/Ketsji/KX_PyMath.cpp36
1 files changed, 35 insertions, 1 deletions
diff --git a/source/gameengine/Ketsji/KX_PyMath.cpp b/source/gameengine/Ketsji/KX_PyMath.cpp
index 92f18590a7e..0093a72808e 100644
--- a/source/gameengine/Ketsji/KX_PyMath.cpp
+++ b/source/gameengine/Ketsji/KX_PyMath.cpp
@@ -44,6 +44,7 @@
#include "ListValue.h"
#include "KX_Python.h"
+#include "KX_PyMath.h"
bool PyObject_IsMT_Matrix(PyObject *pymat, unsigned int rank)
{
@@ -74,6 +75,39 @@ bool PyObject_IsMT_Matrix(PyObject *pymat, unsigned int rank)
return false;
}
+bool PyOrientationTo(PyObject* pyval, MT_Matrix3x3 &mat, const char *error_prefix)
+{
+ MT_Matrix3x3 rot;
+ int size= PySequence_Size(pyval);
+
+ if (size == 4)
+ {
+ MT_Quaternion qrot;
+ if (PyVecTo(pyval, qrot))
+ {
+ rot.setRotation(qrot);
+ return true;
+ }
+ }
+ else if (size == 3) {
+ /* 3x3 matrix or euler */
+ MT_Vector3 erot;
+ if (PyVecTo(pyval, erot))
+ {
+ rot.setEuler(erot);
+ return true;
+ }
+ PyErr_Clear();
+
+ if (PyMatTo(pyval, rot))
+ {
+ return true;
+ }
+ }
+
+ PyErr_Format(PyExc_TypeError, "%s, could not set the orientation from a 3x3 matrix, quaternion or euler sequence", error_prefix);
+ return false;
+}
PyObject* PyObjectFrom(const MT_Matrix4x4 &mat)
{
@@ -93,7 +127,7 @@ PyObject* PyObjectFrom(const MT_Matrix4x4 &mat)
PyList_SET_ITEM(sublist, 0, PyFloat_FromDouble(mat[i][0]));
PyList_SET_ITEM(sublist, 1, PyFloat_FromDouble(mat[i][1]));
PyList_SET_ITEM(sublist, 2, PyFloat_FromDouble(mat[i][2]));
- PyList_SET_ITEM(sublist, 2, PyFloat_FromDouble(mat[i][3]));
+ PyList_SET_ITEM(sublist, 3, PyFloat_FromDouble(mat[i][3]));
PyList_SET_ITEM(list, i, sublist);
}