diff options
author | Campbell Barton <ideasman42@gmail.com> | 2011-12-24 17:26:30 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2011-12-24 17:26:30 +0400 |
commit | f3ac865cc0031d775f67e3fcaa389e6f06d1954e (patch) | |
tree | 4bcf6e50265cb49682a29795324b0f7b650ab17f /source/blender/python | |
parent | 84c8fde2aeb9e2c36802c6eece56aa703103ab8e (diff) |
picky formatting of mathutils
Diffstat (limited to 'source/blender/python')
-rw-r--r-- | source/blender/python/mathutils/mathutils.c | 64 | ||||
-rw-r--r-- | source/blender/python/mathutils/mathutils_Color.c | 102 | ||||
-rw-r--r-- | source/blender/python/mathutils/mathutils_Euler.c | 74 | ||||
-rw-r--r-- | source/blender/python/mathutils/mathutils_Euler.h | 2 | ||||
-rw-r--r-- | source/blender/python/mathutils/mathutils_Matrix.c | 258 | ||||
-rw-r--r-- | source/blender/python/mathutils/mathutils_Quaternion.c | 104 | ||||
-rw-r--r-- | source/blender/python/mathutils/mathutils_Vector.c | 201 | ||||
-rw-r--r-- | source/blender/python/mathutils/mathutils_geometry.c | 262 | ||||
-rw-r--r-- | source/blender/python/mathutils/mathutils_noise.c | 58 |
9 files changed, 562 insertions, 563 deletions
diff --git a/source/blender/python/mathutils/mathutils.c b/source/blender/python/mathutils/mathutils.c index 45fe0092b39..42fa46207f3 100644 --- a/source/blender/python/mathutils/mathutils.c +++ b/source/blender/python/mathutils/mathutils.c @@ -49,10 +49,10 @@ static int mathutils_array_parse_fast(float *array, int i; - i= size; + i = size; do { i--; - if ( ((array[i]= PyFloat_AsDouble((item= PySequence_Fast_GET_ITEM(value_fast, i)))) == -1.0f) && + if ( ((array[i] = PyFloat_AsDouble((item = PySequence_Fast_GET_ITEM(value_fast, i)))) == -1.0f) && PyErr_Occurred()) { PyErr_Format(PyExc_TypeError, @@ -75,10 +75,10 @@ int mathutils_array_parse(float *array, int array_min, int array_max, PyObject * #if 1 /* approx 6x speedup for mathutils types */ - 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 ( (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) { return -1; @@ -104,15 +104,15 @@ int mathutils_array_parse(float *array, int array_min, int array_max, PyObject * else #endif { - PyObject *value_fast= NULL; + PyObject *value_fast = NULL; /* 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); + size = PySequence_Fast_GET_SIZE(value_fast); if (size > array_max || size < array_min) { if (array_max == array_min) { @@ -139,10 +139,10 @@ int mathutils_array_parse_alloc(float **array, int array_min, PyObject *value, c #if 1 /* approx 6x speedup for mathutils types */ - 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 ( (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) { return -1; @@ -155,23 +155,23 @@ int mathutils_array_parse_alloc(float **array, int array_min, PyObject *value, c return -1; } - *array= PyMem_Malloc(size * sizeof(float)); + *array = PyMem_Malloc(size * sizeof(float)); memcpy(*array, ((BaseMathObject *)value)->data, size * sizeof(float)); return size; } else #endif { - PyObject *value_fast= NULL; - //*array= NULL; + PyObject *value_fast = NULL; + //*array = NULL; /* 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); + size = PySequence_Fast_GET_SIZE(value_fast); if (size < array_min) { PyErr_Format(PyExc_ValueError, @@ -180,7 +180,7 @@ int mathutils_array_parse_alloc(float **array, int array_min, PyObject *value, c return -1; } - *array= PyMem_Malloc(size * sizeof(float)); + *array = PyMem_Malloc(size * sizeof(float)); return mathutils_array_parse_fast(*array, size, value_fast, error_prefix); } @@ -261,7 +261,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; } @@ -291,8 +291,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; } @@ -303,7 +303,7 @@ int Mathutils_RegisterCallback(Mathutils_Callback *cb) /* use macros to check for NULL */ int _BaseMathObject_ReadCallback(BaseMathObject *self) { - Mathutils_Callback *cb= mathutils_callbacks[self->cb_type]; + Mathutils_Callback *cb = mathutils_callbacks[self->cb_type]; if (cb->get(self, self->cb_subtype) != -1) return 0; @@ -317,7 +317,7 @@ int _BaseMathObject_ReadCallback(BaseMathObject *self) int _BaseMathObject_WriteCallback(BaseMathObject *self) { - Mathutils_Callback *cb= mathutils_callbacks[self->cb_type]; + Mathutils_Callback *cb = mathutils_callbacks[self->cb_type]; if (cb->set(self, self->cb_subtype) != -1) return 0; @@ -331,7 +331,7 @@ int _BaseMathObject_WriteCallback(BaseMathObject *self) int _BaseMathObject_ReadIndexCallback(BaseMathObject *self, int index) { - Mathutils_Callback *cb= mathutils_callbacks[self->cb_type]; + Mathutils_Callback *cb = mathutils_callbacks[self->cb_type]; if (cb->get_index(self, self->cb_subtype, index) != -1) return 0; @@ -345,7 +345,7 @@ int _BaseMathObject_ReadIndexCallback(BaseMathObject *self, int index) int _BaseMathObject_WriteIndexCallback(BaseMathObject *self, int index) { - Mathutils_Callback *cb= mathutils_callbacks[self->cb_type]; + Mathutils_Callback *cb = mathutils_callbacks[self->cb_type]; if (cb->set_index(self, self->cb_subtype, index) != -1) return 0; @@ -361,7 +361,7 @@ int _BaseMathObject_WriteIndexCallback(BaseMathObject *self, int index) char BaseMathObject_owner_doc[] = "The item this is wrapping or None (readonly)."; PyObject *BaseMathObject_owner_get(BaseMathObject *self, void *UNUSED(closure)) { - PyObject *ret= self->cb_user ? self->cb_user : Py_None; + PyObject *ret = self->cb_user ? self->cb_user : Py_None; Py_INCREF(ret); return ret; } @@ -420,7 +420,7 @@ PyMODINIT_FUNC PyInit_mathutils(void) { PyObject *submodule; PyObject *item; - PyObject *sys_modules= PyThreadState_GET()->interp->modules; + PyObject *sys_modules = PyThreadState_GET()->interp->modules; if (PyType_Ready(&vector_Type) < 0) return NULL; @@ -445,7 +445,7 @@ PyMODINIT_FUNC PyInit_mathutils(void) PyModule_AddObject(submodule, "Color", (PyObject *)&color_Type); /* submodule */ - PyModule_AddObject(submodule, "geometry", (item=PyInit_mathutils_geometry())); + PyModule_AddObject(submodule, "geometry", (item = PyInit_mathutils_geometry())); /* XXX, python doesnt do imports with this usefully yet * 'from mathutils.geometry import PolyFill' * ...fails without this. */ @@ -453,12 +453,12 @@ PyMODINIT_FUNC PyInit_mathutils(void) Py_INCREF(item); /* Noise submodule */ - PyModule_AddObject(submodule, "noise", (item=PyInit_mathutils_noise())); + PyModule_AddObject(submodule, "noise", (item = PyInit_mathutils_noise())); PyDict_SetItemString(sys_modules, "mathutils.noise", item); Py_INCREF(item); - mathutils_matrix_row_cb_index= Mathutils_RegisterCallback(&mathutils_matrix_row_cb); - mathutils_matrix_col_cb_index= Mathutils_RegisterCallback(&mathutils_matrix_col_cb); + mathutils_matrix_row_cb_index = Mathutils_RegisterCallback(&mathutils_matrix_row_cb); + mathutils_matrix_col_cb_index = Mathutils_RegisterCallback(&mathutils_matrix_col_cb); return submodule; } diff --git a/source/blender/python/mathutils/mathutils_Color.c b/source/blender/python/mathutils/mathutils_Color.c index 59fc656a380..c85380fb245 100644 --- a/source/blender/python/mathutils/mathutils_Color.c +++ b/source/blender/python/mathutils/mathutils_Color.c @@ -40,7 +40,7 @@ //makes a new color for you to play with static PyObject *Color_new(PyTypeObject *type, PyObject *args, PyObject *kwds) { - float col[3]= {0.0f, 0.0f, 0.0f}; + float col[3] = {0.0f, 0.0f, 0.0f}; if (kwds && PyDict_Size(kwds)) { PyErr_SetString(PyExc_TypeError, @@ -73,15 +73,15 @@ static PyObject *Color_ToTupleExt(ColorObject *self, int ndigits) PyObject *ret; int i; - ret= PyTuple_New(COLOR_SIZE); + ret = PyTuple_New(COLOR_SIZE); if (ndigits >= 0) { - for (i= 0; i < COLOR_SIZE; i++) { + 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])); } } @@ -118,9 +118,9 @@ static PyObject *Color_repr(ColorObject * self) if (BaseMath_ReadCallback(self) == -1) return NULL; - tuple= Color_ToTupleExt(self, -1); + tuple = Color_ToTupleExt(self, -1); - ret= PyUnicode_FromFormat("Color(%R)", tuple); + ret = PyUnicode_FromFormat("Color(%R)", tuple); Py_DECREF(tuple); return ret; @@ -133,7 +133,7 @@ static PyObject *Color_str(ColorObject * self) if (BaseMath_ReadCallback(self) == -1) return NULL; - ds= BLI_dynstr_new(); + ds = BLI_dynstr_new(); BLI_dynstr_appendf(ds, "<Color (r=%.4f, g=%.4f, b=%.4f)>", self->col[0], self->col[1], self->col[2]); @@ -143,19 +143,19 @@ static PyObject *Color_str(ColorObject * self) //------------------------tp_richcmpr //returns -1 execption, 0 false, 1 true -static PyObject* Color_richcmpr(PyObject *a, PyObject *b, int op) +static PyObject *Color_richcmpr(PyObject *a, PyObject *b, int op) { PyObject *res; - int ok= -1; /* zero is true */ + int ok = -1; /* zero is true */ if (ColorObject_Check(a) && ColorObject_Check(b)) { - ColorObject *colA= (ColorObject*)a; - ColorObject *colB= (ColorObject*)b; + ColorObject *colA = (ColorObject *)a; + ColorObject *colB = (ColorObject *)b; if (BaseMath_ReadCallback(colA) == -1 || BaseMath_ReadCallback(colB) == -1) return NULL; - ok= EXPP_VectorsAreEqual(colA->col, colB->col, COLOR_SIZE, 1) ? 0 : -1; + ok = EXPP_VectorsAreEqual(colA->col, colB->col, COLOR_SIZE, 1) ? 0 : -1; } switch (op) { @@ -190,7 +190,7 @@ 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) { PyErr_SetString(PyExc_IndexError, @@ -218,7 +218,7 @@ static int Color_ass_item(ColorObject * self, int i, PyObject *value) return -1; } - if (i<0) i= COLOR_SIZE-i; + if (i < 0) i= COLOR_SIZE - i; if (i < 0 || i >= COLOR_SIZE) { PyErr_SetString(PyExc_IndexError, "color[attribute] = x: " @@ -244,12 +244,12 @@ static PyObject *Color_slice(ColorObject * self, int begin, int end) return NULL; CLAMP(begin, 0, COLOR_SIZE); - if (end<0) end= (COLOR_SIZE + 1) + end; + if (end < 0) end = (COLOR_SIZE + 1) + end; CLAMP(end, 0, COLOR_SIZE); - begin= MIN2(begin, end); + begin = MIN2(begin, end); - tuple= PyTuple_New(end - begin); - for (count= begin; count < end; count++) { + tuple = PyTuple_New(end - begin); + for (count = begin; count < end; count++) { PyTuple_SET_ITEM(tuple, count - begin, PyFloat_FromDouble(self->col[count])); } @@ -266,11 +266,11 @@ static int Color_ass_slice(ColorObject *self, int begin, int end, PyObject *seq) return -1; CLAMP(begin, 0, COLOR_SIZE); - if (end<0) end= (COLOR_SIZE + 1) + end; + if (end < 0) end = (COLOR_SIZE + 1) + end; 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)) { @@ -280,7 +280,7 @@ static int Color_ass_slice(ColorObject *self, int begin, int end, PyObject *seq) 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); @@ -392,8 +392,8 @@ static PyObject *Color_add(PyObject *v1, PyObject *v2) Py_TYPE(v1)->tp_name, Py_TYPE(v2)->tp_name); return NULL; } - color1 = (ColorObject*)v1; - color2 = (ColorObject*)v2; + color1 = (ColorObject *)v1; + color2 = (ColorObject *)v2; if (BaseMath_ReadCallback(color1) == -1 || BaseMath_ReadCallback(color2) == -1) return NULL; @@ -415,8 +415,8 @@ static PyObject *Color_iadd(PyObject *v1, PyObject *v2) Py_TYPE(v1)->tp_name, Py_TYPE(v2)->tp_name); return NULL; } - color1 = (ColorObject*)v1; - color2 = (ColorObject*)v2; + color1 = (ColorObject *)v1; + color2 = (ColorObject *)v2; if (BaseMath_ReadCallback(color1) == -1 || BaseMath_ReadCallback(color2) == -1) return NULL; @@ -441,8 +441,8 @@ static PyObject *Color_sub(PyObject *v1, PyObject *v2) Py_TYPE(v1)->tp_name, Py_TYPE(v2)->tp_name); return NULL; } - color1 = (ColorObject*)v1; - color2 = (ColorObject*)v2; + color1 = (ColorObject *)v1; + color2 = (ColorObject *)v2; if (BaseMath_ReadCallback(color1) == -1 || BaseMath_ReadCallback(color2) == -1) return NULL; @@ -455,7 +455,7 @@ static PyObject *Color_sub(PyObject *v1, PyObject *v2) /* subtraction in-place: obj -= obj */ static PyObject *Color_isub(PyObject *v1, PyObject *v2) { - ColorObject *color1= NULL, *color2= NULL; + ColorObject *color1 = NULL, *color2 = NULL; if (!ColorObject_Check(v1) || !ColorObject_Check(v2)) { PyErr_Format(PyExc_TypeError, @@ -464,8 +464,8 @@ static PyObject *Color_isub(PyObject *v1, PyObject *v2) Py_TYPE(v1)->tp_name, Py_TYPE(v2)->tp_name); return NULL; } - color1 = (ColorObject*)v1; - color2 = (ColorObject*)v2; + color1 = (ColorObject *)v1; + color2 = (ColorObject *)v2; if (BaseMath_ReadCallback(color1) == -1 || BaseMath_ReadCallback(color2) == -1) return NULL; @@ -491,12 +491,12 @@ static PyObject *Color_mul(PyObject *v1, PyObject *v2) float scalar; if ColorObject_Check(v1) { - color1= (ColorObject *)v1; + color1 = (ColorObject *)v1; if (BaseMath_ReadCallback(color1) == -1) return NULL; } if ColorObject_Check(v2) { - color2= (ColorObject *)v2; + color2 = (ColorObject *)v2; if (BaseMath_ReadCallback(color2) == -1) return NULL; } @@ -507,12 +507,12 @@ static PyObject *Color_mul(PyObject *v1, PyObject *v2) /* col * col, dont support yet! */ } else if (color1) { - if (((scalar= PyFloat_AsDouble(v2)) == -1.0f && PyErr_Occurred())==0) { /* COLOR * FLOAT */ + if (((scalar = PyFloat_AsDouble(v2)) == -1.0f && PyErr_Occurred()) == 0) { /* COLOR * FLOAT */ return color_mul_float(color1, scalar); } } else if (color2) { - if (((scalar= PyFloat_AsDouble(v1)) == -1.0f && PyErr_Occurred())==0) { /* FLOAT * COLOR */ + if (((scalar = PyFloat_AsDouble(v1)) == -1.0f && PyErr_Occurred()) == 0) { /* FLOAT * COLOR */ return color_mul_float(color2, scalar); } } @@ -533,7 +533,7 @@ static PyObject *Color_div(PyObject *v1, PyObject *v2) float scalar; if ColorObject_Check(v1) { - color1= (ColorObject *)v1; + color1 = (ColorObject *)v1; if (BaseMath_ReadCallback(color1) == -1) return NULL; } @@ -544,8 +544,8 @@ 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 = PyFloat_AsDouble(v2)) == -1.0f && PyErr_Occurred()) == 0) { /* COLOR * FLOAT */ + if (scalar == 0.0f) { PyErr_SetString(PyExc_ZeroDivisionError, "Color division: divide by zero error"); return NULL; @@ -570,7 +570,7 @@ static PyObject *Color_imul(PyObject *v1, PyObject *v2) return NULL; /* only support color *= float */ - if (((scalar= PyFloat_AsDouble(v2)) == -1.0f && PyErr_Occurred())==0) { /* COLOR *= FLOAT */ + if (((scalar = PyFloat_AsDouble(v2)) == -1.0f && PyErr_Occurred()) == 0) { /* COLOR *= FLOAT */ mul_vn_fl(color->col, COLOR_SIZE, scalar); } else { @@ -596,8 +596,8 @@ static PyObject *Color_idiv(PyObject *v1, PyObject *v2) return NULL; /* only support color /= float */ - if (((scalar= PyFloat_AsDouble(v2)) == -1.0f && PyErr_Occurred())==0) { /* COLOR /= FLOAT */ - if (scalar==0.0f) { + if (((scalar = PyFloat_AsDouble(v2)) == -1.0f && PyErr_Occurred()) == 0) { /* COLOR /= FLOAT */ + if (scalar == 0.0f) { PyErr_SetString(PyExc_ZeroDivisionError, "Color division: divide by zero error"); return NULL; @@ -619,7 +619,7 @@ static PyObject *Color_idiv(PyObject *v1, PyObject *v2) } /* -obj - returns the negative of this object*/ + returns the negative of this object */ static PyObject *Color_neg(ColorObject *self) { float tcol[COLOR_SIZE]; @@ -684,7 +684,7 @@ static int Color_channel_set(ColorObject * self, PyObject *value, void * type) static PyObject *Color_channel_hsv_get(ColorObject * self, void *type) { float hsv[3]; - int i= GET_INT_FROM_POINTER(type); + int i = GET_INT_FROM_POINTER(type); if (BaseMath_ReadCallback(self) == -1) return NULL; @@ -697,7 +697,7 @@ static PyObject *Color_channel_hsv_get(ColorObject * self, void *type) static int Color_channel_hsv_set(ColorObject * self, PyObject *value, void * type) { float hsv[3]; - int i= GET_INT_FROM_POINTER(type); + int i = GET_INT_FROM_POINTER(type); float f = PyFloat_AsDouble(value); if (f == -1 && PyErr_Occurred()) { @@ -732,7 +732,7 @@ static PyObject *Color_hsv_get(ColorObject * self, void *UNUSED(closure)) rgb_to_hsv(self->col[0], self->col[1], self->col[2], &(hsv[0]), &(hsv[1]), &(hsv[2])); - ret= PyTuple_New(3); + ret = PyTuple_New(3); PyTuple_SET_ITEM(ret, 0, PyFloat_FromDouble(hsv[0])); PyTuple_SET_ITEM(ret, 1, PyFloat_FromDouble(hsv[1])); PyTuple_SET_ITEM(ret, 2, PyFloat_FromDouble(hsv[2])); @@ -847,13 +847,13 @@ PyObject *Color_CreatePyObject(float *col, int type, PyTypeObject *base_type) { ColorObject *self; - self= base_type ? (ColorObject *)base_type->tp_alloc(base_type, 0) : + self = base_type ? (ColorObject *)base_type->tp_alloc(base_type, 0) : (ColorObject *)PyObject_GC_New(ColorObject, &color_Type); if (self) { /* init callbacks as NULL */ - self->cb_user= NULL; - self->cb_type= self->cb_subtype= 0; + self->cb_user = NULL; + self->cb_type = self->cb_subtype = 0; if (type == Py_WRAP) { self->col = col; @@ -878,12 +878,12 @@ PyObject *Color_CreatePyObject(float *col, int type, PyTypeObject *base_type) PyObject *Color_CreatePyObject_cb(PyObject *cb_user, int cb_type, int cb_subtype) { - ColorObject *self= (ColorObject *)Color_CreatePyObject(NULL, Py_NEW, NULL); + ColorObject *self = (ColorObject *)Color_CreatePyObject(NULL, Py_NEW, NULL); if (self) { Py_INCREF(cb_user); - self->cb_user= cb_user; - self->cb_type= (unsigned char)cb_type; - self->cb_subtype= (unsigned char)cb_subtype; + self->cb_user = cb_user; + self->cb_type = (unsigned char)cb_type; + self->cb_subtype = (unsigned char)cb_subtype; PyObject_GC_Track(self); } diff --git a/source/blender/python/mathutils/mathutils_Euler.c b/source/blender/python/mathutils/mathutils_Euler.c index 08e5018b789..f6bd77cd453 100644 --- a/source/blender/python/mathutils/mathutils_Euler.c +++ b/source/blender/python/mathutils/mathutils_Euler.c @@ -44,11 +44,11 @@ //makes a new euler for you to play with static PyObject *Euler_new(PyTypeObject *type, PyObject *args, PyObject *kwds) { - PyObject *seq= NULL; - const char *order_str= NULL; + PyObject *seq = NULL; + const char *order_str = NULL; - float eul[EULER_SIZE]= {0.0f, 0.0f, 0.0f}; - short order= EULER_ORDER_XYZ; + float eul[EULER_SIZE] = {0.0f, 0.0f, 0.0f}; + short order = EULER_ORDER_XYZ; if (kwds && PyDict_Size(kwds)) { PyErr_SetString(PyExc_TypeError, @@ -64,7 +64,7 @@ static PyObject *Euler_new(PyTypeObject *type, PyObject *args, PyObject *kwds) 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: @@ -79,12 +79,12 @@ static PyObject *Euler_new(PyTypeObject *type, PyObject *args, PyObject *kwds) static const char *euler_order_str(EulerObject *self) { static const char order[][4] = {"XYZ", "XZY", "YXZ", "YZX", "ZXY", "ZYX"}; - return order[self->order-EULER_ORDER_XYZ]; + return order[self->order - EULER_ORDER_XYZ]; } 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; @@ -107,15 +107,15 @@ static PyObject *Euler_ToTupleExt(EulerObject *self, int ndigits) PyObject *ret; int i; - ret= PyTuple_New(EULER_SIZE); + ret = PyTuple_New(EULER_SIZE); if (ndigits >= 0) { - for (i= 0; i < EULER_SIZE; i++) { + 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])); } } @@ -310,9 +310,9 @@ static PyObject *Euler_repr(EulerObject * self) if (BaseMath_ReadCallback(self) == -1) return NULL; - tuple= Euler_ToTupleExt(self, -1); + tuple = Euler_ToTupleExt(self, -1); - ret= PyUnicode_FromFormat("Euler(%R, '%s')", tuple, euler_order_str(self)); + ret = PyUnicode_FromFormat("Euler(%R, '%s')", tuple, euler_order_str(self)); Py_DECREF(tuple); return ret; @@ -325,7 +325,7 @@ static PyObject *Euler_str(EulerObject * self) if (BaseMath_ReadCallback(self) == -1) return NULL; - ds= BLI_dynstr_new(); + ds = BLI_dynstr_new(); BLI_dynstr_appendf(ds, "<Euler (x=%.4f, y=%.4f, z=%.4f), order='%s'>", self->eul[0], self->eul[1], self->eul[2], euler_order_str(self)); @@ -333,19 +333,19 @@ static PyObject *Euler_str(EulerObject * self) return mathutils_dynstr_to_py(ds); /* frees ds */ } -static PyObject* Euler_richcmpr(PyObject *a, PyObject *b, int op) +static PyObject *Euler_richcmpr(PyObject *a, PyObject *b, int op) { PyObject *res; - int ok= -1; /* zero is true */ + int ok = -1; /* zero is true */ if (EulerObject_Check(a) && EulerObject_Check(b)) { - EulerObject *eulA= (EulerObject*)a; - EulerObject *eulB= (EulerObject*)b; + EulerObject *eulA = (EulerObject *)a; + EulerObject *eulB = (EulerObject *)b; 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; + ok = ((eulA->order == eulB->order) && EXPP_VectorsAreEqual(eulA->eul, eulB->eul, EULER_SIZE, 1)) ? 0 : -1; } switch (op) { @@ -380,7 +380,7 @@ 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) { PyErr_SetString(PyExc_IndexError, @@ -408,7 +408,7 @@ static int Euler_ass_item(EulerObject * self, int i, PyObject *value) return -1; } - if (i<0) i= EULER_SIZE-i; + if (i < 0) i = EULER_SIZE - i; if (i < 0 || i >= EULER_SIZE) { PyErr_SetString(PyExc_IndexError, @@ -435,11 +435,11 @@ static PyObject *Euler_slice(EulerObject * self, int begin, int end) return NULL; CLAMP(begin, 0, EULER_SIZE); - if (end<0) end= (EULER_SIZE + 1) + end; + if (end < 0) end = (EULER_SIZE + 1) + end; CLAMP(end, 0, EULER_SIZE); - begin= MIN2(begin, end); + begin = MIN2(begin, end); - tuple= PyTuple_New(end - begin); + tuple = PyTuple_New(end - begin); for (count = begin; count < end; count++) { PyTuple_SET_ITEM(tuple, count - begin, PyFloat_FromDouble(self->eul[count])); } @@ -457,11 +457,11 @@ static int Euler_ass_slice(EulerObject *self, int begin, int end, PyObject *seq) return -1; CLAMP(begin, 0, EULER_SIZE); - if (end<0) end= (EULER_SIZE + 1) + end; + if (end < 0) end = (EULER_SIZE + 1) + end; 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)) { @@ -471,7 +471,7 @@ static int Euler_ass_slice(EulerObject *self, int begin, int end, PyObject *seq) 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); @@ -592,13 +592,13 @@ static PyObject *Euler_order_get(EulerObject *self, void *UNUSED(closure)) static int Euler_order_set(EulerObject *self, PyObject *value, void *UNUSED(closure)) { - const char *order_str= _PyUnicode_AsString(value); - short order= euler_order_from_string(order_str, "euler.order"); + const char *order_str = _PyUnicode_AsString(value); + short order = euler_order_from_string(order_str, "euler.order"); if (order == -1) return -1; - self->order= order; + self->order = order; (void)BaseMath_WriteCallback(self); /* order can be written back */ return 0; } @@ -693,13 +693,13 @@ PyObject *Euler_CreatePyObject(float *eul, short order, int type, PyTypeObject * { EulerObject *self; - self= base_type ? (EulerObject *)base_type->tp_alloc(base_type, 0) : + self = base_type ? (EulerObject *)base_type->tp_alloc(base_type, 0) : (EulerObject *)PyObject_GC_New(EulerObject, &euler_Type); if (self) { /* init callbacks as NULL */ - self->cb_user= NULL; - self->cb_type= self->cb_subtype= 0; + self->cb_user = NULL; + self->cb_type = self->cb_subtype = 0; if (type == Py_WRAP) { self->eul = eul; @@ -720,7 +720,7 @@ PyObject *Euler_CreatePyObject(float *eul, short order, int type, PyTypeObject * Py_FatalError("Euler(): invalid type!"); } - self->order= order; + self->order = order; } return (PyObject *)self; @@ -728,12 +728,12 @@ PyObject *Euler_CreatePyObject(float *eul, short order, int type, PyTypeObject * PyObject *Euler_CreatePyObject_cb(PyObject *cb_user, short order, int cb_type, int cb_subtype) { - EulerObject *self= (EulerObject *)Euler_CreatePyObject(NULL, order, Py_NEW, NULL); + EulerObject *self = (EulerObject *)Euler_CreatePyObject(NULL, order, Py_NEW, NULL); if (self) { Py_INCREF(cb_user); - self->cb_user= cb_user; - self->cb_type= (unsigned char)cb_type; - self->cb_subtype= (unsigned char)cb_subtype; + self->cb_user = cb_user; + self->cb_type = (unsigned char)cb_type; + self->cb_subtype = (unsigned char)cb_subtype; PyObject_GC_Track(self); } diff --git a/source/blender/python/mathutils/mathutils_Euler.h b/source/blender/python/mathutils/mathutils_Euler.h index 130384a1792..c42b0daffbc 100644 --- a/source/blender/python/mathutils/mathutils_Euler.h +++ b/source/blender/python/mathutils/mathutils_Euler.h @@ -47,7 +47,7 @@ typedef struct { /*struct data contains a pointer to the actual data that the object uses. It can use either PyMem allocated data (which will be stored in py_data) or be a wrapper for data allocated through -blender (stored in blend_data). This is an either/or struct not both*/ +blender (stored in blend_data). This is an either/or struct not both */ //prototypes PyObject *Euler_CreatePyObject( float *eul, short order, int type, PyTypeObject *base_type); diff --git a/source/blender/python/mathutils/mathutils_Matrix.c b/source/blender/python/mathutils/mathutils_Matrix.c index 07abed20ec7..307c9f8ab73 100644 --- a/source/blender/python/mathutils/mathutils_Matrix.c +++ b/source/blender/python/mathutils/mathutils_Matrix.c @@ -49,23 +49,23 @@ static PyObject *matrix__apply_to_copy(PyNoArgsFunction matrix_func, MatrixObjec static PyObject *MatrixAccess_CreatePyObject(MatrixObject *matrix, const eMatrixAccess_t type); /* matrix row callbacks */ -int mathutils_matrix_row_cb_index= -1; +int mathutils_matrix_row_cb_index = -1; static int mathutils_matrix_vector_check(BaseMathObject *bmo) { - MatrixObject *self= (MatrixObject *)bmo->cb_user; + MatrixObject *self = (MatrixObject *)bmo->cb_user; return BaseMath_ReadCallback(self); } static int mathutils_matrix_vector_get(BaseMathObject *bmo, int row) { - MatrixObject *self= (MatrixObject *)bmo->cb_user; + MatrixObject *self = (MatrixObject *)bmo->cb_user; int col; if (BaseMath_ReadCallback(self) == -1) return -1; - for (col=0; col < self->num_col; col++) { + for (col = 0; col < self->num_col; col++) { bmo->data[col] = MATRIX_ITEM(self, row, col); } @@ -74,13 +74,13 @@ static int mathutils_matrix_vector_get(BaseMathObject *bmo, int row) static int mathutils_matrix_vector_set(BaseMathObject *bmo, int row) { - MatrixObject *self= (MatrixObject *)bmo->cb_user; + MatrixObject *self = (MatrixObject *)bmo->cb_user; int col; if (BaseMath_ReadCallback(self) == -1) return -1; - for (col=0; col < self->num_col; col++) { + for (col = 0; col < self->num_col; col++) { MATRIX_ITEM(self, row, col) = bmo->data[col]; } @@ -90,18 +90,18 @@ static int mathutils_matrix_vector_set(BaseMathObject *bmo, int row) static int mathutils_matrix_vector_get_index(BaseMathObject *bmo, int row, int col) { - MatrixObject *self= (MatrixObject *)bmo->cb_user; + MatrixObject *self = (MatrixObject *)bmo->cb_user; if (BaseMath_ReadCallback(self) == -1) return -1; - bmo->data[col]= MATRIX_ITEM(self, row, col); + bmo->data[col] = MATRIX_ITEM(self, row, col); return 0; } static int mathutils_matrix_vector_set_index(BaseMathObject *bmo, int row, int col) { - MatrixObject *self= (MatrixObject *)bmo->cb_user; + MatrixObject *self = (MatrixObject *)bmo->cb_user; if (BaseMath_ReadCallback(self) == -1) return -1; @@ -122,17 +122,17 @@ Mathutils_Callback mathutils_matrix_row_cb = { /* matrix vector callbacks, this is so you can do matrix[i][j] = val */ /* matrix row callbacks */ -int mathutils_matrix_col_cb_index= -1; +int mathutils_matrix_col_cb_index = -1; static int mathutils_matrix_column_check(BaseMathObject *bmo) { - MatrixObject *self= (MatrixObject *)bmo->cb_user; + MatrixObject *self = (MatrixObject *)bmo->cb_user; return BaseMath_ReadCallback(self); } static int mathutils_matrix_column_get(BaseMathObject *bmo, int col) { - MatrixObject *self= (MatrixObject *)bmo->cb_user; + MatrixObject *self = (MatrixObject *)bmo->cb_user; int num_row; int row; @@ -151,7 +151,7 @@ static int mathutils_matrix_column_get(BaseMathObject *bmo, int col) static int mathutils_matrix_column_set(BaseMathObject *bmo, int col) { - MatrixObject *self= (MatrixObject *)bmo->cb_user; + MatrixObject *self = (MatrixObject *)bmo->cb_user; int num_row; int row; @@ -171,18 +171,18 @@ static int mathutils_matrix_column_set(BaseMathObject *bmo, int col) static int mathutils_matrix_column_get_index(BaseMathObject *bmo, int col, int row) { - MatrixObject *self= (MatrixObject *)bmo->cb_user; + MatrixObject *self = (MatrixObject *)bmo->cb_user; if (BaseMath_ReadCallback(self) == -1) return -1; - bmo->data[row]= MATRIX_ITEM(self, row, col); + bmo->data[row] = MATRIX_ITEM(self, row, col); return 0; } static int mathutils_matrix_column_set_index(BaseMathObject *bmo, int col, int row) { - MatrixObject *self= (MatrixObject *)bmo->cb_user; + MatrixObject *self = (MatrixObject *)bmo->cb_user; if (BaseMath_ReadCallback(self) == -1) return -1; @@ -219,23 +219,23 @@ static PyObject *Matrix_new(PyTypeObject *type, PyObject *args, PyObject *kwds) return Matrix_CreatePyObject(NULL, 4, 4, Py_NEW, type); case 1: { - PyObject *arg= PyTuple_GET_ITEM(args, 0); + PyObject *arg = PyTuple_GET_ITEM(args, 0); /* Input is now as a sequence of rows so length of sequence * is the number of rows */ /* -1 is an error, size checks will accunt for this */ - const unsigned short num_row= PySequence_Size(arg); + const unsigned short num_row = PySequence_Size(arg); if (num_row >= 2 && num_row <= 4) { - PyObject *item= PySequence_GetItem(arg, 0); + PyObject *item = PySequence_GetItem(arg, 0); /* Since each item is a row, number of items is the * same as the number of columns */ - const unsigned short num_col= PySequence_Size(item); + const unsigned short num_col = PySequence_Size(item); Py_XDECREF(item); if (num_col >= 2 && num_col <= 4) { /* sane row & col size, new matrix and assign as slice */ - PyObject *matrix= Matrix_CreatePyObject(NULL, num_col, num_row, Py_NEW, type); + PyObject *matrix = Matrix_CreatePyObject(NULL, num_col, num_row, Py_NEW, type); if (Matrix_ass_slice((MatrixObject *)matrix, 0, INT_MAX, arg) == 0) { return matrix; } @@ -256,8 +256,8 @@ static PyObject *Matrix_new(PyTypeObject *type, PyObject *args, PyObject *kwds) static PyObject *matrix__apply_to_copy(PyNoArgsFunction matrix_func, MatrixObject *self) { - PyObject *ret= Matrix_copy(self); - PyObject *ret_dummy= matrix_func(ret); + PyObject *ret = Matrix_copy(self); + PyObject *ret_dummy = matrix_func(ret); if (ret_dummy) { Py_DECREF(ret_dummy); return (PyObject *)ret; @@ -301,8 +301,8 @@ PyDoc_STRVAR(C_Matrix_Rotation_doc, ); static PyObject *C_Matrix_Rotation(PyObject *cls, PyObject *args) { - PyObject *vec= NULL; - const char *axis= NULL; + PyObject *vec = NULL; + const char *axis = NULL; int matSize; double angle; /* use double because of precision problems at high values */ float mat[16] = {0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, @@ -316,8 +316,8 @@ static PyObject *C_Matrix_Rotation(PyObject *cls, PyObject *args) } if (vec && PyUnicode_Check(vec)) { - axis= _PyUnicode_AsString((PyObject *)vec); - if (axis==NULL || axis[0]=='\0' || axis[1]!='\0' || axis[0] < 'X' || axis[0] > 'Z') { + axis = _PyUnicode_AsString((PyObject *)vec); + if (axis == NULL || axis[0] == '\0' || axis[1] != '\0' || axis[0] < 'X' || axis[0] > 'Z') { PyErr_SetString(PyExc_ValueError, "Matrix.Rotation(): " "3rd argument axis value must be a 3D vector " @@ -326,11 +326,11 @@ static PyObject *C_Matrix_Rotation(PyObject *cls, PyObject *args) } else { /* use the string */ - vec= NULL; + vec = NULL; } } - angle= angle_wrap_rad(angle); + angle = angle_wrap_rad(angle); if (matSize != 2 && matSize != 3 && matSize != 4) { PyErr_SetString(PyExc_ValueError, @@ -361,8 +361,8 @@ static PyObject *C_Matrix_Rotation(PyObject *cls, PyObject *args) axis_angle_to_mat3((float (*)[3])mat, tvec, angle); } else if (matSize == 2) { - const float angle_cos= cosf(angle); - const float angle_sin= sinf(angle); + const float angle_cos = cosf(angle); + const float angle_sin = sinf(angle); //2D rotation matrix mat[0] = angle_cos; @@ -420,7 +420,7 @@ PyDoc_STRVAR(C_Matrix_Scale_doc, ); static PyObject *C_Matrix_Scale(PyObject *cls, PyObject *args) { - PyObject *vec= NULL; + PyObject *vec = NULL; int vec_size; float tvec[3]; float factor; @@ -438,7 +438,7 @@ static PyObject *C_Matrix_Scale(PyObject *cls, PyObject *args) return NULL; } if (vec) { - vec_size= (matSize == 2 ? 2 : 3); + vec_size = (matSize == 2 ? 2 : 3); if (mathutils_array_parse(tvec, vec_size, vec_size, vec, "Matrix.Scale(factor, size, axis), invalid 'axis' arg") == -1) { return NULL; } @@ -526,13 +526,13 @@ static PyObject *C_Matrix_OrthoProjection(PyObject *cls, PyObject *args) if (PyUnicode_Check(axis)) { //ortho projection onto cardinal plane Py_ssize_t plane_len; - const char *plane= _PyUnicode_AsStringAndSize(axis, &plane_len); + const char *plane = _PyUnicode_AsStringAndSize(axis, &plane_len); if (matSize == 2) { - if (plane_len == 1 && plane[0]=='X') { - mat[0]= 1.0f; + if (plane_len == 1 && plane[0] == 'X') { + mat[0] = 1.0f; } - else if (plane_len == 1 && plane[0]=='Y') { - mat[3]= 1.0f; + else if (plane_len == 1 && plane[0] == 'Y') { + mat[3] = 1.0f; } else { PyErr_Format(PyExc_ValueError, @@ -543,17 +543,17 @@ static PyObject *C_Matrix_OrthoProjection(PyObject *cls, PyObject *args) } } else { - if (plane_len == 2 && plane[0]=='X' && plane[1]=='Y') { - mat[0]= 1.0f; - mat[4]= 1.0f; + if (plane_len == 2 && plane[0] == 'X' && plane[1] == 'Y') { + mat[0] = 1.0f; + mat[4] = 1.0f; } - else if (plane_len == 2 && plane[0]=='X' && plane[1]=='Z') { - mat[0]= 1.0f; - mat[8]= 1.0f; + else if (plane_len == 2 && plane[0] == 'X' && plane[1] == 'Z') { + mat[0] = 1.0f; + mat[8] = 1.0f; } - else if (plane_len == 2 && plane[0]=='Y' && plane[1]=='Z') { - mat[4]= 1.0f; - mat[8]= 1.0f; + else if (plane_len == 2 && plane[0] == 'Y' && plane[1] == 'Z') { + mat[4] = 1.0f; + mat[8] = 1.0f; } else { PyErr_Format(PyExc_ValueError, @@ -567,7 +567,7 @@ static PyObject *C_Matrix_OrthoProjection(PyObject *cls, PyObject *args) else { //arbitrary plane - int vec_size= (matSize == 2 ? 2 : 3); + int vec_size = (matSize == 2 ? 2 : 3); float tvec[4]; if (mathutils_array_parse(tvec, vec_size, vec_size, axis, @@ -644,9 +644,9 @@ static PyObject *C_Matrix_Shear(PyObject *cls, PyObject *args) } if (matSize == 2) { - float const factor= PyFloat_AsDouble(fac); + float const factor = PyFloat_AsDouble(fac); - if (factor==-1.0f && PyErr_Occurred()) { + if (factor == -1.0f && PyErr_Occurred()) { PyErr_SetString(PyExc_TypeError, "Matrix.Shear(): " "the factor to be a float"); @@ -751,7 +751,7 @@ static PyObject *Matrix_to_quaternion(MatrixObject *self) if (BaseMath_ReadCallback(self) == -1) return NULL; - /*must be 3-4 cols, 3-4 rows, square matrix*/ + /* must be 3-4 cols, 3-4 rows, square matrix */ if ((self->num_row < 3) || (self->num_col < 3) || (self->num_row != self->num_col)) { PyErr_SetString(PyExc_ValueError, "Matrix.to_quat(): " @@ -787,8 +787,8 @@ PyDoc_STRVAR(Matrix_to_euler_doc, ); static PyObject *Matrix_to_euler(MatrixObject *self, PyObject *args) { - const char *order_str= NULL; - short order= EULER_ORDER_XYZ; + const char *order_str = NULL; + short order = EULER_ORDER_XYZ; float eul[3], eul_compatf[3]; EulerObject *eul_compat = NULL; @@ -808,13 +808,13 @@ static PyObject *Matrix_to_euler(MatrixObject *self, PyObject *args) copy_v3_v3(eul_compatf, eul_compat->eul); } - /*must be 3-4 cols, 3-4 rows, square matrix*/ + /*must be 3-4 cols, 3-4 rows, square matrix */ if (self->num_row ==3 && self->num_col ==3) { - mat= (float (*)[3])self->matrix; + mat = (float (*)[3])self->matrix; } else if (self->num_row ==4 && self->num_col ==4) { copy_m3_m4(tmat, (float (*)[4])self->matrix); - mat= tmat; + mat = tmat; } else { PyErr_SetString(PyExc_ValueError, @@ -824,7 +824,7 @@ static PyObject *Matrix_to_euler(MatrixObject *self, PyObject *args) } if (order_str) { - order= euler_order_from_string(order_str, "Matrix.to_euler()"); + order = euler_order_from_string(order_str, "Matrix.to_euler()"); if (order == -1) return NULL; @@ -849,10 +849,10 @@ PyDoc_STRVAR(Matrix_resize_4x4_doc, ); static PyObject *Matrix_resize_4x4(MatrixObject *self) { - float mat[4][4]= MAT4_UNITY; + float mat[4][4] = MAT4_UNITY; int col; - if (self->wrapped==Py_WRAP) { + if (self->wrapped == Py_WRAP) { PyErr_SetString(PyExc_TypeError, "Matrix.resize_4x4(): " "cannot resize wrapped data - make a copy and resize that"); @@ -898,10 +898,10 @@ static PyObject *Matrix_to_4x4(MatrixObject *self) if (BaseMath_ReadCallback(self) == -1) return NULL; - if (self->num_row==4 && self->num_col==4) { + if (self->num_row == 4 && self->num_col == 4) { return Matrix_CreatePyObject(self->matrix, 4, 4, Py_NEW, Py_TYPE(self)); } - else if (self->num_row==3 && self->num_col==3) { + else if (self->num_row == 3 && self->num_col == 3) { float mat[4][4]; copy_m4_m3(mat, (float (*)[3])self->matrix); return Matrix_CreatePyObject((float *)mat, 4, 4, Py_NEW, Py_TYPE(self)); @@ -982,7 +982,7 @@ static PyObject *Matrix_to_scale(MatrixObject *self) if (BaseMath_ReadCallback(self) == -1) return NULL; - /*must be 3-4 cols, 3-4 rows, square matrix*/ + /*must be 3-4 cols, 3-4 rows, square matrix */ if ((self->num_row < 3) || (self->num_col < 3)) { PyErr_SetString(PyExc_TypeError, "Matrix.to_scale(): " @@ -1028,11 +1028,11 @@ static PyObject *Matrix_invert(MatrixObject *self) return NULL; } - /*calculate the determinant*/ + /* calculate the determinant */ det = matrix_determinant_internal(self); if (det != 0) { - /*calculate the classical adjoint*/ + /* calculate the classical adjoint */ if (self->num_col == 2) { mat[0] = MATRIX_ITEM(self, 1, 1); mat[1] = -MATRIX_ITEM(self, 0, 1); @@ -1045,11 +1045,11 @@ static PyObject *Matrix_invert(MatrixObject *self) else if (self->num_col == 4) { adjoint_m4_m4((float (*)[4]) mat, (float (*)[4])self->matrix); } - /*divide by determinate*/ + /* divide by determinate */ for (x = 0; x < (self->num_col * self->num_row); x++) { mat[x] /= det; } - /*set values*/ + /* set values */ for (x = 0; x < self->num_col; x++) { for (y = 0; y < self->num_row; y++) { MATRIX_ITEM(self, y, x) = mat[z]; @@ -1151,7 +1151,7 @@ static PyObject *Matrix_decompose(MatrixObject *self) mat4_to_loc_rot_size(loc, rot, size, (float (*)[4])self->matrix); mat3_to_quat(quat, rot); - ret= PyTuple_New(3); + ret = PyTuple_New(3); PyTuple_SET_ITEM(ret, 0, Vector_CreatePyObject(loc, 3, Py_NEW, NULL)); PyTuple_SET_ITEM(ret, 1, Quaternion_CreatePyObject(quat, Py_NEW, NULL)); PyTuple_SET_ITEM(ret, 2, Vector_CreatePyObject(size, 3, Py_NEW, NULL)); @@ -1176,7 +1176,7 @@ PyDoc_STRVAR(Matrix_lerp_doc, static PyObject *Matrix_lerp(MatrixObject *self, PyObject *args) { MatrixObject *mat2 = NULL; - float fac, mat[MATRIX_MAX_DIM*MATRIX_MAX_DIM]; + float fac, mat[MATRIX_MAX_DIM * MATRIX_MAX_DIM]; if (!PyArg_ParseTuple(args, "O!f:lerp", &matrix_Type, &mat2, &fac)) return NULL; @@ -1192,10 +1192,10 @@ static PyObject *Matrix_lerp(MatrixObject *self, PyObject *args) return NULL; /* TODO, different sized matrix */ - if (self->num_col==4 && self->num_row==4) { + if (self->num_col == 4 && self->num_row == 4) { blend_m4_m4m4((float (*)[4])mat, (float (*)[4])self->matrix, (float (*)[4])mat2->matrix, fac); } - else if (self->num_col==3 && self->num_row==3) { + else if (self->num_col == 3 && self->num_row == 3) { blend_m3_m3m3((float (*)[3])mat, (float (*)[3])self->matrix, (float (*)[3])mat2->matrix, fac); } else { @@ -1360,17 +1360,17 @@ static PyObject *Matrix_copy(MatrixObject *self) } /*----------------------------print object (internal)-------------*/ -/*print the object to screen*/ +/* print the object to screen */ static PyObject *Matrix_repr(MatrixObject *self) { int col, row; - PyObject *rows[MATRIX_MAX_DIM]= {NULL}; + PyObject *rows[MATRIX_MAX_DIM] = {NULL}; if (BaseMath_ReadCallback(self) == -1) return NULL; for (row = 0; row < self->num_row; row++) { - rows[row]= PyTuple_New(self->num_col); + rows[row] = PyTuple_New(self->num_col); for (col = 0; col < self->num_col; col++) { PyTuple_SET_ITEM(rows[row], col, PyFloat_FromDouble(MATRIX_ITEM(self, row, col))); } @@ -1393,7 +1393,7 @@ static PyObject *Matrix_repr(MatrixObject *self) return NULL; } -static PyObject* Matrix_str(MatrixObject *self) +static PyObject *Matrix_str(MatrixObject *self) { DynStr *ds; @@ -1405,14 +1405,14 @@ static PyObject* Matrix_str(MatrixObject *self) if (BaseMath_ReadCallback(self) == -1) return NULL; - ds= BLI_dynstr_new(); + ds = BLI_dynstr_new(); /* First determine the maximum width for each column */ for (col = 0; col < self->num_col; col++) { - maxsize[col]= 0; + maxsize[col] = 0; for (row = 0; row < self->num_row; row++) { - int size= BLI_snprintf(dummy_buf, sizeof(dummy_buf), "%.4f", MATRIX_ITEM(self, row, col)); - maxsize[col]= MAX2(maxsize[col], size); + int size = BLI_snprintf(dummy_buf, sizeof(dummy_buf), "%.4f", MATRIX_ITEM(self, row, col)); + maxsize[col] = MAX2(maxsize[col], size); } } @@ -1429,21 +1429,21 @@ static PyObject* Matrix_str(MatrixObject *self) return mathutils_dynstr_to_py(ds); /* frees ds */ } -static PyObject* Matrix_richcmpr(PyObject *a, PyObject *b, int op) +static PyObject *Matrix_richcmpr(PyObject *a, PyObject *b, int op) { PyObject *res; - int ok= -1; /* zero is true */ + int ok = -1; /* zero is true */ if (MatrixObject_Check(a) && MatrixObject_Check(b)) { - MatrixObject *matA= (MatrixObject*)a; - MatrixObject *matB= (MatrixObject*)b; + MatrixObject *matA = (MatrixObject *)a; + MatrixObject *matB = (MatrixObject *)b; if (BaseMath_ReadCallback(matA) == -1 || BaseMath_ReadCallback(matB) == -1) return NULL; - ok= ( (matA->num_row == matB->num_row) && - (matA->num_col == matB->num_col) && - EXPP_VectorsAreEqual(matA->matrix, matB->matrix, (matA->num_col * matA->num_row), 1) + ok = ( (matA->num_row == matB->num_row) && + (matA->num_col == matB->num_col) && + EXPP_VectorsAreEqual(matA->matrix, matB->matrix, (matA->num_col * matA->num_row), 1) ) ? 0 : -1; } @@ -1470,14 +1470,14 @@ static PyObject* Matrix_richcmpr(PyObject *a, PyObject *b, int op) /*---------------------SEQUENCE PROTOCOLS------------------------ ----------------------------len(object)------------------------ - sequence length*/ + sequence length */ static int Matrix_len(MatrixObject *self) { return (self->num_row); } /*----------------------------object[]--------------------------- sequence accessor (get) - the wrapped vector gives direct access to the matrix data*/ + the wrapped vector gives direct access to the matrix data */ static PyObject *Matrix_item_row(MatrixObject *self, int row) { if (BaseMath_ReadCallback(self) == -1) @@ -1574,10 +1574,10 @@ static PyObject *Matrix_slice(MatrixObject *self, int begin, int end) CLAMP(begin, 0, self->num_row); CLAMP(end, 0, self->num_row); - begin= MIN2(begin, end); + begin = MIN2(begin, end); - tuple= PyTuple_New(end - begin); - for (count= begin; count < end; count++) { + tuple = PyTuple_New(end - begin); + for (count = begin; count < end; count++) { PyTuple_SET_ITEM(tuple, count - begin, Vector_CreatePyObject_cb((PyObject *)self, self->num_col, mathutils_matrix_row_cb_index, count)); @@ -1589,7 +1589,7 @@ static PyObject *Matrix_slice(MatrixObject *self, int begin, int end) sequence slice (set)*/ static int Matrix_ass_slice(MatrixObject *self, int begin, int end, PyObject *value) { - PyObject *value_fast= NULL; + PyObject *value_fast = NULL; if (BaseMath_ReadCallback(self) == -1) return -1; @@ -1599,12 +1599,12 @@ static int Matrix_ass_slice(MatrixObject *self, int begin, int end, PyObject *va begin = MIN2(begin, end); /* non list/tuple cases */ - if (!(value_fast=PySequence_Fast(value, "matrix[begin:end] = value"))) { + if (!(value_fast = PySequence_Fast(value, "matrix[begin:end] = value"))) { /* PySequence_Fast sets the error */ return -1; } else { - const int size= end - begin; + const int size = end - begin; int row, col; float mat[16]; float vec[4]; @@ -1619,10 +1619,10 @@ static int Matrix_ass_slice(MatrixObject *self, int begin, int end, PyObject *va memcpy(mat, self->matrix, self->num_col * self->num_row * sizeof(float)); - /*parse sub items*/ + /* parse sub items */ for (row = begin; row < end; row++) { - /*parse each sub sequence*/ - PyObject *item= PySequence_Fast_GET_ITEM(value_fast, row - begin); + /* parse each sub sequence */ + PyObject *item = PySequence_Fast_GET_ITEM(value_fast, row - begin); if (mathutils_array_parse(vec, self->num_col, self->num_col, item, "matrix[begin:end] = value assignment") < 0) return -1; @@ -1648,8 +1648,8 @@ static PyObject *Matrix_add(PyObject *m1, PyObject *m2) float mat[16]; MatrixObject *mat1 = NULL, *mat2 = NULL; - mat1 = (MatrixObject*)m1; - mat2 = (MatrixObject*)m2; + mat1 = (MatrixObject *)m1; + mat2 = (MatrixObject *)m2; if (!MatrixObject_Check(m1) || !MatrixObject_Check(m2)) { PyErr_Format(PyExc_TypeError, @@ -1680,8 +1680,8 @@ static PyObject *Matrix_sub(PyObject *m1, PyObject *m2) float mat[16]; MatrixObject *mat1 = NULL, *mat2 = NULL; - mat1 = (MatrixObject*)m1; - mat2 = (MatrixObject*)m2; + mat1 = (MatrixObject *)m1; + mat2 = (MatrixObject *)m2; if (!MatrixObject_Check(m1) || !MatrixObject_Check(m2)) { PyErr_Format(PyExc_TypeError, @@ -1723,22 +1723,22 @@ static PyObject *Matrix_mul(PyObject *m1, PyObject *m2) MatrixObject *mat1 = NULL, *mat2 = NULL; if (MatrixObject_Check(m1)) { - mat1 = (MatrixObject*)m1; + mat1 = (MatrixObject *)m1; if (BaseMath_ReadCallback(mat1) == -1) return NULL; } if (MatrixObject_Check(m2)) { - mat2 = (MatrixObject*)m2; + mat2 = (MatrixObject *)m2; if (BaseMath_ReadCallback(mat2) == -1) return NULL; } if (mat1 && mat2) { - /*MATRIX * MATRIX*/ - float mat[16]= {0.0f, 0.0f, 0.0f, 0.0f, - 0.0f, 0.0f, 0.0f, 0.0f, - 0.0f, 0.0f, 0.0f, 0.0f, - 0.0f, 0.0f, 0.0f, 1.0f}; + /* MATRIX * MATRIX */ + float mat[16] = {0.0f, 0.0f, 0.0f, 0.0f, + 0.0f, 0.0f, 0.0f, 0.0f, + 0.0f, 0.0f, 0.0f, 0.0f, + 0.0f, 0.0f, 0.0f, 1.0f}; double dot = 0.0f; int col, row, item; @@ -1763,14 +1763,14 @@ static PyObject *Matrix_mul(PyObject *m1, PyObject *m2) } else if (mat2) { /*FLOAT/INT * MATRIX */ - if (((scalar= PyFloat_AsDouble(m1)) == -1.0f && PyErr_Occurred())==0) { + if (((scalar = PyFloat_AsDouble(m1)) == -1.0f && PyErr_Occurred()) == 0) { return matrix_mul_float(mat2, scalar); } } else if (mat1) { /* MATRIX * VECTOR */ if (VectorObject_Check(m2)) { - VectorObject *vec2= (VectorObject *)m2; + VectorObject *vec2 = (VectorObject *)m2; float tvec[4]; if (BaseMath_ReadCallback(vec2) == -1) return NULL; @@ -1788,7 +1788,7 @@ static PyObject *Matrix_mul(PyObject *m1, PyObject *m2) return Vector_CreatePyObject(tvec, vec_size, Py_NEW, Py_TYPE(m2)); } /*FLOAT/INT * MATRIX */ - else if (((scalar= PyFloat_AsDouble(m2)) == -1.0f && PyErr_Occurred())==0) { + else if (((scalar = PyFloat_AsDouble(m2)) == -1.0f && PyErr_Occurred()) == 0) { return matrix_mul_float(mat1, scalar); } } @@ -1802,7 +1802,7 @@ static PyObject *Matrix_mul(PyObject *m1, PyObject *m2) Py_TYPE(m1)->tp_name, Py_TYPE(m2)->tp_name); return NULL; } -static PyObject* Matrix_inv(MatrixObject *self) +static PyObject *Matrix_inv(MatrixObject *self) { if (BaseMath_ReadCallback(self) == -1) return NULL; @@ -1825,7 +1825,7 @@ static PySequenceMethods Matrix_SeqMethods = { }; -static PyObject *Matrix_subscript(MatrixObject* self, PyObject* item) +static PyObject *Matrix_subscript(MatrixObject *self, PyObject *item) { if (PyIndex_Check(item)) { Py_ssize_t i; @@ -1862,7 +1862,7 @@ static PyObject *Matrix_subscript(MatrixObject* self, PyObject* item) } } -static int Matrix_ass_subscript(MatrixObject* self, PyObject* item, PyObject* value) +static int Matrix_ass_subscript(MatrixObject *self, PyObject *item, PyObject *value) { if (PyIndex_Check(item)) { Py_ssize_t i = PyNumber_AsSsize_t(item, PyExc_IndexError); @@ -2188,16 +2188,16 @@ PyObject *Matrix_CreatePyObject(float *mat, return NULL; } - self= base_type ? (MatrixObject *)base_type->tp_alloc(base_type, 0) : - (MatrixObject *)PyObject_GC_New(MatrixObject, &matrix_Type); + self = base_type ? (MatrixObject *)base_type->tp_alloc(base_type, 0) : + (MatrixObject *)PyObject_GC_New(MatrixObject, &matrix_Type); if (self) { self->num_col = num_col; self->num_row = num_row; /* init callbacks as NULL */ - self->cb_user= NULL; - self->cb_type= self->cb_subtype= 0; + self->cb_user = NULL; + self->cb_type = self->cb_subtype = 0; if (type == Py_WRAP) { self->matrix = mat; @@ -2217,7 +2217,7 @@ PyObject *Matrix_CreatePyObject(float *mat, } else if (num_col == num_row) { /* or if no arguments are passed return identity matrix for square matrices */ - PyObject *ret_dummy= Matrix_identity(self); + PyObject *ret_dummy = Matrix_identity(self); Py_DECREF(ret_dummy); } else { @@ -2238,12 +2238,12 @@ PyObject *Matrix_CreatePyObject_cb(PyObject *cb_user, const unsigned short num_col, const unsigned short num_row, int cb_type, int cb_subtype) { - MatrixObject *self= (MatrixObject *)Matrix_CreatePyObject(NULL, num_col, num_row, Py_NEW, NULL); + MatrixObject *self = (MatrixObject *)Matrix_CreatePyObject(NULL, num_col, num_row, Py_NEW, NULL); if (self) { Py_INCREF(cb_user); - self->cb_user= cb_user; - self->cb_type= (unsigned char)cb_type; - self->cb_subtype= (unsigned char)cb_subtype; + self->cb_user = cb_user; + self->cb_type = (unsigned char)cb_type; + self->cb_subtype = (unsigned char)cb_subtype; PyObject_GC_Track(self); } return (PyObject *) self; @@ -2290,9 +2290,9 @@ static int MatrixAccess_len(MatrixAccessObject *self) self->matrix_user->num_col; } -static PyObject *MatrixAccess_subscript(MatrixAccessObject* self, PyObject* item) +static PyObject *MatrixAccess_subscript(MatrixAccessObject *self, PyObject *item) { - MatrixObject *matrix_user= self->matrix_user; + MatrixObject *matrix_user = self->matrix_user; if (PyIndex_Check(item)) { Py_ssize_t i; @@ -2319,9 +2319,9 @@ static PyObject *MatrixAccess_subscript(MatrixAccessObject* self, PyObject* item } } -static int MatrixAccess_ass_subscript(MatrixAccessObject* self, PyObject* item, PyObject* value) +static int MatrixAccess_ass_subscript(MatrixAccessObject *self, PyObject *item, PyObject *value) { - MatrixObject *matrix_user= self->matrix_user; + MatrixObject *matrix_user = self->matrix_user; if (PyIndex_Check(item)) { Py_ssize_t i = PyNumber_AsSsize_t(item, PyExc_IndexError); @@ -2385,12 +2385,12 @@ PyTypeObject matrix_access_Type = { static PyObject *MatrixAccess_CreatePyObject(MatrixObject *matrix, const eMatrixAccess_t type) { - MatrixAccessObject *matrix_access= (MatrixAccessObject *)PyObject_GC_New(MatrixObject, &matrix_access_Type); + MatrixAccessObject *matrix_access = (MatrixAccessObject *)PyObject_GC_New(MatrixObject, &matrix_access_Type); - matrix_access->matrix_user= matrix; + matrix_access->matrix_user = matrix; Py_INCREF(matrix); - matrix_access->type= type; + matrix_access->type = type; return (PyObject *)matrix_access; } diff --git a/source/blender/python/mathutils/mathutils_Quaternion.c b/source/blender/python/mathutils/mathutils_Quaternion.c index 2dd266d83fb..a563e280f1c 100644 --- a/source/blender/python/mathutils/mathutils_Quaternion.c +++ b/source/blender/python/mathutils/mathutils_Quaternion.c @@ -51,15 +51,15 @@ static PyObject *Quaternion_to_tuple_ext(QuaternionObject *self, int ndigits) PyObject *ret; int i; - ret= PyTuple_New(QUAT_SIZE); + ret = PyTuple_New(QUAT_SIZE); if (ndigits >= 0) { - for (i= 0; i < QUAT_SIZE; i++) { + 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])); } } @@ -86,8 +86,8 @@ static PyObject *Quaternion_to_euler(QuaternionObject *self, PyObject *args) { float tquat[4]; float eul[3]; - const char *order_str= NULL; - short order= EULER_ORDER_XYZ; + const char *order_str = NULL; + short order = EULER_ORDER_XYZ; EulerObject *eul_compat = NULL; if (!PyArg_ParseTuple(args, "|sO!:to_euler", &order_str, &euler_Type, &eul_compat)) @@ -97,7 +97,7 @@ static PyObject *Quaternion_to_euler(QuaternionObject *self, PyObject *args) return NULL; if (order_str) { - order= euler_order_from_string(order_str, "Matrix.to_euler()"); + order = euler_order_from_string(order_str, "Matrix.to_euler()"); if (order == -1) return NULL; @@ -169,7 +169,7 @@ static PyObject *Quaternion_to_axis_angle(QuaternionObject *self) quat__axis_angle_sanitize(axis, &angle); - ret= PyTuple_New(2); + ret = PyTuple_New(2); PyTuple_SET_ITEM(ret, 0, Vector_CreatePyObject(axis, 3, Py_NEW, NULL)); PyTuple_SET_ITEM(ret, 1, PyFloat_FromDouble(angle)); return ret; @@ -320,7 +320,7 @@ static PyObject *Quaternion_rotate(QuaternionObject *self, PyObject *value) if (mathutils_any_to_rotmat(other_rmat, value, "Quaternion.rotate(value)") == -1) return NULL; - length= normalize_qt_qt(tquat, self->quat); + length = normalize_qt_qt(tquat, self->quat); quat_to_mat3(self_rmat, tquat); mul_m3_m3m3(rmat, other_rmat, self_rmat); @@ -486,9 +486,9 @@ static PyObject *Quaternion_repr(QuaternionObject *self) if (BaseMath_ReadCallback(self) == -1) return NULL; - tuple= Quaternion_to_tuple_ext(self, -1); + tuple = Quaternion_to_tuple_ext(self, -1); - ret= PyUnicode_FromFormat("Quaternion(%R)", tuple); + ret = PyUnicode_FromFormat("Quaternion(%R)", tuple); Py_DECREF(tuple); return ret; @@ -501,7 +501,7 @@ static PyObject *Quaternion_str(QuaternionObject *self) if (BaseMath_ReadCallback(self) == -1) return NULL; - ds= BLI_dynstr_new(); + ds = BLI_dynstr_new(); BLI_dynstr_appendf(ds, "<Quaternion (w=%.4f, x=%.4f, y=%.4f, z=%.4f)>", self->quat[0], self->quat[1], self->quat[2], self->quat[3]); @@ -509,19 +509,19 @@ static PyObject *Quaternion_str(QuaternionObject *self) return mathutils_dynstr_to_py(ds); /* frees ds */ } -static PyObject* Quaternion_richcmpr(PyObject *a, PyObject *b, int op) +static PyObject *Quaternion_richcmpr(PyObject *a, PyObject *b, int op) { PyObject *res; - int ok= -1; /* zero is true */ + int ok = -1; /* zero is true */ if (QuaternionObject_Check(a) && QuaternionObject_Check(b)) { - QuaternionObject *quatA= (QuaternionObject *)a; - QuaternionObject *quatB= (QuaternionObject *)b; + QuaternionObject *quatA = (QuaternionObject *)a; + QuaternionObject *quatB = (QuaternionObject *)b; if (BaseMath_ReadCallback(quatA) == -1 || BaseMath_ReadCallback(quatB) == -1) return NULL; - ok= (EXPP_VectorsAreEqual(quatA->quat, quatB->quat, QUAT_SIZE, 1)) ? 0 : -1; + ok = (EXPP_VectorsAreEqual(quatA->quat, quatB->quat, QUAT_SIZE, 1)) ? 0 : -1; } switch (op) { @@ -556,7 +556,7 @@ 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) { PyErr_SetString(PyExc_IndexError, @@ -575,15 +575,15 @@ static PyObject *Quaternion_item(QuaternionObject *self, int i) //sequence accessor (set) 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 */ + float scalar = (float)PyFloat_AsDouble(ob); + 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) { PyErr_SetString(PyExc_IndexError, @@ -609,12 +609,12 @@ static PyObject *Quaternion_slice(QuaternionObject *self, int begin, int end) return NULL; CLAMP(begin, 0, QUAT_SIZE); - if (end<0) end= (QUAT_SIZE + 1) + end; + if (end < 0) end = (QUAT_SIZE + 1) + end; CLAMP(end, 0, QUAT_SIZE); - begin= MIN2(begin, end); + begin = MIN2(begin, end); - tuple= PyTuple_New(end - begin); - for (count= begin; count < end; count++) { + tuple = PyTuple_New(end - begin); + for (count = begin; count < end; count++) { PyTuple_SET_ITEM(tuple, count - begin, PyFloat_FromDouble(self->quat[count])); } @@ -631,11 +631,11 @@ static int Quaternion_ass_slice(QuaternionObject *self, int begin, int end, PyOb return -1; CLAMP(begin, 0, QUAT_SIZE); - if (end<0) end= (QUAT_SIZE + 1) + end; + if (end < 0) end = (QUAT_SIZE + 1) + end; 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)) { @@ -646,7 +646,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); @@ -809,7 +809,7 @@ static PyObject *Quaternion_mul(PyObject *q1, PyObject *q2) } /* 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) { + if (((scalar = PyFloat_AsDouble(q1)) == -1.0f && PyErr_Occurred()) == 0) { return quat_mul_float(quat2, scalar); } } @@ -836,7 +836,7 @@ static PyObject *Quaternion_mul(PyObject *q1, PyObject *q2) return Vector_CreatePyObject(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); } } @@ -950,7 +950,7 @@ static PyObject *Quaternion_angle_get(QuaternionObject *self, void *UNUSED(closu normalize_qt_qt(tquat, self->quat); - angle= 2.0f * saacos(tquat[0]); + angle = 2.0f * saacos(tquat[0]); quat__axis_angle_sanitize(NULL, &angle); @@ -968,18 +968,18 @@ static int Quaternion_angle_set(QuaternionObject *self, PyObject *value, void *U if (BaseMath_ReadCallback(self) == -1) return -1; - len= normalize_qt_qt(tquat, self->quat); + len = normalize_qt_qt(tquat, self->quat); quat_to_axis_angle(axis, &angle_dummy, tquat); - angle= PyFloat_AsDouble(value); + angle = PyFloat_AsDouble(value); - if (angle==-1.0f && PyErr_Occurred()) { /* parsed item not a number */ + if (angle == -1.0f && PyErr_Occurred()) { /* parsed item not a number */ PyErr_SetString(PyExc_TypeError, "Quaternion.angle = value: float expected"); return -1; } - angle= angle_wrap_rad(angle); + angle = angle_wrap_rad(angle); quat__axis_angle_sanitize(axis, &angle); @@ -1021,7 +1021,7 @@ static int Quaternion_axis_vector_set(QuaternionObject *self, PyObject *value, v if (BaseMath_ReadCallback(self) == -1) return -1; - len= normalize_qt_qt(tquat, self->quat); + len = normalize_qt_qt(tquat, self->quat); quat_to_axis_angle(axis, &angle, tquat); /* axis value is unused */ if (mathutils_array_parse(axis, 3, 3, value, "quat.axis = other") == -1) @@ -1041,9 +1041,9 @@ static int Quaternion_axis_vector_set(QuaternionObject *self, PyObject *value, v //----------------------------------mathutils.Quaternion() -------------- static PyObject *Quaternion_new(PyTypeObject *type, PyObject *args, PyObject *kwds) { - PyObject *seq= NULL; + PyObject *seq = NULL; double angle = 0.0f; - float quat[QUAT_SIZE]= {0.0f, 0.0f, 0.0f, 0.0f}; + float quat[QUAT_SIZE] = {0.0f, 0.0f, 0.0f, 0.0f}; if (kwds && PyDict_Size(kwds)) { PyErr_SetString(PyExc_TypeError, @@ -1065,7 +1065,7 @@ static PyObject *Quaternion_new(PyTypeObject *type, PyObject *args, PyObject *kw case 2: if (mathutils_array_parse(quat, 3, 3, seq, "mathutils.Quaternion()") == -1) return NULL; - angle= angle_wrap_rad(angle); /* clamp because of precision issues */ + angle = angle_wrap_rad(angle); /* clamp because of precision issues */ axis_angle_to_quat(quat, quat, angle); break; /* PyArg_ParseTuple assures no more then 2 */ @@ -1075,8 +1075,8 @@ static PyObject *Quaternion_new(PyTypeObject *type, PyObject *args, PyObject *kw static PyObject *quat__apply_to_copy(PyNoArgsFunction quat_func, QuaternionObject *self) { - PyObject *ret= Quaternion_copy(self); - PyObject *ret_dummy= quat_func(ret); + PyObject *ret = Quaternion_copy(self); + PyObject *ret_dummy = quat_func(ret); if (ret_dummy) { Py_DECREF(ret_dummy); return ret; @@ -1095,9 +1095,9 @@ static void quat__axis_angle_sanitize(float axis[3], float *angle) !finite(axis[1]) || !finite(axis[2])) { - axis[0]= 1.0f; - axis[1]= 0.0f; - axis[2]= 0.0f; + axis[0] = 1.0f; + axis[1] = 0.0f; + axis[2] = 0.0f; } else if ( EXPP_FloatsAreEqual(axis[0], 0.0f, 10) && EXPP_FloatsAreEqual(axis[1], 0.0f, 10) && @@ -1109,7 +1109,7 @@ static void quat__axis_angle_sanitize(float axis[3], float *angle) if (angle) { if (!finite(*angle)) { - *angle= 0.0f; + *angle = 0.0f; } } } @@ -1225,13 +1225,13 @@ PyObject *Quaternion_CreatePyObject(float *quat, int type, PyTypeObject *base_ty { QuaternionObject *self; - self= base_type ? (QuaternionObject *)base_type->tp_alloc(base_type, 0) : - (QuaternionObject *)PyObject_GC_New(QuaternionObject, &quaternion_Type); + self = base_type ? (QuaternionObject *)base_type->tp_alloc(base_type, 0) : + (QuaternionObject *)PyObject_GC_New(QuaternionObject, &quaternion_Type); if (self) { /* init callbacks as NULL */ - self->cb_user= NULL; - self->cb_type= self->cb_subtype= 0; + self->cb_user = NULL; + self->cb_type = self->cb_subtype = 0; if (type == Py_WRAP) { self->quat = quat; @@ -1256,12 +1256,12 @@ PyObject *Quaternion_CreatePyObject(float *quat, int type, PyTypeObject *base_ty PyObject *Quaternion_CreatePyObject_cb(PyObject *cb_user, int cb_type, int cb_subtype) { - QuaternionObject *self= (QuaternionObject *)Quaternion_CreatePyObject(NULL, Py_NEW, NULL); + QuaternionObject *self = (QuaternionObject *)Quaternion_CreatePyObject(NULL, Py_NEW, NULL); if (self) { Py_INCREF(cb_user); - self->cb_user= cb_user; - self->cb_type= (unsigned char)cb_type; - self->cb_subtype= (unsigned char)cb_subtype; + self->cb_user = cb_user; + self->cb_type = (unsigned char)cb_type; + self->cb_subtype = (unsigned char)cb_subtype; PyObject_GC_Track(self); } diff --git a/source/blender/python/mathutils/mathutils_Vector.c b/source/blender/python/mathutils/mathutils_Vector.c index 69e51832bda..f5d4ca7ec4e 100644 --- a/source/blender/python/mathutils/mathutils_Vector.c +++ b/source/blender/python/mathutils/mathutils_Vector.c @@ -55,12 +55,12 @@ static int row_vector_multiplication(float rvec[MAX_DIMENSIONS], VectorObject *v */ static PyObject *Vector_new(PyTypeObject *type, PyObject *args, PyObject *UNUSED(kwds)) { - float *vec= NULL; - int size= 3; /* default to a 3D vector */ + float *vec = NULL; + int size = 3; /* default to a 3D vector */ switch (PyTuple_GET_SIZE(args)) { case 0: - vec= PyMem_Malloc(size * sizeof(float)); + vec = PyMem_Malloc(size * sizeof(float)); if (vec == NULL) { PyErr_SetString(PyExc_MemoryError, @@ -72,7 +72,7 @@ static PyObject *Vector_new(PyTypeObject *type, PyObject *args, PyObject *UNUSED fill_vn_fl(vec, size, 0.0f); break; case 1: - if ((size=mathutils_array_parse_alloc(&vec, 2, PyTuple_GET_ITEM(args, 0), "mathutils.Vector()")) == -1) { + if ((size = mathutils_array_parse_alloc(&vec, 2, PyTuple_GET_ITEM(args, 0), "mathutils.Vector()")) == -1) { if (vec) { PyMem_Free(vec); } @@ -90,8 +90,8 @@ static PyObject *Vector_new(PyTypeObject *type, PyObject *args, PyObject *UNUSED static PyObject *vec__apply_to_copy(PyNoArgsFunction vec_func, VectorObject *self) { - PyObject *ret= Vector_copy(self); - PyObject *ret_dummy= vec_func(ret); + PyObject *ret = Vector_copy(self); + PyObject *ret_dummy = vec_func(ret); if (ret_dummy) { Py_DECREF(ret_dummy); return (PyObject *)ret; @@ -117,7 +117,7 @@ static PyObject *C_Vector_Fill(PyObject *cls, PyObject *args) { float *vec; int size; - float fill= 0.0f; + float fill = 0.0f; if (!PyArg_ParseTuple(args, "i|f:Vector.Fill", &size, &fill)) { return NULL; @@ -129,7 +129,7 @@ static PyObject *C_Vector_Fill(PyObject *cls, PyObject *args) return NULL; } - vec= PyMem_Malloc(size * sizeof(float)); + vec = PyMem_Malloc(size * sizeof(float)); if (vec == NULL) { PyErr_SetString(PyExc_MemoryError, @@ -159,8 +159,8 @@ static PyObject *C_Vector_Range(PyObject *cls, PyObject *args) { float *vec; int stop, size; - int start= 0; - int step= 1; + int start = 0; + int step = 1; if (!PyArg_ParseTuple(args, "i|ii:Vector.Range", &start, &stop, &step)) { return NULL; @@ -169,7 +169,7 @@ static PyObject *C_Vector_Range(PyObject *cls, PyObject *args) switch (PyTuple_GET_SIZE(args)) { case 1: size = start; - start= 0; + start = 0; break; case 2: if (start >= stop) { @@ -179,7 +179,7 @@ static PyObject *C_Vector_Range(PyObject *cls, PyObject *args) return NULL; } - size= stop - start; + size = stop - start; break; default: if (start >= stop) { @@ -188,13 +188,13 @@ static PyObject *C_Vector_Range(PyObject *cls, PyObject *args) "than the stop value"); return NULL; } - size= (stop - start)/step; + size = (stop - start)/step; if (size%step) size++; break; } - vec= PyMem_Malloc(size * sizeof(float)); + vec = PyMem_Malloc(size * sizeof(float)); if (vec == NULL) { PyErr_SetString(PyExc_MemoryError, @@ -236,9 +236,9 @@ static PyObject *C_Vector_Linspace(PyObject *cls, PyObject *args) return NULL; } - step= (end - start)/(float)(size-1); + step = (end - start)/(float)(size-1); - vec= PyMem_Malloc(size * sizeof(float)); + vec = PyMem_Malloc(size * sizeof(float)); if (vec == NULL) { PyErr_SetString(PyExc_MemoryError, @@ -265,7 +265,7 @@ PyDoc_STRVAR(C_Vector_Repeat_doc, static PyObject *C_Vector_Repeat(PyObject *cls, PyObject *args) { float *vec; - float *iter_vec= NULL; + float *iter_vec = NULL; int i, size, value_size; PyObject *value; @@ -279,7 +279,7 @@ static PyObject *C_Vector_Repeat(PyObject *cls, PyObject *args) return NULL; } - if ((value_size=mathutils_array_parse_alloc(&iter_vec, 2, value, "Vector.Repeat(vector, size), invalid 'vector' arg")) == -1) { + if ((value_size = mathutils_array_parse_alloc(&iter_vec, 2, value, "Vector.Repeat(vector, size), invalid 'vector' arg")) == -1) { PyMem_Free(iter_vec); return NULL; } @@ -291,7 +291,7 @@ static PyObject *C_Vector_Repeat(PyObject *cls, PyObject *args) return NULL; } - vec= PyMem_Malloc(size * sizeof(float)); + vec = PyMem_Malloc(size * sizeof(float)); if (vec == NULL) { PyErr_SetString(PyExc_MemoryError, @@ -300,9 +300,9 @@ static PyObject *C_Vector_Repeat(PyObject *cls, PyObject *args) return NULL; } - i= 0; + i = 0; while (i < size) { - vec[i]= iter_vec[i % value_size]; + vec[i] = iter_vec[i % value_size]; i++; } @@ -373,7 +373,7 @@ static PyObject *Vector_resize(VectorObject *self, PyObject *value) { int size; - if (self->wrapped==Py_WRAP) { + if (self->wrapped == Py_WRAP) { PyErr_SetString(PyExc_TypeError, "Vector.resize(): " "cannot resize wrapped data - only python vectors"); @@ -441,7 +441,7 @@ static PyObject *Vector_resized(VectorObject *self, PyObject *value) return NULL; } - vec= PyMem_Malloc(size * sizeof(float)); + vec = PyMem_Malloc(size * sizeof(float)); if (vec == NULL) { PyErr_SetString(PyExc_MemoryError, @@ -466,7 +466,7 @@ PyDoc_STRVAR(Vector_resize_2d_doc, ); static PyObject *Vector_resize_2d(VectorObject *self) { - if (self->wrapped==Py_WRAP) { + if (self->wrapped == Py_WRAP) { PyErr_SetString(PyExc_TypeError, "Vector.resize_2d(): " "cannot resize wrapped data - only python vectors"); @@ -501,7 +501,7 @@ PyDoc_STRVAR(Vector_resize_3d_doc, ); static PyObject *Vector_resize_3d(VectorObject *self) { - if (self->wrapped==Py_WRAP) { + if (self->wrapped == Py_WRAP) { PyErr_SetString(PyExc_TypeError, "Vector.resize_3d(): " "cannot resize wrapped data - only python vectors"); @@ -539,7 +539,7 @@ PyDoc_STRVAR(Vector_resize_4d_doc, ); static PyObject *Vector_resize_4d(VectorObject *self) { - if (self->wrapped==Py_WRAP) { + if (self->wrapped == Py_WRAP) { PyErr_SetString(PyExc_TypeError, "Vector.resize_4d(): " "cannot resize wrapped data - only python vectors"); @@ -595,7 +595,7 @@ PyDoc_STRVAR(Vector_to_3d_doc, ); static PyObject *Vector_to_3d(VectorObject *self) { - float tvec[3]= {0.0f}; + float tvec[3] = {0.0f}; if (BaseMath_ReadCallback(self) == -1) return NULL; @@ -613,7 +613,7 @@ PyDoc_STRVAR(Vector_to_4d_doc, ); static PyObject *Vector_to_4d(VectorObject *self) { - float tvec[4]= {0.0f, 0.0f, 0.0f, 1.0f}; + float tvec[4] = {0.0f, 0.0f, 0.0f, 1.0f}; if (BaseMath_ReadCallback(self) == -1) return NULL; @@ -638,7 +638,7 @@ static PyObject *Vector_to_tuple_ext(VectorObject *self, int ndigits) PyObject *ret; int i; - ret= PyTuple_New(self->size); + ret = PyTuple_New(self->size); if (ndigits >= 0) { for (i = 0; i < self->size; i++) { @@ -656,7 +656,7 @@ static PyObject *Vector_to_tuple_ext(VectorObject *self, int ndigits) static PyObject *Vector_to_tuple(VectorObject *self, PyObject *args) { - int ndigits= 0; + int ndigits = 0; if (!PyArg_ParseTuple(args, "|i:to_tuple", &ndigits)) return NULL; @@ -668,8 +668,8 @@ static PyObject *Vector_to_tuple(VectorObject *self, PyObject *args) return NULL; } - if (PyTuple_GET_SIZE(args)==0) - ndigits= -1; + if (PyTuple_GET_SIZE(args) == 0) + ndigits = -1; if (BaseMath_ReadCallback(self) == -1) return NULL; @@ -709,7 +709,7 @@ static PyObject *Vector_to_track_quat(VectorObject *self, PyObject *args) return NULL; if (strack) { - const char *axis_err_msg= "only X, -X, Y, -Y, Z or -Z for track axis"; + const char *axis_err_msg = "only X, -X, Y, -Y, Z or -Z for track axis"; if (strlen(strack) == 2) { if (strack[0] == '-') { @@ -757,7 +757,7 @@ static PyObject *Vector_to_track_quat(VectorObject *self, PyObject *args) } if (sup) { - const char *axis_err_msg= "only X, Y or Z for up axis"; + const char *axis_err_msg = "only X, Y or Z for up axis"; if (strlen(sup) == 1) { switch (*sup) { case 'X': @@ -821,7 +821,7 @@ static PyObject *Vector_reflect(VectorObject *self, PyObject *value) if (BaseMath_ReadCallback(self) == -1) return NULL; - if ((value_size= mathutils_array_parse(tvec, 2, 4, value, "Vector.reflect(other), invalid 'other' arg")) == -1) + if ((value_size = mathutils_array_parse(tvec, 2, 4, value, "Vector.reflect(other), invalid 'other' arg")) == -1) return NULL; if (self->size < 2 || self->size > 4) { @@ -875,7 +875,7 @@ static PyObject *Vector_cross(VectorObject *self, PyObject *value) return NULL; } - ret= (VectorObject *)Vector_CreatePyObject(NULL, 3, Py_NEW, Py_TYPE(self)); + ret = (VectorObject *)Vector_CreatePyObject(NULL, 3, Py_NEW, Py_TYPE(self)); cross_v3_v3v3(ret->vec, self->vec, tvec); return (PyObject *)ret; } @@ -925,12 +925,12 @@ PyDoc_STRVAR(Vector_angle_doc, ); static PyObject *Vector_angle(VectorObject *self, PyObject *args) { - const int size= MIN2(self->size, 3); /* 4D angle makes no sense */ + const int size = MIN2(self->size, 3); /* 4D angle makes no sense */ float tvec[MAX_DIMENSIONS]; PyObject *value; - double dot= 0.0f, dot_self= 0.0f, dot_other= 0.0f; + double dot = 0.0f, dot_self = 0.0f, dot_other = 0.0f; int x; - PyObject *fallback= NULL; + PyObject *fallback = NULL; if (!PyArg_ParseTuple(args, "O|O:angle", &value, &fallback)) return NULL; @@ -1022,7 +1022,7 @@ PyDoc_STRVAR(Vector_project_doc, ); static PyObject *Vector_project(VectorObject *self, PyObject *value) { - const int size= self->size; + const int size = self->size; float tvec[MAX_DIMENSIONS]; float vec[MAX_DIMENSIONS]; double dot = 0.0f, dot2 = 0.0f; @@ -1070,8 +1070,8 @@ PyDoc_STRVAR(Vector_lerp_doc, ); static PyObject *Vector_lerp(VectorObject *self, PyObject *args) { - const int size= self->size; - PyObject *value= NULL; + const int size = self->size; + PyObject *value = NULL; float fac, ifac; float *tvec, *vec; int x; @@ -1087,7 +1087,7 @@ static PyObject *Vector_lerp(VectorObject *self, PyObject *args) goto cleanup; } - vec= PyMem_Malloc(size * sizeof(float)); + vec = PyMem_Malloc(size * sizeof(float)); if (vec == NULL) { PyErr_SetString(PyExc_MemoryError, "Vector.lerp(): " @@ -1095,7 +1095,7 @@ static PyObject *Vector_lerp(VectorObject *self, PyObject *args) return NULL; } - ifac= 1.0f - fac; + ifac = 1.0f - fac; for (x = 0; x < size; x++) { vec[x] = (ifac * self->vec[x]) + (fac * tvec[x]); @@ -1166,8 +1166,8 @@ static PyObject *Vector_repr(VectorObject *self) if (BaseMath_ReadCallback(self) == -1) return NULL; - tuple= Vector_to_tuple_ext(self, -1); - ret= PyUnicode_FromFormat("Vector(%R)", tuple); + tuple = Vector_to_tuple_ext(self, -1); + ret = PyUnicode_FromFormat("Vector(%R)", tuple); Py_DECREF(tuple); return ret; } @@ -1181,7 +1181,7 @@ static PyObject *Vector_str(VectorObject *self) if (BaseMath_ReadCallback(self) == -1) return NULL; - ds= BLI_dynstr_new(); + ds = BLI_dynstr_new(); BLI_dynstr_append(ds, "<Vector ("); @@ -1204,7 +1204,7 @@ static int Vector_len(VectorObject *self) /* sequence accessor (get): vector[index] */ static PyObject *vector_item_internal(VectorObject *self, int i, const int is_attr) { - if (i<0) i= self->size-i; + if (i < 0) i = self->size-i; if (i < 0 || i >= self->size) { if (is_attr) { @@ -1233,14 +1233,14 @@ static PyObject *Vector_item(VectorObject *self, int i) static int vector_ass_item_internal(VectorObject *self, int i, PyObject *value, const int is_attr) { float scalar; - if ((scalar=PyFloat_AsDouble(value))==-1.0f && PyErr_Occurred()) { /* parsed item not a number */ + if ((scalar = PyFloat_AsDouble(value)) == -1.0f && PyErr_Occurred()) { /* parsed item not a number */ PyErr_SetString(PyExc_TypeError, "vector[index] = x: " "index argument not a number"); return -1; } - if (i<0) i= self->size-i; + if (i < 0) i = self->size-i; if (i < 0 || i >= self->size) { if (is_attr) { @@ -1277,11 +1277,11 @@ static PyObject *Vector_slice(VectorObject *self, int begin, int end) return NULL; CLAMP(begin, 0, self->size); - if (end<0) end= self->size+end+1; + if (end < 0) end = self->size + end + 1; CLAMP(end, 0, self->size); - begin= MIN2(begin, end); + begin = MIN2(begin, end); - tuple= PyTuple_New(end - begin); + tuple = PyTuple_New(end - begin); for (count = begin; count < end; count++) { PyTuple_SET_ITEM(tuple, count - begin, PyFloat_FromDouble(self->vec[count])); } @@ -1292,7 +1292,7 @@ static PyObject *Vector_slice(VectorObject *self, int begin, int end) static int Vector_ass_slice(VectorObject *self, int begin, int end, PyObject *seq) { int size = 0; - float *vec= NULL; + float *vec = NULL; if (BaseMath_ReadCallback(self) == -1) return -1; @@ -1333,7 +1333,7 @@ cleanup: static PyObject *Vector_add(PyObject *v1, PyObject *v2) { VectorObject *vec1 = NULL, *vec2 = NULL; - float *vec= NULL; + float *vec = NULL; if (!VectorObject_Check(v1) || !VectorObject_Check(v2)) { PyErr_Format(PyExc_AttributeError, @@ -1356,7 +1356,7 @@ static PyObject *Vector_add(PyObject *v1, PyObject *v2) return NULL; } - vec= PyMem_Malloc(vec1->size * sizeof(float)); + vec = PyMem_Malloc(vec1->size * sizeof(float)); if (vec == NULL) { /*allocation failure*/ PyErr_SetString(PyExc_MemoryError, @@ -1428,7 +1428,7 @@ static PyObject *Vector_sub(PyObject *v1, PyObject *v2) return NULL; } - vec= PyMem_Malloc(vec1->size * sizeof(float)); + vec = PyMem_Malloc(vec1->size * sizeof(float)); if (vec == NULL) { /*allocation failure*/ PyErr_SetString(PyExc_MemoryError, @@ -1445,7 +1445,7 @@ static PyObject *Vector_sub(PyObject *v1, PyObject *v2) /* subtraction in-place: obj -= obj */ static PyObject *Vector_isub(PyObject *v1, PyObject *v2) { - VectorObject *vec1= NULL, *vec2= NULL; + VectorObject *vec1 = NULL, *vec2 = NULL; if (!VectorObject_Check(v1) || !VectorObject_Check(v2)) { PyErr_Format(PyExc_AttributeError, @@ -1486,7 +1486,7 @@ static PyObject *Vector_isub(PyObject *v1, PyObject *v2) * note: vector/matrix multiplication IS NOT COMMUTATIVE!!!! * note: assume read callbacks have been done first. */ -int column_vector_multiplication(float r_vec[MAX_DIMENSIONS], VectorObject* vec, MatrixObject * mat) +int column_vector_multiplication(float r_vec[MAX_DIMENSIONS], VectorObject *vec, MatrixObject *mat) { float vec_cpy[MAX_DIMENSIONS]; double dot = 0.0f; @@ -1522,8 +1522,7 @@ int column_vector_multiplication(float r_vec[MAX_DIMENSIONS], VectorObject* vec, static PyObject *vector_mul_float(VectorObject *vec, const float scalar) { - float *tvec= NULL; - tvec= PyMem_Malloc(vec->size * sizeof(float)); + float *tvec = PyMem_Malloc(vec->size * sizeof(float)); if (tvec == NULL) { /*allocation failure*/ PyErr_SetString(PyExc_MemoryError, @@ -1543,12 +1542,12 @@ static PyObject *Vector_mul(PyObject *v1, PyObject *v2) int vec_size; if VectorObject_Check(v1) { - vec1= (VectorObject *)v1; + vec1 = (VectorObject *)v1; if (BaseMath_ReadCallback(vec1) == -1) return NULL; } if VectorObject_Check(v2) { - vec2= (VectorObject *)v2; + vec2 = (VectorObject *)v2; if (BaseMath_ReadCallback(vec2) == -1) return NULL; } @@ -1614,12 +1613,12 @@ static PyObject *Vector_mul(PyObject *v1, PyObject *v2) #endif /* ------ to be removed ------*/ } - else if (((scalar= PyFloat_AsDouble(v2)) == -1.0f && PyErr_Occurred())==0) { /* VEC * FLOAT */ + else if (((scalar = PyFloat_AsDouble(v2)) == -1.0f && PyErr_Occurred()) == 0) { /* VEC * FLOAT */ return vector_mul_float(vec1, scalar); } } else if (vec2) { - if (((scalar= PyFloat_AsDouble(v1)) == -1.0f && PyErr_Occurred())==0) { /* FLOAT * VEC */ + if (((scalar = PyFloat_AsDouble(v1)) == -1.0f && PyErr_Occurred()) == 0) { /* FLOAT * VEC */ return vector_mul_float(vec2, scalar); } } @@ -1693,7 +1692,7 @@ static PyObject *Vector_imul(PyObject *v1, PyObject *v2) #endif /* ------ to be removed ------*/ } - else if (((scalar= PyFloat_AsDouble(v2)) == -1.0f && PyErr_Occurred())==0) { /* VEC *= FLOAT */ + else if (((scalar = PyFloat_AsDouble(v2)) == -1.0f && PyErr_Occurred()) == 0) { /* VEC *= FLOAT */ mul_vn_fl(vec->vec, vec->size, scalar); } else { @@ -1712,7 +1711,7 @@ static PyObject *Vector_imul(PyObject *v1, PyObject *v2) /* divid: obj / obj */ static PyObject *Vector_div(PyObject *v1, PyObject *v2) { - float *vec= NULL, scalar; + float *vec = NULL, scalar; VectorObject *vec1 = NULL; if (!VectorObject_Check(v1)) { /* not a vector */ @@ -1726,21 +1725,21 @@ static PyObject *Vector_div(PyObject *v1, PyObject *v2) if (BaseMath_ReadCallback(vec1) == -1) return NULL; - if ((scalar=PyFloat_AsDouble(v2)) == -1.0f && PyErr_Occurred()) { /* parsed item not a number */ + if ((scalar = PyFloat_AsDouble(v2)) == -1.0f && PyErr_Occurred()) { /* parsed item not a number */ PyErr_SetString(PyExc_TypeError, "Vector division: " "Vector must be divided by a float"); return NULL; } - if (scalar==0.0f) { + if (scalar == 0.0f) { PyErr_SetString(PyExc_ZeroDivisionError, "Vector division: " "divide by zero error"); return NULL; } - vec= PyMem_Malloc(vec1->size * sizeof(float)); + vec = PyMem_Malloc(vec1->size * sizeof(float)); if (vec == NULL) { /*allocation failure*/ PyErr_SetString(PyExc_MemoryError, @@ -1749,7 +1748,7 @@ static PyObject *Vector_div(PyObject *v1, PyObject *v2) return NULL; } - mul_vn_vn_fl(vec, vec1->vec, vec1->size, 1.0f/scalar); + mul_vn_vn_fl(vec, vec1->vec, vec1->size, 1.0f / scalar); return Vector_CreatePyObject_alloc(vec, vec1->size, Py_TYPE(v1)); } @@ -1763,21 +1762,21 @@ static PyObject *Vector_idiv(PyObject *v1, PyObject *v2) if (BaseMath_ReadCallback(vec1) == -1) return NULL; - if ((scalar=PyFloat_AsDouble(v2)) == -1.0f && PyErr_Occurred()) { /* parsed item not a number */ + if ((scalar = PyFloat_AsDouble(v2)) == -1.0f && PyErr_Occurred()) { /* parsed item not a number */ PyErr_SetString(PyExc_TypeError, "Vector division: " "Vector must be divided by a float"); return NULL; } - if (scalar==0.0f) { + if (scalar == 0.0f) { PyErr_SetString(PyExc_ZeroDivisionError, "Vector division: " "divide by zero error"); return NULL; } - mul_vn_fl(vec1->vec, vec1->size, 1.0f/scalar); + mul_vn_fl(vec1->vec, vec1->size, 1.0f / scalar); (void)BaseMath_WriteCallback(vec1); @@ -1794,7 +1793,7 @@ static PyObject *Vector_neg(VectorObject *self) if (BaseMath_ReadCallback(self) == -1) return NULL; - tvec= PyMem_Malloc(self->size * sizeof(float)); + tvec = PyMem_Malloc(self->size * sizeof(float)); negate_vn_vn(tvec, self->vec, self->size); return Vector_CreatePyObject_alloc(tvec, self->size, Py_TYPE(self)); } @@ -1812,7 +1811,7 @@ static double vec_magnitude_nosqrt(float *data, int size) /*------------------------tp_richcmpr returns -1 execption, 0 false, 1 true */ -static PyObject* Vector_richcmpr(PyObject *objectA, PyObject *objectB, int comparison_type) +static PyObject *Vector_richcmpr(PyObject *objectA, PyObject *objectB, int comparison_type) { VectorObject *vecA = NULL, *vecB = NULL; int result = 0; @@ -1909,7 +1908,7 @@ static PySequenceMethods Vector_SeqMethods = { (ssizeargfunc) NULL, /* sq_inplace_repeat */ }; -static PyObject *Vector_subscript(VectorObject* self, PyObject* item) +static PyObject *Vector_subscript(VectorObject *self, PyObject *item) { if (PyIndex_Check(item)) { Py_ssize_t i; @@ -1946,7 +1945,7 @@ static PyObject *Vector_subscript(VectorObject* self, PyObject* item) } } -static int Vector_ass_subscript(VectorObject* self, PyObject* item, PyObject* value) +static int Vector_ass_subscript(VectorObject *self, PyObject *item, PyObject *value) { if (PyIndex_Check(item)) { Py_ssize_t i = PyNumber_AsSsize_t(item, PyExc_IndexError); @@ -2054,7 +2053,7 @@ static int Vector_length_set(VectorObject *self, PyObject *value) if (BaseMath_ReadCallback(self) == -1) return -1; - if ((param=PyFloat_AsDouble(value)) == -1.0 && PyErr_Occurred()) { + if ((param = PyFloat_AsDouble(value)) == -1.0 && PyErr_Occurred()) { PyErr_SetString(PyExc_TypeError, "length must be set to a number"); return -1; @@ -2070,19 +2069,19 @@ static int Vector_length_set(VectorObject *self, PyObject *value) return 0; } - dot= dot_vn_vn(self->vec, self->vec, self->size); + dot = dot_vn_vn(self->vec, self->vec, self->size); if (!dot) /* cant sqrt zero */ return 0; dot = sqrt(dot); - if (dot==param) + if (dot == param) return 0; - dot= dot/param; + dot = dot / param; - mul_vn_fl(self->vec, self->size, 1.0/dot); + mul_vn_fl(self->vec, self->size, 1.0 / dot); (void)BaseMath_WriteCallback(self); /* checked already */ @@ -2161,7 +2160,7 @@ static int Vector_swizzle_set(VectorObject *self, PyObject *value, void *closure /* Check that the closure can be used with this vector: even 2D vectors have swizzles defined for axes z and w, but they would be invalid. */ swizzleClosure = GET_INT_FROM_POINTER(closure); - axis_from= 0; + axis_from = 0; while (swizzleClosure & SWIZZLE_VALID_AXIS) { axis_to = swizzleClosure & SWIZZLE_AXIS; if (axis_to >= self->size) @@ -2175,15 +2174,15 @@ static int Vector_swizzle_set(VectorObject *self, PyObject *value, void *closure axis_from++; } - if (((scalarVal=PyFloat_AsDouble(value)) == -1 && PyErr_Occurred())==0) { + if (((scalarVal = PyFloat_AsDouble(value)) == -1 && PyErr_Occurred()) == 0) { int i; - for (i=0; i < MAX_DIMENSIONS; i++) - vec_assign[i]= scalarVal; + for (i = 0; i < MAX_DIMENSIONS; i++) + vec_assign[i] = scalarVal; - size_from= axis_from; + size_from = axis_from; } else if ( (PyErr_Clear()), /* run but ignore the result */ - (size_from=mathutils_array_parse(vec_assign, 2, 4, value, + (size_from = mathutils_array_parse(vec_assign, 2, 4, value, "mathutils.Vector.**** = swizzle assignment")) == -1) { return -1; @@ -2619,7 +2618,7 @@ static int row_vector_multiplication(float rvec[MAX_DIMENSIONS], VectorObject *v { float vec_cpy[MAX_DIMENSIONS]; double dot = 0.0f; - int row, col, z= 0, vec_size= vec->size; + int row, col, z = 0, vec_size = vec->size; if (mat->num_row != vec_size) { if (mat->num_row == 4 && vec_size == 3) { @@ -2818,22 +2817,22 @@ PyObject *Vector_CreatePyObject(float *vec, const int size, const int type, PyTy return NULL; } - self= base_type ? (VectorObject *)base_type->tp_alloc(base_type, 0) : - (VectorObject *)PyObject_GC_New(VectorObject, &vector_Type); + self = base_type ? (VectorObject *)base_type->tp_alloc(base_type, 0) : + (VectorObject *)PyObject_GC_New(VectorObject, &vector_Type); if (self) { self->size = size; /* init callbacks as NULL */ - self->cb_user= NULL; - self->cb_type= self->cb_subtype= 0; + self->cb_user = NULL; + self->cb_type = self->cb_subtype = 0; if (type == Py_WRAP) { self->vec = vec; self->wrapped = Py_WRAP; } else if (type == Py_NEW) { - self->vec= PyMem_Malloc(size * sizeof(float)); + self->vec = PyMem_Malloc(size * sizeof(float)); if (vec) { memcpy(self->vec, vec, size * sizeof(float)); } @@ -2855,12 +2854,12 @@ PyObject *Vector_CreatePyObject(float *vec, const int size, const int type, PyTy PyObject *Vector_CreatePyObject_cb(PyObject *cb_user, int size, int cb_type, int cb_subtype) { float dummy[4] = {0.0, 0.0, 0.0, 0.0}; /* dummy init vector, callbacks will be used on access */ - VectorObject *self= (VectorObject *)Vector_CreatePyObject(dummy, size, Py_NEW, NULL); + VectorObject *self = (VectorObject *)Vector_CreatePyObject(dummy, size, Py_NEW, NULL); if (self) { Py_INCREF(cb_user); - self->cb_user= cb_user; - self->cb_type= (unsigned char)cb_type; - self->cb_subtype= (unsigned char)cb_subtype; + self->cb_user = cb_user; + self->cb_type = (unsigned char)cb_type; + self->cb_subtype = (unsigned char)cb_subtype; PyObject_GC_Track(self); } @@ -2870,8 +2869,8 @@ PyObject *Vector_CreatePyObject_cb(PyObject *cb_user, int size, int cb_type, int PyObject *Vector_CreatePyObject_alloc(float *vec, const int size, PyTypeObject *base_type) { VectorObject *vect_ob; - vect_ob= (VectorObject *)Vector_CreatePyObject(vec, size, Py_WRAP, base_type); - vect_ob->wrapped= Py_NEW; + vect_ob = (VectorObject *)Vector_CreatePyObject(vec, size, Py_WRAP, base_type); + vect_ob->wrapped = Py_NEW; return (PyObject *)vect_ob; } diff --git a/source/blender/python/mathutils/mathutils_geometry.c b/source/blender/python/mathutils/mathutils_geometry.c index f3a843baf66..d7e7bef5f23 100644 --- a/source/blender/python/mathutils/mathutils_geometry.c +++ b/source/blender/python/mathutils/mathutils_geometry.c @@ -47,7 +47,7 @@ #include "BLI_math.h" #include "BLI_utildefines.h" -#define SWAP_FLOAT(a, b, tmp) tmp=a; a=b; b=tmp +#define SWAP_FLOAT(a, b, tmp) tmp = a; a = b; b = tmp /*-------------------------DOC STRINGS ---------------------------*/ PyDoc_STRVAR(M_Geometry_doc, @@ -76,12 +76,12 @@ PyDoc_STRVAR(M_Geometry_intersect_ray_tri_doc, " :return: The point of intersection or None if no intersection is found\n" " :rtype: :class:`mathutils.Vector` or None\n" ); -static PyObject *M_Geometry_intersect_ray_tri(PyObject *UNUSED(self), PyObject* args) +static PyObject *M_Geometry_intersect_ray_tri(PyObject *UNUSED(self), PyObject *args) { VectorObject *ray, *ray_off, *vec1, *vec2, *vec3; float dir[3], orig[3], v1[3], v2[3], v3[3], e1[3], e2[3], pvec[3], tvec[3], qvec[3]; float det, inv_det, u, v, t; - int clip= 1; + int clip = 1; if (!PyArg_ParseTuple(args, "O!O!O!O!O!|i:intersect_ray_tri", @@ -125,19 +125,19 @@ static PyObject *M_Geometry_intersect_ray_tri(PyObject *UNUSED(self), PyObject* cross_v3_v3v3(pvec, dir, e2); /* if determinant is near zero, ray lies in plane of triangle */ - det= dot_v3v3(e1, pvec); + det = dot_v3v3(e1, pvec); if (det > -0.000001f && det < 0.000001f) { Py_RETURN_NONE; } - inv_det= 1.0f / det; + inv_det = 1.0f / det; /* calculate distance from v1 to ray origin */ sub_v3_v3v3(tvec, orig, v1); /* calculate U parameter and test bounds */ - u= dot_v3v3(tvec, pvec) * inv_det; + u = dot_v3v3(tvec, pvec) * inv_det; if (clip && (u < 0.0f || u > 1.0f)) { Py_RETURN_NONE; } @@ -146,14 +146,14 @@ static PyObject *M_Geometry_intersect_ray_tri(PyObject *UNUSED(self), PyObject* cross_v3_v3v3(qvec, tvec, e1); /* calculate V parameter and test bounds */ - v= dot_v3v3(dir, qvec) * inv_det; + v = dot_v3v3(dir, qvec) * inv_det; if (clip && (v < 0.0f || u + v > 1.0f)) { Py_RETURN_NONE; } /* calculate t, ray intersects triangle */ - t= dot_v3v3(e2, qvec) * inv_det; + t = dot_v3v3(e2, qvec) * inv_det; mul_v3_fl(dir, t); add_v3_v3v3(pvec, orig, dir); @@ -217,31 +217,31 @@ static PyObject *M_Geometry_intersect_line_line(PyObject *UNUSED(self), PyObject copy_v3_v3(v4, vec4->vec); } else { - v1[0]= vec1->vec[0]; - v1[1]= vec1->vec[1]; - v1[2]= 0.0f; + v1[0] = vec1->vec[0]; + v1[1] = vec1->vec[1]; + v1[2] = 0.0f; - v2[0]= vec2->vec[0]; - v2[1]= vec2->vec[1]; - v2[2]= 0.0f; + v2[0] = vec2->vec[0]; + v2[1] = vec2->vec[1]; + v2[2] = 0.0f; - v3[0]= vec3->vec[0]; - v3[1]= vec3->vec[1]; - v3[2]= 0.0f; + v3[0] = vec3->vec[0]; + v3[1] = vec3->vec[1]; + v3[2] = 0.0f; - v4[0]= vec4->vec[0]; - v4[1]= vec4->vec[1]; - v4[2]= 0.0f; + v4[0] = vec4->vec[0]; + v4[1] = vec4->vec[1]; + v4[2] = 0.0f; } - result= isect_line_line_v3(v1, v2, v3, v4, i1, i2); + result = isect_line_line_v3(v1, v2, v3, v4, i1, i2); if (result == 0) { /* colinear */ Py_RETURN_NONE; } else { - tuple= PyTuple_New(2); + tuple = PyTuple_New(2); PyTuple_SET_ITEM(tuple, 0, Vector_CreatePyObject(i1, vec1->size, Py_NEW, NULL)); PyTuple_SET_ITEM(tuple, 1, Vector_CreatePyObject(i2, vec1->size, Py_NEW, NULL)); return tuple; @@ -273,7 +273,7 @@ PyDoc_STRVAR(M_Geometry_normal_doc, " :type v4: :class:`mathutils.Vector`\n" " :rtype: :class:`mathutils.Vector`\n" ); -static PyObject *M_Geometry_normal(PyObject *UNUSED(self), PyObject* args) +static PyObject *M_Geometry_normal(PyObject *UNUSED(self), PyObject *args) { VectorObject *vec1, *vec2, *vec3, *vec4; float n[3]; @@ -356,7 +356,7 @@ PyDoc_STRVAR(M_Geometry_area_tri_doc, " :type v3: :class:`mathutils.Vector`\n" " :rtype: float\n" ); -static PyObject *M_Geometry_area_tri(PyObject *UNUSED(self), PyObject* args) +static PyObject *M_Geometry_area_tri(PyObject *UNUSED(self), PyObject *args) { VectorObject *vec1, *vec2, *vec3; @@ -411,7 +411,7 @@ PyDoc_STRVAR(M_Geometry_intersect_line_line_2d_doc, " :return: The point of intersection or None when not found\n" " :rtype: :class:`mathutils.Vector` or None\n" ); -static PyObject *M_Geometry_intersect_line_line_2d(PyObject *UNUSED(self), PyObject* args) +static PyObject *M_Geometry_intersect_line_line_2d(PyObject *UNUSED(self), PyObject *args) { VectorObject *line_a1, *line_a2, *line_b1, *line_b2; float vi[2]; @@ -459,10 +459,10 @@ PyDoc_STRVAR(M_Geometry_intersect_line_plane_doc, " :return: The point of intersection or None when not found\n" " :rtype: :class:`mathutils.Vector` or None\n" ); -static PyObject *M_Geometry_intersect_line_plane(PyObject *UNUSED(self), PyObject* args) +static PyObject *M_Geometry_intersect_line_plane(PyObject *UNUSED(self), PyObject *args) { VectorObject *line_a, *line_b, *plane_co, *plane_no; - int no_flip= 0; + int no_flip = 0; float isect[3]; if (!PyArg_ParseTuple(args, "O!O!O!O!|i:intersect_line_plane", &vector_Type, &line_a, @@ -513,7 +513,7 @@ PyDoc_STRVAR(M_Geometry_intersect_plane_plane_doc, " :return: The line of the intersection represented as a point and a vector\n" " :rtype: tuple pair of :class:`mathutils.Vector`\n" ); -static PyObject *M_Geometry_intersect_plane_plane(PyObject *UNUSED(self), PyObject* args) +static PyObject *M_Geometry_intersect_plane_plane(PyObject *UNUSED(self), PyObject *args) { PyObject *ret; VectorObject *plane_a_co, *plane_a_no, *plane_b_co, *plane_b_no; @@ -551,7 +551,7 @@ static PyObject *M_Geometry_intersect_plane_plane(PyObject *UNUSED(self), PyObje normalize_v3(isect_no); - ret= PyTuple_New(2); + ret = PyTuple_New(2); PyTuple_SET_ITEM(ret, 0, Vector_CreatePyObject(isect_co, 3, Py_NEW, NULL)); PyTuple_SET_ITEM(ret, 1, Vector_CreatePyObject(isect_no, 3, Py_NEW, NULL)); return ret; @@ -574,11 +574,11 @@ PyDoc_STRVAR(M_Geometry_intersect_line_sphere_doc, " :return: The intersection points as a pair of vectors or None when there is no intersection\n" " :rtype: A tuple pair containing :class:`mathutils.Vector` or None\n" ); -static PyObject *M_Geometry_intersect_line_sphere(PyObject *UNUSED(self), PyObject* args) +static PyObject *M_Geometry_intersect_line_sphere(PyObject *UNUSED(self), PyObject *args) { VectorObject *line_a, *line_b, *sphere_co; float sphere_radius; - int clip= TRUE; + int clip = TRUE; float isect_a[3]; float isect_b[3]; @@ -606,24 +606,24 @@ static PyObject *M_Geometry_intersect_line_sphere(PyObject *UNUSED(self), PyObje return NULL; } else { - short use_a= TRUE; - short use_b= TRUE; + short use_a = TRUE; + short use_b = TRUE; float lambda; - PyObject *ret= PyTuple_New(2); + PyObject *ret = PyTuple_New(2); 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; - 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; + 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; + use_a = FALSE; + use_b = FALSE; } if (use_a) { PyTuple_SET_ITEM(ret, 0, Vector_CreatePyObject(isect_a, 3, Py_NEW, NULL)); } @@ -654,11 +654,11 @@ PyDoc_STRVAR(M_Geometry_intersect_line_sphere_2d_doc, " :return: The intersection points as a pair of vectors or None when there is no intersection\n" " :rtype: A tuple pair containing :class:`mathutils.Vector` or None\n" ); -static PyObject *M_Geometry_intersect_line_sphere_2d(PyObject *UNUSED(self), PyObject* args) +static PyObject *M_Geometry_intersect_line_sphere_2d(PyObject *UNUSED(self), PyObject *args) { VectorObject *line_a, *line_b, *sphere_co; float sphere_radius; - int clip= TRUE; + int clip = TRUE; float isect_a[3]; float isect_b[3]; @@ -679,24 +679,24 @@ static PyObject *M_Geometry_intersect_line_sphere_2d(PyObject *UNUSED(self), PyO return NULL; } else { - short use_a= TRUE; - short use_b= TRUE; + short use_a = TRUE; + short use_b = TRUE; float lambda; - PyObject *ret= PyTuple_New(2); + PyObject *ret = PyTuple_New(2); 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; - 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; + 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; + use_a = FALSE; + use_b = FALSE; } if (use_a) { PyTuple_SET_ITEM(ret, 0, Vector_CreatePyObject(isect_a, 2, Py_NEW, NULL)); } @@ -722,7 +722,7 @@ PyDoc_STRVAR(M_Geometry_intersect_point_line_doc, " :type line_p1: :class:`mathutils.Vector`\n" " :rtype: (:class:`mathutils.Vector`, float)\n" ); -static PyObject *M_Geometry_intersect_point_line(PyObject *UNUSED(self), PyObject* args) +static PyObject *M_Geometry_intersect_point_line(PyObject *UNUSED(self), PyObject *args) { VectorObject *pt, *line_1, *line_2; float pt_in[3], pt_out[3], l1[3], l2[3]; @@ -745,19 +745,19 @@ static PyObject *M_Geometry_intersect_point_line(PyObject *UNUSED(self), PyObjec } /* accept 2d verts */ - if (pt->size==3) { copy_v3_v3(pt_in, pt->vec);} - else { pt_in[2]=0.0; copy_v2_v2(pt_in, pt->vec); } + if (pt->size == 3) { copy_v3_v3(pt_in, pt->vec);} + else { pt_in[2] = 0.0f; copy_v2_v2(pt_in, pt->vec); } - if (line_1->size==3) { copy_v3_v3(l1, line_1->vec);} - else { l1[2]=0.0; copy_v2_v2(l1, line_1->vec); } + if (line_1->size == 3) { copy_v3_v3(l1, line_1->vec);} + else { l1[2] = 0.0f; copy_v2_v2(l1, line_1->vec); } - if (line_2->size==3) { copy_v3_v3(l2, line_2->vec);} - else { l2[2]=0.0; copy_v2_v2(l2, line_2->vec); } + if (line_2->size == 3) { copy_v3_v3(l2, line_2->vec);} + else { l2[2] = 0.0f; copy_v2_v2(l2, line_2->vec); } /* do the calculation */ - lambda= closest_to_line_v3(pt_out, pt_in, l1, l2); + lambda = closest_to_line_v3(pt_out, pt_in, l1, l2); - ret= PyTuple_New(2); + ret = PyTuple_New(2); PyTuple_SET_ITEM(ret, 0, Vector_CreatePyObject(pt_out, 3, Py_NEW, NULL)); PyTuple_SET_ITEM(ret, 1, PyFloat_FromDouble(lambda)); return ret; @@ -778,7 +778,7 @@ PyDoc_STRVAR(M_Geometry_intersect_point_tri_2d_doc, " :type tri_p3: :class:`mathutils.Vector`\n" " :rtype: int\n" ); -static PyObject *M_Geometry_intersect_point_tri_2d(PyObject *UNUSED(self), PyObject* args) +static PyObject *M_Geometry_intersect_point_tri_2d(PyObject *UNUSED(self), PyObject *args) { VectorObject *pt_vec, *tri_p1, *tri_p2, *tri_p3; @@ -820,7 +820,7 @@ PyDoc_STRVAR(M_Geometry_intersect_point_quad_2d_doc, " :type quad_p4: :class:`mathutils.Vector`\n" " :rtype: int\n" ); -static PyObject *M_Geometry_intersect_point_quad_2d(PyObject *UNUSED(self), PyObject* args) +static PyObject *M_Geometry_intersect_point_quad_2d(PyObject *UNUSED(self), PyObject *args) { VectorObject *pt_vec, *quad_p1, *quad_p2, *quad_p3, *quad_p4; @@ -860,7 +860,7 @@ PyDoc_STRVAR(M_Geometry_distance_point_to_plane_doc, " :type plane_no: :class:`mathutils.Vector`\n" " :rtype: float\n" ); -static PyObject *M_Geometry_distance_point_to_plane(PyObject *UNUSED(self), PyObject* args) +static PyObject *M_Geometry_distance_point_to_plane(PyObject *UNUSED(self), PyObject *args) { VectorObject *pt, *plene_co, *plane_no; @@ -963,7 +963,7 @@ PyDoc_STRVAR(M_Geometry_interpolate_bezier_doc, " :return: The interpolated points\n" " :rtype: list of :class:`mathutils.Vector`'s\n" ); -static PyObject *M_Geometry_interpolate_bezier(PyObject *UNUSED(self), PyObject* args) +static PyObject *M_Geometry_interpolate_bezier(PyObject *UNUSED(self), PyObject *args) { VectorObject *vec_k1, *vec_h1, *vec_k2, *vec_h2; int resolu; @@ -972,10 +972,10 @@ static PyObject *M_Geometry_interpolate_bezier(PyObject *UNUSED(self), PyObject* float *coord_array, *fp; PyObject *list; - float k1[4]= {0.0, 0.0, 0.0, 0.0}; - float h1[4]= {0.0, 0.0, 0.0, 0.0}; - float k2[4]= {0.0, 0.0, 0.0, 0.0}; - float h2[4]= {0.0, 0.0, 0.0, 0.0}; + float k1[4] = {0.0, 0.0, 0.0, 0.0}; + float h1[4] = {0.0, 0.0, 0.0, 0.0}; + float k2[4] = {0.0, 0.0, 0.0, 0.0}; + float h2[4] = {0.0, 0.0, 0.0, 0.0}; if (!PyArg_ParseTuple(args, "O!O!O!O!i:interpolate_bezier", @@ -1001,21 +1001,21 @@ static PyObject *M_Geometry_interpolate_bezier(PyObject *UNUSED(self), PyObject* return NULL; } - dims= MAX4(vec_k1->size, vec_h1->size, vec_h2->size, vec_k2->size); + 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++) { - forward_diff_bezier(k1[i], h1[i], h2[i], k2[i], coord_array+i, resolu-1, sizeof(float)*dims); + coord_array = MEM_callocN(dims * (resolu) * sizeof(float), "interpolate_bezier"); + 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) { + list = PyList_New(resolu); + fp = coord_array; + for (i = 0; i < resolu; i++, fp = fp + dims) { PyList_SET_ITEM(list, i, Vector_CreatePyObject(fp, dims, Py_NEW, NULL)); } MEM_freeN(coord_array); @@ -1036,13 +1036,13 @@ static PyObject *M_Geometry_tesselate_polygon(PyObject *UNUSED(self), PyObject * { PyObject *tri_list; /*return this list of tri's */ PyObject *polyLine, *polyVec; - int i, len_polylines, len_polypoints, ls_error= 0; + int i, len_polylines, len_polypoints, ls_error = 0; /* display listbase */ - ListBase dispbase={NULL, NULL}; + ListBase dispbase = {NULL, NULL}; DispList *dl; float *fp; /*pointer to the array of malloced dl->verts to set the points from the vectors */ - int index, *dl_face, totpoints=0; + int index, *dl_face, totpoints = 0; if (!PySequence_Check(polyLineSeq)) { PyErr_SetString(PyExc_TypeError, @@ -1050,10 +1050,10 @@ static PyObject *M_Geometry_tesselate_polygon(PyObject *UNUSED(self), PyObject * return NULL; } - len_polylines= PySequence_Size(polyLineSeq); + len_polylines = PySequence_Size(polyLineSeq); - for (i= 0; i < len_polylines; ++i) { - polyLine= PySequence_GetItem(polyLineSeq, i); + for (i = 0; i < len_polylines; ++i) { + polyLine = PySequence_GetItem(polyLineSeq, i); if (!PySequence_Check(polyLine)) { freedisplist(&dispbase); Py_XDECREF(polyLine); /* may be null so use Py_XDECREF*/ @@ -1062,8 +1062,8 @@ static PyObject *M_Geometry_tesselate_polygon(PyObject *UNUSED(self), PyObject * return NULL; } - len_polypoints= PySequence_Size(polyLine); - if (len_polypoints>0) { /* dont bother adding edges as polylines */ + len_polypoints = PySequence_Size(polyLine); + if (len_polypoints > 0) { /* dont bother adding edges as polylines */ #if 0 if (EXPP_check_sequence_consistency(polyLine, &vector_Type) != 1) { freedisplist(&dispbase); @@ -1073,32 +1073,32 @@ static PyObject *M_Geometry_tesselate_polygon(PyObject *UNUSED(self), PyObject * return NULL; } #endif - dl= MEM_callocN(sizeof(DispList), "poly disp"); + dl = MEM_callocN(sizeof(DispList), "poly disp"); BLI_addtail(&dispbase, dl); - dl->type= DL_INDEX3; - dl->nr= len_polypoints; - dl->type= DL_POLY; - dl->parts= 1; /* no faces, 1 edge loop */ - dl->col= 0; /* no material */ - 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) { - polyVec= PySequence_GetItem(polyLine, index); + dl->type = DL_INDEX3; + dl->nr = len_polypoints; + dl->type = DL_POLY; + dl->parts = 1; /* no faces, 1 edge loop */ + dl->col = 0; /* no material */ + 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) { + polyVec = PySequence_GetItem(polyLine, index); if (VectorObject_Check(polyVec)) { if (BaseMath_ReadCallback((VectorObject *)polyVec) == -1) - ls_error= 1; + ls_error = 1; - fp[0]= ((VectorObject *)polyVec)->vec[0]; - fp[1]= ((VectorObject *)polyVec)->vec[1]; + fp[0] = ((VectorObject *)polyVec)->vec[0]; + fp[1] = ((VectorObject *)polyVec)->vec[1]; if (((VectorObject *)polyVec)->size > 2) - fp[2]= ((VectorObject *)polyVec)->vec[2]; + fp[2] = ((VectorObject *)polyVec)->vec[2]; else - fp[2]= 0.0f; /* if its a 2d vector then set the z to be zero */ + fp[2] = 0.0f; /* if its a 2d vector then set the z to be zero */ } else { - ls_error= 1; + ls_error = 1; } totpoints++; @@ -1121,9 +1121,9 @@ static PyObject *M_Geometry_tesselate_polygon(PyObject *UNUSED(self), PyObject * /* The faces are stored in a new DisplayList thats added to the head of the listbase */ - dl= dispbase.first; + dl = dispbase.first; - tri_list= PyList_New(dl->parts); + tri_list = PyList_New(dl->parts); if (!tri_list) { freedisplist(&dispbase); PyErr_SetString(PyExc_RuntimeError, @@ -1131,11 +1131,11 @@ static PyObject *M_Geometry_tesselate_polygon(PyObject *UNUSED(self), PyObject * return NULL; } - index= 0; - dl_face= dl->index; + index = 0; + dl_face = dl->index; 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; + dl_face += 3; index++; } freedisplist(&dispbase); @@ -1143,7 +1143,7 @@ static PyObject *M_Geometry_tesselate_polygon(PyObject *UNUSED(self), PyObject * else { /* no points, do this so scripts dont barf */ freedisplist(&dispbase); /* possible some dl was allocated */ - tri_list= PyList_New(0); + tri_list = PyList_New(0); } return tri_list; @@ -1164,13 +1164,13 @@ static int boxPack_FromPyObject(PyObject *value, boxPack **boxarray) return -1; } - len= PyList_GET_SIZE(value); + len = PyList_GET_SIZE(value); - (*boxarray)= MEM_mallocN(len*sizeof(boxPack), "boxPack box"); + *boxarray = MEM_mallocN(len * sizeof(boxPack), "boxPack box"); - for (i= 0; i < len; i++) { - list_item= PyList_GET_ITEM(value, 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) { MEM_freeN(*boxarray); PyErr_SetString(PyExc_TypeError, @@ -1178,14 +1178,14 @@ static int boxPack_FromPyObject(PyObject *value, boxPack **boxarray) return -1; } - box= (*boxarray)+i; + box = (*boxarray) + i; - item_1= PyList_GET_ITEM(list_item, 2); - item_2= PyList_GET_ITEM(list_item, 3); + item_1 = PyList_GET_ITEM(list_item, 2); + item_2 = PyList_GET_ITEM(list_item, 3); - box->w= (float)PyFloat_AsDouble(item_1); - box->h= (float)PyFloat_AsDouble(item_2); - box->index= i; + box->w = (float)PyFloat_AsDouble(item_1); + box->h = (float)PyFloat_AsDouble(item_2); + box->index = i; /* accounts for error case too and overwrites with own error */ if (box->w < 0.0f || box->h < 0.0f) { @@ -1207,11 +1207,11 @@ static void boxPack_ToPyObject(PyObject *value, boxPack **boxarray) PyObject *list_item; boxPack *box; - len= PyList_GET_SIZE(value); + len = PyList_GET_SIZE(value); - for (i= 0; i < len; i++) { - box= (*boxarray)+i; - list_item= PyList_GET_ITEM(value, box->index); + 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)); PyList_SET_ITEM(list_item, 1, PyFloat_FromDouble(box->y)); } @@ -1230,7 +1230,7 @@ PyDoc_STRVAR(M_Geometry_box_pack_2d_doc, ); static PyObject *M_Geometry_box_pack_2d(PyObject *UNUSED(self), PyObject *boxlist) { - float tot_width= 0.0f, tot_height= 0.0f; + float tot_width = 0.0f, tot_height = 0.0f; Py_ssize_t len; PyObject *ret; @@ -1241,9 +1241,9 @@ static PyObject *M_Geometry_box_pack_2d(PyObject *UNUSED(self), PyObject *boxlis return NULL; } - len= PyList_GET_SIZE(boxlist); + len = PyList_GET_SIZE(boxlist); if (len) { - boxPack *boxarray= NULL; + boxPack *boxarray = NULL; if (boxPack_FromPyObject(boxlist, &boxarray) == -1) { return NULL; /* exception set */ } @@ -1254,7 +1254,7 @@ static PyObject *M_Geometry_box_pack_2d(PyObject *UNUSED(self), PyObject *boxlis boxPack_ToPyObject(boxlist, &boxarray); } - ret= PyTuple_New(2); + ret = PyTuple_New(2); PyTuple_SET_ITEM(ret, 0, PyFloat_FromDouble(tot_width)); PyTuple_SET_ITEM(ret, 1, PyFloat_FromDouble(tot_width)); return ret; @@ -1263,7 +1263,7 @@ static PyObject *M_Geometry_box_pack_2d(PyObject *UNUSED(self), PyObject *boxlis #endif /* MATH_STANDALONE */ -static PyMethodDef M_Geometry_methods[]= { +static PyMethodDef M_Geometry_methods[] = { {"intersect_ray_tri", (PyCFunction) M_Geometry_intersect_ray_tri, METH_VARARGS, M_Geometry_intersect_ray_tri_doc}, {"intersect_point_line", (PyCFunction) M_Geometry_intersect_point_line, METH_VARARGS, M_Geometry_intersect_point_line_doc}, {"intersect_point_tri_2d", (PyCFunction) M_Geometry_intersect_point_tri_2d, METH_VARARGS, M_Geometry_intersect_point_tri_2d_doc}, @@ -1286,7 +1286,7 @@ static PyMethodDef M_Geometry_methods[]= { {NULL, NULL, 0, NULL} }; -static struct PyModuleDef M_Geometry_module_def= { +static struct PyModuleDef M_Geometry_module_def = { PyModuleDef_HEAD_INIT, "mathutils.geometry", /* m_name */ M_Geometry_doc, /* m_doc */ @@ -1301,6 +1301,6 @@ static struct PyModuleDef M_Geometry_module_def= { /*----------------------------MODULE INIT-------------------------*/ PyMODINIT_FUNC PyInit_mathutils_geometry(void) { - PyObject *submodule= PyModule_Create(&M_Geometry_module_def); + PyObject *submodule = PyModule_Create(&M_Geometry_module_def); return submodule; } diff --git a/source/blender/python/mathutils/mathutils_noise.c b/source/blender/python/mathutils/mathutils_noise.c index c0e8ac24baa..fceff965fcb 100644 --- a/source/blender/python/mathutils/mathutils_noise.c +++ b/source/blender/python/mathutils/mathutils_noise.c @@ -199,8 +199,8 @@ static float frand(void) /* Fills an array of length size with random numbers in the range (-1, 1)*/ static void rand_vn(float *array_tar, const int size) { - float *array_pt= array_tar + (size-1); - int i= size; + float *array_pt = array_tar + (size-1); + int i = size; while (i--) { *(array_pt--) = 2.0f * frand() - 1.0f; } } @@ -208,9 +208,9 @@ static void rand_vn(float *array_tar, const int size) static void noise_vector(float x, float y, float z, int nb, float v[3]) { /* Simply evaluate noise at 3 different positions */ - v[0]= (float)(2.0f * BLI_gNoise(1.f, x + 9.321f, y - 1.531f, z - 7.951f, 0, nb) - 1.0f); - v[1]= (float)(2.0f * BLI_gNoise(1.f, x, y, z, 0, nb) - 1.0f); - v[2]= (float)(2.0f * BLI_gNoise(1.f, x + 6.327f, y + 0.1671f, z - 2.672f, 0, nb) - 1.0f); + v[0] = (float)(2.0f * BLI_gNoise(1.f, x + 9.321f, y - 1.531f, z - 7.951f, 0, nb) - 1.0f); + v[1] = (float)(2.0f * BLI_gNoise(1.f, x, y, z, 0, nb) - 1.0f); + v[2] = (float)(2.0f * BLI_gNoise(1.f, x + 6.327f, y + 0.1671f, z - 2.672f, 0, nb) - 1.0f); } /* Returns a turbulence value for a given position (x, y, z) */ @@ -301,9 +301,9 @@ PyDoc_STRVAR(M_Noise_random_unit_vector_doc, ); static PyObject *M_Noise_random_unit_vector(PyObject *UNUSED(self), PyObject *args) { - float vec[4]= {0.0f, 0.0f, 0.0f, 0.0f}; - float norm= 2.0f; - int size= 3; + float vec[4] = {0.0f, 0.0f, 0.0f, 0.0f}; + float norm = 2.0f; + int size = 3; if (!PyArg_ParseTuple(args, "|i:random_vector", &size)) return NULL; @@ -313,9 +313,9 @@ static PyObject *M_Noise_random_unit_vector(PyObject *UNUSED(self), PyObject *ar return NULL; } - while (norm==0.0f || norm>=1.0f) { + while (norm == 0.0f || norm >= 1.0f) { rand_vn(vec, size); - norm= normalize_vn(vec, size); + norm = normalize_vn(vec, size); } return Vector_CreatePyObject(vec, size, Py_NEW, NULL); @@ -384,7 +384,7 @@ static PyObject *M_Noise_noise(PyObject *UNUSED(self), PyObject *args) { PyObject *value; float vec[3]; - int nb= 1; + int nb = 1; if (!PyArg_ParseTuple(args, "O|i:noise", &value, &nb)) return NULL; @@ -410,7 +410,7 @@ static PyObject *M_Noise_noise_vector(PyObject *UNUSED(self), PyObject *args) { PyObject *value; float vec[3], r_vec[3]; - int nb= 1; + int nb = 1; if (!PyArg_ParseTuple(args, "O|i:noise_vector", &value, &nb)) return NULL; @@ -447,8 +447,8 @@ static PyObject *M_Noise_turbulence(PyObject *UNUSED(self), PyObject *args) { PyObject *value; float vec[3]; - int oct, hd, nb= 1; - float as= 0.5f, fs= 2.0f; + int oct, hd, nb = 1; + float as = 0.5f, fs = 2.0f; if (!PyArg_ParseTuple(args, "Oii|iff:turbulence", &value, &oct, &hd, &nb, &as, &fs)) return NULL; @@ -483,8 +483,8 @@ static PyObject *M_Noise_turbulence_vector(PyObject *UNUSED(self), PyObject *arg { PyObject *value; float vec[3], r_vec[3]; - int oct, hd, nb= 1; - float as =0.5f, fs= 2.0f; + int oct, hd, nb = 1; + float as =0.5f, fs = 2.0f; if (!PyArg_ParseTuple(args, "Oii|iff:turbulence_vector", &value, &oct, &hd, &nb, &as, &fs)) return NULL; @@ -519,7 +519,7 @@ static PyObject *M_Noise_fractal(PyObject *UNUSED(self), PyObject *args) PyObject *value; float vec[3]; float H, lac, oct; - int nb= 1; + int nb = 1; if (!PyArg_ParseTuple(args, "Offf|i:fractal", &value, &H, &lac, &oct, &nb)) return NULL; @@ -553,7 +553,7 @@ static PyObject *M_Noise_multi_fractal(PyObject *UNUSED(self), PyObject *args) PyObject *value; float vec[3]; float H, lac, oct; - int nb= 1; + int nb = 1; if (!PyArg_ParseTuple(args, "Offf|i:multi_fractal", &value, &H, &lac, &oct, &nb)) return NULL; @@ -585,7 +585,7 @@ static PyObject *M_Noise_variable_lacunarity(PyObject *UNUSED(self), PyObject *a PyObject *value; float vec[3]; float d; - int nt1= 1, nt2= 1; + int nt1 = 1, nt2 = 1; if (!PyArg_ParseTuple(args, "Of|ii:variable_lacunarity", &value, &d, &nt1, &nt2)) return NULL; @@ -621,7 +621,7 @@ static PyObject *M_Noise_hetero_terrain(PyObject *UNUSED(self), PyObject *args) PyObject *value; float vec[3]; float H, lac, oct, ofs; - int nb= 1; + int nb = 1; if (!PyArg_ParseTuple(args, "Offff|i:hetero_terrain", &value, &H, &lac, &oct, &ofs, &nb)) return NULL; @@ -659,7 +659,7 @@ static PyObject *M_Noise_hybrid_multi_fractal(PyObject *UNUSED(self), PyObject * PyObject *value; float vec[3]; float H, lac, oct, ofs, gn; - int nb= 1; + int nb = 1; if (!PyArg_ParseTuple(args, "Offfff|i:hybrid_multi_fractal", &value, &H, &lac, &oct, &ofs, &gn, &nb)) return NULL; @@ -697,7 +697,7 @@ static PyObject *M_Noise_ridged_multi_fractal(PyObject *UNUSED(self), PyObject * PyObject *value; float vec[3]; float H, lac, oct, ofs, gn; - int nb= 1; + int nb = 1; if (!PyArg_ParseTuple(args, "Offfff|i:ridged_multi_fractal", &value, &H, &lac, &oct, &ofs, &gn, &nb)) return NULL; @@ -728,8 +728,8 @@ static PyObject *M_Noise_voronoi(PyObject *UNUSED(self), PyObject *args) PyObject *list; float vec[3]; float da[4], pa[12]; - int dtype= 0; - float me= 2.5f; /* default minkovsky exponent */ + int dtype = 0; + float me = 2.5f; /* default minkovsky exponent */ int i; @@ -739,12 +739,12 @@ static PyObject *M_Noise_voronoi(PyObject *UNUSED(self), PyObject *args) if (mathutils_array_parse(vec, 3, 3, value, "voronoi: invalid 'position' arg") == -1) return NULL; - list= PyList_New(4); + list = PyList_New(4); voronoi(vec[0], vec[1], vec[2], da, pa, me, dtype); - for (i=0; i<4; i++) { - PyList_SET_ITEM(list, i, Vector_CreatePyObject(pa + 3*i, 3, Py_NEW, NULL)); + for (i = 0; i < 4; i++) { + PyList_SET_ITEM(list, i, Vector_CreatePyObject(pa + 3 * i, 3, Py_NEW, NULL)); } return Py_BuildValue("[[ffff]O]", da[0], da[1], da[2], da[3], list); @@ -841,11 +841,11 @@ PyMODINIT_FUNC PyInit_mathutils_noise(void) /* use current time as seed for random number generator by default */ setRndSeed(0); - PyModule_AddObject(submodule, "types", (item_types=PyInit_mathutils_noise_types())); + PyModule_AddObject(submodule, "types", (item_types = PyInit_mathutils_noise_types())); PyDict_SetItemString(PyThreadState_GET()->interp->modules, "noise.types", item_types); Py_INCREF(item_types); - PyModule_AddObject(submodule, "distance_metrics", (item_metrics=PyInit_mathutils_noise_metrics())); + PyModule_AddObject(submodule, "distance_metrics", (item_metrics = PyInit_mathutils_noise_metrics())); PyDict_SetItemString(PyThreadState_GET()->interp->modules, "noise.distance_metrics", item_metrics); Py_INCREF(item_metrics); |