Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2014-07-16 05:57:28 +0400
committerCampbell Barton <ideasman42@gmail.com>2014-07-16 05:57:28 +0400
commitde379c05dea561fbd02dc875fd7f4ae6178579b5 (patch)
tree484134b76918bdf4660fd67ea0192f2f6074d66d
parent28940d79b1946df721fc6f11b65bb074d05ad44c (diff)
bmesh py api: add BMesh.calc_tessface()
-rw-r--r--source/blender/python/bmesh/bmesh_py_types.c39
1 files changed, 39 insertions, 0 deletions
diff --git a/source/blender/python/bmesh/bmesh_py_types.c b/source/blender/python/bmesh/bmesh_py_types.c
index dc2792e6e42..c2fa0c00cfc 100644
--- a/source/blender/python/bmesh/bmesh_py_types.c
+++ b/source/blender/python/bmesh/bmesh_py_types.c
@@ -1217,6 +1217,44 @@ static PyObject *bpy_bmesh_calc_volume(BPy_BMElem *self, PyObject *args, PyObjec
}
}
+PyDoc_STRVAR(bpy_bmesh_calc_tessface_doc,
+".. method:: calc_tessface()\n"
+"\n"
+" Calculate triangle tessellation from quads/ngons.\n"
+"\n"
+" :return: The triangulated faces.\n"
+" :rtype: list of :class:`BMLoop` tuples\n"
+);
+static PyObject *bpy_bmesh_calc_tessface(BPy_BMElem *self)
+{
+ BMesh *bm;
+
+ int looptris_tot;
+ int tottri;
+ BMLoop *(*looptris)[3];
+
+ PyObject *ret;
+ int i;
+
+ BPY_BM_CHECK_OBJ(self);
+
+ bm = self->bm;
+
+ looptris_tot = poly_to_tri_count(bm->totface, bm->totloop);
+ looptris = PyMem_MALLOC(sizeof(*looptris) * looptris_tot);
+
+ BM_bmesh_calc_tessellation(bm, looptris, &tottri);
+
+ ret = PyList_New(tottri);
+ for (i = 0; i < tottri; i++) {
+ PyList_SET_ITEM(ret, i, BPy_BMLoop_Array_As_Tuple(bm, looptris[i], 3));
+ }
+
+ PyMem_FREE(looptris);
+
+ return ret;
+}
+
/* Elem
* ---- */
@@ -2488,6 +2526,7 @@ static struct PyMethodDef bpy_bmesh_methods[] = {
/* calculations */
{"calc_volume", (PyCFunction)bpy_bmesh_calc_volume, METH_VARARGS | METH_KEYWORDS, bpy_bmesh_calc_volume_doc},
+ {"calc_tessface", (PyCFunction)bpy_bmesh_calc_tessface, METH_NOARGS, bpy_bmesh_calc_tessface_doc},
{NULL, NULL, 0, NULL}
};