diff options
author | Campbell Barton <ideasman42@gmail.com> | 2019-04-17 07:17:24 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2019-04-17 07:21:24 +0300 |
commit | e12c08e8d170b7ca40f204a5b0423c23a9fbc2c1 (patch) | |
tree | 8cf3453d12edb177a218ef8009357518ec6cab6a /source/blender/python/mathutils/mathutils_interpolate.c | |
parent | b3dabc200a4b0399ec6b81f2ff2730d07b44fcaa (diff) |
ClangFormat: apply to source, most of intern
Apply clang format as proposed in T53211.
For details on usage and instructions for migrating branches
without conflicts, see:
https://wiki.blender.org/wiki/Tools/ClangFormat
Diffstat (limited to 'source/blender/python/mathutils/mathutils_interpolate.c')
-rw-r--r-- | source/blender/python/mathutils/mathutils_interpolate.c | 152 |
1 files changed, 73 insertions, 79 deletions
diff --git a/source/blender/python/mathutils/mathutils_interpolate.c b/source/blender/python/mathutils/mathutils_interpolate.c index 792f8b1f065..6abb66899d5 100644 --- a/source/blender/python/mathutils/mathutils_interpolate.c +++ b/source/blender/python/mathutils/mathutils_interpolate.c @@ -18,7 +18,6 @@ * \ingroup pymathutils */ - #include <Python.h> #include "mathutils.h" @@ -32,105 +31,100 @@ #endif /*-------------------------DOC STRINGS ---------------------------*/ -PyDoc_STRVAR(M_Interpolate_doc, -"The Blender interpolate module" -); +PyDoc_STRVAR(M_Interpolate_doc, "The Blender interpolate module"); /* ---------------------------------WEIGHT CALCULATION ----------------------- */ #ifndef MATH_STANDALONE PyDoc_STRVAR(M_Interpolate_poly_3d_calc_doc, -".. function:: poly_3d_calc(veclist, pt)\n" -"\n" -" Calculate barycentric weights for a point on a polygon.\n" -"\n" -" :arg veclist: list of vectors\n" -" :arg pt: point" -" :rtype: list of per-vector weights\n" -); + ".. function:: poly_3d_calc(veclist, pt)\n" + "\n" + " Calculate barycentric weights for a point on a polygon.\n" + "\n" + " :arg veclist: list of vectors\n" + " :arg pt: point" + " :rtype: list of per-vector weights\n"); static PyObject *M_Interpolate_poly_3d_calc(PyObject *UNUSED(self), PyObject *args) { - float fp[3]; - float (*vecs)[3]; - Py_ssize_t len; - - PyObject *point, *veclist, *ret; - int i; - - if (!PyArg_ParseTuple( - args, "OO!:poly_3d_calc", - &veclist, - &vector_Type, &point)) - { - return NULL; - } - - if (BaseMath_ReadCallback((VectorObject *)point) == -1) { - return NULL; - } - - fp[0] = ((VectorObject *)point)->vec[0]; - fp[1] = ((VectorObject *)point)->vec[1]; - if (((VectorObject *)point)->size > 2) { - fp[2] = ((VectorObject *)point)->vec[2]; - } - else { - /* if its a 2d vector then set the z to be zero */ - fp[2] = 0.0f; - } - - len = mathutils_array_parse_alloc_v(((float **)&vecs), 3, veclist, __func__); - if (len == -1) { - return NULL; - } - - if (len) { - float *weights = MEM_mallocN(sizeof(float) * len, __func__); - - interp_weights_poly_v3(weights, vecs, len, fp); - - ret = PyList_New(len); - for (i = 0; i < len; i++) { - PyList_SET_ITEM(ret, i, PyFloat_FromDouble(weights[i])); - } - - MEM_freeN(weights); - - PyMem_Free(vecs); - } - else { - ret = PyList_New(0); - } - - return ret; + float fp[3]; + float(*vecs)[3]; + Py_ssize_t len; + + PyObject *point, *veclist, *ret; + int i; + + if (!PyArg_ParseTuple(args, "OO!:poly_3d_calc", &veclist, &vector_Type, &point)) { + return NULL; + } + + if (BaseMath_ReadCallback((VectorObject *)point) == -1) { + return NULL; + } + + fp[0] = ((VectorObject *)point)->vec[0]; + fp[1] = ((VectorObject *)point)->vec[1]; + if (((VectorObject *)point)->size > 2) { + fp[2] = ((VectorObject *)point)->vec[2]; + } + else { + /* if its a 2d vector then set the z to be zero */ + fp[2] = 0.0f; + } + + len = mathutils_array_parse_alloc_v(((float **)&vecs), 3, veclist, __func__); + if (len == -1) { + return NULL; + } + + if (len) { + float *weights = MEM_mallocN(sizeof(float) * len, __func__); + + interp_weights_poly_v3(weights, vecs, len, fp); + + ret = PyList_New(len); + for (i = 0; i < len; i++) { + PyList_SET_ITEM(ret, i, PyFloat_FromDouble(weights[i])); + } + + MEM_freeN(weights); + + PyMem_Free(vecs); + } + else { + ret = PyList_New(0); + } + + return ret; } #endif /* MATH_STANDALONE */ - static PyMethodDef M_Interpolate_methods[] = { #ifndef MATH_STANDALONE - {"poly_3d_calc", (PyCFunction) M_Interpolate_poly_3d_calc, METH_VARARGS, M_Interpolate_poly_3d_calc_doc}, + {"poly_3d_calc", + (PyCFunction)M_Interpolate_poly_3d_calc, + METH_VARARGS, + M_Interpolate_poly_3d_calc_doc}, #endif - {NULL, NULL, 0, NULL}, + {NULL, NULL, 0, NULL}, }; static struct PyModuleDef M_Interpolate_module_def = { - PyModuleDef_HEAD_INIT, - "mathutils.interpolate", /* m_name */ - M_Interpolate_doc, /* m_doc */ - 0, /* m_size */ - M_Interpolate_methods, /* m_methods */ - NULL, /* m_reload */ - NULL, /* m_traverse */ - NULL, /* m_clear */ - NULL, /* m_free */ + PyModuleDef_HEAD_INIT, + "mathutils.interpolate", /* m_name */ + M_Interpolate_doc, /* m_doc */ + 0, /* m_size */ + M_Interpolate_methods, /* m_methods */ + NULL, /* m_reload */ + NULL, /* m_traverse */ + NULL, /* m_clear */ + NULL, /* m_free */ }; /*----------------------------MODULE INIT-------------------------*/ PyMODINIT_FUNC PyInit_mathutils_interpolate(void) { - PyObject *submodule = PyModule_Create(&M_Interpolate_module_def); - return submodule; + PyObject *submodule = PyModule_Create(&M_Interpolate_module_def); + return submodule; } |