previous fix wasnt working in edge mode, now selection +/- works in vert/edge/face...
authorCampbell Barton <ideasman42@gmail.com>
Thu, 23 Feb 2012 15:47:18 +0000 (15:47 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Thu, 23 Feb 2012 15:47:18 +0000 (15:47 +0000)
source/blender/bmesh/bmesh_operator_api.h
source/blender/bmesh/intern/bmesh_operators.c
source/blender/bmesh/operators/bmo_utils.c
source/blender/editors/mesh/bmesh_select.c
source/blender/editors/mesh/bmesh_tools.c
source/blender/editors/mesh/bmesh_utils.c

index 804515f96bf8cde15a1419b9da748bd169f032d9..79c89392015b77695d94d5fbdff6e9e74c70aaac 100644 (file)
@@ -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
index edfea460f1a12d791f2479f0cba051c55d72a5fc..f26dd7bbe6f96c1ec8d9fc5deb18e020b1cc03e2 100644 (file)
@@ -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);
                }
 
index 7281e6de559af2713625678713ef5384fe3485b8..d80535efb76f81e641a27a99b2565794213072aa 100644 (file)
@@ -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);
+                               }
+
                        }
                }
        }
index 1377970083c379e7a61dac78d62003bd2f36fbf5..73436dbfe14643ada5d6b34badfb10718f8b9f53 100644 (file)
@@ -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)) {
index ba34eb40fa3a8a2a527f299cfd8608e73a742803..947e5a8d5ea3a861f631bb1eca03a9bb26a9099c 100644 (file)
@@ -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;
        }
index 8f69c523d48a30808b32d64169df3c566461b39d..0f49ffa78e823e87eac6c78bba282f3716cee0bf 100644 (file)
@@ -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);