diff options
author | Campbell Barton <ideasman42@gmail.com> | 2013-06-24 08:41:03 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2013-06-24 08:41:03 +0400 |
commit | bc79e226eee4fd218b3d047007a5609a8f7c39b2 (patch) | |
tree | 05184a54635138c395ed4b610d99f71ff8009558 /source/blender/editors/mesh/meshtools.c | |
parent | 15aed4127b3537f2efd6265acab8d73c26136754 (diff) |
de-duplicate ED_mesh_active_dvert_* functions.
not to devs - please don't just copy static functions around, make them api calls and add to headers.
Diffstat (limited to 'source/blender/editors/mesh/meshtools.c')
-rw-r--r-- | source/blender/editors/mesh/meshtools.c | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/source/blender/editors/mesh/meshtools.c b/source/blender/editors/mesh/meshtools.c index e34b792ab69..b8b245802bf 100644 --- a/source/blender/editors/mesh/meshtools.c +++ b/source/blender/editors/mesh/meshtools.c @@ -1362,3 +1362,54 @@ bool ED_mesh_pick_vert(bContext *C, Object *ob, const int mval[2], unsigned int return true; } + + +MDeformVert *ED_mesh_active_dvert_get_em(Object *ob, BMVert **r_eve) +{ + if (ob->mode & OB_MODE_EDIT && ob->type == OB_MESH && ob->defbase.first) { + Mesh *me = ob->data; + BMEditMesh *em = me->edit_btmesh; + const int cd_dvert_offset = CustomData_get_offset(&em->bm->vdata, CD_MDEFORMVERT); + + if (cd_dvert_offset != -1) { + BMEditSelection *ese = (BMEditSelection *)em->bm->selected.last; + + if (ese && ese->htype == BM_VERT) { + BMVert *eve = (BMVert *)ese->ele; + if (r_eve) *r_eve = eve; + return BM_ELEM_CD_GET_VOID_P(eve, cd_dvert_offset); + } + } + } + + if (r_eve) *r_eve = NULL; + return NULL; +} + +MDeformVert *ED_mesh_active_dvert_get_ob(Object *ob, int *r_index) +{ + Mesh *me = ob->data; + int index = BKE_mesh_mselect_active_get(me, ME_VSEL); + if (r_index) *r_index = index; + if (index == -1 || me->dvert == NULL) { + return NULL; + } + else { + return me->dvert + index; + } +} + +MDeformVert *ED_mesh_active_dvert_get_only(Object *ob) +{ + if (ob->type == OB_MESH) { + if (ob->mode & OB_MODE_EDIT) { + return ED_mesh_active_dvert_get_em(ob, NULL); + } + else { + return ED_mesh_active_dvert_get_ob(ob, NULL); + } + } + else { + return NULL; + } +} |