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>2013-04-05 23:26:33 +0400
committerCampbell Barton <ideasman42@gmail.com>2013-04-05 23:26:33 +0400
commit79e58c31a085c52a4901fdb8a0d026aa4ab2e594 (patch)
treecfa3ce355b92a7c8575da65d97ff57ba24e5624e /source/blender/python/bmesh
parent7404c1a553662c4dc1468a78b2237cd54c9598a2 (diff)
add BM_face_calc_center_mean_weighted() gives much better result at cost of some speed.
Diffstat (limited to 'source/blender/python/bmesh')
-rw-r--r--source/blender/python/bmesh/bmesh_py_types.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/source/blender/python/bmesh/bmesh_py_types.c b/source/blender/python/bmesh/bmesh_py_types.c
index 833ec3b7467..0e75ee088d3 100644
--- a/source/blender/python/bmesh/bmesh_py_types.c
+++ b/source/blender/python/bmesh/bmesh_py_types.c
@@ -1627,6 +1627,22 @@ static PyObject *bpy_bmface_calc_center_mean(BPy_BMFace *self)
return Vector_CreatePyObject(cent, 3, Py_NEW, NULL);
}
+PyDoc_STRVAR(bpy_bmface_calc_center_mean_weighted_doc,
+".. method:: calc_center_median_weighted()\n"
+"\n"
+" Return median center of the face weighted by edge lengths.\n"
+"\n"
+" :return: a 3D vector.\n"
+" :rtype: :class:`mathutils.Vector`\n"
+);
+static PyObject *bpy_bmface_calc_center_mean_weighted(BPy_BMFace *self)
+{
+ float cent[3];
+
+ BPY_BM_CHECK_OBJ(self);
+ BM_face_calc_center_mean_weighted(self->f, cent);
+ return Vector_CreatePyObject(cent, 3, Py_NEW, NULL);
+}
PyDoc_STRVAR(bpy_bmface_calc_center_bounds_doc,
".. method:: calc_center_bounds()\n"
@@ -2482,6 +2498,7 @@ static struct PyMethodDef bpy_bmface_methods[] = {
{"calc_area", (PyCFunction)bpy_bmface_calc_area, METH_NOARGS, bpy_bmface_calc_area_doc},
{"calc_perimeter", (PyCFunction)bpy_bmface_calc_perimeter, METH_NOARGS, bpy_bmface_calc_perimeter_doc},
{"calc_center_median", (PyCFunction)bpy_bmface_calc_center_mean, METH_NOARGS, bpy_bmface_calc_center_mean_doc},
+ {"calc_center_median_weighted", (PyCFunction)bpy_bmface_calc_center_mean_weighted, METH_NOARGS, bpy_bmface_calc_center_mean_weighted_doc},
{"calc_center_bounds", (PyCFunction)bpy_bmface_calc_center_bounds, METH_NOARGS, bpy_bmface_calc_center_bounds_doc},
{"normal_update", (PyCFunction)bpy_bmface_normal_update, METH_NOARGS, bpy_bmface_normal_update_doc},