diff options
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/python/bmesh/bmesh_py_types.c | 39 | ||||
-rw-r--r-- | source/blender/python/bmesh/bmesh_py_types.h | 5 | ||||
-rw-r--r-- | source/blender/python/bmesh/bmesh_py_utils.c | 8 |
3 files changed, 45 insertions, 7 deletions
diff --git a/source/blender/python/bmesh/bmesh_py_types.c b/source/blender/python/bmesh/bmesh_py_types.c index c2b496f914b..dc2792e6e42 100644 --- a/source/blender/python/bmesh/bmesh_py_types.c +++ b/source/blender/python/bmesh/bmesh_py_types.c @@ -3669,7 +3669,6 @@ err_cleanup: } } - PyObject *BPy_BMElem_Array_As_Tuple(BMesh *bm, BMHeader **elem, Py_ssize_t elem_len) { Py_ssize_t i; @@ -3677,6 +3676,44 @@ PyObject *BPy_BMElem_Array_As_Tuple(BMesh *bm, BMHeader **elem, Py_ssize_t elem_ for (i = 0; i < elem_len; i++) { PyTuple_SET_ITEM(ret, i, BPy_BMElem_CreatePyObject(bm, elem[i])); } + return ret; +} +PyObject *BPy_BMVert_Array_As_Tuple(BMesh *bm, BMVert **elem, Py_ssize_t elem_len) +{ + Py_ssize_t i; + PyObject *ret = PyTuple_New(elem_len); + for (i = 0; i < elem_len; i++) { + PyTuple_SET_ITEM(ret, i, BPy_BMVert_CreatePyObject(bm, elem[i])); + } + return ret; +} +PyObject *BPy_BMEdge_Array_As_Tuple(BMesh *bm, BMEdge **elem, Py_ssize_t elem_len) +{ + Py_ssize_t i; + PyObject *ret = PyTuple_New(elem_len); + for (i = 0; i < elem_len; i++) { + PyTuple_SET_ITEM(ret, i, BPy_BMEdge_CreatePyObject(bm, elem[i])); + } + + return ret; +} +PyObject *BPy_BMFace_Array_As_Tuple(BMesh *bm, BMFace **elem, Py_ssize_t elem_len) +{ + Py_ssize_t i; + PyObject *ret = PyTuple_New(elem_len); + for (i = 0; i < elem_len; i++) { + PyTuple_SET_ITEM(ret, i, BPy_BMFace_CreatePyObject(bm, elem[i])); + } + + return ret; +} +PyObject *BPy_BMLoop_Array_As_Tuple(BMesh *bm, BMLoop **elem, Py_ssize_t elem_len) +{ + Py_ssize_t i; + PyObject *ret = PyTuple_New(elem_len); + for (i = 0; i < elem_len; i++) { + PyTuple_SET_ITEM(ret, i, BPy_BMLoop_CreatePyObject(bm, elem[i])); + } return ret; } diff --git a/source/blender/python/bmesh/bmesh_py_types.h b/source/blender/python/bmesh/bmesh_py_types.h index 0909ce0d26a..86fa61d5f7e 100644 --- a/source/blender/python/bmesh/bmesh_py_types.h +++ b/source/blender/python/bmesh/bmesh_py_types.h @@ -164,6 +164,11 @@ void *BPy_BMElem_PySeq_As_Array(BMesh **r_bm, PyObject *seq, Py_ssize_t min, Py_ const char *error_prefix); PyObject *BPy_BMElem_Array_As_Tuple(BMesh *bm, BMHeader **elem, Py_ssize_t elem_len); +PyObject *BPy_BMVert_Array_As_Tuple(BMesh *bm, BMVert **elem, Py_ssize_t elem_len); +PyObject *BPy_BMEdge_Array_As_Tuple(BMesh *bm, BMEdge **elem, Py_ssize_t elem_len); +PyObject *BPy_BMFace_Array_As_Tuple(BMesh *bm, BMFace **elem, Py_ssize_t elem_len); +PyObject *BPy_BMLoop_Array_As_Tuple(BMesh *bm, BMLoop **elem, Py_ssize_t elem_len); + int BPy_BMElem_CheckHType(PyTypeObject *type, const char htype); char *BPy_BMElem_StringFromHType_ex(const char htype, char ret[32]); char *BPy_BMElem_StringFromHType(const char htype); diff --git a/source/blender/python/bmesh/bmesh_py_utils.c b/source/blender/python/bmesh/bmesh_py_utils.c index cd5290bcd91..a1e11d197d5 100644 --- a/source/blender/python/bmesh/bmesh_py_utils.c +++ b/source/blender/python/bmesh/bmesh_py_utils.c @@ -247,7 +247,7 @@ static PyObject *bpy_bm_utils_vert_separate(PyObject *UNUSED(self), PyObject *ar BM_vert_separate(bm, py_vert->v, &elem, &elem_len, edge_array, edge_array_len); /* return collected verts */ - ret = BPy_BMElem_Array_As_Tuple(bm, (BMHeader **)elem, elem_len); + ret = BPy_BMVert_Array_As_Tuple(bm, elem, elem_len); MEM_freeN(elem); PyMem_FREE(edge_array); @@ -535,11 +535,7 @@ static PyObject *bpy_bm_utils_face_split_edgenet(PyObject *UNUSED(self), PyObjec PyMem_FREE(edge_array); if (ok) { - PyObject *ret = PyTuple_New(face_arr_len); - int i; - for (i = 0; i < face_arr_len; i++) { - PyTuple_SET_ITEM(ret, i, BPy_BMFace_CreatePyObject(bm, face_arr[i])); - } + PyObject *ret = BPy_BMFace_Array_As_Tuple(bm, face_arr, face_arr_len); MEM_freeN(face_arr); return ret; } |