formatting edits & remove debug print.
This commit is contained in:
@@ -50,21 +50,21 @@ static PyObject *Euler_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
|
||||
float eul[EULER_SIZE]= {0.0f, 0.0f, 0.0f};
|
||||
short order= EULER_ORDER_XYZ;
|
||||
|
||||
if(kwds && PyDict_Size(kwds)) {
|
||||
if (kwds && PyDict_Size(kwds)) {
|
||||
PyErr_SetString(PyExc_TypeError,
|
||||
"mathutils.Euler(): "
|
||||
"takes no keyword args");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if(!PyArg_ParseTuple(args, "|Os:mathutils.Euler", &seq, &order_str))
|
||||
if (!PyArg_ParseTuple(args, "|Os:mathutils.Euler", &seq, &order_str))
|
||||
return NULL;
|
||||
|
||||
switch(PyTuple_GET_SIZE(args)) {
|
||||
case 0:
|
||||
break;
|
||||
case 2:
|
||||
if((order=euler_order_from_string(order_str, "mathutils.Euler()")) == -1)
|
||||
if ((order=euler_order_from_string(order_str, "mathutils.Euler()")) == -1)
|
||||
return NULL;
|
||||
/* intentionally pass through */
|
||||
case 1:
|
||||
@@ -84,7 +84,7 @@ static const char *euler_order_str(EulerObject *self)
|
||||
|
||||
short euler_order_from_string(const char *str, const char *error_prefix)
|
||||
{
|
||||
if((str[0] && str[1] && str[2] && str[3]=='\0')) {
|
||||
if ((str[0] && str[1] && str[2] && str[3]=='\0')) {
|
||||
switch(*((PY_INT32_T *)str)) {
|
||||
case 'X'|'Y'<<8|'Z'<<16: return EULER_ORDER_XYZ;
|
||||
case 'X'|'Z'<<8|'Y'<<16: return EULER_ORDER_XZY;
|
||||
@@ -109,13 +109,13 @@ static PyObject *Euler_ToTupleExt(EulerObject *self, int ndigits)
|
||||
|
||||
ret= PyTuple_New(EULER_SIZE);
|
||||
|
||||
if(ndigits >= 0) {
|
||||
for(i= 0; i < EULER_SIZE; i++) {
|
||||
if (ndigits >= 0) {
|
||||
for (i= 0; i < EULER_SIZE; i++) {
|
||||
PyTuple_SET_ITEM(ret, i, PyFloat_FromDouble(double_round((double)self->eul[i], ndigits)));
|
||||
}
|
||||
}
|
||||
else {
|
||||
for(i= 0; i < EULER_SIZE; i++) {
|
||||
for (i= 0; i < EULER_SIZE; i++) {
|
||||
PyTuple_SET_ITEM(ret, i, PyFloat_FromDouble(self->eul[i]));
|
||||
}
|
||||
}
|
||||
@@ -138,7 +138,7 @@ static PyObject *Euler_to_quaternion(EulerObject * self)
|
||||
{
|
||||
float quat[4];
|
||||
|
||||
if(BaseMath_ReadCallback(self) == -1)
|
||||
if (BaseMath_ReadCallback(self) == -1)
|
||||
return NULL;
|
||||
|
||||
eulO_to_quat(quat, self->eul, self->order);
|
||||
@@ -159,7 +159,7 @@ static PyObject *Euler_to_matrix(EulerObject * self)
|
||||
{
|
||||
float mat[9];
|
||||
|
||||
if(BaseMath_ReadCallback(self) == -1)
|
||||
if (BaseMath_ReadCallback(self) == -1)
|
||||
return NULL;
|
||||
|
||||
eulO_to_mat3((float (*)[3])mat, self->eul, self->order);
|
||||
@@ -176,7 +176,7 @@ static PyObject *Euler_zero(EulerObject * self)
|
||||
{
|
||||
zero_v3(self->eul);
|
||||
|
||||
if(BaseMath_WriteCallback(self) == -1)
|
||||
if (BaseMath_WriteCallback(self) == -1)
|
||||
return NULL;
|
||||
|
||||
Py_RETURN_NONE;
|
||||
@@ -198,21 +198,21 @@ static PyObject *Euler_rotate_axis(EulerObject * self, PyObject *args)
|
||||
float angle = 0.0f;
|
||||
int axis; /* actually a character */
|
||||
|
||||
if(!PyArg_ParseTuple(args, "Cf:rotate", &axis, &angle)){
|
||||
if (!PyArg_ParseTuple(args, "Cf:rotate", &axis, &angle)) {
|
||||
PyErr_SetString(PyExc_TypeError,
|
||||
"Euler.rotate_axis(): "
|
||||
"expected an axis 'X', 'Y', 'Z' and an angle (float)");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if(!(ELEM3(axis, 'X', 'Y', 'Z'))){
|
||||
if (!(ELEM3(axis, 'X', 'Y', 'Z'))) {
|
||||
PyErr_SetString(PyExc_ValueError,
|
||||
"Euler.rotate_axis(): "
|
||||
"expected axis to be 'X', 'Y' or 'Z'");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if(BaseMath_ReadCallback(self) == -1)
|
||||
if (BaseMath_ReadCallback(self) == -1)
|
||||
return NULL;
|
||||
|
||||
|
||||
@@ -235,10 +235,10 @@ static PyObject *Euler_rotate(EulerObject * self, PyObject *value)
|
||||
{
|
||||
float self_rmat[3][3], other_rmat[3][3], rmat[3][3];
|
||||
|
||||
if(BaseMath_ReadCallback(self) == -1)
|
||||
if (BaseMath_ReadCallback(self) == -1)
|
||||
return NULL;
|
||||
|
||||
if(mathutils_any_to_rotmat(other_rmat, value, "euler.rotate(value)") == -1)
|
||||
if (mathutils_any_to_rotmat(other_rmat, value, "euler.rotate(value)") == -1)
|
||||
return NULL;
|
||||
|
||||
eulO_to_mat3(self_rmat, self->eul, self->order);
|
||||
@@ -262,10 +262,10 @@ static PyObject *Euler_make_compatible(EulerObject * self, PyObject *value)
|
||||
{
|
||||
float teul[EULER_SIZE];
|
||||
|
||||
if(BaseMath_ReadCallback(self) == -1)
|
||||
if (BaseMath_ReadCallback(self) == -1)
|
||||
return NULL;
|
||||
|
||||
if(mathutils_array_parse(teul, EULER_SIZE, EULER_SIZE, value, "euler.make_compatible(other), invalid 'other' arg") == -1)
|
||||
if (mathutils_array_parse(teul, EULER_SIZE, EULER_SIZE, value, "euler.make_compatible(other), invalid 'other' arg") == -1)
|
||||
return NULL;
|
||||
|
||||
compatible_eul(self->eul, teul);
|
||||
@@ -291,7 +291,7 @@ PyDoc_STRVAR(Euler_copy_doc,
|
||||
);
|
||||
static PyObject *Euler_copy(EulerObject *self)
|
||||
{
|
||||
if(BaseMath_ReadCallback(self) == -1)
|
||||
if (BaseMath_ReadCallback(self) == -1)
|
||||
return NULL;
|
||||
|
||||
return newEulerObject(self->eul, self->order, Py_NEW, Py_TYPE(self));
|
||||
@@ -304,7 +304,7 @@ static PyObject *Euler_repr(EulerObject * self)
|
||||
{
|
||||
PyObject *ret, *tuple;
|
||||
|
||||
if(BaseMath_ReadCallback(self) == -1)
|
||||
if (BaseMath_ReadCallback(self) == -1)
|
||||
return NULL;
|
||||
|
||||
tuple= Euler_ToTupleExt(self, -1);
|
||||
@@ -324,7 +324,7 @@ static PyObject* Euler_richcmpr(PyObject *a, PyObject *b, int op)
|
||||
EulerObject *eulA= (EulerObject*)a;
|
||||
EulerObject *eulB= (EulerObject*)b;
|
||||
|
||||
if(BaseMath_ReadCallback(eulA) == -1 || BaseMath_ReadCallback(eulB) == -1)
|
||||
if (BaseMath_ReadCallback(eulA) == -1 || BaseMath_ReadCallback(eulB) == -1)
|
||||
return NULL;
|
||||
|
||||
ok= ((eulA->order == eulB->order) && EXPP_VectorsAreEqual(eulA->eul, eulB->eul, EULER_SIZE, 1)) ? 0 : -1;
|
||||
@@ -362,16 +362,16 @@ static int Euler_len(EulerObject *UNUSED(self))
|
||||
//sequence accessor (get)
|
||||
static PyObject *Euler_item(EulerObject * self, int i)
|
||||
{
|
||||
if(i<0) i= EULER_SIZE-i;
|
||||
if (i<0) i= EULER_SIZE-i;
|
||||
|
||||
if(i < 0 || i >= EULER_SIZE) {
|
||||
if (i < 0 || i >= EULER_SIZE) {
|
||||
PyErr_SetString(PyExc_IndexError,
|
||||
"euler[attribute]: "
|
||||
"array index out of range");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if(BaseMath_ReadIndexCallback(self, i) == -1)
|
||||
if (BaseMath_ReadIndexCallback(self, i) == -1)
|
||||
return NULL;
|
||||
|
||||
return PyFloat_FromDouble(self->eul[i]);
|
||||
@@ -383,16 +383,16 @@ static int Euler_ass_item(EulerObject * self, int i, PyObject *value)
|
||||
{
|
||||
float f = PyFloat_AsDouble(value);
|
||||
|
||||
if(f == -1 && PyErr_Occurred()) { // parsed item not a number
|
||||
if (f == -1 && PyErr_Occurred()) { // parsed item not a number
|
||||
PyErr_SetString(PyExc_TypeError,
|
||||
"euler[attribute] = x: "
|
||||
"argument not a number");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if(i<0) i= EULER_SIZE-i;
|
||||
if (i<0) i= EULER_SIZE-i;
|
||||
|
||||
if(i < 0 || i >= EULER_SIZE){
|
||||
if (i < 0 || i >= EULER_SIZE) {
|
||||
PyErr_SetString(PyExc_IndexError,
|
||||
"euler[attribute] = x: "
|
||||
"array assignment index out of range");
|
||||
@@ -401,7 +401,7 @@ static int Euler_ass_item(EulerObject * self, int i, PyObject *value)
|
||||
|
||||
self->eul[i] = f;
|
||||
|
||||
if(BaseMath_WriteIndexCallback(self, i) == -1)
|
||||
if (BaseMath_WriteIndexCallback(self, i) == -1)
|
||||
return -1;
|
||||
|
||||
return 0;
|
||||
@@ -413,7 +413,7 @@ static PyObject *Euler_slice(EulerObject * self, int begin, int end)
|
||||
PyObject *tuple;
|
||||
int count;
|
||||
|
||||
if(BaseMath_ReadCallback(self) == -1)
|
||||
if (BaseMath_ReadCallback(self) == -1)
|
||||
return NULL;
|
||||
|
||||
CLAMP(begin, 0, EULER_SIZE);
|
||||
@@ -422,7 +422,7 @@ static PyObject *Euler_slice(EulerObject * self, int begin, int end)
|
||||
begin= MIN2(begin, end);
|
||||
|
||||
tuple= PyTuple_New(end - begin);
|
||||
for(count = begin; count < end; count++) {
|
||||
for (count = begin; count < end; count++) {
|
||||
PyTuple_SET_ITEM(tuple, count - begin, PyFloat_FromDouble(self->eul[count]));
|
||||
}
|
||||
|
||||
@@ -435,7 +435,7 @@ static int Euler_ass_slice(EulerObject *self, int begin, int end, PyObject *seq)
|
||||
int i, size;
|
||||
float eul[EULER_SIZE];
|
||||
|
||||
if(BaseMath_ReadCallback(self) == -1)
|
||||
if (BaseMath_ReadCallback(self) == -1)
|
||||
return -1;
|
||||
|
||||
CLAMP(begin, 0, EULER_SIZE);
|
||||
@@ -443,17 +443,17 @@ static int Euler_ass_slice(EulerObject *self, int begin, int end, PyObject *seq)
|
||||
CLAMP(end, 0, EULER_SIZE);
|
||||
begin = MIN2(begin, end);
|
||||
|
||||
if((size=mathutils_array_parse(eul, 0, EULER_SIZE, seq, "mathutils.Euler[begin:end] = []")) == -1)
|
||||
if ((size=mathutils_array_parse(eul, 0, EULER_SIZE, seq, "mathutils.Euler[begin:end] = []")) == -1)
|
||||
return -1;
|
||||
|
||||
if(size != (end - begin)){
|
||||
if (size != (end - begin)) {
|
||||
PyErr_SetString(PyExc_ValueError,
|
||||
"euler[begin:end] = []: "
|
||||
"size mismatch in slice assignment");
|
||||
return -1;
|
||||
}
|
||||
|
||||
for(i= 0; i < EULER_SIZE; i++)
|
||||
for (i= 0; i < EULER_SIZE; i++)
|
||||
self->eul[begin + i] = eul[i];
|
||||
|
||||
(void)BaseMath_WriteCallback(self);
|
||||
@@ -566,7 +566,7 @@ static int Euler_setAxis(EulerObject *self, PyObject *value, void *type)
|
||||
/* rotation order */
|
||||
static PyObject *Euler_getOrder(EulerObject *self, void *UNUSED(closure))
|
||||
{
|
||||
if(BaseMath_ReadCallback(self) == -1) /* can read order too */
|
||||
if (BaseMath_ReadCallback(self) == -1) /* can read order too */
|
||||
return NULL;
|
||||
|
||||
return PyUnicode_FromString(euler_order_str(self));
|
||||
@@ -577,7 +577,7 @@ static int Euler_setOrder(EulerObject *self, PyObject *value, void *UNUSED(closu
|
||||
const char *order_str= _PyUnicode_AsString(value);
|
||||
short order= euler_order_from_string(order_str, "euler.order");
|
||||
|
||||
if(order == -1)
|
||||
if (order == -1)
|
||||
return -1;
|
||||
|
||||
self->order= order;
|
||||
@@ -678,18 +678,18 @@ PyObject *newEulerObject(float *eul, short order, int type, PyTypeObject *base_t
|
||||
self= base_type ? (EulerObject *)base_type->tp_alloc(base_type, 0) :
|
||||
(EulerObject *)PyObject_GC_New(EulerObject, &euler_Type);
|
||||
|
||||
if(self) {
|
||||
if (self) {
|
||||
/* init callbacks as NULL */
|
||||
self->cb_user= NULL;
|
||||
self->cb_type= self->cb_subtype= 0;
|
||||
|
||||
if(type == Py_WRAP) {
|
||||
if (type == Py_WRAP) {
|
||||
self->eul = eul;
|
||||
self->wrapped = Py_WRAP;
|
||||
}
|
||||
else if (type == Py_NEW) {
|
||||
self->eul = PyMem_Malloc(EULER_SIZE * sizeof(float));
|
||||
if(eul) {
|
||||
if (eul) {
|
||||
copy_v3_v3(self->eul, eul);
|
||||
}
|
||||
else {
|
||||
@@ -711,7 +711,7 @@ PyObject *newEulerObject(float *eul, short order, int type, PyTypeObject *base_t
|
||||
PyObject *newEulerObject_cb(PyObject *cb_user, short order, int cb_type, int cb_subtype)
|
||||
{
|
||||
EulerObject *self= (EulerObject *)newEulerObject(NULL, order, Py_NEW, NULL);
|
||||
if(self) {
|
||||
if (self) {
|
||||
Py_INCREF(cb_user);
|
||||
self->cb_user= cb_user;
|
||||
self->cb_type= (unsigned char)cb_type;
|
||||
|
||||
Reference in New Issue
Block a user