diff options
author | Campbell Barton <ideasman42@gmail.com> | 2012-02-10 10:16:21 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2012-02-10 10:16:21 +0400 |
commit | 3453ec8fae3b55a2a50e8bfd298b836c38ce7e41 (patch) | |
tree | e76f6edd29f2172e9b3746f373c0fa3762747993 /source | |
parent | d7b8e7e9bcc63447e708c2709b51fe4fdb7930f2 (diff) |
reviewed selection flushing code, some of this was incorrect, checked all uses against trunk.
loop select also was incorrectly calling EDBM_select_flush() rather then EDBM_store_selection(), tsk tsk. (and strange nobody noticed this).
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/editors/include/ED_mesh.h | 5 | ||||
-rw-r--r-- | source/blender/editors/mesh/bmesh_select.c | 47 | ||||
-rw-r--r-- | source/blender/editors/mesh/bmesh_tools.c | 40 | ||||
-rw-r--r-- | source/blender/editors/mesh/bmeshutils.c | 11 | ||||
-rw-r--r-- | source/blender/editors/mesh/editbmesh_add.c | 4 | ||||
-rw-r--r-- | source/blender/editors/mesh/loopcut.c | 6 | ||||
-rw-r--r-- | source/blender/editors/space_view3d/view3d_select.c | 6 | ||||
-rw-r--r-- | source/blender/editors/uvedit/uvedit_ops.c | 16 |
8 files changed, 72 insertions, 63 deletions
diff --git a/source/blender/editors/include/ED_mesh.h b/source/blender/editors/include/ED_mesh.h index 41472f01499..322d7c2a184 100644 --- a/source/blender/editors/include/ED_mesh.h +++ b/source/blender/editors/include/ED_mesh.h @@ -157,9 +157,8 @@ void EDBM_select_less(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_mode_flush(struct BMEditMesh *em, int selectmode); +void EDBM_selectmode_flush_ex(struct BMEditMesh *em, int selectmode); +void EDBM_selectmode_flush(struct BMEditMesh *em); void EDBM_deselect_flush(struct BMEditMesh *em); void EDBM_select_flush(struct BMEditMesh *em); diff --git a/source/blender/editors/mesh/bmesh_select.c b/source/blender/editors/mesh/bmesh_select.c index 40ce1973c57..2043c0d0837 100644 --- a/source/blender/editors/mesh/bmesh_select.c +++ b/source/blender/editors/mesh/bmesh_select.c @@ -766,7 +766,7 @@ static int similar_edge_select_exec(bContext *C, wmOperator *op) /* select the output */ BMO_HeaderFlag_Buffer(em->bm, &bmop, "edgeout", BM_SELECT, BM_ALL); - EDBM_select_flush(em); + EDBM_selectmode_flush(em); /* finish the operator */ if (!EDBM_FinishOp(em, &bmop, op, TRUE)) { @@ -817,7 +817,7 @@ static int similar_vert_select_exec(bContext *C, wmOperator *op) return OPERATOR_CANCELLED; } - EDBM_select_flush(em); + EDBM_selectmode_flush(em); /* dependencies graph and notification stuff */ DAG_id_tag_update(ob->data, OB_RECALC_DATA); @@ -956,14 +956,14 @@ static int loop_multiselect(bContext *C, wmOperator *op) eed = edarray[edindex]; walker_select(em, BMW_EDGERING, eed, 1); } - EDBM_select_flush(em); + EDBM_selectmode_flush(em); } else{ for(edindex = 0; edindex < totedgesel; edindex +=1) { eed = edarray[edindex]; walker_select(em, BMW_LOOP, eed, 1); } - EDBM_select_flush(em); + EDBM_selectmode_flush(em); } MEM_freeN(edarray); // if (EM_texFaceCheck()) @@ -1041,7 +1041,7 @@ static void mouse_mesh_loop(bContext *C, int mval[2], short extend, short ring) walker_select(em, BMW_LOOP, eed, select); } - EDBM_select_flush(em); + EDBM_selectmode_flush(em); // if (EM_texFaceCheck()) /* sets as active, useful for other tools */ @@ -1394,7 +1394,7 @@ static void mouse_mesh_shortest_path(bContext *C, int mval[2]) edgetag_context_set(em, vc.scene, e, act); /* switch the edge option */ } - EDBM_select_flush(em); + EDBM_selectmode_flush(em); /* even if this is selected it may not be in the selection list */ if (edgetag_context_check(vc.scene, em, e)==0) @@ -1506,7 +1506,7 @@ int mouse_mesh(bContext *C, const int mval[2], short extend) } } - EDBM_select_flush(vc.em); + EDBM_selectmode_flush(vc.em); // if (EM_texFaceCheck()) { @@ -1567,14 +1567,6 @@ void EDBM_selectmode_set(BMEditMesh *em) EDBM_strip_selections(em); /*strip BMEditSelections from em->selected that are not relevant to new mode*/ if (em->selectmode & SCE_SELECT_VERTEX) { - /*BMIter iter; - - eed = BMIter_New(&iter, em->bm, BM_EDGES_OF_MESH, NULL); - for ( ; eed; eed=BMIter_Step(&iter)) BM_Select(em->bm, eed, FALSE); - - efa = BMIter_New(&iter, em->bm, BM_FACES_OF_MESH, NULL); - for ( ; efa; efa=BMIter_Step(&iter)) BM_Select(em->bm, efa, FALSE);*/ - EDBM_select_flush(em); } else if (em->selectmode & SCE_SELECT_EDGE) { @@ -1590,7 +1582,7 @@ void EDBM_selectmode_set(BMEditMesh *em) } /* selects faces based on edge status */ - EDBM_select_flush(em); + EDBM_selectmode_flush(em); } else if (em->selectmode & SCE_SELECT_FACE) { /* deselect eges, and select again based on face select */ @@ -1809,7 +1801,16 @@ static int select_linked_pick_invoke(bContext *C, wmOperator *op, wmEvent *event BM_Select(bm, e->v2, sel); } BMW_End(&walker); - EDBM_select_mode_flush(em, SCE_SELECT_VERTEX); + + /* BMESH_TODO, see trunks 'select_linked_pick_invoke' this uses 'f1' flag and does its own flushing + * the problem with calling selectmode flush below is that it will select edges from parts + * of the mesh that didnt change, perhaps we should have selection flushing functions that only check + * tagged geometry. + * For now I dont think this is a showstopper - campbell */ + + /* now use vertex select flag to select rest */ + EDBM_selectmode_flush_ex(em, SCE_SELECT_VERTEX); + } WM_event_add_notifier(C, NC_GEOM|ND_SELECT, obedit); @@ -1908,7 +1909,7 @@ static int select_linked_exec(bContext *C, wmOperator *op) } BMW_End(&walker); } - EDBM_select_mode_flush(em, SCE_SELECT_VERTEX); + EDBM_selectmode_flush_ex(em, SCE_SELECT_VERTEX); WM_event_add_notifier(C, NC_GEOM|ND_SELECT, obedit); @@ -2052,7 +2053,7 @@ static void walker_deselect_nth(BMEditMesh *em, int nth, int offset, BMHeader *h BMO_pop(bm); /* Flush selection up */ - EDBM_select_mode_flush(em, flushtype); + EDBM_selectmode_flush_ex(em, flushtype); } static void deselect_nth_active(BMEditMesh *em, BMVert **v_p, BMEdge **e_p, BMFace **f_p) @@ -2067,7 +2068,7 @@ static void deselect_nth_active(BMEditMesh *em, BMVert **v_p, BMEdge **e_p, BMFa *e_p= NULL; *f_p= NULL; - EDBM_select_flush(em); + EDBM_selectmode_flush(em); ese= (BMEditSelection*)em->bm->selected.last; if (ese) { @@ -2399,7 +2400,7 @@ static int mesh_select_random_exec(bContext *C, wmOperator *op) BM_Select(em->bm, eve, TRUE); } } - EDBM_select_flush(em); + EDBM_selectmode_flush(em); } else if (em->selectmode & SCE_SELECT_EDGE) { BM_ITER(eed, &iter, em->bm, BM_EDGES_OF_MESH, NULL) { @@ -2407,7 +2408,7 @@ static int mesh_select_random_exec(bContext *C, wmOperator *op) BM_Select(em->bm, eed, TRUE); } } - EDBM_select_flush(em); + EDBM_selectmode_flush(em); } else { BM_ITER(efa, &iter, em->bm, BM_FACES_OF_MESH, NULL) { @@ -2415,7 +2416,7 @@ static int mesh_select_random_exec(bContext *C, wmOperator *op) BM_Select(em->bm, efa, TRUE); } } - EDBM_select_flush(em); + EDBM_selectmode_flush(em); } WM_event_add_notifier(C, NC_GEOM|ND_SELECT, obedit->data); diff --git a/source/blender/editors/mesh/bmesh_tools.c b/source/blender/editors/mesh/bmesh_tools.c index 15ca5ed95e4..7b8478f37aa 100644 --- a/source/blender/editors/mesh/bmesh_tools.c +++ b/source/blender/editors/mesh/bmesh_tools.c @@ -1445,7 +1445,7 @@ void EDBM_hide_mesh(BMEditMesh *em, int swap) BM_Hide(em->bm, h, 1); } - EDBM_select_flush(em); + EDBM_selectmode_flush(em); /*original hide flushing comment (OUTDATED): hide happens on least dominant select mode, and flushes up, not down! (helps preventing errors in subsurf) */ @@ -1532,7 +1532,7 @@ void EDBM_reveal_mesh(BMEditMesh *em) } } - EDBM_select_flush(em); + EDBM_selectmode_flush(em); } static int reveal_mesh_exec(bContext *C, wmOperator *UNUSED(op)) @@ -2296,7 +2296,7 @@ static int select_vertex_path_exec(bContext *C, wmOperator *op) return OPERATOR_CANCELLED; } - EDBM_select_flush(em); + EDBM_selectmode_flush(em); /* dependencies graph and notification stuff */ /* DAG_object_flush_update(scene, ob, OB_RECALC_DATA); @@ -2541,7 +2541,7 @@ static int mesh_rip_invoke(bContext *C, wmOperator *op, wmEvent *event) BM_Select(bm, ripvert, TRUE); } - EDBM_select_flush(em); + EDBM_selectmode_flush(em); BLI_assert(singlesel ? (bm->totvertsel > 0) : (bm->totedgesel > 0)); @@ -2788,7 +2788,7 @@ static int select_axis_exec(bContext *C, wmOperator *op) } } - EDBM_select_flush(em); + EDBM_selectmode_flush(em); WM_event_add_notifier(C, NC_GEOM|ND_DATA, obedit->data); return OPERATOR_FINISHED; @@ -3296,20 +3296,20 @@ static int mesh_separate_loose(Main *bmain, Scene *scene, Base *editbase, wmOper BMesh *bm = em->bm; int max_iter = bm->totvert; - /*Clear all selected vertices*/ + /* Clear all selected vertices */ BM_ITER(v, &iter, bm, BM_VERTS_OF_MESH, NULL) { BM_Select(bm, v, FALSE); } - /*Flush the selection to clear edge/face selections to match - selected vertices*/ - EDBM_select_mode_flush(em, SCE_SELECT_VERTEX); + /* Flush the selection to clear edge/face selections to match + * selected vertices*/ + EDBM_selectmode_flush_ex(em, SCE_SELECT_VERTEX); - /*A "while(true)" loop should work here as each iteration should - select and remove at least one vertex and when all vertices - are selected the loop will break out. But guard against bad - behavior by limiting iterations to the number of vertices in the - original mesh.*/ + /* A "while(true)" loop should work here as each iteration should + * select and remove at least one vertex and when all vertices + * are selected the loop will break out. But guard against bad + * behavior by limiting iterations to the number of vertices in the + * original mesh.*/ for(i=0; i<max_iter; i++) { /* Get a seed vertex to start the walk */ @@ -3340,9 +3340,9 @@ static int mesh_separate_loose(Main *bmain, Scene *scene, Base *editbase, wmOper } BMW_End(&walker); - /*Flush the selection to get edge/face selections matching - the vertex selection*/ - EDBM_select_mode_flush(em, SCE_SELECT_VERTEX); + /* Flush the selection to get edge/face selections matching + * the vertex selection*/ + EDBM_selectmode_flush_ex(em, SCE_SELECT_VERTEX); if (bm->totvert == bm->totvertsel) { /* Every vertex selected, nothing to separate, work is done */ @@ -3849,7 +3849,7 @@ static int select_by_number_vertices_exec(bContext *C, wmOperator *op) } } - EDBM_select_flush(em); + EDBM_selectmode_flush(em); WM_event_add_notifier(C, NC_GEOM|ND_SELECT, obedit->data); return OPERATOR_FINISHED; @@ -3905,7 +3905,7 @@ static int select_loose_verts_exec(bContext *C, wmOperator *UNUSED(op)) } } - EDBM_select_flush(em); + EDBM_selectmode_flush(em); WM_event_add_notifier(C, NC_GEOM|ND_SELECT, obedit->data); return OPERATOR_FINISHED; @@ -3933,7 +3933,7 @@ static int select_mirror_exec(bContext *C, wmOperator *op) int extend= RNA_boolean_get(op->ptr, "extend"); EDBM_select_mirrored(obedit, em, extend); - EDBM_select_flush(em); + EDBM_selectmode_flush(em); WM_event_add_notifier(C, NC_GEOM|ND_SELECT, obedit->data); return OPERATOR_FINISHED; diff --git a/source/blender/editors/mesh/bmeshutils.c b/source/blender/editors/mesh/bmeshutils.c index daa95139978..d5eb7a16a34 100644 --- a/source/blender/editors/mesh/bmeshutils.c +++ b/source/blender/editors/mesh/bmeshutils.c @@ -418,13 +418,18 @@ BMFace *EDBM_get_face_for_index(BMEditMesh *tm, int index) return (tm->face_index && index<tm->bm->totface && index>=0) ? tm->face_index[index] : NULL; } -void EDBM_select_mode_flush(BMEditMesh *em, int selectmode) +void EDBM_selectmode_flush_ex(BMEditMesh *em, int selectmode) { em->bm->selectmode = selectmode; BM_SelectMode_Flush(em->bm); em->bm->selectmode = em->selectmode; } +void EDBM_selectmode_flush(BMEditMesh *em) +{ + EDBM_selectmode_flush_ex(em, em->selectmode); +} + void EDBM_deselect_flush(BMEditMesh *em) { /* function below doesnt use. just do this to keep the values in sync */ @@ -452,7 +457,7 @@ void EDBM_select_more(BMEditMesh *em) BMO_HeaderFlag_Buffer(em->bm, &bmop, "geomout", BM_SELECT, BM_ALL); BMO_Finish_Op(em->bm, &bmop); - EDBM_select_flush(em); + EDBM_selectmode_flush(em); } void EDBM_select_less(BMEditMesh *em) @@ -467,7 +472,7 @@ void EDBM_select_less(BMEditMesh *em) BMO_HeaderFlag_Buffer(em->bm, &bmop, "geomout", BM_SELECT, BM_ALL); BMO_Finish_Op(em->bm, &bmop); - EDBM_select_flush(em); + EDBM_selectmode_flush(em); } int EDBM_get_actSelection(BMEditMesh *em, BMEditSelection *ese) diff --git a/source/blender/editors/mesh/editbmesh_add.c b/source/blender/editors/mesh/editbmesh_add.c index 997f96db735..98462647db9 100644 --- a/source/blender/editors/mesh/editbmesh_add.c +++ b/source/blender/editors/mesh/editbmesh_add.c @@ -151,8 +151,8 @@ static void make_prim_finish(bContext *C, int *state, int enter_editmode) em = me->edit_btmesh; /* Primitive has all verts selected, use vert select flush - to push this up to edges & faces. */ - EDBM_select_mode_flush(em, SCE_SELECT_VERTEX); + * to push this up to edges & faces. */ + EDBM_selectmode_flush_ex(em, SCE_SELECT_VERTEX); DAG_id_tag_update(obedit->data, OB_RECALC_DATA); WM_event_add_notifier(C, NC_GEOM|ND_DATA, obedit->data); diff --git a/source/blender/editors/mesh/loopcut.c b/source/blender/editors/mesh/loopcut.c index 5081ad1600b..f78a2bdf49c 100644 --- a/source/blender/editors/mesh/loopcut.c +++ b/source/blender/editors/mesh/loopcut.c @@ -333,11 +333,11 @@ static void ringsel_finish(bContext *C, wmOperator *op) /* sets as active, useful for other tools */ if(em->selectmode & SCE_SELECT_VERTEX) - EDBM_select_flush(em); + EDBM_store_selection(em, lcd->eed->v1); /* low priority TODO, get vertrex close to mouse */ if(em->selectmode & SCE_SELECT_EDGE) - EDBM_select_flush(em); + EDBM_store_selection(em, lcd->eed); - EDBM_select_flush(lcd->em); + EDBM_selectmode_flush(lcd->em); WM_event_add_notifier(C, NC_GEOM|ND_SELECT, lcd->ob->data); } } diff --git a/source/blender/editors/space_view3d/view3d_select.c b/source/blender/editors/space_view3d/view3d_select.c index 7e6b77047ea..5d7901a481b 100644 --- a/source/blender/editors/space_view3d/view3d_select.c +++ b/source/blender/editors/space_view3d/view3d_select.c @@ -562,7 +562,7 @@ static void do_lasso_select_mesh(ViewContext *vc, int mcords[][2], short moves, } EDBM_free_backbuf(); - EDBM_select_flush(vc->em); + EDBM_selectmode_flush(vc->em); } #if 0 @@ -1819,7 +1819,7 @@ static int do_mesh_box_select(ViewContext *vc, rcti *rect, int select, int exten EDBM_free_backbuf(); - EDBM_select_flush(vc->em); + EDBM_selectmode_flush(vc->em); return OPERATOR_FINISHED; } @@ -2348,7 +2348,7 @@ static void mesh_circle_select(ViewContext *vc, int select, const int mval[2], f } EDBM_free_backbuf(); - EDBM_select_flush(vc->em); + EDBM_selectmode_flush(vc->em); } static void paint_facesel_circle_select(ViewContext *vc, int select, const int mval[2], float rad) diff --git a/source/blender/editors/uvedit/uvedit_ops.c b/source/blender/editors/uvedit/uvedit_ops.c index f7bc631e27c..a3dcec011ef 100644 --- a/source/blender/editors/uvedit/uvedit_ops.c +++ b/source/blender/editors/uvedit/uvedit_ops.c @@ -2176,15 +2176,19 @@ static int mouse_select(bContext *C, float co[2], int extend, int loop) } } +#if 0 /* BM_Select API handles all of this? */ + if(sync) { /* flush for mesh selection */ if(ts->selectmode != SCE_SELECT_FACE) { - if(flush==1) EDBM_select_mode_flush(em, ts->selectmode); - //else if(flush==-1) EDBM_deselect_flush(em); <-- I think this takes care of itself. . . + if(flush==1) EDBM_select_flush(em); + else if(flush==-1) EDBM_deselect_flush(em); } } - DAG_id_tag_update(obedit->data, 0); +#endif + + DAG_id_tag_update(obedit->data, 0); WM_event_add_notifier(C, NC_GEOM|ND_SELECT, obedit->data); BLI_array_free(hitv); @@ -2680,11 +2684,11 @@ static int border_select_exec(bContext *C, wmOperator *op) if(change) { /* make sure newly selected vert selection is updated*/ -#if 0 //ok, I think the BM_Select API handles all of this? +#if 0 /* BM_Select API handles all of this? */ if(ts->uv_flag & UV_SYNC_SELECTION) { if(ts->selectmode != SCE_SELECT_FACE) { - if(select) EM_select_flush(em); - else EM_deselect_flush(em); + if(select) EDBM_select_flush(em); + else EDBM_deselect_flush(em); } } #endif |