change return values from mathutils callbacks to match pythons (-1 is error), so error macro's can be used in both.
This commit is contained in:
@@ -90,7 +90,7 @@ static PyObject *Quaternion_to_euler(QuaternionObject *self, PyObject *args)
|
||||
if(!PyArg_ParseTuple(args, "|sO!:to_euler", &order_str, &euler_Type, &eul_compat))
|
||||
return NULL;
|
||||
|
||||
if(!BaseMath_ReadCallback(self))
|
||||
if(BaseMath_ReadCallback(self) == -1)
|
||||
return NULL;
|
||||
|
||||
if(order_str) {
|
||||
@@ -105,7 +105,7 @@ static PyObject *Quaternion_to_euler(QuaternionObject *self, PyObject *args)
|
||||
if(eul_compat) {
|
||||
float mat[3][3];
|
||||
|
||||
if(!BaseMath_ReadCallback(eul_compat))
|
||||
if(BaseMath_ReadCallback(eul_compat) == -1)
|
||||
return NULL;
|
||||
|
||||
quat_to_mat3(mat, tquat);
|
||||
@@ -133,7 +133,7 @@ static PyObject *Quaternion_to_matrix(QuaternionObject *self)
|
||||
{
|
||||
float mat[9]; /* all values are set */
|
||||
|
||||
if(!BaseMath_ReadCallback(self))
|
||||
if(BaseMath_ReadCallback(self) == -1)
|
||||
return NULL;
|
||||
|
||||
quat_to_mat3( (float (*)[3]) mat,self->quat);
|
||||
@@ -155,7 +155,7 @@ static PyObject *Quaternion_cross(QuaternionObject *self, PyObject *value)
|
||||
{
|
||||
float quat[QUAT_SIZE], tquat[QUAT_SIZE];
|
||||
|
||||
if(!BaseMath_ReadCallback(self))
|
||||
if(BaseMath_ReadCallback(self) == -1)
|
||||
return NULL;
|
||||
|
||||
if(mathutils_array_parse(tquat, QUAT_SIZE, QUAT_SIZE, value, "quaternion.cross(other), invalid 'other' arg") == -1)
|
||||
@@ -180,7 +180,7 @@ static PyObject *Quaternion_dot(QuaternionObject *self, PyObject *value)
|
||||
{
|
||||
float tquat[QUAT_SIZE];
|
||||
|
||||
if(!BaseMath_ReadCallback(self))
|
||||
if(BaseMath_ReadCallback(self) == -1)
|
||||
return NULL;
|
||||
|
||||
if(mathutils_array_parse(tquat, QUAT_SIZE, QUAT_SIZE, value, "quaternion.dot(other), invalid 'other' arg") == -1)
|
||||
@@ -203,7 +203,7 @@ static PyObject *Quaternion_difference(QuaternionObject *self, PyObject *value)
|
||||
{
|
||||
float tquat[QUAT_SIZE], quat[QUAT_SIZE];
|
||||
|
||||
if(!BaseMath_ReadCallback(self))
|
||||
if(BaseMath_ReadCallback(self) == -1)
|
||||
return NULL;
|
||||
|
||||
if(mathutils_array_parse(tquat, QUAT_SIZE, QUAT_SIZE, value, "quaternion.difference(other), invalid 'other' arg") == -1)
|
||||
@@ -236,7 +236,7 @@ static PyObject *Quaternion_slerp(QuaternionObject *self, PyObject *args)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if(!BaseMath_ReadCallback(self))
|
||||
if(BaseMath_ReadCallback(self) == -1)
|
||||
return NULL;
|
||||
|
||||
if(mathutils_array_parse(tquat, QUAT_SIZE, QUAT_SIZE, value, "quaternion.slerp(other), invalid 'other' arg") == -1)
|
||||
@@ -265,7 +265,7 @@ static PyObject *Quaternion_rotate(QuaternionObject *self, PyObject *value)
|
||||
float self_rmat[3][3], other_rmat[3][3], rmat[3][3];
|
||||
float tquat[4], length;
|
||||
|
||||
if(!BaseMath_ReadCallback(self))
|
||||
if(BaseMath_ReadCallback(self) == -1)
|
||||
return NULL;
|
||||
|
||||
if(mathutils_any_to_rotmat(other_rmat, value, "quaternion.rotate(value)") == -1)
|
||||
@@ -291,7 +291,7 @@ static char Quaternion_normalize_doc[] =
|
||||
;
|
||||
static PyObject *Quaternion_normalize(QuaternionObject *self)
|
||||
{
|
||||
if(!BaseMath_ReadCallback(self))
|
||||
if(BaseMath_ReadCallback(self) == -1)
|
||||
return NULL;
|
||||
|
||||
normalize_qt(self->quat);
|
||||
@@ -320,7 +320,7 @@ static char Quaternion_invert_doc[] =
|
||||
;
|
||||
static PyObject *Quaternion_invert(QuaternionObject *self)
|
||||
{
|
||||
if(!BaseMath_ReadCallback(self))
|
||||
if(BaseMath_ReadCallback(self) == -1)
|
||||
return NULL;
|
||||
|
||||
invert_qt(self->quat);
|
||||
@@ -352,7 +352,7 @@ static char Quaternion_identity_doc[] =
|
||||
;
|
||||
static PyObject *Quaternion_identity(QuaternionObject *self)
|
||||
{
|
||||
if(!BaseMath_ReadCallback(self))
|
||||
if(BaseMath_ReadCallback(self) == -1)
|
||||
return NULL;
|
||||
|
||||
unit_qt(self->quat);
|
||||
@@ -371,7 +371,7 @@ static char Quaternion_negate_doc[] =
|
||||
;
|
||||
static PyObject *Quaternion_negate(QuaternionObject *self)
|
||||
{
|
||||
if(!BaseMath_ReadCallback(self))
|
||||
if(BaseMath_ReadCallback(self) == -1)
|
||||
return NULL;
|
||||
|
||||
mul_qt_fl(self->quat, -1.0f);
|
||||
@@ -387,7 +387,7 @@ static char Quaternion_conjugate_doc[] =
|
||||
;
|
||||
static PyObject *Quaternion_conjugate(QuaternionObject *self)
|
||||
{
|
||||
if(!BaseMath_ReadCallback(self))
|
||||
if(BaseMath_ReadCallback(self) == -1)
|
||||
return NULL;
|
||||
|
||||
conjugate_qt(self->quat);
|
||||
@@ -421,7 +421,7 @@ static char Quaternion_copy_doc[] =
|
||||
;
|
||||
static PyObject *Quaternion_copy(QuaternionObject *self)
|
||||
{
|
||||
if(!BaseMath_ReadCallback(self))
|
||||
if(BaseMath_ReadCallback(self) == -1)
|
||||
return NULL;
|
||||
|
||||
return newQuaternionObject(self->quat, Py_NEW, Py_TYPE(self));
|
||||
@@ -433,7 +433,7 @@ static PyObject *Quaternion_repr(QuaternionObject *self)
|
||||
{
|
||||
PyObject *ret, *tuple;
|
||||
|
||||
if(!BaseMath_ReadCallback(self))
|
||||
if(BaseMath_ReadCallback(self) == -1)
|
||||
return NULL;
|
||||
|
||||
tuple= Quaternion_to_tuple_ext(self, -1);
|
||||
@@ -453,7 +453,7 @@ static PyObject* Quaternion_richcmpr(PyObject *a, PyObject *b, int op)
|
||||
QuaternionObject *quatA= (QuaternionObject *)a;
|
||||
QuaternionObject *quatB= (QuaternionObject *)b;
|
||||
|
||||
if(!BaseMath_ReadCallback(quatA) || !BaseMath_ReadCallback(quatB))
|
||||
if(BaseMath_ReadCallback(quatA) == -1 || BaseMath_ReadCallback(quatB) == -1)
|
||||
return NULL;
|
||||
|
||||
ok= (EXPP_VectorsAreEqual(quatA->quat, quatB->quat, QUAT_SIZE, 1)) ? 0 : -1;
|
||||
@@ -498,7 +498,7 @@ static PyObject *Quaternion_item(QuaternionObject *self, int i)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if(!BaseMath_ReadIndexCallback(self, i))
|
||||
if(BaseMath_ReadIndexCallback(self, i) == -1)
|
||||
return NULL;
|
||||
|
||||
return PyFloat_FromDouble(self->quat[i]);
|
||||
@@ -522,7 +522,7 @@ static int Quaternion_ass_item(QuaternionObject *self, int i, PyObject *ob)
|
||||
}
|
||||
self->quat[i] = scalar;
|
||||
|
||||
if(!BaseMath_WriteIndexCallback(self, i))
|
||||
if(BaseMath_WriteIndexCallback(self, i) == -1)
|
||||
return -1;
|
||||
|
||||
return 0;
|
||||
@@ -534,7 +534,7 @@ static PyObject *Quaternion_slice(QuaternionObject *self, int begin, int end)
|
||||
PyObject *tuple;
|
||||
int count;
|
||||
|
||||
if(!BaseMath_ReadCallback(self))
|
||||
if(BaseMath_ReadCallback(self) == -1)
|
||||
return NULL;
|
||||
|
||||
CLAMP(begin, 0, QUAT_SIZE);
|
||||
@@ -556,7 +556,7 @@ static int Quaternion_ass_slice(QuaternionObject *self, int begin, int end, PyOb
|
||||
int i, size;
|
||||
float quat[QUAT_SIZE];
|
||||
|
||||
if(!BaseMath_ReadCallback(self))
|
||||
if(BaseMath_ReadCallback(self) == -1)
|
||||
return -1;
|
||||
|
||||
CLAMP(begin, 0, QUAT_SIZE);
|
||||
@@ -659,7 +659,7 @@ static PyObject *Quaternion_add(PyObject *q1, PyObject *q2)
|
||||
quat1 = (QuaternionObject*)q1;
|
||||
quat2 = (QuaternionObject*)q2;
|
||||
|
||||
if(!BaseMath_ReadCallback(quat1) || !BaseMath_ReadCallback(quat2))
|
||||
if(BaseMath_ReadCallback(quat1) == -1 || BaseMath_ReadCallback(quat2) == -1)
|
||||
return NULL;
|
||||
|
||||
add_qt_qtqt(quat, quat1->quat, quat2->quat, 1.0f);
|
||||
@@ -681,7 +681,7 @@ static PyObject *Quaternion_sub(PyObject *q1, PyObject *q2)
|
||||
quat1 = (QuaternionObject*)q1;
|
||||
quat2 = (QuaternionObject*)q2;
|
||||
|
||||
if(!BaseMath_ReadCallback(quat1) || !BaseMath_ReadCallback(quat2))
|
||||
if(BaseMath_ReadCallback(quat1) == -1 || BaseMath_ReadCallback(quat2) == -1)
|
||||
return NULL;
|
||||
|
||||
for(x = 0; x < QUAT_SIZE; x++) {
|
||||
@@ -708,12 +708,12 @@ static PyObject *Quaternion_mul(PyObject *q1, PyObject *q2)
|
||||
|
||||
if(QuaternionObject_Check(q1)) {
|
||||
quat1 = (QuaternionObject*)q1;
|
||||
if(!BaseMath_ReadCallback(quat1))
|
||||
if(BaseMath_ReadCallback(quat1) == -1)
|
||||
return NULL;
|
||||
}
|
||||
if(QuaternionObject_Check(q2)) {
|
||||
quat2 = (QuaternionObject*)q2;
|
||||
if(!BaseMath_ReadCallback(quat2))
|
||||
if(BaseMath_ReadCallback(quat2) == -1)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -746,7 +746,7 @@ static PyObject *Quaternion_neg(QuaternionObject *self)
|
||||
{
|
||||
float tquat[QUAT_SIZE];
|
||||
|
||||
if(!BaseMath_ReadCallback(self))
|
||||
if(BaseMath_ReadCallback(self) == -1)
|
||||
return NULL;
|
||||
|
||||
negate_v4_v4(tquat, self->quat);
|
||||
@@ -823,7 +823,7 @@ static int Quaternion_setAxis( QuaternionObject *self, PyObject *value, void *ty
|
||||
|
||||
static PyObject *Quaternion_getMagnitude(QuaternionObject *self, void *UNUSED(closure))
|
||||
{
|
||||
if(!BaseMath_ReadCallback(self))
|
||||
if(BaseMath_ReadCallback(self) == -1)
|
||||
return NULL;
|
||||
|
||||
return PyFloat_FromDouble(sqrt(dot_qtqt(self->quat, self->quat)));
|
||||
@@ -833,7 +833,7 @@ static PyObject *Quaternion_getAngle(QuaternionObject *self, void *UNUSED(closur
|
||||
{
|
||||
float tquat[4];
|
||||
|
||||
if(!BaseMath_ReadCallback(self))
|
||||
if(BaseMath_ReadCallback(self) == -1)
|
||||
return NULL;
|
||||
|
||||
normalize_qt_qt(tquat, self->quat);
|
||||
@@ -848,7 +848,7 @@ static int Quaternion_setAngle(QuaternionObject *self, PyObject *value, void *UN
|
||||
float axis[3], angle_dummy;
|
||||
double angle;
|
||||
|
||||
if(!BaseMath_ReadCallback(self))
|
||||
if(BaseMath_ReadCallback(self) == -1)
|
||||
return -1;
|
||||
|
||||
len= normalize_qt_qt(tquat, self->quat);
|
||||
@@ -874,7 +874,7 @@ static int Quaternion_setAngle(QuaternionObject *self, PyObject *value, void *UN
|
||||
axis_angle_to_quat(self->quat, axis, angle);
|
||||
mul_qt_fl(self->quat, len);
|
||||
|
||||
if(!BaseMath_WriteCallback(self))
|
||||
if(BaseMath_WriteCallback(self) == -1)
|
||||
return -1;
|
||||
|
||||
return 0;
|
||||
@@ -887,7 +887,7 @@ static PyObject *Quaternion_getAxisVec(QuaternionObject *self, void *UNUSED(clos
|
||||
float axis[3];
|
||||
float angle;
|
||||
|
||||
if(!BaseMath_ReadCallback(self))
|
||||
if(BaseMath_ReadCallback(self) == -1)
|
||||
return NULL;
|
||||
|
||||
normalize_qt_qt(tquat, self->quat);
|
||||
@@ -912,7 +912,7 @@ static int Quaternion_setAxisVec(QuaternionObject *self, PyObject *value, void *
|
||||
float axis[3];
|
||||
float angle;
|
||||
|
||||
if(!BaseMath_ReadCallback(self))
|
||||
if(BaseMath_ReadCallback(self) == -1)
|
||||
return -1;
|
||||
|
||||
len= normalize_qt_qt(tquat, self->quat);
|
||||
@@ -924,7 +924,7 @@ static int Quaternion_setAxisVec(QuaternionObject *self, PyObject *value, void *
|
||||
axis_angle_to_quat(self->quat, axis, angle);
|
||||
mul_qt_fl(self->quat, len);
|
||||
|
||||
if(!BaseMath_WriteCallback(self))
|
||||
if(BaseMath_WriteCallback(self) == -1)
|
||||
return -1;
|
||||
|
||||
return 0;
|
||||
|
||||
Reference in New Issue
Block a user