added exception messages to game engine matrix and vector conversions. also removed own unneeded defines in arithb.c

This commit is contained in:
Campbell Barton
2008-07-25 21:14:23 +00:00
parent a7f951f25e
commit 229a5809bb
2 changed files with 20 additions and 8 deletions

View File

@@ -2536,11 +2536,6 @@ int IsectPQ2Df(float pt[2], float v1[2], float v2[2], float v3[2], float v4[2])
}
/* copied from Geometry.c - todo - move to arithb.c or some other generic place we can reuse */
#define SIDE_OF_LINE(pa,pb,pp) ((pa[0]-pp[0])*(pb[1]-pp[1]))-((pb[0]-pp[0])*(pa[1]-pp[1]))
#define POINT_IN_TRI(p0,p1,p2,p3) ((SIDE_OF_LINE(p1,p2,p0)>=0) && (SIDE_OF_LINE(p2,p3,p0)>=0) && (SIDE_OF_LINE(p3,p1,p0)>=0))
/**
*
* @param min

View File

@@ -84,7 +84,10 @@ bool PyMatTo(PyObject* pymat, T& mat)
}
} else
noerror = false;
if (noerror==false)
PyErr_SetString(PyExc_TypeError, "could not be converted to a matrix (sequence of sequences)");
return noerror;
}
@@ -97,9 +100,13 @@ bool PyVecTo(PyObject* pyval, T& vec)
if (PySequence_Check(pyval))
{
unsigned int numitems = PySequence_Size(pyval);
if (numitems != Size(vec))
if (numitems != Size(vec)) {
char err[128];
sprintf(err, "error setting vector, %d args, should be %d", numitems, Size(vec));
PyErr_SetString(PyExc_AttributeError, err);
return false;
}
for (unsigned int x = 0; x < numitems; x++)
{
PyObject *item = PySequence_GetItem(pyval, x); /* new ref */
@@ -107,7 +114,17 @@ bool PyVecTo(PyObject* pyval, T& vec)
Py_DECREF(item);
}
if (PyErr_Occurred()) {
PyErr_SetString(PyExc_AttributeError, "one or more of the items in the sequence was not a float");
return false;
}
return true;
} else
{
char err[128];
sprintf(err, "not a sequence type, expected a sequence of numbers size %d", Size(vec));
PyErr_SetString(PyExc_AttributeError, err);
}
return false;