formatting edits & remove debug print.

This commit is contained in:
2011-10-13 01:29:08 +00:00
parent 6955c47fac
commit 276e5f7095
28 changed files with 1331 additions and 1320 deletions

View File

@@ -49,14 +49,14 @@ static int mathutils_array_parse_fast(float *array, int array_min, int array_max
int i, size;
/* non list/tuple cases */
if(!(value_fast=PySequence_Fast(value, error_prefix))) {
if (!(value_fast=PySequence_Fast(value, error_prefix))) {
/* PySequence_Fast sets the error */
return -1;
}
size= PySequence_Fast_GET_SIZE(value_fast);
if(size > array_max || size < array_min) {
if (size > array_max || size < array_min) {
if (array_max == array_min) {
PyErr_Format(PyExc_ValueError,
"%.200s: sequence size is %d, expected %d",
@@ -74,7 +74,7 @@ static int mathutils_array_parse_fast(float *array, int array_min, int array_max
i= size;
do {
i--;
if(((array[i]= PyFloat_AsDouble((item= PySequence_Fast_GET_ITEM(value_fast, i)))) == -1.0f) && PyErr_Occurred()) {
if (((array[i]= PyFloat_AsDouble((item= PySequence_Fast_GET_ITEM(value_fast, i)))) == -1.0f) && PyErr_Occurred()) {
PyErr_Format(PyExc_TypeError,
"%.200s: sequence index %d expected a number, "
"found '%.200s' type, ",
@@ -82,7 +82,7 @@ static int mathutils_array_parse_fast(float *array, int array_min, int array_max
Py_DECREF(value_fast);
return -1;
}
} while(i);
} while (i);
Py_XDECREF(value_fast);
return size;
@@ -94,16 +94,16 @@ int mathutils_array_parse(float *array, int array_min, int array_max, PyObject *
#if 1 /* approx 6x speedup for mathutils types */
int size;
if( (size= VectorObject_Check(value) ? ((VectorObject *)value)->size : 0) ||
if ( (size= VectorObject_Check(value) ? ((VectorObject *)value)->size : 0) ||
(size= EulerObject_Check(value) ? 3 : 0) ||
(size= QuaternionObject_Check(value) ? 4 : 0) ||
(size= ColorObject_Check(value) ? 3 : 0))
{
if(BaseMath_ReadCallback((BaseMathObject *)value) == -1) {
if (BaseMath_ReadCallback((BaseMathObject *)value) == -1) {
return -1;
}
if(size > array_max || size < array_min) {
if (size > array_max || size < array_min) {
if (array_max == array_min) {
PyErr_Format(PyExc_ValueError,
"%.200s: sequence size is %d, expected %d",
@@ -129,8 +129,8 @@ int mathutils_array_parse(float *array, int array_min, int array_max, PyObject *
int mathutils_any_to_rotmat(float rmat[3][3], PyObject *value, const char *error_prefix)
{
if(EulerObject_Check(value)) {
if(BaseMath_ReadCallback((BaseMathObject *)value) == -1) {
if (EulerObject_Check(value)) {
if (BaseMath_ReadCallback((BaseMathObject *)value) == -1) {
return -1;
}
else {
@@ -139,7 +139,7 @@ int mathutils_any_to_rotmat(float rmat[3][3], PyObject *value, const char *error
}
}
else if (QuaternionObject_Check(value)) {
if(BaseMath_ReadCallback((BaseMathObject *)value) == -1) {
if (BaseMath_ReadCallback((BaseMathObject *)value) == -1) {
return -1;
}
else {
@@ -150,10 +150,10 @@ int mathutils_any_to_rotmat(float rmat[3][3], PyObject *value, const char *error
}
}
else if (MatrixObject_Check(value)) {
if(BaseMath_ReadCallback((BaseMathObject *)value) == -1) {
if (BaseMath_ReadCallback((BaseMathObject *)value) == -1) {
return -1;
}
else if(((MatrixObject *)value)->col_size < 3 || ((MatrixObject *)value)->row_size < 3) {
else if (((MatrixObject *)value)->col_size < 3 || ((MatrixObject *)value)->row_size < 3) {
PyErr_Format(PyExc_ValueError,
"%.200s: matrix must have minimum 3x3 dimensions",
error_prefix);
@@ -202,7 +202,7 @@ int EXPP_FloatsAreEqual(float af, float bf, int maxDiff)
int EXPP_VectorsAreEqual(float *vecA, float *vecB, int size, int floatSteps)
{
int x;
for (x=0; x< size; x++){
for (x=0; x< size; x++) {
if (EXPP_FloatsAreEqual(vecA[x], vecB[x], floatSteps) == 0)
return 0;
}
@@ -220,8 +220,8 @@ int Mathutils_RegisterCallback(Mathutils_Callback *cb)
int i;
/* find the first free slot */
for(i= 0; mathutils_callbacks[i]; i++) {
if(mathutils_callbacks[i]==cb) /* already registered? */
for (i= 0; mathutils_callbacks[i]; i++) {
if (mathutils_callbacks[i]==cb) /* already registered? */
return i;
}
@@ -233,10 +233,10 @@ int Mathutils_RegisterCallback(Mathutils_Callback *cb)
int _BaseMathObject_ReadCallback(BaseMathObject *self)
{
Mathutils_Callback *cb= mathutils_callbacks[self->cb_type];
if(cb->get(self, self->cb_subtype) != -1)
if (cb->get(self, self->cb_subtype) != -1)
return 0;
if(!PyErr_Occurred()) {
if (!PyErr_Occurred()) {
PyErr_Format(PyExc_RuntimeError,
"%s read, user has become invalid",
Py_TYPE(self)->tp_name);
@@ -247,10 +247,10 @@ int _BaseMathObject_ReadCallback(BaseMathObject *self)
int _BaseMathObject_WriteCallback(BaseMathObject *self)
{
Mathutils_Callback *cb= mathutils_callbacks[self->cb_type];
if(cb->set(self, self->cb_subtype) != -1)
if (cb->set(self, self->cb_subtype) != -1)
return 0;
if(!PyErr_Occurred()) {
if (!PyErr_Occurred()) {
PyErr_Format(PyExc_RuntimeError,
"%s write, user has become invalid",
Py_TYPE(self)->tp_name);
@@ -261,10 +261,10 @@ int _BaseMathObject_WriteCallback(BaseMathObject *self)
int _BaseMathObject_ReadIndexCallback(BaseMathObject *self, int index)
{
Mathutils_Callback *cb= mathutils_callbacks[self->cb_type];
if(cb->get_index(self, self->cb_subtype, index) != -1)
if (cb->get_index(self, self->cb_subtype, index) != -1)
return 0;
if(!PyErr_Occurred()) {
if (!PyErr_Occurred()) {
PyErr_Format(PyExc_RuntimeError,
"%s read index, user has become invalid",
Py_TYPE(self)->tp_name);
@@ -275,10 +275,10 @@ int _BaseMathObject_ReadIndexCallback(BaseMathObject *self, int index)
int _BaseMathObject_WriteIndexCallback(BaseMathObject *self, int index)
{
Mathutils_Callback *cb= mathutils_callbacks[self->cb_type];
if(cb->set_index(self, self->cb_subtype, index) != -1)
if (cb->set_index(self, self->cb_subtype, index) != -1)
return 0;
if(!PyErr_Occurred()) {
if (!PyErr_Occurred()) {
PyErr_Format(PyExc_RuntimeError,
"%s write index, user has become invalid",
Py_TYPE(self)->tp_name);
@@ -316,11 +316,11 @@ int BaseMathObject_clear(BaseMathObject *self)
void BaseMathObject_dealloc(BaseMathObject *self)
{
/* only free non wrapped */
if(self->wrapped != Py_WRAP) {
if (self->wrapped != Py_WRAP) {
PyMem_Free(self->data);
}
if(self->cb_user) {
if (self->cb_user) {
PyObject_GC_UnTrack(self);
BaseMathObject_clear(self);
}
@@ -350,15 +350,15 @@ PyMODINIT_FUNC PyInit_mathutils(void)
PyObject *submodule;
PyObject *item;
if(PyType_Ready(&vector_Type) < 0)
if (PyType_Ready(&vector_Type) < 0)
return NULL;
if(PyType_Ready(&matrix_Type) < 0)
if (PyType_Ready(&matrix_Type) < 0)
return NULL;
if(PyType_Ready(&euler_Type) < 0)
if (PyType_Ready(&euler_Type) < 0)
return NULL;
if(PyType_Ready(&quaternion_Type) < 0)
if (PyType_Ready(&quaternion_Type) < 0)
return NULL;
if(PyType_Ready(&color_Type) < 0)
if (PyType_Ready(&color_Type) < 0)
return NULL;
submodule = PyModule_Create(&M_Mathutils_module_def);

View File

@@ -42,7 +42,7 @@ static PyObject *Color_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
{
float col[3]= {0.0f, 0.0f, 0.0f};
if(kwds && PyDict_Size(kwds)) {
if (kwds && PyDict_Size(kwds)) {
PyErr_SetString(PyExc_TypeError,
"mathutils.Color(): "
"takes no keyword args");
@@ -53,7 +53,7 @@ static PyObject *Color_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
case 0:
break;
case 1:
if((mathutils_array_parse(col, COLOR_SIZE, COLOR_SIZE, PyTuple_GET_ITEM(args, 0), "mathutils.Color()")) == -1)
if ((mathutils_array_parse(col, COLOR_SIZE, COLOR_SIZE, PyTuple_GET_ITEM(args, 0), "mathutils.Color()")) == -1)
return NULL;
break;
default:
@@ -75,13 +75,13 @@ static PyObject *Color_ToTupleExt(ColorObject *self, int ndigits)
ret= PyTuple_New(COLOR_SIZE);
if(ndigits >= 0) {
for(i= 0; i < COLOR_SIZE; i++) {
if (ndigits >= 0) {
for (i= 0; i < COLOR_SIZE; i++) {
PyTuple_SET_ITEM(ret, i, PyFloat_FromDouble(double_round((double)self->col[i], ndigits)));
}
}
else {
for(i= 0; i < COLOR_SIZE; i++) {
for (i= 0; i < COLOR_SIZE; i++) {
PyTuple_SET_ITEM(ret, i, PyFloat_FromDouble(self->col[i]));
}
}
@@ -102,7 +102,7 @@ PyDoc_STRVAR(Color_copy_doc,
);
static PyObject *Color_copy(ColorObject *self)
{
if(BaseMath_ReadCallback(self) == -1)
if (BaseMath_ReadCallback(self) == -1)
return NULL;
return newColorObject(self->col, Py_NEW, Py_TYPE(self));
@@ -115,7 +115,7 @@ static PyObject *Color_repr(ColorObject * self)
{
PyObject *ret, *tuple;
if(BaseMath_ReadCallback(self) == -1)
if (BaseMath_ReadCallback(self) == -1)
return NULL;
tuple= Color_ToTupleExt(self, -1);
@@ -137,7 +137,7 @@ static PyObject* Color_richcmpr(PyObject *a, PyObject *b, int op)
ColorObject *colA= (ColorObject*)a;
ColorObject *colB= (ColorObject*)b;
if(BaseMath_ReadCallback(colA) == -1 || BaseMath_ReadCallback(colB) == -1)
if (BaseMath_ReadCallback(colA) == -1 || BaseMath_ReadCallback(colB) == -1)
return NULL;
ok= EXPP_VectorsAreEqual(colA->col, colB->col, COLOR_SIZE, 1) ? 0 : -1;
@@ -175,16 +175,16 @@ static int Color_len(ColorObject *UNUSED(self))
//sequence accessor (get)
static PyObject *Color_item(ColorObject * self, int i)
{
if(i<0) i= COLOR_SIZE-i;
if (i<0) i= COLOR_SIZE-i;
if(i < 0 || i >= COLOR_SIZE) {
if (i < 0 || i >= COLOR_SIZE) {
PyErr_SetString(PyExc_IndexError,
"color[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->col[i]);
@@ -196,16 +196,16 @@ static int Color_ass_item(ColorObject * 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,
"color[attribute] = x: "
"argument not a number");
return -1;
}
if(i<0) i= COLOR_SIZE-i;
if (i<0) i= COLOR_SIZE-i;
if(i < 0 || i >= COLOR_SIZE){
if (i < 0 || i >= COLOR_SIZE) {
PyErr_SetString(PyExc_IndexError, "color[attribute] = x: "
"array assignment index out of range");
return -1;
@@ -213,7 +213,7 @@ static int Color_ass_item(ColorObject * self, int i, PyObject *value)
self->col[i] = f;
if(BaseMath_WriteIndexCallback(self, i) == -1)
if (BaseMath_WriteIndexCallback(self, i) == -1)
return -1;
return 0;
@@ -225,7 +225,7 @@ static PyObject *Color_slice(ColorObject * self, int begin, int end)
PyObject *tuple;
int count;
if(BaseMath_ReadCallback(self) == -1)
if (BaseMath_ReadCallback(self) == -1)
return NULL;
CLAMP(begin, 0, COLOR_SIZE);
@@ -234,7 +234,7 @@ static PyObject *Color_slice(ColorObject * 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->col[count]));
}
@@ -247,7 +247,7 @@ static int Color_ass_slice(ColorObject *self, int begin, int end, PyObject *seq)
int i, size;
float col[COLOR_SIZE];
if(BaseMath_ReadCallback(self) == -1)
if (BaseMath_ReadCallback(self) == -1)
return -1;
CLAMP(begin, 0, COLOR_SIZE);
@@ -255,17 +255,17 @@ static int Color_ass_slice(ColorObject *self, int begin, int end, PyObject *seq)
CLAMP(end, 0, COLOR_SIZE);
begin = MIN2(begin, end);
if((size=mathutils_array_parse(col, 0, COLOR_SIZE, seq, "mathutils.Color[begin:end] = []")) == -1)
if ((size=mathutils_array_parse(col, 0, COLOR_SIZE, seq, "mathutils.Color[begin:end] = []")) == -1)
return -1;
if(size != (end - begin)){
if (size != (end - begin)) {
PyErr_SetString(PyExc_ValueError,
"color[begin:end] = []: "
"size mismatch in slice assignment");
return -1;
}
for(i= 0; i < COLOR_SIZE; i++)
for (i= 0; i < COLOR_SIZE; i++)
self->col[begin + i] = col[i];
(void)BaseMath_WriteCallback(self);
@@ -379,7 +379,7 @@ static PyObject *Color_add(PyObject *v1, PyObject *v2)
color1 = (ColorObject*)v1;
color2 = (ColorObject*)v2;
if(BaseMath_ReadCallback(color1) == -1 || BaseMath_ReadCallback(color2) == -1)
if (BaseMath_ReadCallback(color1) == -1 || BaseMath_ReadCallback(color2) == -1)
return NULL;
add_vn_vnvn(col, color1->col, color2->col, COLOR_SIZE);
@@ -401,7 +401,7 @@ static PyObject *Color_iadd(PyObject *v1, PyObject *v2)
color1 = (ColorObject*)v1;
color2 = (ColorObject*)v2;
if(BaseMath_ReadCallback(color1) == -1 || BaseMath_ReadCallback(color2) == -1)
if (BaseMath_ReadCallback(color1) == -1 || BaseMath_ReadCallback(color2) == -1)
return NULL;
add_vn_vn(color1->col, color2->col, COLOR_SIZE);
@@ -426,7 +426,7 @@ static PyObject *Color_sub(PyObject *v1, PyObject *v2)
color1 = (ColorObject*)v1;
color2 = (ColorObject*)v2;
if(BaseMath_ReadCallback(color1) == -1 || BaseMath_ReadCallback(color2) == -1)
if (BaseMath_ReadCallback(color1) == -1 || BaseMath_ReadCallback(color2) == -1)
return NULL;
sub_vn_vnvn(col, color1->col, color2->col, COLOR_SIZE);
@@ -448,7 +448,7 @@ static PyObject *Color_isub(PyObject *v1, PyObject *v2)
color1 = (ColorObject*)v1;
color2 = (ColorObject*)v2;
if(BaseMath_ReadCallback(color1) == -1 || BaseMath_ReadCallback(color2) == -1)
if (BaseMath_ReadCallback(color1) == -1 || BaseMath_ReadCallback(color2) == -1)
return NULL;
sub_vn_vn(color1->col, color2->col, COLOR_SIZE);
@@ -473,12 +473,12 @@ static PyObject *Color_mul(PyObject *v1, PyObject *v2)
if ColorObject_Check(v1) {
color1= (ColorObject *)v1;
if(BaseMath_ReadCallback(color1) == -1)
if (BaseMath_ReadCallback(color1) == -1)
return NULL;
}
if ColorObject_Check(v2) {
color2= (ColorObject *)v2;
if(BaseMath_ReadCallback(color2) == -1)
if (BaseMath_ReadCallback(color2) == -1)
return NULL;
}
@@ -515,7 +515,7 @@ static PyObject *Color_div(PyObject *v1, PyObject *v2)
if ColorObject_Check(v1) {
color1= (ColorObject *)v1;
if(BaseMath_ReadCallback(color1) == -1)
if (BaseMath_ReadCallback(color1) == -1)
return NULL;
}
else {
@@ -526,7 +526,7 @@ static PyObject *Color_div(PyObject *v1, PyObject *v2)
/* make sure v1 is always the vector */
if (((scalar= PyFloat_AsDouble(v2)) == -1.0f && PyErr_Occurred())==0) { /* COLOR * FLOAT */
if(scalar==0.0f) {
if (scalar==0.0f) {
PyErr_SetString(PyExc_ZeroDivisionError,
"Color division: divide by zero error");
return NULL;
@@ -547,7 +547,7 @@ static PyObject *Color_imul(PyObject *v1, PyObject *v2)
ColorObject *color = (ColorObject *)v1;
float scalar;
if(BaseMath_ReadCallback(color) == -1)
if (BaseMath_ReadCallback(color) == -1)
return NULL;
/* only support color *= float */
@@ -572,12 +572,12 @@ static PyObject *Color_idiv(PyObject *v1, PyObject *v2)
ColorObject *color = (ColorObject *)v1;
float scalar;
if(BaseMath_ReadCallback(color) == -1)
if (BaseMath_ReadCallback(color) == -1)
return NULL;
/* only support color /= float */
if (((scalar= PyFloat_AsDouble(v2)) == -1.0f && PyErr_Occurred())==0) { /* COLOR /= FLOAT */
if(scalar==0.0f) {
if (scalar==0.0f) {
PyErr_SetString(PyExc_ZeroDivisionError,
"Color division: divide by zero error");
return NULL;
@@ -603,7 +603,7 @@ static PyObject *Color_neg(ColorObject *self)
{
float tcol[COLOR_SIZE];
if(BaseMath_ReadCallback(self) == -1)
if (BaseMath_ReadCallback(self) == -1)
return NULL;
negate_vn_vn(tcol, self->col, COLOR_SIZE);
@@ -665,7 +665,7 @@ static PyObject *Color_getChannelHSV(ColorObject * self, void *type)
float hsv[3];
int i= GET_INT_FROM_POINTER(type);
if(BaseMath_ReadCallback(self) == -1)
if (BaseMath_ReadCallback(self) == -1)
return NULL;
rgb_to_hsv(self->col[0], self->col[1], self->col[2], &(hsv[0]), &(hsv[1]), &(hsv[2]));
@@ -679,14 +679,14 @@ static int Color_setChannelHSV(ColorObject * self, PyObject *value, void * type)
int i= GET_INT_FROM_POINTER(type);
float f = PyFloat_AsDouble(value);
if(f == -1 && PyErr_Occurred()) {
if (f == -1 && PyErr_Occurred()) {
PyErr_SetString(PyExc_TypeError,
"color.h/s/v = value: "
"argument not a number");
return -1;
}
if(BaseMath_ReadCallback(self) == -1)
if (BaseMath_ReadCallback(self) == -1)
return -1;
rgb_to_hsv(self->col[0], self->col[1], self->col[2], &(hsv[0]), &(hsv[1]), &(hsv[2]));
@@ -694,7 +694,7 @@ static int Color_setChannelHSV(ColorObject * self, PyObject *value, void * type)
hsv[i] = f;
hsv_to_rgb(hsv[0], hsv[1], hsv[2], &(self->col[0]), &(self->col[1]), &(self->col[2]));
if(BaseMath_WriteCallback(self) == -1)
if (BaseMath_WriteCallback(self) == -1)
return -1;
return 0;
@@ -706,7 +706,7 @@ static PyObject *Color_getHSV(ColorObject * self, void *UNUSED(closure))
float hsv[3];
PyObject *ret;
if(BaseMath_ReadCallback(self) == -1)
if (BaseMath_ReadCallback(self) == -1)
return NULL;
rgb_to_hsv(self->col[0], self->col[1], self->col[2], &(hsv[0]), &(hsv[1]), &(hsv[2]));
@@ -722,7 +722,7 @@ static int Color_setHSV(ColorObject * self, PyObject *value, void *UNUSED(closur
{
float hsv[3];
if(mathutils_array_parse(hsv, 3, 3, value, "mathutils.Color.hsv = value") == -1)
if (mathutils_array_parse(hsv, 3, 3, value, "mathutils.Color.hsv = value") == -1)
return -1;
CLAMP(hsv[0], 0.0f, 1.0f);
@@ -731,7 +731,7 @@ static int Color_setHSV(ColorObject * self, PyObject *value, void *UNUSED(closur
hsv_to_rgb(hsv[0], hsv[1], hsv[2], &(self->col[0]), &(self->col[1]), &(self->col[2]));
if(BaseMath_WriteCallback(self) == -1)
if (BaseMath_WriteCallback(self) == -1)
return -1;
return 0;
@@ -834,11 +834,11 @@ PyObject *newColorObject(float *col, int type, PyTypeObject *base_type)
self->cb_user= NULL;
self->cb_type= self->cb_subtype= 0;
if(type == Py_WRAP){
if(type == Py_WRAP) {
self->col = col;
self->wrapped = Py_WRAP;
}
else if (type == Py_NEW){
else if (type == Py_NEW) {
self->col = PyMem_Malloc(COLOR_SIZE * sizeof(float));
if(col)
copy_v3_v3(self->col, col);

View File

@@ -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;

File diff suppressed because it is too large Load Diff

View File

@@ -53,13 +53,13 @@ static PyObject *Quaternion_to_tuple_ext(QuaternionObject *self, int ndigits)
ret= PyTuple_New(QUAT_SIZE);
if(ndigits >= 0) {
for(i= 0; i < QUAT_SIZE; i++) {
if (ndigits >= 0) {
for (i= 0; i < QUAT_SIZE; i++) {
PyTuple_SET_ITEM(ret, i, PyFloat_FromDouble(double_round((double)self->quat[i], ndigits)));
}
}
else {
for(i= 0; i < QUAT_SIZE; i++) {
for (i= 0; i < QUAT_SIZE; i++) {
PyTuple_SET_ITEM(ret, i, PyFloat_FromDouble(self->quat[i]));
}
}
@@ -90,34 +90,34 @@ static PyObject *Quaternion_to_euler(QuaternionObject *self, PyObject *args)
short order= EULER_ORDER_XYZ;
EulerObject *eul_compat = NULL;
if(!PyArg_ParseTuple(args, "|sO!:to_euler", &order_str, &euler_Type, &eul_compat))
if (!PyArg_ParseTuple(args, "|sO!:to_euler", &order_str, &euler_Type, &eul_compat))
return NULL;
if(BaseMath_ReadCallback(self) == -1)
if (BaseMath_ReadCallback(self) == -1)
return NULL;
if(order_str) {
if (order_str) {
order= euler_order_from_string(order_str, "Matrix.to_euler()");
if(order == -1)
if (order == -1)
return NULL;
}
normalize_qt_qt(tquat, self->quat);
if(eul_compat) {
if (eul_compat) {
float mat[3][3];
if(BaseMath_ReadCallback(eul_compat) == -1)
if (BaseMath_ReadCallback(eul_compat) == -1)
return NULL;
quat_to_mat3(mat, tquat);
if(order == EULER_ORDER_XYZ) mat3_to_compatible_eul(eul, eul_compat->eul, mat);
if (order == EULER_ORDER_XYZ) mat3_to_compatible_eul(eul, eul_compat->eul, mat);
else mat3_to_compatible_eulO(eul, eul_compat->eul, order, mat);
}
else {
if(order == EULER_ORDER_XYZ) quat_to_eul(eul, tquat);
if (order == EULER_ORDER_XYZ) quat_to_eul(eul, tquat);
else quat_to_eulO(eul, order, tquat);
}
@@ -136,7 +136,7 @@ static PyObject *Quaternion_to_matrix(QuaternionObject *self)
{
float mat[9]; /* all values are set */
if(BaseMath_ReadCallback(self) == -1)
if (BaseMath_ReadCallback(self) == -1)
return NULL;
quat_to_mat3((float (*)[3])mat, self->quat);
@@ -158,10 +158,10 @@ static PyObject *Quaternion_cross(QuaternionObject *self, PyObject *value)
{
float quat[QUAT_SIZE], tquat[QUAT_SIZE];
if(BaseMath_ReadCallback(self) == -1)
if (BaseMath_ReadCallback(self) == -1)
return NULL;
if(mathutils_array_parse(tquat, QUAT_SIZE, QUAT_SIZE, value, "Quaternion.cross(other), invalid 'other' arg") == -1)
if (mathutils_array_parse(tquat, QUAT_SIZE, QUAT_SIZE, value, "Quaternion.cross(other), invalid 'other' arg") == -1)
return NULL;
mul_qt_qtqt(quat, self->quat, tquat);
@@ -183,10 +183,10 @@ static PyObject *Quaternion_dot(QuaternionObject *self, PyObject *value)
{
float tquat[QUAT_SIZE];
if(BaseMath_ReadCallback(self) == -1)
if (BaseMath_ReadCallback(self) == -1)
return NULL;
if(mathutils_array_parse(tquat, QUAT_SIZE, QUAT_SIZE, value, "Quaternion.dot(other), invalid 'other' arg") == -1)
if (mathutils_array_parse(tquat, QUAT_SIZE, QUAT_SIZE, value, "Quaternion.dot(other), invalid 'other' arg") == -1)
return NULL;
return PyFloat_FromDouble(dot_qtqt(self->quat, tquat));
@@ -206,10 +206,10 @@ static PyObject *Quaternion_rotation_difference(QuaternionObject *self, PyObject
{
float tquat[QUAT_SIZE], quat[QUAT_SIZE];
if(BaseMath_ReadCallback(self) == -1)
if (BaseMath_ReadCallback(self) == -1)
return NULL;
if(mathutils_array_parse(tquat, QUAT_SIZE, QUAT_SIZE, value, "Quaternion.difference(other), invalid 'other' arg") == -1)
if (mathutils_array_parse(tquat, QUAT_SIZE, QUAT_SIZE, value, "Quaternion.difference(other), invalid 'other' arg") == -1)
return NULL;
rotation_between_quats_to_quat(quat, self->quat, tquat);
@@ -234,20 +234,20 @@ static PyObject *Quaternion_slerp(QuaternionObject *self, PyObject *args)
PyObject *value;
float tquat[QUAT_SIZE], quat[QUAT_SIZE], fac;
if(!PyArg_ParseTuple(args, "Of:slerp", &value, &fac)) {
if (!PyArg_ParseTuple(args, "Of:slerp", &value, &fac)) {
PyErr_SetString(PyExc_TypeError,
"quat.slerp(): "
"expected Quaternion types and float");
return NULL;
}
if(BaseMath_ReadCallback(self) == -1)
if (BaseMath_ReadCallback(self) == -1)
return NULL;
if(mathutils_array_parse(tquat, QUAT_SIZE, QUAT_SIZE, value, "Quaternion.slerp(other), invalid 'other' arg") == -1)
if (mathutils_array_parse(tquat, QUAT_SIZE, QUAT_SIZE, value, "Quaternion.slerp(other), invalid 'other' arg") == -1)
return NULL;
if(fac > 1.0f || fac < 0.0f) {
if (fac > 1.0f || fac < 0.0f) {
PyErr_SetString(PyExc_ValueError,
"quat.slerp(): "
"interpolation factor must be between 0.0 and 1.0");
@@ -272,10 +272,10 @@ 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) == -1)
if (BaseMath_ReadCallback(self) == -1)
return NULL;
if(mathutils_any_to_rotmat(other_rmat, value, "Quaternion.rotate(value)") == -1)
if (mathutils_any_to_rotmat(other_rmat, value, "Quaternion.rotate(value)") == -1)
return NULL;
length= normalize_qt_qt(tquat, self->quat);
@@ -298,7 +298,7 @@ PyDoc_STRVAR(Quaternion_normalize_doc,
);
static PyObject *Quaternion_normalize(QuaternionObject *self)
{
if(BaseMath_ReadCallback(self) == -1)
if (BaseMath_ReadCallback(self) == -1)
return NULL;
normalize_qt(self->quat);
@@ -327,7 +327,7 @@ PyDoc_STRVAR(Quaternion_invert_doc,
);
static PyObject *Quaternion_invert(QuaternionObject *self)
{
if(BaseMath_ReadCallback(self) == -1)
if (BaseMath_ReadCallback(self) == -1)
return NULL;
invert_qt(self->quat);
@@ -359,7 +359,7 @@ PyDoc_STRVAR(Quaternion_identity_doc,
);
static PyObject *Quaternion_identity(QuaternionObject *self)
{
if(BaseMath_ReadCallback(self) == -1)
if (BaseMath_ReadCallback(self) == -1)
return NULL;
unit_qt(self->quat);
@@ -378,7 +378,7 @@ PyDoc_STRVAR(Quaternion_negate_doc,
);
static PyObject *Quaternion_negate(QuaternionObject *self)
{
if(BaseMath_ReadCallback(self) == -1)
if (BaseMath_ReadCallback(self) == -1)
return NULL;
mul_qt_fl(self->quat, -1.0f);
@@ -394,7 +394,7 @@ PyDoc_STRVAR(Quaternion_conjugate_doc,
);
static PyObject *Quaternion_conjugate(QuaternionObject *self)
{
if(BaseMath_ReadCallback(self) == -1)
if (BaseMath_ReadCallback(self) == -1)
return NULL;
conjugate_qt(self->quat);
@@ -429,7 +429,7 @@ PyDoc_STRVAR(Quaternion_copy_doc,
);
static PyObject *Quaternion_copy(QuaternionObject *self)
{
if(BaseMath_ReadCallback(self) == -1)
if (BaseMath_ReadCallback(self) == -1)
return NULL;
return newQuaternionObject(self->quat, Py_NEW, Py_TYPE(self));
@@ -441,7 +441,7 @@ static PyObject *Quaternion_repr(QuaternionObject *self)
{
PyObject *ret, *tuple;
if(BaseMath_ReadCallback(self) == -1)
if (BaseMath_ReadCallback(self) == -1)
return NULL;
tuple= Quaternion_to_tuple_ext(self, -1);
@@ -461,7 +461,7 @@ static PyObject* Quaternion_richcmpr(PyObject *a, PyObject *b, int op)
QuaternionObject *quatA= (QuaternionObject *)a;
QuaternionObject *quatB= (QuaternionObject *)b;
if(BaseMath_ReadCallback(quatA) == -1 || BaseMath_ReadCallback(quatB) == -1)
if (BaseMath_ReadCallback(quatA) == -1 || BaseMath_ReadCallback(quatB) == -1)
return NULL;
ok= (EXPP_VectorsAreEqual(quatA->quat, quatB->quat, QUAT_SIZE, 1)) ? 0 : -1;
@@ -499,16 +499,16 @@ static int Quaternion_len(QuaternionObject *UNUSED(self))
//sequence accessor (get)
static PyObject *Quaternion_item(QuaternionObject *self, int i)
{
if(i<0) i= QUAT_SIZE-i;
if (i<0) i= QUAT_SIZE-i;
if(i < 0 || i >= QUAT_SIZE) {
if (i < 0 || i >= QUAT_SIZE) {
PyErr_SetString(PyExc_IndexError,
"quaternion[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->quat[i]);
@@ -519,16 +519,16 @@ static PyObject *Quaternion_item(QuaternionObject *self, int i)
static int Quaternion_ass_item(QuaternionObject *self, int i, PyObject *ob)
{
float scalar= (float)PyFloat_AsDouble(ob);
if(scalar==-1.0f && PyErr_Occurred()) { /* parsed item not a number */
if (scalar==-1.0f && PyErr_Occurred()) { /* parsed item not a number */
PyErr_SetString(PyExc_TypeError,
"quaternion[index] = x: "
"index argument not a number");
return -1;
}
if(i<0) i= QUAT_SIZE-i;
if (i<0) i= QUAT_SIZE-i;
if(i < 0 || i >= QUAT_SIZE){
if (i < 0 || i >= QUAT_SIZE) {
PyErr_SetString(PyExc_IndexError,
"quaternion[attribute] = x: "
"array assignment index out of range");
@@ -536,7 +536,7 @@ static int Quaternion_ass_item(QuaternionObject *self, int i, PyObject *ob)
}
self->quat[i] = scalar;
if(BaseMath_WriteIndexCallback(self, i) == -1)
if (BaseMath_WriteIndexCallback(self, i) == -1)
return -1;
return 0;
@@ -548,7 +548,7 @@ static PyObject *Quaternion_slice(QuaternionObject *self, int begin, int end)
PyObject *tuple;
int count;
if(BaseMath_ReadCallback(self) == -1)
if (BaseMath_ReadCallback(self) == -1)
return NULL;
CLAMP(begin, 0, QUAT_SIZE);
@@ -557,7 +557,7 @@ static PyObject *Quaternion_slice(QuaternionObject *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->quat[count]));
}
@@ -570,7 +570,7 @@ static int Quaternion_ass_slice(QuaternionObject *self, int begin, int end, PyOb
int i, size;
float quat[QUAT_SIZE];
if(BaseMath_ReadCallback(self) == -1)
if (BaseMath_ReadCallback(self) == -1)
return -1;
CLAMP(begin, 0, QUAT_SIZE);
@@ -578,10 +578,10 @@ static int Quaternion_ass_slice(QuaternionObject *self, int begin, int end, PyOb
CLAMP(end, 0, QUAT_SIZE);
begin = MIN2(begin, end);
if((size=mathutils_array_parse(quat, 0, QUAT_SIZE, seq, "mathutils.Quaternion[begin:end] = []")) == -1)
if ((size=mathutils_array_parse(quat, 0, QUAT_SIZE, seq, "mathutils.Quaternion[begin:end] = []")) == -1)
return -1;
if(size != (end - begin)){
if (size != (end - begin)) {
PyErr_SetString(PyExc_ValueError,
"quaternion[begin:end] = []: "
"size mismatch in slice assignment");
@@ -589,7 +589,7 @@ static int Quaternion_ass_slice(QuaternionObject *self, int begin, int end, PyOb
}
/* parsed well - now set in vector */
for(i= 0; i < size; i++)
for (i= 0; i < size; i++)
self->quat[begin + i] = quat[i];
(void)BaseMath_WriteCallback(self);
@@ -674,7 +674,7 @@ static PyObject *Quaternion_add(PyObject *q1, PyObject *q2)
float quat[QUAT_SIZE];
QuaternionObject *quat1 = NULL, *quat2 = NULL;
if(!QuaternionObject_Check(q1) || !QuaternionObject_Check(q2)) {
if (!QuaternionObject_Check(q1) || !QuaternionObject_Check(q2)) {
PyErr_SetString(PyExc_TypeError,
"Quaternion addition: "
"arguments not valid for this operation");
@@ -683,7 +683,7 @@ static PyObject *Quaternion_add(PyObject *q1, PyObject *q2)
quat1 = (QuaternionObject*)q1;
quat2 = (QuaternionObject*)q2;
if(BaseMath_ReadCallback(quat1) == -1 || BaseMath_ReadCallback(quat2) == -1)
if (BaseMath_ReadCallback(quat1) == -1 || BaseMath_ReadCallback(quat2) == -1)
return NULL;
add_qt_qtqt(quat, quat1->quat, quat2->quat, 1.0f);
@@ -697,7 +697,7 @@ static PyObject *Quaternion_sub(PyObject *q1, PyObject *q2)
float quat[QUAT_SIZE];
QuaternionObject *quat1 = NULL, *quat2 = NULL;
if(!QuaternionObject_Check(q1) || !QuaternionObject_Check(q2)) {
if (!QuaternionObject_Check(q1) || !QuaternionObject_Check(q2)) {
PyErr_SetString(PyExc_TypeError,
"Quaternion addition: "
"arguments not valid for this operation");
@@ -707,10 +707,10 @@ static PyObject *Quaternion_sub(PyObject *q1, PyObject *q2)
quat1 = (QuaternionObject*)q1;
quat2 = (QuaternionObject*)q2;
if(BaseMath_ReadCallback(quat1) == -1 || BaseMath_ReadCallback(quat2) == -1)
if (BaseMath_ReadCallback(quat1) == -1 || BaseMath_ReadCallback(quat2) == -1)
return NULL;
for(x = 0; x < QUAT_SIZE; x++) {
for (x = 0; x < QUAT_SIZE; x++) {
quat[x] = quat1->quat[x] - quat2->quat[x];
}
@@ -732,24 +732,24 @@ static PyObject *Quaternion_mul(PyObject *q1, PyObject *q2)
float quat[QUAT_SIZE], scalar;
QuaternionObject *quat1 = NULL, *quat2 = NULL;
if(QuaternionObject_Check(q1)) {
if (QuaternionObject_Check(q1)) {
quat1 = (QuaternionObject*)q1;
if(BaseMath_ReadCallback(quat1) == -1)
if (BaseMath_ReadCallback(quat1) == -1)
return NULL;
}
if(QuaternionObject_Check(q2)) {
if (QuaternionObject_Check(q2)) {
quat2 = (QuaternionObject*)q2;
if(BaseMath_ReadCallback(quat2) == -1)
if (BaseMath_ReadCallback(quat2) == -1)
return NULL;
}
if(quat1 && quat2) { /* QUAT*QUAT (cross product) */
if (quat1 && quat2) { /* QUAT*QUAT (cross product) */
mul_qt_qtqt(quat, quat1->quat, quat2->quat);
return newQuaternionObject(quat, Py_NEW, Py_TYPE(q1));
}
/* the only case this can happen (for a supported type is "FLOAT*QUAT") */
else if(quat2) { /* FLOAT*QUAT */
if(((scalar= PyFloat_AsDouble(q1)) == -1.0f && PyErr_Occurred())==0) {
else if (quat2) { /* FLOAT*QUAT */
if (((scalar= PyFloat_AsDouble(q1)) == -1.0f && PyErr_Occurred())==0) {
return quat_mul_float(quat2, scalar);
}
}
@@ -759,14 +759,14 @@ static PyObject *Quaternion_mul(PyObject *q1, PyObject *q2)
VectorObject *vec2 = (VectorObject *)q2;
float tvec[3];
if(vec2->size != 3) {
if (vec2->size != 3) {
PyErr_SetString(PyExc_ValueError,
"Vector multiplication: "
"only 3D vector rotations (with quats) "
"currently supported");
return NULL;
}
if(BaseMath_ReadCallback(vec2) == -1) {
if (BaseMath_ReadCallback(vec2) == -1) {
return NULL;
}
@@ -776,7 +776,7 @@ static PyObject *Quaternion_mul(PyObject *q1, PyObject *q2)
return newVectorObject(tvec, 3, Py_NEW, Py_TYPE(vec2));
}
/* QUAT * FLOAT */
else if((((scalar= PyFloat_AsDouble(q2)) == -1.0f && PyErr_Occurred())==0)) {
else if ((((scalar= PyFloat_AsDouble(q2)) == -1.0f && PyErr_Occurred())==0)) {
return quat_mul_float(quat1, scalar);
}
}
@@ -797,7 +797,7 @@ static PyObject *Quaternion_neg(QuaternionObject *self)
{
float tquat[QUAT_SIZE];
if(BaseMath_ReadCallback(self) == -1)
if (BaseMath_ReadCallback(self) == -1)
return NULL;
negate_v4_v4(tquat, self->quat);
@@ -874,7 +874,7 @@ static int Quaternion_setAxis(QuaternionObject *self, PyObject *value, void *typ
static PyObject *Quaternion_getMagnitude(QuaternionObject *self, void *UNUSED(closure))
{
if(BaseMath_ReadCallback(self) == -1)
if (BaseMath_ReadCallback(self) == -1)
return NULL;
return PyFloat_FromDouble(sqrt(dot_qtqt(self->quat, self->quat)));
@@ -884,7 +884,7 @@ static PyObject *Quaternion_getAngle(QuaternionObject *self, void *UNUSED(closur
{
float tquat[4];
if(BaseMath_ReadCallback(self) == -1)
if (BaseMath_ReadCallback(self) == -1)
return NULL;
normalize_qt_qt(tquat, self->quat);
@@ -899,7 +899,7 @@ static int Quaternion_setAngle(QuaternionObject *self, PyObject *value, void *UN
float axis[3], angle_dummy;
double angle;
if(BaseMath_ReadCallback(self) == -1)
if (BaseMath_ReadCallback(self) == -1)
return -1;
len= normalize_qt_qt(tquat, self->quat);
@@ -907,7 +907,7 @@ static int Quaternion_setAngle(QuaternionObject *self, PyObject *value, void *UN
angle= PyFloat_AsDouble(value);
if(angle==-1.0 && PyErr_Occurred()) { /* parsed item not a number */
if (angle==-1.0 && PyErr_Occurred()) { /* parsed item not a number */
PyErr_SetString(PyExc_TypeError,
"Quaternion.angle = value: float expected");
return -1;
@@ -916,7 +916,7 @@ static int Quaternion_setAngle(QuaternionObject *self, PyObject *value, void *UN
angle= angle_wrap_rad(angle);
/* If the axis of rotation is 0,0,0 set it to 1,0,0 - for zero-degree rotations */
if( EXPP_FloatsAreEqual(axis[0], 0.0f, 10) &&
if ( EXPP_FloatsAreEqual(axis[0], 0.0f, 10) &&
EXPP_FloatsAreEqual(axis[1], 0.0f, 10) &&
EXPP_FloatsAreEqual(axis[2], 0.0f, 10)
) {
@@ -926,7 +926,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) == -1)
if (BaseMath_WriteCallback(self) == -1)
return -1;
return 0;
@@ -939,14 +939,14 @@ static PyObject *Quaternion_getAxisVec(QuaternionObject *self, void *UNUSED(clos
float axis[3];
float angle;
if(BaseMath_ReadCallback(self) == -1)
if (BaseMath_ReadCallback(self) == -1)
return NULL;
normalize_qt_qt(tquat, self->quat);
quat_to_axis_angle(axis, &angle, tquat);
/* If the axis of rotation is 0,0,0 set it to 1,0,0 - for zero-degree rotations */
if( EXPP_FloatsAreEqual(axis[0], 0.0f, 10) &&
if ( EXPP_FloatsAreEqual(axis[0], 0.0f, 10) &&
EXPP_FloatsAreEqual(axis[1], 0.0f, 10) &&
EXPP_FloatsAreEqual(axis[2], 0.0f, 10)
) {
@@ -964,7 +964,7 @@ static int Quaternion_setAxisVec(QuaternionObject *self, PyObject *value, void *
float axis[3];
float angle;
if(BaseMath_ReadCallback(self) == -1)
if (BaseMath_ReadCallback(self) == -1)
return -1;
len= normalize_qt_qt(tquat, self->quat);
@@ -976,7 +976,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) == -1)
if (BaseMath_WriteCallback(self) == -1)
return -1;
return 0;
@@ -989,14 +989,14 @@ static PyObject *Quaternion_new(PyTypeObject *type, PyObject *args, PyObject *kw
double angle = 0.0f;
float quat[QUAT_SIZE]= {0.0f, 0.0f, 0.0f, 0.0f};
if(kwds && PyDict_Size(kwds)) {
if (kwds && PyDict_Size(kwds)) {
PyErr_SetString(PyExc_TypeError,
"mathutils.Quaternion(): "
"takes no keyword args");
return NULL;
}
if(!PyArg_ParseTuple(args, "|Od:mathutils.Quaternion", &seq, &angle))
if (!PyArg_ParseTuple(args, "|Od:mathutils.Quaternion", &seq, &angle))
return NULL;
switch(PyTuple_GET_SIZE(args)) {
@@ -1021,7 +1021,7 @@ static PyObject *quat__apply_to_copy(PyNoArgsFunction quat_func, QuaternionObjec
{
PyObject *ret= Quaternion_copy(self);
PyObject *ret_dummy= quat_func(ret);
if(ret_dummy) {
if (ret_dummy) {
Py_DECREF(ret_dummy);
return (PyObject *)ret;
}
@@ -1144,18 +1144,18 @@ PyObject *newQuaternionObject(float *quat, int type, PyTypeObject *base_type)
self= base_type ? (QuaternionObject *)base_type->tp_alloc(base_type, 0) :
(QuaternionObject *)PyObject_GC_New(QuaternionObject, &quaternion_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->quat = quat;
self->wrapped = Py_WRAP;
}
else if (type == Py_NEW){
else if (type == Py_NEW) {
self->quat = PyMem_Malloc(QUAT_SIZE * sizeof(float));
if(!quat) { //new empty
if (!quat) { //new empty
unit_qt(self->quat);
}
else {
@@ -1173,7 +1173,7 @@ PyObject *newQuaternionObject(float *quat, int type, PyTypeObject *base_type)
PyObject *newQuaternionObject_cb(PyObject *cb_user, int cb_type, int cb_subtype)
{
QuaternionObject *self= (QuaternionObject *)newQuaternionObject(NULL, Py_NEW, NULL);
if(self) {
if (self) {
Py_INCREF(cb_user);
self->cb_user= cb_user;
self->cb_type= (unsigned char)cb_type;

View File

@@ -123,11 +123,11 @@ static PyObject *Vector_normalize(VectorObject *self)
if(BaseMath_ReadCallback(self) == -1)
return NULL;
for(i = 0; i < self->size; i++) {
for (i = 0; i < self->size; i++) {
norm += self->vec[i] * self->vec[i];
}
norm = (float) sqrt(norm);
for(i = 0; i < self->size; i++) {
for (i = 0; i < self->size; i++) {
self->vec[i] /= norm;
}
@@ -251,11 +251,11 @@ static PyObject *Vector_resize_4d(VectorObject *self)
return NULL;
}
if(self->size == 2){
if(self->size == 2) {
self->vec[2] = 0.0f;
self->vec[3] = 1.0f;
}
else if(self->size == 3){
else if(self->size == 3) {
self->vec[3] = 1.0f;
}
self->size = 4;
@@ -332,12 +332,12 @@ static PyObject *Vector_to_tuple_ext(VectorObject *self, int ndigits)
ret= PyTuple_New(self->size);
if(ndigits >= 0) {
for(i = 0; i < self->size; i++) {
for (i = 0; i < self->size; i++) {
PyTuple_SET_ITEM(ret, i, PyFloat_FromDouble(double_round((double)self->vec[i], ndigits)));
}
}
else {
for(i = 0; i < self->size; i++) {
for (i = 0; i < self->size; i++) {
PyTuple_SET_ITEM(ret, i, PyFloat_FromDouble(self->vec[i]));
}
}
@@ -581,7 +581,7 @@ static PyObject *Vector_dot(VectorObject *self, PyObject *value)
if(mathutils_array_parse(tvec, self->size, self->size, value, "Vector.dot(other), invalid 'other' arg") == -1)
return NULL;
for(x = 0; x < self->size; x++) {
for (x = 0; x < self->size; x++) {
dot += (double)(self->vec[x] * tvec[x]);
}
@@ -621,11 +621,11 @@ static PyObject *Vector_angle(VectorObject *self, PyObject *args)
if(mathutils_array_parse(tvec, size, size, value, "Vector.angle(other), invalid 'other' arg") == -1)
return NULL;
for(x = 0; x < size; x++) {
for (x = 0; x < size; x++) {
test_v1 += (double)(self->vec[x] * self->vec[x]);
test_v2 += (double)(tvec[x] * tvec[x]);
}
if (!test_v1 || !test_v2){
if (!test_v1 || !test_v2) {
/* avoid exception */
if(fallback) {
Py_INCREF(fallback);
@@ -640,7 +640,7 @@ static PyObject *Vector_angle(VectorObject *self, PyObject *args)
}
//dot product
for(x = 0; x < self->size; x++) {
for (x = 0; x < self->size; x++) {
dot += (double)(self->vec[x] * tvec[x]);
}
dot /= (sqrt(test_v1) * sqrt(test_v2));
@@ -714,13 +714,13 @@ static PyObject *Vector_project(VectorObject *self, PyObject *value)
return NULL;
//get dot products
for(x = 0; x < size; x++) {
for (x = 0; x < size; x++) {
dot += (double)(self->vec[x] * tvec[x]);
dot2 += (double)(tvec[x] * tvec[x]);
}
//projection
dot /= dot2;
for(x = 0; x < size; x++) {
for (x = 0; x < size; x++) {
vec[x] = (float)dot * tvec[x];
}
return newVectorObject(vec, size, Py_NEW, Py_TYPE(self));
@@ -757,7 +757,7 @@ static PyObject *Vector_lerp(VectorObject *self, PyObject *args)
ifac= 1.0f - fac;
for(x = 0; x < size; x++) {
for (x = 0; x < size; x++) {
vec[x] = (ifac * self->vec[x]) + (fac * tvec[x]);
}
return newVectorObject(vec, size, Py_NEW, Py_TYPE(self));
@@ -872,7 +872,7 @@ static int vector_ass_item_internal(VectorObject *self, int i, PyObject *value,
if(i<0) i= self->size-i;
if(i < 0 || i >= self->size){
if(i < 0 || i >= self->size) {
if(is_attr) {
PyErr_Format(PyExc_AttributeError,
"Vector.%c = x: unavailable on %dd vector",
@@ -912,7 +912,7 @@ static PyObject *Vector_slice(VectorObject *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->vec[count]));
}
@@ -936,7 +936,7 @@ static int Vector_ass_slice(VectorObject *self, int begin, int end, PyObject *se
return -1;
/*parsed well - now set in vector*/
for(y = 0; y < size; y++){
for (y = 0; y < size; y++) {
self->vec[begin + y] = vec[y];
}
@@ -1088,7 +1088,7 @@ int column_vector_multiplication(float rvec[MAX_DIMENSIONS], VectorObject* vec,
double dot = 0.0f;
int x, y, z = 0;
if(mat->row_size != vec->size){
if(mat->row_size != vec->size) {
if(mat->row_size == 4 && vec->size == 3) {
vec_cpy[3] = 1.0f;
}
@@ -1105,8 +1105,8 @@ int column_vector_multiplication(float rvec[MAX_DIMENSIONS], VectorObject* vec,
rvec[3] = 1.0f;
for(x = 0; x < mat->col_size; x++) {
for(y = 0; y < mat->row_size; y++) {
for (x = 0; x < mat->col_size; x++) {
for (y = 0; y < mat->row_size; y++) {
dot += (double)(mat->matrix[y][x] * vec_cpy[y]);
}
rvec[z++] = (float)dot;
@@ -1153,7 +1153,7 @@ static PyObject *Vector_mul(PyObject *v1, PyObject *v2)
}
/*dot product*/
for(i = 0; i < vec1->size; i++) {
for (i = 0; i < vec1->size; i++) {
dot += (double)(vec1->vec[i] * vec2->vec[i]);
}
return PyFloat_FromDouble(dot);
@@ -1325,7 +1325,7 @@ static PyObject *Vector_div(PyObject *v1, PyObject *v2)
return NULL;
}
for(i = 0; i < vec1->size; i++) {
for (i = 0; i < vec1->size; i++) {
vec[i] = vec1->vec[i] / scalar;
}
return newVectorObject(vec, vec1->size, Py_NEW, Py_TYPE(v1));
@@ -1354,7 +1354,7 @@ static PyObject *Vector_idiv(PyObject *v1, PyObject *v2)
"divide by zero error");
return NULL;
}
for(i = 0; i < vec1->size; i++) {
for (i = 0; i < vec1->size; i++) {
vec1->vec[i] /= scalar;
}
@@ -1383,7 +1383,7 @@ static double vec_magnitude_nosqrt(float *data, int size)
double dot = 0.0f;
int i;
for(i=0; i<size; i++){
for (i=0; i<size; i++) {
dot += (double)data[i];
}
/*return (double)sqrt(dot);*/
@@ -1403,8 +1403,8 @@ static PyObject* Vector_richcmpr(PyObject *objectA, PyObject *objectB, int compa
double epsilon = .000001f;
double lenA, lenB;
if (!VectorObject_Check(objectA) || !VectorObject_Check(objectB)){
if (comparison_type == Py_NE){
if (!VectorObject_Check(objectA) || !VectorObject_Check(objectB)) {
if (comparison_type == Py_NE) {
Py_RETURN_TRUE;
}
else {
@@ -1417,8 +1417,8 @@ static PyObject* Vector_richcmpr(PyObject *objectA, PyObject *objectB, int compa
if(BaseMath_ReadCallback(vecA) == -1 || BaseMath_ReadCallback(vecB) == -1)
return NULL;
if (vecA->size != vecB->size){
if (comparison_type == Py_NE){
if (vecA->size != vecB->size) {
if (comparison_type == Py_NE) {
Py_RETURN_TRUE;
}
else {
@@ -1426,18 +1426,18 @@ static PyObject* Vector_richcmpr(PyObject *objectA, PyObject *objectB, int compa
}
}
switch (comparison_type){
switch (comparison_type) {
case Py_LT:
lenA = vec_magnitude_nosqrt(vecA->vec, vecA->size);
lenB = vec_magnitude_nosqrt(vecB->vec, vecB->size);
if(lenA < lenB){
if(lenA < lenB) {
result = 1;
}
break;
case Py_LE:
lenA = vec_magnitude_nosqrt(vecA->vec, vecA->size);
lenB = vec_magnitude_nosqrt(vecB->vec, vecB->size);
if(lenA < lenB){
if(lenA < lenB) {
result = 1;
}
else {
@@ -1453,14 +1453,14 @@ static PyObject* Vector_richcmpr(PyObject *objectA, PyObject *objectB, int compa
case Py_GT:
lenA = vec_magnitude_nosqrt(vecA->vec, vecA->size);
lenB = vec_magnitude_nosqrt(vecB->vec, vecB->size);
if(lenA > lenB){
if(lenA > lenB) {
result = 1;
}
break;
case Py_GE:
lenA = vec_magnitude_nosqrt(vecA->vec, vecA->size);
lenB = vec_magnitude_nosqrt(vecB->vec, vecB->size);
if(lenA > lenB){
if(lenA > lenB) {
result = 1;
}
else {
@@ -1471,7 +1471,7 @@ static PyObject* Vector_richcmpr(PyObject *objectA, PyObject *objectB, int compa
printf("The result of the comparison could not be evaluated");
break;
}
if (result == 1){
if (result == 1) {
Py_RETURN_TRUE;
}
else {
@@ -1631,7 +1631,7 @@ static PyObject *Vector_getLength(VectorObject *self, void *UNUSED(closure))
if(BaseMath_ReadCallback(self) == -1)
return NULL;
for(i = 0; i < self->size; i++){
for (i = 0; i < self->size; i++) {
dot += (double)(self->vec[i] * self->vec[i]);
}
return PyFloat_FromDouble(sqrt(dot));
@@ -1661,7 +1661,7 @@ static int Vector_setLength(VectorObject *self, PyObject *value)
return 0;
}
for(i = 0; i < self->size; i++){
for (i = 0; i < self->size; i++) {
dot += (double)(self->vec[i] * self->vec[i]);
}
@@ -1675,7 +1675,7 @@ static int Vector_setLength(VectorObject *self, PyObject *value)
dot= dot/param;
for(i = 0; i < self->size; i++){
for (i = 0; i < self->size; i++) {
self->vec[i]= self->vec[i] / (float)dot;
}
@@ -1693,7 +1693,7 @@ static PyObject *Vector_getLengthSquared(VectorObject *self, void *UNUSED(closur
if(BaseMath_ReadCallback(self) == -1)
return NULL;
for(i = 0; i < self->size; i++){
for (i = 0; i < self->size; i++) {
dot += (double)(self->vec[i] * self->vec[i]);
}
return PyFloat_FromDouble(dot);
@@ -1778,7 +1778,7 @@ static int Vector_setSwizzle(VectorObject *self, PyObject *value, void *closure)
if (((scalarVal=PyFloat_AsDouble(value)) == -1 && PyErr_Occurred())==0) {
int i;
for(i=0; i < MAX_DIMENSIONS; i++)
for (i=0; i < MAX_DIMENSIONS; i++)
vec_assign[i]= scalarVal;
size_from= axis_from;
@@ -2219,8 +2219,8 @@ static int row_vector_multiplication(float rvec[MAX_DIMENSIONS], VectorObject *v
double dot = 0.0f;
int x, y, z= 0, vec_size= vec->size;
if(mat->col_size != vec_size){
if(mat->col_size == 4 && vec_size != 3){
if(mat->col_size != vec_size) {
if(mat->col_size == 4 && vec_size != 3) {
PyErr_SetString(PyExc_ValueError,
"vector * matrix: matrix column size "
"and the vector size must be the same");
@@ -2235,11 +2235,11 @@ static int row_vector_multiplication(float rvec[MAX_DIMENSIONS], VectorObject *v
return -1;
memcpy(vec_cpy, vec->vec, vec_size * sizeof(float));
printf("asasas\n");
rvec[3] = 1.0f;
//muliplication
for(x = 0; x < mat->row_size; x++) {
for(y = 0; y < mat->col_size; y++) {
for (x = 0; x < mat->row_size; x++) {
for (y = 0; y < mat->col_size; y++) {
dot += mat->matrix[x][y] * vec_cpy[y];
}
rvec[z++] = (float)dot;

View File

@@ -86,16 +86,16 @@ static PyObject *M_Geometry_intersect_ray_tri(PyObject *UNUSED(self), PyObject*
float det, inv_det, u, v, t;
int clip= 1;
if(!PyArg_ParseTuple(args, "O!O!O!O!O!|i:intersect_ray_tri", &vector_Type, &vec1, &vector_Type, &vec2, &vector_Type, &vec3, &vector_Type, &ray, &vector_Type, &ray_off , &clip)) {
if (!PyArg_ParseTuple(args, "O!O!O!O!O!|i:intersect_ray_tri", &vector_Type, &vec1, &vector_Type, &vec2, &vector_Type, &vec3, &vector_Type, &ray, &vector_Type, &ray_off , &clip)) {
return NULL;
}
if(vec1->size != 3 || vec2->size != 3 || vec3->size != 3 || ray->size != 3 || ray_off->size != 3) {
if (vec1->size != 3 || vec2->size != 3 || vec3->size != 3 || ray->size != 3 || ray_off->size != 3) {
PyErr_SetString(PyExc_ValueError,
"only 3D vectors for all parameters");
return NULL;
}
if(BaseMath_ReadCallback(vec1) == -1 || BaseMath_ReadCallback(vec2) == -1 || BaseMath_ReadCallback(vec3) == -1 || BaseMath_ReadCallback(ray) == -1 || BaseMath_ReadCallback(ray_off) == -1)
if (BaseMath_ReadCallback(vec1) == -1 || BaseMath_ReadCallback(vec2) == -1 || BaseMath_ReadCallback(vec3) == -1 || BaseMath_ReadCallback(ray) == -1 || BaseMath_ReadCallback(ray_off) == -1)
return NULL;
VECCOPY(v1, vec1->vec);
@@ -174,19 +174,19 @@ static PyObject *M_Geometry_intersect_line_line(PyObject *UNUSED(self), PyObject
VectorObject *vec1, *vec2, *vec3, *vec4;
float v1[3], v2[3], v3[3], v4[3], i1[3], i2[3];
if(!PyArg_ParseTuple(args, "O!O!O!O!:intersect_line_line", &vector_Type, &vec1, &vector_Type, &vec2, &vector_Type, &vec3, &vector_Type, &vec4)) {
if (!PyArg_ParseTuple(args, "O!O!O!O!:intersect_line_line", &vector_Type, &vec1, &vector_Type, &vec2, &vector_Type, &vec3, &vector_Type, &vec4)) {
return NULL;
}
if(vec1->size != vec2->size || vec1->size != vec3->size || vec3->size != vec2->size) {
if (vec1->size != vec2->size || vec1->size != vec3->size || vec3->size != vec2->size) {
PyErr_SetString(PyExc_ValueError,
"vectors must be of the same size");
return NULL;
}
if(BaseMath_ReadCallback(vec1) == -1 || BaseMath_ReadCallback(vec2) == -1 || BaseMath_ReadCallback(vec3) == -1 || BaseMath_ReadCallback(vec4) == -1)
if (BaseMath_ReadCallback(vec1) == -1 || BaseMath_ReadCallback(vec2) == -1 || BaseMath_ReadCallback(vec3) == -1 || BaseMath_ReadCallback(vec4) == -1)
return NULL;
if(vec1->size == 3 || vec1->size == 2) {
if (vec1->size == 3 || vec1->size == 2) {
int result;
if (vec1->size == 3) {
@@ -257,42 +257,42 @@ static PyObject *M_Geometry_normal(PyObject *UNUSED(self), PyObject* args)
VectorObject *vec1, *vec2, *vec3, *vec4;
float n[3];
if(PyTuple_GET_SIZE(args) == 3) {
if(!PyArg_ParseTuple(args, "O!O!O!:normal", &vector_Type, &vec1, &vector_Type, &vec2, &vector_Type, &vec3)) {
if (PyTuple_GET_SIZE(args) == 3) {
if (!PyArg_ParseTuple(args, "O!O!O!:normal", &vector_Type, &vec1, &vector_Type, &vec2, &vector_Type, &vec3)) {
return NULL;
}
if(vec1->size != vec2->size || vec1->size != vec3->size) {
if (vec1->size != vec2->size || vec1->size != vec3->size) {
PyErr_SetString(PyExc_ValueError,
"vectors must be of the same size");
return NULL;
}
if(vec1->size < 3) {
if (vec1->size < 3) {
PyErr_SetString(PyExc_ValueError,
"2D vectors unsupported");
return NULL;
}
if(BaseMath_ReadCallback(vec1) == -1 || BaseMath_ReadCallback(vec2) == -1 || BaseMath_ReadCallback(vec3) == -1)
if (BaseMath_ReadCallback(vec1) == -1 || BaseMath_ReadCallback(vec2) == -1 || BaseMath_ReadCallback(vec3) == -1)
return NULL;
normal_tri_v3(n, vec1->vec, vec2->vec, vec3->vec);
}
else {
if(!PyArg_ParseTuple(args, "O!O!O!O!:normal", &vector_Type, &vec1, &vector_Type, &vec2, &vector_Type, &vec3, &vector_Type, &vec4)) {
if (!PyArg_ParseTuple(args, "O!O!O!O!:normal", &vector_Type, &vec1, &vector_Type, &vec2, &vector_Type, &vec3, &vector_Type, &vec4)) {
return NULL;
}
if(vec1->size != vec2->size || vec1->size != vec3->size || vec1->size != vec4->size) {
if (vec1->size != vec2->size || vec1->size != vec3->size || vec1->size != vec4->size) {
PyErr_SetString(PyExc_ValueError,
"vectors must be of the same size");
return NULL;
}
if(vec1->size < 3) {
if (vec1->size < 3) {
PyErr_SetString(PyExc_ValueError,
"2D vectors unsupported");
return NULL;
}
if(BaseMath_ReadCallback(vec1) == -1 || BaseMath_ReadCallback(vec2) == -1 || BaseMath_ReadCallback(vec3) == -1 || BaseMath_ReadCallback(vec4) == -1)
if (BaseMath_ReadCallback(vec1) == -1 || BaseMath_ReadCallback(vec2) == -1 || BaseMath_ReadCallback(vec3) == -1 || BaseMath_ReadCallback(vec4) == -1)
return NULL;
normal_quad_v3(n, vec1->vec, vec2->vec, vec3->vec, vec4->vec);
@@ -320,17 +320,17 @@ static PyObject *M_Geometry_area_tri(PyObject *UNUSED(self), PyObject* args)
{
VectorObject *vec1, *vec2, *vec3;
if(!PyArg_ParseTuple(args, "O!O!O!:area_tri", &vector_Type, &vec1, &vector_Type, &vec2, &vector_Type, &vec3)) {
if (!PyArg_ParseTuple(args, "O!O!O!:area_tri", &vector_Type, &vec1, &vector_Type, &vec2, &vector_Type, &vec3)) {
return NULL;
}
if(vec1->size != vec2->size || vec1->size != vec3->size) {
if (vec1->size != vec2->size || vec1->size != vec3->size) {
PyErr_SetString(PyExc_ValueError,
"vectors must be of the same size");
return NULL;
}
if(BaseMath_ReadCallback(vec1) == -1 || BaseMath_ReadCallback(vec2) == -1 || BaseMath_ReadCallback(vec3) == -1)
if (BaseMath_ReadCallback(vec1) == -1 || BaseMath_ReadCallback(vec2) == -1 || BaseMath_ReadCallback(vec3) == -1)
return NULL;
if (vec1->size == 3) {
@@ -367,7 +367,7 @@ static PyObject *M_Geometry_intersect_line_line_2d(PyObject *UNUSED(self), PyObj
{
VectorObject *line_a1, *line_a2, *line_b1, *line_b2;
float vi[2];
if(!PyArg_ParseTuple(args, "O!O!O!O!:intersect_line_line_2d",
if (!PyArg_ParseTuple(args, "O!O!O!O!:intersect_line_line_2d",
&vector_Type, &line_a1,
&vector_Type, &line_a2,
&vector_Type, &line_b1,
@@ -376,10 +376,10 @@ static PyObject *M_Geometry_intersect_line_line_2d(PyObject *UNUSED(self), PyObj
return NULL;
}
if(BaseMath_ReadCallback(line_a1) == -1 || BaseMath_ReadCallback(line_a2) == -1 || BaseMath_ReadCallback(line_b1) == -1 || BaseMath_ReadCallback(line_b2) == -1)
if (BaseMath_ReadCallback(line_a1) == -1 || BaseMath_ReadCallback(line_a2) == -1 || BaseMath_ReadCallback(line_b1) == -1 || BaseMath_ReadCallback(line_b2) == -1)
return NULL;
if(isect_seg_seg_v2_point(line_a1->vec, line_a2->vec, line_b1->vec, line_b2->vec, vi) == 1) {
if (isect_seg_seg_v2_point(line_a1->vec, line_a2->vec, line_b1->vec, line_b2->vec, vi) == 1) {
return newVectorObject(vi, 2, Py_NEW, NULL);
}
else {
@@ -411,7 +411,7 @@ static PyObject *M_Geometry_intersect_line_plane(PyObject *UNUSED(self), PyObjec
VectorObject *line_a, *line_b, *plane_co, *plane_no;
int no_flip= 0;
float isect[3];
if(!PyArg_ParseTuple(args, "O!O!O!O!|i:intersect_line_plane",
if (!PyArg_ParseTuple(args, "O!O!O!O!|i:intersect_line_plane",
&vector_Type, &line_a,
&vector_Type, &line_b,
&vector_Type, &plane_co,
@@ -421,7 +421,7 @@ static PyObject *M_Geometry_intersect_line_plane(PyObject *UNUSED(self), PyObjec
return NULL;
}
if( BaseMath_ReadCallback(line_a) == -1 ||
if ( BaseMath_ReadCallback(line_a) == -1 ||
BaseMath_ReadCallback(line_b) == -1 ||
BaseMath_ReadCallback(plane_co) == -1 ||
BaseMath_ReadCallback(plane_no) == -1
@@ -429,14 +429,14 @@ static PyObject *M_Geometry_intersect_line_plane(PyObject *UNUSED(self), PyObjec
return NULL;
}
if(ELEM4(2, line_a->size, line_b->size, plane_co->size, plane_no->size)) {
if (ELEM4(2, line_a->size, line_b->size, plane_co->size, plane_no->size)) {
PyErr_SetString(PyExc_ValueError,
"geometry.intersect_line_plane(...): "
" can't use 2D Vectors");
return NULL;
}
if(isect_line_plane_v3(isect, line_a->vec, line_b->vec, plane_co->vec, plane_no->vec, no_flip) == 1) {
if (isect_line_plane_v3(isect, line_a->vec, line_b->vec, plane_co->vec, plane_no->vec, no_flip) == 1) {
return newVectorObject(isect, 3, Py_NEW, NULL);
}
else {
@@ -471,7 +471,7 @@ static PyObject *M_Geometry_intersect_line_sphere(PyObject *UNUSED(self), PyObje
float isect_a[3];
float isect_b[3];
if(!PyArg_ParseTuple(args, "O!O!O!f|i:intersect_line_sphere",
if (!PyArg_ParseTuple(args, "O!O!O!f|i:intersect_line_sphere",
&vector_Type, &line_a,
&vector_Type, &line_b,
&vector_Type, &sphere_co,
@@ -480,14 +480,14 @@ static PyObject *M_Geometry_intersect_line_sphere(PyObject *UNUSED(self), PyObje
return NULL;
}
if( BaseMath_ReadCallback(line_a) == -1 ||
if ( BaseMath_ReadCallback(line_a) == -1 ||
BaseMath_ReadCallback(line_b) == -1 ||
BaseMath_ReadCallback(sphere_co) == -1
) {
return NULL;
}
if(ELEM3(2, line_a->size, line_b->size, sphere_co->size)) {
if (ELEM3(2, line_a->size, line_b->size, sphere_co->size)) {
PyErr_SetString(PyExc_ValueError,
"geometry.intersect_line_sphere(...): "
" can't use 2D Vectors");
@@ -502,22 +502,22 @@ static PyObject *M_Geometry_intersect_line_sphere(PyObject *UNUSED(self), PyObje
switch(isect_line_sphere_v3(line_a->vec, line_b->vec, sphere_co->vec, sphere_radius, isect_a, isect_b)) {
case 1:
if(!(!clip || (((lambda= line_point_factor_v3(isect_a, line_a->vec, line_b->vec)) >= 0.0f) && (lambda <= 1.0f)))) use_a= FALSE;
if (!(!clip || (((lambda= line_point_factor_v3(isect_a, line_a->vec, line_b->vec)) >= 0.0f) && (lambda <= 1.0f)))) use_a= FALSE;
use_b= FALSE;
break;
case 2:
if(!(!clip || (((lambda= line_point_factor_v3(isect_a, line_a->vec, line_b->vec)) >= 0.0f) && (lambda <= 1.0f)))) use_a= FALSE;
if(!(!clip || (((lambda= line_point_factor_v3(isect_b, line_a->vec, line_b->vec)) >= 0.0f) && (lambda <= 1.0f)))) use_b= FALSE;
if (!(!clip || (((lambda= line_point_factor_v3(isect_a, line_a->vec, line_b->vec)) >= 0.0f) && (lambda <= 1.0f)))) use_a= FALSE;
if (!(!clip || (((lambda= line_point_factor_v3(isect_b, line_a->vec, line_b->vec)) >= 0.0f) && (lambda <= 1.0f)))) use_b= FALSE;
break;
default:
use_a= FALSE;
use_b= FALSE;
}
if(use_a) { PyTuple_SET_ITEM(ret, 0, newVectorObject(isect_a, 3, Py_NEW, NULL)); }
if (use_a) { PyTuple_SET_ITEM(ret, 0, newVectorObject(isect_a, 3, Py_NEW, NULL)); }
else { PyTuple_SET_ITEM(ret, 0, Py_None); Py_INCREF(Py_None); }
if(use_b) { PyTuple_SET_ITEM(ret, 1, newVectorObject(isect_b, 3, Py_NEW, NULL)); }
if (use_b) { PyTuple_SET_ITEM(ret, 1, newVectorObject(isect_b, 3, Py_NEW, NULL)); }
else { PyTuple_SET_ITEM(ret, 1, Py_None); Py_INCREF(Py_None); }
return ret;
@@ -551,7 +551,7 @@ static PyObject *M_Geometry_intersect_line_sphere_2d(PyObject *UNUSED(self), PyO
float isect_a[3];
float isect_b[3];
if(!PyArg_ParseTuple(args, "O!O!O!f|i:intersect_line_sphere_2d",
if (!PyArg_ParseTuple(args, "O!O!O!f|i:intersect_line_sphere_2d",
&vector_Type, &line_a,
&vector_Type, &line_b,
&vector_Type, &sphere_co,
@@ -560,7 +560,7 @@ static PyObject *M_Geometry_intersect_line_sphere_2d(PyObject *UNUSED(self), PyO
return NULL;
}
if( BaseMath_ReadCallback(line_a) == -1 ||
if ( BaseMath_ReadCallback(line_a) == -1 ||
BaseMath_ReadCallback(line_b) == -1 ||
BaseMath_ReadCallback(sphere_co) == -1
) {
@@ -575,22 +575,22 @@ static PyObject *M_Geometry_intersect_line_sphere_2d(PyObject *UNUSED(self), PyO
switch(isect_line_sphere_v2(line_a->vec, line_b->vec, sphere_co->vec, sphere_radius, isect_a, isect_b)) {
case 1:
if(!(!clip || (((lambda= line_point_factor_v2(isect_a, line_a->vec, line_b->vec)) >= 0.0f) && (lambda <= 1.0f)))) use_a= FALSE;
if (!(!clip || (((lambda= line_point_factor_v2(isect_a, line_a->vec, line_b->vec)) >= 0.0f) && (lambda <= 1.0f)))) use_a= FALSE;
use_b= FALSE;
break;
case 2:
if(!(!clip || (((lambda= line_point_factor_v2(isect_a, line_a->vec, line_b->vec)) >= 0.0f) && (lambda <= 1.0f)))) use_a= FALSE;
if(!(!clip || (((lambda= line_point_factor_v2(isect_b, line_a->vec, line_b->vec)) >= 0.0f) && (lambda <= 1.0f)))) use_b= FALSE;
if (!(!clip || (((lambda= line_point_factor_v2(isect_a, line_a->vec, line_b->vec)) >= 0.0f) && (lambda <= 1.0f)))) use_a= FALSE;
if (!(!clip || (((lambda= line_point_factor_v2(isect_b, line_a->vec, line_b->vec)) >= 0.0f) && (lambda <= 1.0f)))) use_b= FALSE;
break;
default:
use_a= FALSE;
use_b= FALSE;
}
if(use_a) { PyTuple_SET_ITEM(ret, 0, newVectorObject(isect_a, 2, Py_NEW, NULL)); }
if (use_a) { PyTuple_SET_ITEM(ret, 0, newVectorObject(isect_a, 2, Py_NEW, NULL)); }
else { PyTuple_SET_ITEM(ret, 0, Py_None); Py_INCREF(Py_None); }
if(use_b) { PyTuple_SET_ITEM(ret, 1, newVectorObject(isect_b, 2, Py_NEW, NULL)); }
if (use_b) { PyTuple_SET_ITEM(ret, 1, newVectorObject(isect_b, 2, Py_NEW, NULL)); }
else { PyTuple_SET_ITEM(ret, 1, Py_None); Py_INCREF(Py_None); }
return ret;
@@ -617,7 +617,7 @@ static PyObject *M_Geometry_intersect_point_line(PyObject *UNUSED(self), PyObjec
float lambda;
PyObject *ret;
if(!PyArg_ParseTuple(args, "O!O!O!:intersect_point_line",
if (!PyArg_ParseTuple(args, "O!O!O!:intersect_point_line",
&vector_Type, &pt,
&vector_Type, &line_1,
&vector_Type, &line_2)
@@ -625,7 +625,7 @@ static PyObject *M_Geometry_intersect_point_line(PyObject *UNUSED(self), PyObjec
return NULL;
}
if(BaseMath_ReadCallback(pt) == -1 || BaseMath_ReadCallback(line_1) == -1 || BaseMath_ReadCallback(line_2) == -1)
if (BaseMath_ReadCallback(pt) == -1 || BaseMath_ReadCallback(line_1) == -1 || BaseMath_ReadCallback(line_2) == -1)
return NULL;
/* accept 2d verts */
@@ -666,7 +666,7 @@ static PyObject *M_Geometry_intersect_point_tri_2d(PyObject *UNUSED(self), PyObj
{
VectorObject *pt_vec, *tri_p1, *tri_p2, *tri_p3;
if(!PyArg_ParseTuple(args, "O!O!O!O!:intersect_point_tri_2d",
if (!PyArg_ParseTuple(args, "O!O!O!O!:intersect_point_tri_2d",
&vector_Type, &pt_vec,
&vector_Type, &tri_p1,
&vector_Type, &tri_p2,
@@ -675,7 +675,7 @@ static PyObject *M_Geometry_intersect_point_tri_2d(PyObject *UNUSED(self), PyObj
return NULL;
}
if(BaseMath_ReadCallback(pt_vec) == -1 || BaseMath_ReadCallback(tri_p1) == -1 || BaseMath_ReadCallback(tri_p2) == -1 || BaseMath_ReadCallback(tri_p3) == -1)
if (BaseMath_ReadCallback(pt_vec) == -1 || BaseMath_ReadCallback(tri_p1) == -1 || BaseMath_ReadCallback(tri_p2) == -1 || BaseMath_ReadCallback(tri_p3) == -1)
return NULL;
return PyLong_FromLong(isect_point_tri_v2(pt_vec->vec, tri_p1->vec, tri_p2->vec, tri_p3->vec));
@@ -702,7 +702,7 @@ static PyObject *M_Geometry_intersect_point_quad_2d(PyObject *UNUSED(self), PyOb
{
VectorObject *pt_vec, *quad_p1, *quad_p2, *quad_p3, *quad_p4;
if(!PyArg_ParseTuple(args, "O!O!O!O!O!:intersect_point_quad_2d",
if (!PyArg_ParseTuple(args, "O!O!O!O!O!:intersect_point_quad_2d",
&vector_Type, &pt_vec,
&vector_Type, &quad_p1,
&vector_Type, &quad_p2,
@@ -712,7 +712,7 @@ static PyObject *M_Geometry_intersect_point_quad_2d(PyObject *UNUSED(self), PyOb
return NULL;
}
if(BaseMath_ReadCallback(pt_vec) == -1 || BaseMath_ReadCallback(quad_p1) == -1 || BaseMath_ReadCallback(quad_p2) == -1 || BaseMath_ReadCallback(quad_p3) == -1 || BaseMath_ReadCallback(quad_p4) == -1)
if (BaseMath_ReadCallback(pt_vec) == -1 || BaseMath_ReadCallback(quad_p1) == -1 || BaseMath_ReadCallback(quad_p2) == -1 || BaseMath_ReadCallback(quad_p3) == -1 || BaseMath_ReadCallback(quad_p4) == -1)
return NULL;
return PyLong_FromLong(isect_point_quad_v2(pt_vec->vec, quad_p1->vec, quad_p2->vec, quad_p3->vec, quad_p4->vec));
@@ -747,7 +747,7 @@ static PyObject *M_Geometry_barycentric_transform(PyObject *UNUSED(self), PyObje
VectorObject *vec_t1_src, *vec_t2_src, *vec_t3_src;
float vec[3];
if(!PyArg_ParseTuple(args, "O!O!O!O!O!O!O!:barycentric_transform",
if (!PyArg_ParseTuple(args, "O!O!O!O!O!O!O!:barycentric_transform",
&vector_Type, &vec_pt,
&vector_Type, &vec_t1_src,
&vector_Type, &vec_t2_src,
@@ -759,7 +759,7 @@ static PyObject *M_Geometry_barycentric_transform(PyObject *UNUSED(self), PyObje
return NULL;
}
if( vec_pt->size != 3 ||
if ( vec_pt->size != 3 ||
vec_t1_src->size != 3 ||
vec_t2_src->size != 3 ||
vec_t3_src->size != 3 ||
@@ -814,7 +814,7 @@ static PyObject *M_Geometry_interpolate_bezier(PyObject *UNUSED(self), PyObject*
float h2[4]= {0.0, 0.0, 0.0, 0.0};
if(!PyArg_ParseTuple(args, "O!O!O!O!i:interpolate_bezier",
if (!PyArg_ParseTuple(args, "O!O!O!O!i:interpolate_bezier",
&vector_Type, &vec_k1,
&vector_Type, &vec_h1,
&vector_Type, &vec_h2,
@@ -823,30 +823,30 @@ static PyObject *M_Geometry_interpolate_bezier(PyObject *UNUSED(self), PyObject*
return NULL;
}
if(resolu <= 1) {
if (resolu <= 1) {
PyErr_SetString(PyExc_ValueError,
"resolution must be 2 or over");
return NULL;
}
if(BaseMath_ReadCallback(vec_k1) == -1 || BaseMath_ReadCallback(vec_h1) == -1 || BaseMath_ReadCallback(vec_k2) == -1 || BaseMath_ReadCallback(vec_h2) == -1)
if (BaseMath_ReadCallback(vec_k1) == -1 || BaseMath_ReadCallback(vec_h1) == -1 || BaseMath_ReadCallback(vec_k2) == -1 || BaseMath_ReadCallback(vec_h2) == -1)
return NULL;
dims= MAX4(vec_k1->size, vec_h1->size, vec_h2->size, vec_k2->size);
for(i=0; i < vec_k1->size; i++) k1[i]= vec_k1->vec[i];
for(i=0; i < vec_h1->size; i++) h1[i]= vec_h1->vec[i];
for(i=0; i < vec_k2->size; i++) k2[i]= vec_k2->vec[i];
for(i=0; i < vec_h2->size; i++) h2[i]= vec_h2->vec[i];
for (i=0; i < vec_k1->size; i++) k1[i]= vec_k1->vec[i];
for (i=0; i < vec_h1->size; i++) h1[i]= vec_h1->vec[i];
for (i=0; i < vec_k2->size; i++) k2[i]= vec_k2->vec[i];
for (i=0; i < vec_h2->size; i++) h2[i]= vec_h2->vec[i];
coord_array= MEM_callocN(dims * (resolu) * sizeof(float), "interpolate_bezier");
for(i=0; i<dims; i++) {
for (i=0; i<dims; i++) {
forward_diff_bezier(k1[i], h1[i], h2[i], k2[i], coord_array+i, resolu-1, sizeof(float)*dims);
}
list= PyList_New(resolu);
fp= coord_array;
for(i=0; i<resolu; i++, fp= fp+dims) {
for (i=0; i<resolu; i++, fp= fp+dims) {
PyList_SET_ITEM(list, i, newVectorObject(fp, dims, Py_NEW, NULL));
}
MEM_freeN(coord_array);
@@ -875,7 +875,7 @@ static PyObject *M_Geometry_tesselate_polygon(PyObject *UNUSED(self), PyObject *
float *fp; /*pointer to the array of malloced dl->verts to set the points from the vectors */
int index, *dl_face, totpoints=0;
if(!PySequence_Check(polyLineSeq)) {
if (!PySequence_Check(polyLineSeq)) {
PyErr_SetString(PyExc_TypeError,
"expected a sequence of poly lines");
return NULL;
@@ -883,7 +883,7 @@ static PyObject *M_Geometry_tesselate_polygon(PyObject *UNUSED(self), PyObject *
len_polylines= PySequence_Size(polyLineSeq);
for(i= 0; i < len_polylines; ++i) {
for (i= 0; i < len_polylines; ++i) {
polyLine= PySequence_GetItem(polyLineSeq, i);
if (!PySequence_Check(polyLine)) {
freedisplist(&dispbase);
@@ -914,16 +914,16 @@ static PyObject *M_Geometry_tesselate_polygon(PyObject *UNUSED(self), PyObject *
dl->verts= fp= MEM_callocN(sizeof(float)*3*len_polypoints, "dl verts");
dl->index= MEM_callocN(sizeof(int)*3*len_polypoints, "dl index");
for(index= 0; index<len_polypoints; ++index, fp+=3) {
for (index= 0; index<len_polypoints; ++index, fp+=3) {
polyVec= PySequence_GetItem(polyLine, index);
if(VectorObject_Check(polyVec)) {
if (VectorObject_Check(polyVec)) {
if(BaseMath_ReadCallback((VectorObject *)polyVec) == -1)
if (BaseMath_ReadCallback((VectorObject *)polyVec) == -1)
ls_error= 1;
fp[0]= ((VectorObject *)polyVec)->vec[0];
fp[1]= ((VectorObject *)polyVec)->vec[1];
if(((VectorObject *)polyVec)->size > 2)
if (((VectorObject *)polyVec)->size > 2)
fp[2]= ((VectorObject *)polyVec)->vec[2];
else
fp[2]= 0.0f; /* if its a 2d vector then set the z to be zero */
@@ -939,7 +939,7 @@ static PyObject *M_Geometry_tesselate_polygon(PyObject *UNUSED(self), PyObject *
Py_DECREF(polyLine);
}
if(ls_error) {
if (ls_error) {
freedisplist(&dispbase); /* possible some dl was allocated */
PyErr_SetString(PyExc_TypeError,
"A point in one of the polylines "
@@ -955,7 +955,7 @@ static PyObject *M_Geometry_tesselate_polygon(PyObject *UNUSED(self), PyObject *
dl= dispbase.first;
tri_list= PyList_New(dl->parts);
if(!tri_list) {
if (!tri_list) {
freedisplist(&dispbase);
PyErr_SetString(PyExc_RuntimeError,
"failed to make a new list");
@@ -964,7 +964,7 @@ static PyObject *M_Geometry_tesselate_polygon(PyObject *UNUSED(self), PyObject *
index= 0;
dl_face= dl->index;
while(index < dl->parts) {
while (index < dl->parts) {
PyList_SET_ITEM(tri_list, index, Py_BuildValue("iii", dl_face[0], dl_face[1], dl_face[2]));
dl_face+= 3;
index++;
@@ -989,7 +989,7 @@ static int boxPack_FromPyObject(PyObject *value, boxPack **boxarray)
/* Error checking must already be done */
if(!PyList_Check(value)) {
if (!PyList_Check(value)) {
PyErr_SetString(PyExc_TypeError,
"can only back a list of [x, y, w, h]");
return -1;
@@ -1000,9 +1000,9 @@ static int boxPack_FromPyObject(PyObject *value, boxPack **boxarray)
(*boxarray)= MEM_mallocN(len*sizeof(boxPack), "boxPack box");
for(i= 0; i < len; i++) {
for (i= 0; i < len; i++) {
list_item= PyList_GET_ITEM(value, i);
if(!PyList_Check(list_item) || PyList_GET_SIZE(list_item) < 4) {
if (!PyList_Check(list_item) || PyList_GET_SIZE(list_item) < 4) {
MEM_freeN(*boxarray);
PyErr_SetString(PyExc_TypeError,
"can only pack a list of [x, y, w, h]");
@@ -1040,7 +1040,7 @@ static void boxPack_ToPyObject(PyObject *value, boxPack **boxarray)
len= PyList_GET_SIZE(value);
for(i= 0; i < len; i++) {
for (i= 0; i < len; i++) {
box= (*boxarray)+i;
list_item= PyList_GET_ITEM(value, box->index);
PyList_SET_ITEM(list_item, 0, PyFloat_FromDouble(box->x));
@@ -1066,7 +1066,7 @@ static PyObject *M_Geometry_box_pack_2d(PyObject *UNUSED(self), PyObject *boxlis
PyObject *ret;
if(!PyList_Check(boxlist)) {
if (!PyList_Check(boxlist)) {
PyErr_SetString(PyExc_TypeError,
"expected a list of boxes [[x, y, w, h], ... ]");
return NULL;
@@ -1075,7 +1075,7 @@ static PyObject *M_Geometry_box_pack_2d(PyObject *UNUSED(self), PyObject *boxlis
len= PyList_GET_SIZE(boxlist);
if (len) {
boxPack *boxarray= NULL;
if(boxPack_FromPyObject(boxlist, &boxarray) == -1) {
if (boxPack_FromPyObject(boxlist, &boxarray) == -1) {
return NULL; /* exception set */
}