diff options
author | Campbell Barton <ideasman42@gmail.com> | 2012-04-19 15:25:05 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2012-04-19 15:25:05 +0400 |
commit | db2edfcfdec81fb03667a63e70f05ee832bf2586 (patch) | |
tree | 0420d0ad4380a67bf1e473174f3ca8f325bb5a13 /source/blender/python | |
parent | 250560a423ea889ec491cdfde887571dea3c9e7c (diff) |
bmesh api function: BM_edge_face_tangent()
was used by inset but make into an api function since scripts can use this too.
Diffstat (limited to 'source/blender/python')
-rw-r--r-- | source/blender/python/bmesh/bmesh_py_types.c | 35 |
1 files changed, 33 insertions, 2 deletions
diff --git a/source/blender/python/bmesh/bmesh_py_types.c b/source/blender/python/bmesh/bmesh_py_types.c index 5fcefc7533b..6b6fd8a0bd4 100644 --- a/source/blender/python/bmesh/bmesh_py_types.c +++ b/source/blender/python/bmesh/bmesh_py_types.c @@ -1243,6 +1243,36 @@ static PyObject *bpy_bmedge_calc_face_angle(BPy_BMEdge *self) return PyFloat_FromDouble(BM_edge_face_angle(self->e)); } +PyDoc_STRVAR(bpy_bmedge_calc_tangent_doc, +".. method:: calc_tangent(loop)\n" +"\n" +" Return the tangent at this edge relative to a face (pointing inward into the face).\n" +" This uses the face normal for calculation.\n" +"\n" +" :arg loop: The loop used for tangent calculation.\n" +" :type loop: :class:`BMLoop`\n" +" :return: a normalized vector.\n" +" :rtype: :class:`mathutils.Vector`\n" +); +static PyObject *bpy_bmedge_calc_tangent(BPy_BMEdge *self, PyObject *args) +{ + BPy_BMLoop *py_loop; + BPY_BM_CHECK_OBJ(self); + + if (!PyArg_ParseTuple(args, "O!:BMEdge.calc_face_tangent", + &BPy_BMLoop_Type, &py_loop)) + { + return NULL; + } + else { + float vec[3]; + BPY_BM_CHECK_OBJ(py_loop); + /* no need to check if they are from the same mesh or even connected */ + BM_edge_face_tangent(self->e, py_loop->l, vec); + return Vector_CreatePyObject(vec, 3, Py_NEW, NULL); + } +} + PyDoc_STRVAR(bpy_bmedge_other_vert_doc, ".. method:: other_vert(vert)\n" @@ -2078,8 +2108,9 @@ static struct PyMethodDef bpy_bmedge_methods[] = { {"other_vert", (PyCFunction)bpy_bmedge_other_vert, METH_O, bpy_bmedge_other_vert_doc}, - {"calc_length", (PyCFunction)bpy_bmedge_calc_length, METH_NOARGS, bpy_bmedge_calc_length_doc}, - {"calc_face_angle", (PyCFunction)bpy_bmedge_calc_face_angle, METH_NOARGS, bpy_bmedge_calc_face_angle_doc}, + {"calc_length", (PyCFunction)bpy_bmedge_calc_length, METH_NOARGS, bpy_bmedge_calc_length_doc}, + {"calc_face_angle", (PyCFunction)bpy_bmedge_calc_face_angle, METH_NOARGS, bpy_bmedge_calc_face_angle_doc}, + {"calc_tangent", (PyCFunction)bpy_bmedge_calc_tangent, METH_VARARGS, bpy_bmedge_calc_tangent_doc}, {"normal_update", (PyCFunction)bpy_bmedge_normal_update, METH_NOARGS, bpy_bmedge_normal_update_doc}, |