Revision: 22216 http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=22216 Author: joeedh Date: 2009-08-05 04:34:54 +0200 (Wed, 05 Aug 2009)
Log Message: ----------- select linked has been bmeshafied, yay Modified Paths: -------------- branches/bmesh/blender/source/blender/bmesh/intern/bmesh_marking.c branches/bmesh/blender/source/blender/bmesh/intern/bmesh_walkers.c branches/bmesh/blender/source/blender/editors/include/ED_mesh.h branches/bmesh/blender/source/blender/editors/mesh/bmesh_select.c branches/bmesh/blender/source/blender/editors/mesh/bmeshutils.c branches/bmesh/blender/source/blender/editors/mesh/editmesh_mods.c branches/bmesh/blender/source/blender/editors/uvedit/uvedit_ops.c branches/bmesh/blender/source/blender/editors/uvedit/uvedit_unwrap_ops.c Modified: branches/bmesh/blender/source/blender/bmesh/intern/bmesh_marking.c =================================================================== --- branches/bmesh/blender/source/blender/bmesh/intern/bmesh_marking.c 2009-08-04 22:59:50 UTC (rev 22215) +++ branches/bmesh/blender/source/blender/bmesh/intern/bmesh_marking.c 2009-08-05 02:34:54 UTC (rev 22216) @@ -150,9 +150,18 @@ /*ensure vert selections are valid, only if not in a multiselect mode that shares SCE_SELECT_VERT*/ - if (bm->selectmode & (SCE_SELECT_VERTEX|SCE_SELECT_EDGE)) testiso = 1; - else if (bm->selectmode & (SCE_SELECT_VERTEX|SCE_SELECT_FACE)) testiso = 1; - + switch (bm->selectmode) { + case SCE_SELECT_VERTEX: + case SCE_SELECT_EDGE: + case SCE_SELECT_FACE: + case SCE_SELECT_EDGE|SCE_SELECT_FACE: + testiso = 1; + break; + default: + testiso = 0; + break; + } + if (testiso && !select) { BMIter eiter; BMEdge *e2; @@ -177,8 +186,8 @@ if (!BM_TestHFlag(e, BM_SELECT)) bm->totedgesel += 1; BM_SetHFlag(&(e->head), BM_SELECT); - BM_SetHFlag(e->v1, BM_SELECT); - BM_SetHFlag(e->v2, BM_SELECT); + BM_Select(bm, e->v1, 1); + BM_Select(bm, e->v2, 1); } else{ if (BM_TestHFlag(e, BM_SELECT)) bm->totedgesel -= 1; @@ -208,8 +217,8 @@ BM_SetHFlag(&(f->head), BM_SELECT); l = f->loopbase; do{ - BM_SetHFlag(&(l->v->head), BM_SELECT); - BM_SetHFlag(&(l->e->head), BM_SELECT); + BM_Select_Vert(bm, l->v, 1); + BM_Select_Edge(bm, l->e, 1); l = ((BMLoop*)(l->head.next)); }while(l != f->loopbase); } @@ -219,8 +228,8 @@ BM_ClearHFlag(&(f->head), BM_SELECT); l = f->loopbase; do { - BM_ClearHFlag(&(l->v->head), BM_SELECT); - BM_ClearHFlag(&(l->e->head), BM_SELECT); + BM_Select_Vert(bm, l->v, 0); + BM_Select_Edge(bm, l->e, 0); l = ((BMLoop*)(l->head.next)); } while(l != f->loopbase); } Modified: branches/bmesh/blender/source/blender/bmesh/intern/bmesh_walkers.c =================================================================== --- branches/bmesh/blender/source/blender/bmesh/intern/bmesh_walkers.c 2009-08-04 22:59:50 UTC (rev 22215) +++ branches/bmesh/blender/source/blender/bmesh/intern/bmesh_walkers.c 2009-08-05 02:34:54 UTC (rev 22216) @@ -303,6 +303,7 @@ if(v->edge){ shellWalk->base = v; shellWalk->curedge = v->edge; + BLI_ghash_insert(walker->visithash, v->edge, NULL); } } static void *shellWalker_yield(BMWalker *walker) @@ -316,44 +317,37 @@ BMEdge *curedge, *next = NULL; BMVert *ov = NULL; int restrictpass = 1; - shellWalker *shellWalk = walker->currentstate; + shellWalker shellWalk = *((shellWalker*)walker->currentstate); - if (!BLI_ghash_haskey(walker->visithash, shellWalk->base)) - BLI_ghash_insert(walker->visithash, shellWalk->base, NULL); + if (!BLI_ghash_haskey(walker->visithash, shellWalk.base)) + BLI_ghash_insert(walker->visithash, shellWalk.base, NULL); + BMW_popstate(walker); + /*find the next edge whose other vertex has not been visited*/ - curedge = shellWalk->curedge; + curedge = shellWalk.curedge; do{ if (!BLI_ghash_haskey(walker->visithash, curedge)) { BLI_ghash_insert(walker->visithash, curedge, NULL); - if(walker->restrictflag && - (!BMO_TestFlag(walker->bm, curedge, walker->restrictflag))) + + if(!(walker->restrictflag && + !BMO_TestFlag(walker->bm, curedge, walker->restrictflag))) { - restrictpass = 0; - } - if(restrictpass) { - ov = BM_OtherEdgeVert(curedge, shellWalk->base); + ov = BM_OtherEdgeVert(curedge, shellWalk.base); - /*save current state*/ - shellWalk->curedge = curedge; - /*push a new state onto the stack*/ BMW_pushstate(walker); /*populate the new state*/ + ((shellWalker*)walker->currentstate)->base = ov; ((shellWalker*)walker->currentstate)->curedge = curedge; - /*break out of loop*/ - - next = curedge; - break; } } - curedge = bmesh_disk_nextedge(curedge, shellWalk->base); - }while(curedge != shellWalk->curedge); + curedge = bmesh_disk_nextedge(curedge, shellWalk.base); + }while(curedge != shellWalk.curedge); - shellWalk->current = next; - return next; + return shellWalk.curedge; } /* Island Boundary Walker: Modified: branches/bmesh/blender/source/blender/editors/include/ED_mesh.h =================================================================== --- branches/bmesh/blender/source/blender/editors/include/ED_mesh.h 2009-08-04 22:59:50 UTC (rev 22215) +++ branches/bmesh/blender/source/blender/editors/include/ED_mesh.h 2009-08-05 02:34:54 UTC (rev 22216) @@ -93,15 +93,23 @@ struct BMFace *EDBM_get_face_for_index(struct BMEditMesh *tm, int index); struct BMFace *EDBM_get_actFace(struct BMEditMesh *em, int sloppy); +/*flushes based on the current select mode. if in vertex select mode, + verts select/deselect edges and faces, if in edge select mode, + edges select/deselect faces and vertices, and in face select mode faces select/deselect + edges and vertices.*/ void EDBM_selectmode_flush(struct BMEditMesh *em); int EDBM_get_actSelection(struct BMEditMesh *em, struct BMEditSelection *ese); +/*exactly the same as EDBM_selectmode_flush, but you pass in the selectmode + instead of using the current one*/ +void EDBM_select_flush(struct BMEditMesh *em, int selectmode); +void EDBM_selectmode_set(struct BMEditMesh *em); +void EDBM_convertsel(struct BMEditMesh *em, short oldmode, short selectmode); + void EDBM_editselection_center(struct BMEditMesh *em, float *center, struct BMEditSelection *ese); void EDBM_editselection_plane(struct BMEditMesh *em, float *plane, struct BMEditSelection *ese); void EDBM_editselection_normal(float *normal, struct BMEditSelection *ese); -void EDBM_selectmode_set(struct BMEditMesh *em); -void EDBM_convertsel(struct BMEditMesh *em, short oldmode, short selectmode); void EDBM_hide_mesh(struct BMEditMesh *em, int swap); void EDBM_reveal_mesh(struct BMEditMesh *em); Modified: branches/bmesh/blender/source/blender/editors/mesh/bmesh_select.c =================================================================== --- branches/bmesh/blender/source/blender/editors/mesh/bmesh_select.c 2009-08-04 22:59:50 UTC (rev 22215) +++ branches/bmesh/blender/source/blender/editors/mesh/bmesh_select.c 2009-08-05 02:34:54 UTC (rev 22216) @@ -1537,10 +1537,13 @@ } BMW_Init(&walker, em->bm, BMW_SHELL, 0); - e = BMW_Begin(&walker, eed); + e = BMW_Begin(&walker, eed->v1); for (; e; e=BMW_Step(&walker)) { - BM_Select(em->bm, e, sel); + BM_Select(em->bm, e->v1, sel); + BM_Select(em->bm, e->v2, sel); } + BMW_End(&walker); + EDBM_select_flush(em, SCE_SELECT_VERTEX); WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_SELECT, obedit); return OPERATOR_FINISHED; @@ -1562,3 +1565,57 @@ RNA_def_boolean(ot->srna, "deselect", 0, "Deselect", ""); RNA_def_boolean(ot->srna, "limit", 0, "Limit by Seams", ""); } + + +static int select_linked_exec(bContext *C, wmOperator *op) +{ + Object *obedit= CTX_data_edit_object(C); + BMEditMesh *em= ((Mesh*)obedit->data)->edit_btmesh; + V_DECLARE(verts); + BMVert **verts = NULL; + BMIter iter; + BMVert *v; + BMEdge *e; + BMWalker walker; + int i, tot; + + tot = 0; + BM_ITER(v, &iter, em->bm, BM_VERTS_OF_MESH, NULL) { + if (BM_TestHFlag(v, BM_SELECT)) { + V_GROW(verts); + verts[tot++] = v; + } + } + + BMW_Init(&walker, em->bm, BMW_SHELL, 0); + for (i=0; i<tot; i++) { + e = BMW_Begin(&walker, verts[i]); + for (; e; e=BMW_Step(&walker)) { + BM_Select(em->bm, e->v1, 1); + BM_Select(em->bm, e->v2, 1); + } + } + BMW_End(&walker); + EDBM_select_flush(em, SCE_SELECT_VERTEX); + + V_FREE(verts); + WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_SELECT, obedit); + + return OPERATOR_FINISHED; +} + +void MESH_OT_select_linked(wmOperatorType *ot) +{ + /* identifiers */ + ot->name= "Select Linked All"; + ot->idname= "MESH_OT_select_linked"; + + /* api callbacks */ + ot->exec= select_linked_exec; + ot->poll= ED_operator_editmesh; + + /* flags */ + ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; + + RNA_def_boolean(ot->srna, "limit", 0, "Limit by Seams", ""); +} Modified: branches/bmesh/blender/source/blender/editors/mesh/bmeshutils.c =================================================================== --- branches/bmesh/blender/source/blender/editors/mesh/bmeshutils.c 2009-08-04 22:59:50 UTC (rev 22215) +++ branches/bmesh/blender/source/blender/editors/mesh/bmeshutils.c 2009-08-05 02:34:54 UTC (rev 22216) @@ -386,6 +386,13 @@ } +void EDBM_select_flush(BMEditMesh *em, int selectmode) +{ + em->bm->selectmode = selectmode; + BM_SelectMode_Flush(em->bm); + em->bm->selectmode = em->selectmode; +} + void EDBM_selectmode_flush(BMEditMesh *em) { em->bm->selectmode = em->selectmode; @@ -440,6 +447,7 @@ type = BM_FACES_OF_MESH; break; } + ele = BMIter_New(&iter, em->bm, type, NULL); for ( ; ele; ele=BMIter_Step(&iter)) { if (flag & BM_SELECT) BM_Select(em->bm, ele, 0); @@ -467,6 +475,7 @@ type = BM_FACES_OF_MESH; break; } + ele = BMIter_New(&iter, em->bm, type, NULL); for ( ; ele; ele=BMIter_Step(&iter)) { if (flag & BM_SELECT) BM_Select(em->bm, ele, 1); Modified: branches/bmesh/blender/source/blender/editors/mesh/editmesh_mods.c =================================================================== --- branches/bmesh/blender/source/blender/editors/mesh/editmesh_mods.c 2009-08-04 22:59:50 UTC (rev 22215) +++ branches/bmesh/blender/source/blender/editors/mesh/editmesh_mods.c 2009-08-05 02:34:54 UTC (rev 22216) @@ -1900,42 +1900,6 @@ // if (EM_texFaceCheck()) } -static int select_linked_exec(bContext *C, wmOperator *op) -{ - Object *obedit= CTX_data_edit_object(C); - EditMesh *em= BKE_mesh_get_editmesh(obedit->data); - - if( RNA_boolean_get(op->ptr, "limit") ) { - ViewContext vc; - em_setup_viewcontext(C, &vc); - select_linked_limited_invoke(&vc, 1, 1); - } - else - selectconnected_mesh_all(em); - - WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_SELECT, obedit); - - BKE_mesh_end_editmesh(obedit->data, em); - return OPERATOR_FINISHED; -} - -void MESH_OT_select_linked(wmOperatorType *ot) -{ - /* identifiers */ - ot->name= "Select Linked All"; - ot->idname= "MESH_OT_select_linked"; - - /* api callbacks */ - ot->exec= select_linked_exec; - ot->poll= ED_operator_editmesh; - - /* flags */ - ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; - - RNA_def_boolean(ot->srna, "limit", 0, "Limit by Seams", ""); -} - - /* ************************* */ /* swap is 0 or 1, if 1 it hides not selected */ Modified: branches/bmesh/blender/source/blender/editors/uvedit/uvedit_ops.c @@ Diff output truncated at 10240 characters. @@ _______________________________________________ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org http://lists.blender.org/mailman/listinfo/bf-blender-cvs