added exception messages to game engine matrix and vector conversions. also removed own unneeded defines in arithb.c
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user