diff options
author | Campbell Barton <ideasman42@gmail.com> | 2009-06-25 14:11:37 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2009-06-25 14:11:37 +0400 |
commit | d428ba1de8074e8b0ca2b7c0b060c18ebf7d6b0c (patch) | |
tree | 0200656374d9d08125eba99ecc009ca3e70cc7fb /source/gameengine/Ketsji/KX_PyMath.h | |
parent | 7a357cba3994bee7d05c7a8bf5736eb94067d564 (diff) |
PyAPI RNA/BGE
* all mathutils types now have optional callbacks
* PyRNA returns mathutils quat and euler types automatically when they have the rotation subtype.
* PyRNA, reuse the BPy_StructRNA PyObject rather name making a new one for each function returned.
* use more arithb.c functions for Mathutils quaternion type (less inline cruft).
* BGE Mathutils integration mostly finished- KX_PyMath now converts to Mathutils types rather then lists.
* make all mathutils types share the same header so they can share a number of functions - dealloc, getWrapped, getOwner.
Diffstat (limited to 'source/gameengine/Ketsji/KX_PyMath.h')
-rw-r--r-- | source/gameengine/Ketsji/KX_PyMath.h | 35 |
1 files changed, 28 insertions, 7 deletions
diff --git a/source/gameengine/Ketsji/KX_PyMath.h b/source/gameengine/Ketsji/KX_PyMath.h index a7ce4bc6930..90a13425aa0 100644 --- a/source/gameengine/Ketsji/KX_PyMath.h +++ b/source/gameengine/Ketsji/KX_PyMath.h @@ -31,6 +31,12 @@ #ifndef __KX_PYMATH_H__ #define __KX_PYMATH_H__ +#ifdef USE_MATHUTILS +extern "C" { +#include "../../blender/python/generic/Mathutils.h" /* so we can have mathutils callbacks */ +} +#endif + #include "MT_Point2.h" #include "MT_Point3.h" #include "MT_Vector2.h" @@ -98,7 +104,28 @@ bool PyMatTo(PyObject* pymat, T& mat) template<class T> bool PyVecTo(PyObject* pyval, T& vec) { - +#ifdef USE_MATHUTILS + /* no need for BaseMath_ReadCallback() here, reading the sequences will do this */ + + if(VectorObject_Check(pyval)) { + VectorObject *pyvec= (VectorObject *)pyval; + if (pyvec->size != Size(vec)) { + PyErr_Format(PyExc_AttributeError, "error setting vector, %d args, should be %d", pyvec->size, Size(vec)); + return false; + } + vec.getValue((float *) pyvec->vec); + return true; + } + else if(EulerObject_Check(pyval)) { + EulerObject *pyeul= (EulerObject *)pyval; + if (3 != Size(vec)) { + PyErr_Format(PyExc_AttributeError, "error setting vector, %d args, should be %d", 3, Size(vec)); + return false; + } + vec.getValue((float *) pyeul->eul); + return true; + } else +#endif if(PyTuple_Check(pyval)) { unsigned int numitems = PyTuple_GET_SIZE(pyval); @@ -186,10 +213,4 @@ PyObject* PyObjectFrom(const MT_Tuple3 &vec); */ PyObject* PyObjectFrom(const MT_Tuple4 &pos); -/** - * True if the given PyObject can be converted to an MT_Matrix - * @param rank = 3 (for MT_Matrix3x3) or 4 (for MT_Matrix4x4) - */ -bool PyObject_IsMT_Matrix(PyObject *pymat, unsigned int rank); - #endif |