diff options
author | Campbell Barton <ideasman42@gmail.com> | 2016-02-29 00:45:03 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2016-02-29 01:00:21 +0300 |
commit | 97677f572542e0deb4870613edabd7c0f59a63cb (patch) | |
tree | bcd92a9fc9824bba5b39917815a10f2ec8c581d7 | |
parent | 42fe1ba84462395b4a0aea4403b5a4d7ff08530f (diff) |
Minor optimization to skin operators
- store layer lookup
- single hash adding to set
-rw-r--r-- | source/blender/editors/object/object_modifier.c | 23 |
1 files changed, 9 insertions, 14 deletions
diff --git a/source/blender/editors/object/object_modifier.c b/source/blender/editors/object/object_modifier.c index 77d32ffafc0..264945b00bf 100644 --- a/source/blender/editors/object/object_modifier.c +++ b/source/blender/editors/object/object_modifier.c @@ -1460,7 +1460,7 @@ static int skin_edit_poll(bContext *C) edit_modifier_poll_generic(C, &RNA_SkinModifier, (1 << OB_MESH))); } -static void skin_root_clear(BMesh *bm, BMVert *bm_vert, GSet *visited) +static void skin_root_clear(BMVert *bm_vert, GSet *visited, const int cd_vert_skin_offset) { BMEdge *bm_edge; BMIter bm_iter; @@ -1468,16 +1468,13 @@ static void skin_root_clear(BMesh *bm, BMVert *bm_vert, GSet *visited) BM_ITER_ELEM (bm_edge, &bm_iter, bm_vert, BM_EDGES_OF_VERT) { BMVert *v2 = BM_edge_other_vert(bm_edge, bm_vert); - if (!BLI_gset_haskey(visited, v2)) { - MVertSkin *vs = CustomData_bmesh_get(&bm->vdata, - v2->head.data, - CD_MVERT_SKIN); + if (BLI_gset_add(visited, v2)) { + MVertSkin *vs = BM_ELEM_CD_GET_VOID_P(v2, cd_vert_skin_offset); /* clear vertex root flag and add to visited set */ vs->flag &= ~MVERT_SKIN_ROOT; - BLI_gset_insert(visited, v2); - skin_root_clear(bm, v2, visited); + skin_root_clear(v2, visited, cd_vert_skin_offset); } } } @@ -1487,6 +1484,7 @@ static int skin_root_mark_exec(bContext *C, wmOperator *UNUSED(op)) Object *ob = CTX_data_edit_object(C); BMEditMesh *em = BKE_editmesh_from_object(ob); BMesh *bm = em->bm; + const int cd_vert_skin_offset = CustomData_get_offset(&bm->vdata, CD_MVERT_SKIN); BMVert *bm_vert; BMIter bm_iter; GSet *visited; @@ -1496,19 +1494,16 @@ static int skin_root_mark_exec(bContext *C, wmOperator *UNUSED(op)) BKE_mesh_ensure_skin_customdata(ob->data); BM_ITER_MESH (bm_vert, &bm_iter, bm, BM_VERTS_OF_MESH) { - if (!BLI_gset_haskey(visited, bm_vert) && - BM_elem_flag_test(bm_vert, BM_ELEM_SELECT)) + if (BM_elem_flag_test(bm_vert, BM_ELEM_SELECT) && + BLI_gset_add(visited, bm_vert)) { - MVertSkin *vs = CustomData_bmesh_get(&bm->vdata, - bm_vert->head.data, - CD_MVERT_SKIN); + MVertSkin *vs = BM_ELEM_CD_GET_VOID_P(bm_vert, cd_vert_skin_offset); /* mark vertex as root and add to visited set */ vs->flag |= MVERT_SKIN_ROOT; - BLI_gset_insert(visited, bm_vert); /* clear root flag from all connected vertices (recursively) */ - skin_root_clear(bm, bm_vert, visited); + skin_root_clear(bm_vert, visited, cd_vert_skin_offset); } } |