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.
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user