diff options
author | Campbell Barton <ideasman42@gmail.com> | 2012-02-23 19:47:18 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2012-02-23 19:47:18 +0400 |
commit | c6f340e6b050775cec512c1e8eef6e10af4cf996 (patch) | |
tree | 37afef915a4ba49a93087d09e1840328bf239732 | |
parent | 668297c8b8cb874163c837b1c3ecb1068896b3d2 (diff) |
previous fix wasnt working in edge mode, now selection +/- works in vert/edge/face modes.
-rw-r--r-- | source/blender/bmesh/bmesh_operator_api.h | 4 | ||||
-rw-r--r-- | source/blender/bmesh/intern/bmesh_operators.c | 18 | ||||
-rw-r--r-- | source/blender/bmesh/operators/bmo_utils.c | 5 | ||||
-rw-r--r-- | source/blender/editors/mesh/bmesh_select.c | 6 | ||||
-rw-r--r-- | source/blender/editors/mesh/bmesh_tools.c | 30 | ||||
-rw-r--r-- | source/blender/editors/mesh/bmesh_utils.c | 10 |
6 files changed, 44 insertions, 29 deletions
diff --git a/source/blender/bmesh/bmesh_operator_api.h b/source/blender/bmesh/bmesh_operator_api.h index 804515f96bf..79c89392015 100644 --- a/source/blender/bmesh/bmesh_operator_api.h +++ b/source/blender/bmesh/bmesh_operator_api.h @@ -320,10 +320,10 @@ void BMO_slot_buffer_flag_disable(struct BMesh *bm, struct BMOperator *op, const /* tool-flags all elements inside an element slot array with flag flag. */ void BMO_slot_buffer_hflag_enable(struct BMesh *bm, struct BMOperator *op, const char *slotname, - const char hflag, const char htype); + const char hflag, const char htype, char do_flush_select); /* clears tool-flag flag from all elements inside a slot array. */ void BMO_slot_buffer_hflag_disable(struct BMesh *bm, struct BMOperator *op, const char *slotname, - const char hflag, const char htype); + const char hflag, const char htype, char do_flush_select); /* puts every element of type type (which is a bitmask) with header flag * flag, into a slot. note: ignores hidden elements (e.g. elements with diff --git a/source/blender/bmesh/intern/bmesh_operators.c b/source/blender/bmesh/intern/bmesh_operators.c index edfea460f1a..f26dd7bbe6f 100644 --- a/source/blender/bmesh/intern/bmesh_operators.c +++ b/source/blender/bmesh/intern/bmesh_operators.c @@ -765,7 +765,7 @@ void BMO_slot_from_flag(BMesh *bm, BMOperator *op, const char *slotname, * using the selection API where appropriate. */ void BMO_slot_buffer_hflag_enable(BMesh *bm, BMOperator *op, const char *slotname, - const char hflag, const char htype) + const char hflag, const char htype, char do_flush_select) { BMOpSlot *slot = BMO_slot_get(op, slotname); BMHeader **data = slot->data.p; @@ -773,11 +773,15 @@ void BMO_slot_buffer_hflag_enable(BMesh *bm, BMOperator *op, const char *slotnam BLI_assert(slot->slottype > BMO_OP_SLOT_VEC); + if (!(hflag & BM_ELEM_SELECT)) { + do_flush_select = FALSE; + } + for (i = 0; i < slot->len; i++) { if (!(htype & data[i]->htype)) continue; - if (hflag & BM_ELEM_SELECT) { + if (do_flush_select) { BM_elem_select_set(bm, data[i], TRUE); } BM_elem_flag_enable(data[i], hflag); @@ -792,19 +796,23 @@ void BMO_slot_buffer_hflag_enable(BMesh *bm, BMOperator *op, const char *slotnam * using the selection API where appropriate. */ void BMO_slot_buffer_hflag_disable(BMesh *bm, BMOperator *op, const char *slotname, - const char hflag, const char htype) + const char hflag, const char htype, char do_flush_select) { BMOpSlot *slot = BMO_slot_get(op, slotname); BMHeader **data = slot->data.p; int i; BLI_assert(slot->slottype > BMO_OP_SLOT_VEC); - + + if (!(hflag & BM_ELEM_SELECT)) { + do_flush_select = FALSE; + } + for (i = 0; i < slot->len; i++) { if (!(htype & data[i]->htype)) continue; - if (hflag & BM_ELEM_SELECT) { + if (do_flush_select) { BM_elem_select_set(bm, data[i], FALSE); } diff --git a/source/blender/bmesh/operators/bmo_utils.c b/source/blender/bmesh/operators/bmo_utils.c index 7281e6de559..d80535efb76 100644 --- a/source/blender/bmesh/operators/bmo_utils.c +++ b/source/blender/bmesh/operators/bmo_utils.c @@ -194,6 +194,11 @@ static void bmesh_regionextend_constrict(BMesh *bm, BMOperator *op, int usefaces if (e) { BMO_elem_flag_enable(bm, v, SEL_FLAG); + + BM_ITER(e, &eiter, bm, BM_EDGES_OF_VERT, v) { + BMO_elem_flag_enable(bm, e, SEL_FLAG); + } + } } } diff --git a/source/blender/editors/mesh/bmesh_select.c b/source/blender/editors/mesh/bmesh_select.c index 1377970083c..73436dbfe14 100644 --- a/source/blender/editors/mesh/bmesh_select.c +++ b/source/blender/editors/mesh/bmesh_select.c @@ -710,7 +710,7 @@ static int similar_face_select_exec(bContext *C, wmOperator *op) EDBM_flag_disable_all(em, BM_ELEM_SELECT); /* select the output */ - BMO_slot_buffer_hflag_enable(em->bm, &bmop, "faceout", BM_ELEM_SELECT, BM_ALL); + BMO_slot_buffer_hflag_enable(em->bm, &bmop, "faceout", BM_ELEM_SELECT, BM_ALL, TRUE); /* finish the operator */ if (!EDBM_FinishOp(em, &bmop, op, TRUE)) { @@ -751,7 +751,7 @@ static int similar_edge_select_exec(bContext *C, wmOperator *op) EDBM_flag_disable_all(em, BM_ELEM_SELECT); /* select the output */ - BMO_slot_buffer_hflag_enable(em->bm, &bmop, "edgeout", BM_ELEM_SELECT, BM_ALL); + BMO_slot_buffer_hflag_enable(em->bm, &bmop, "edgeout", BM_ELEM_SELECT, BM_ALL, TRUE); EDBM_selectmode_flush(em); /* finish the operator */ @@ -796,7 +796,7 @@ static int similar_vert_select_exec(bContext *C, wmOperator *op) EDBM_flag_disable_all(em, BM_ELEM_SELECT); /* select the output */ - BMO_slot_buffer_hflag_enable(em->bm, &bmop, "vertout", BM_ELEM_SELECT, BM_ALL); + BMO_slot_buffer_hflag_enable(em->bm, &bmop, "vertout", BM_ELEM_SELECT, BM_ALL, TRUE); /* finish the operator */ if (!EDBM_FinishOp(em, &bmop, op, TRUE)) { diff --git a/source/blender/editors/mesh/bmesh_tools.c b/source/blender/editors/mesh/bmesh_tools.c index ba34eb40fa3..947e5a8d5ea 100644 --- a/source/blender/editors/mesh/bmesh_tools.c +++ b/source/blender/editors/mesh/bmesh_tools.c @@ -207,7 +207,7 @@ static short EDBM_Extrude_edges_indiv(BMEditMesh *em, wmOperator *op, const char EDBM_flag_disable_all(em, BM_ELEM_SELECT); BMO_op_exec(em->bm, &bmop); - BMO_slot_buffer_hflag_enable(em->bm, &bmop, "geomout", BM_ELEM_SELECT, BM_VERT|BM_EDGE); + BMO_slot_buffer_hflag_enable(em->bm, &bmop, "geomout", BM_ELEM_SELECT, BM_VERT|BM_EDGE, TRUE); if (!EDBM_FinishOp(em, &bmop, op, TRUE)) { return 0; @@ -224,10 +224,10 @@ static short EDBM_Extrude_verts_indiv(BMEditMesh *em, wmOperator *op, const char EDBM_InitOpf(em, &bmop, op, "extrude_vert_indiv verts=%hv", hflag); /* deselect original verts */ - BMO_slot_buffer_hflag_disable(em->bm, &bmop, "verts", BM_ELEM_SELECT, BM_VERT); + BMO_slot_buffer_hflag_disable(em->bm, &bmop, "verts", BM_ELEM_SELECT, BM_VERT, TRUE); BMO_op_exec(em->bm, &bmop); - BMO_slot_buffer_hflag_enable(em->bm, &bmop, "vertout", BM_ELEM_SELECT, BM_VERT); + BMO_slot_buffer_hflag_enable(em->bm, &bmop, "vertout", BM_ELEM_SELECT, BM_VERT, TRUE); if (!EDBM_FinishOp(em, &bmop, op, TRUE)) { return 0; @@ -1031,7 +1031,7 @@ static int addedgeface_mesh_exec(bContext *C, wmOperator *op) return OPERATOR_CANCELLED; BMO_op_exec(em->bm, &bmop); - BMO_slot_buffer_hflag_enable(em->bm, &bmop, "faceout", BM_ELEM_SELECT, BM_FACE); + BMO_slot_buffer_hflag_enable(em->bm, &bmop, "faceout", BM_ELEM_SELECT, BM_FACE, TRUE); if (!EDBM_FinishOp(em, &bmop, op, TRUE)) { return OPERATOR_CANCELLED; @@ -1262,7 +1262,7 @@ static int mesh_duplicate_exec(bContext *C, wmOperator *op) BMO_op_exec(em->bm, &bmop); EDBM_flag_disable_all(em, BM_ELEM_SELECT); - BMO_slot_buffer_hflag_enable(em->bm, &bmop, "newout", BM_ELEM_SELECT, BM_ALL); + BMO_slot_buffer_hflag_enable(em->bm, &bmop, "newout", BM_ELEM_SELECT, BM_ALL, TRUE); if (!EDBM_FinishOp(em, &bmop, op, TRUE)) { return OPERATOR_CANCELLED; @@ -1387,10 +1387,10 @@ static int edge_rotate_selected(bContext *C, wmOperator *op) /* avoid adding to the selection if we start off with only a selected edge, * we could also just deselect the single edge easily but use the BMO api * since it seems this is more 'correct' */ - if (do_deselect) BMO_slot_buffer_hflag_disable(em->bm, &bmop, "edges", BM_ELEM_SELECT, BM_EDGE); + if (do_deselect) BMO_slot_buffer_hflag_disable(em->bm, &bmop, "edges", BM_ELEM_SELECT, BM_EDGE, TRUE); BMO_op_exec(em->bm, &bmop); - BMO_slot_buffer_hflag_enable(em->bm, &bmop, "edgeout", BM_ELEM_SELECT, BM_EDGE); + BMO_slot_buffer_hflag_enable(em->bm, &bmop, "edgeout", BM_ELEM_SELECT, BM_EDGE, TRUE); if (!EDBM_FinishOp(em, &bmop, op, TRUE)) { return OPERATOR_CANCELLED; @@ -2286,7 +2286,7 @@ static int select_vertex_path_exec(bContext *C, wmOperator *op) /* EDBM_flag_disable_all(em, BM_ELEM_SELECT); */ /* select the output */ - BMO_slot_buffer_hflag_enable(em->bm, &bmop, "vertout", BM_ELEM_SELECT, BM_ALL); + BMO_slot_buffer_hflag_enable(em->bm, &bmop, "vertout", BM_ELEM_SELECT, BM_ALL, TRUE); /* finish the operator */ if (!EDBM_FinishOp(em, &bmop, op, TRUE)) { @@ -2504,7 +2504,7 @@ static int mesh_rip_invoke(bContext *C, wmOperator *op, wmEvent *event) BMBVH_FreeBVH(bvhtree); EDBM_flag_disable_all(em, BM_ELEM_SELECT); - BMO_slot_buffer_hflag_enable(bm, &bmop, side?"edgeout2":"edgeout1", BM_ELEM_SELECT, BM_EDGE); + BMO_slot_buffer_hflag_enable(bm, &bmop, side?"edgeout2":"edgeout1", BM_ELEM_SELECT, BM_EDGE, TRUE); BM_ITER(e, &iter, bm, BM_EDGES_OF_MESH, NULL) { if (BM_elem_flag_test(e, BM_ELEM_SELECT)) { @@ -2839,13 +2839,13 @@ static int solidify_exec(bContext *C, wmOperator *op) /* deselect only the faces in the region to be solidified (leave wire edges and loose verts selected, as there will be no corresponding geometry selected below) */ - BMO_slot_buffer_hflag_disable(bm, &bmop, "geom", BM_ELEM_SELECT, BM_FACE); + BMO_slot_buffer_hflag_disable(bm, &bmop, "geom", BM_ELEM_SELECT, BM_FACE, TRUE); /* run the solidify operator */ BMO_op_exec(bm, &bmop); /* select the newly generated faces */ - BMO_slot_buffer_hflag_enable(bm, &bmop, "geomout", BM_ELEM_SELECT, BM_FACE); + BMO_slot_buffer_hflag_enable(bm, &bmop, "geomout", BM_ELEM_SELECT, BM_FACE, TRUE); if (!EDBM_FinishOp(em, &bmop, op, TRUE)) { return OPERATOR_CANCELLED; @@ -3416,7 +3416,7 @@ static int fill_mesh_exec(bContext *C, wmOperator *op) BMO_op_exec(em->bm, &bmop); /* select new geometry */ - BMO_slot_buffer_hflag_enable(em->bm, &bmop, "geomout", BM_ELEM_SELECT, BM_FACE|BM_EDGE); + BMO_slot_buffer_hflag_enable(em->bm, &bmop, "geomout", BM_ELEM_SELECT, BM_FACE|BM_EDGE, TRUE); if (!EDBM_FinishOp(em, &bmop, op, TRUE)) { return OPERATOR_CANCELLED; @@ -3630,7 +3630,7 @@ static int split_mesh_exec(bContext *C, wmOperator *op) EDBM_InitOpf(em, &bmop, op, "split geom=%hvef", BM_ELEM_SELECT); BMO_op_exec(em->bm, &bmop); BM_mesh_elem_flag_disable_all(em->bm, BM_VERT | BM_EDGE | BM_FACE, BM_ELEM_SELECT); - BMO_slot_buffer_hflag_enable(em->bm, &bmop, "geomout", BM_ELEM_SELECT, BM_ALL); + BMO_slot_buffer_hflag_enable(em->bm, &bmop, "geomout", BM_ELEM_SELECT, BM_ALL, TRUE); if (!EDBM_FinishOp(em, &bmop, op, TRUE)) { return OPERATOR_CANCELLED; } @@ -3693,7 +3693,7 @@ static int spin_mesh_exec(bContext *C, wmOperator *op) } BMO_op_exec(bm, &spinop); EDBM_flag_disable_all(em, BM_ELEM_SELECT); - BMO_slot_buffer_hflag_enable(bm, &spinop, "lastout", BM_ELEM_SELECT, BM_ALL); + BMO_slot_buffer_hflag_enable(bm, &spinop, "lastout", BM_ELEM_SELECT, BM_ALL, TRUE); if (!EDBM_FinishOp(em, &spinop, op, TRUE)) { return OPERATOR_CANCELLED; } @@ -3819,7 +3819,7 @@ static int screw_mesh_exec(bContext *C, wmOperator *op) } BMO_op_exec(bm, &spinop); EDBM_flag_disable_all(em, BM_ELEM_SELECT); - BMO_slot_buffer_hflag_enable(bm, &spinop, "lastout", BM_ELEM_SELECT, BM_ALL); + BMO_slot_buffer_hflag_enable(bm, &spinop, "lastout", BM_ELEM_SELECT, BM_ALL, TRUE); if (!EDBM_FinishOp(em, &spinop, op, TRUE)) { return OPERATOR_CANCELLED; } diff --git a/source/blender/editors/mesh/bmesh_utils.c b/source/blender/editors/mesh/bmesh_utils.c index 8f69c523d48..0f49ffa78e8 100644 --- a/source/blender/editors/mesh/bmesh_utils.c +++ b/source/blender/editors/mesh/bmesh_utils.c @@ -209,7 +209,7 @@ int EDBM_CallAndSelectOpf(BMEditMesh *em, wmOperator *op, const char *selectslot BM_mesh_elem_flag_disable_all(em->bm, BM_VERT|BM_EDGE|BM_FACE, BM_ELEM_SELECT); - BMO_slot_buffer_hflag_enable(em->bm, &bmop, selectslot, BM_ELEM_SELECT, BM_ALL); + BMO_slot_buffer_hflag_enable(em->bm, &bmop, selectslot, BM_ELEM_SELECT, BM_ALL, TRUE); va_end(list); return EDBM_FinishOp(em, &bmop, op, TRUE); @@ -418,10 +418,11 @@ void EDBM_select_more(BMEditMesh *em) "regionextend geom=%hvef constrict=%b use_faces=%b", BM_ELEM_SELECT, FALSE, use_faces); BMO_op_exec(em->bm, &bmop); - BMO_slot_buffer_hflag_enable(em->bm, &bmop, "geomout", BM_ELEM_SELECT, BM_ALL); + /* dont flush selection in edge/vertex mode */ + BMO_slot_buffer_hflag_enable(em->bm, &bmop, "geomout", BM_ELEM_SELECT, BM_ALL, use_faces ? TRUE : FALSE); BMO_op_finish(em->bm, &bmop); - EDBM_selectmode_flush(em); + EDBM_select_flush(em); } void EDBM_select_less(BMEditMesh *em) @@ -433,7 +434,8 @@ void EDBM_select_less(BMEditMesh *em) "regionextend geom=%hvef constrict=%b use_faces=%b", BM_ELEM_SELECT, TRUE, use_faces); BMO_op_exec(em->bm, &bmop); - BMO_slot_buffer_hflag_disable(em->bm, &bmop, "geomout", BM_ELEM_SELECT, BM_ALL); + /* dont flush selection in edge/vertex mode */ + BMO_slot_buffer_hflag_disable(em->bm, &bmop, "geomout", BM_ELEM_SELECT, BM_ALL, use_faces ? TRUE : FALSE); BMO_op_finish(em->bm, &bmop); EDBM_selectmode_flush(em); |