fix [#30768] Project from View UV map tool includes hidden geometry r45323
authorCampbell Barton <ideasman42@gmail.com>
Mon, 2 Apr 2012 04:45:44 +0000 (04:45 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Mon, 2 Apr 2012 04:45:44 +0000 (04:45 +0000)
select all could select hidden faces, now BM_mesh_elem_flag_enable/disable_all takes an argument to skip hidden elements.

source/blender/bmesh/intern/bmesh_marking.c
source/blender/bmesh/intern/bmesh_marking.h
source/blender/bmesh/operators/bmo_inset.c
source/blender/bmesh/operators/bmo_subdivide.c
source/blender/editors/mesh/editmesh_tools.c
source/blender/editors/mesh/editmesh_utils.c
source/blender/modifiers/intern/MOD_array.c

index 2116acc337eb56c62e3e243141b22f4b4254bb6b..3117c74c1a73182570e3254660c15090ceb2ab1d 100644 (file)
@@ -762,7 +762,7 @@ void BM_select_history_validate(BMesh *bm)
        }
 }
 
-void BM_mesh_elem_flag_disable_all(BMesh *bm, const char htype, const char hflag)
+void BM_mesh_elem_flag_disable_all(BMesh *bm, const char htype, const char hflag, int respecthide)
 {
        const char iter_types[3] = {BM_VERTS_OF_MESH,
                                    BM_EDGES_OF_MESH,
@@ -778,7 +778,10 @@ void BM_mesh_elem_flag_disable_all(BMesh *bm, const char htype, const char hflag
                BM_select_history_clear(bm);
        }
 
-       if (htype == (BM_VERT | BM_EDGE | BM_FACE) && (hflag == BM_ELEM_SELECT)) {
+       if ((htype == (BM_VERT | BM_EDGE | BM_FACE)) &&
+           (hflag == BM_ELEM_SELECT) &&
+           (respecthide == FALSE))
+       {
                /* fast path for deselect all, avoid topology loops
                 * since we know all will be de-selected anyway. */
                for (i = 0; i < 3; i++) {
@@ -794,6 +797,11 @@ void BM_mesh_elem_flag_disable_all(BMesh *bm, const char htype, const char hflag
                        if (htype & flag_types[i]) {
                                ele = BM_iter_new(&iter, bm, iter_types[i], NULL);
                                for ( ; ele; ele = BM_iter_step(&iter)) {
+
+                                       if (respecthide && BM_elem_flag_test(ele, BM_ELEM_HIDDEN)) {
+                                               continue;
+                                       }
+
                                        if (hflag & BM_ELEM_SELECT) {
                                                BM_elem_select_set(bm, ele, FALSE);
                                        }
@@ -804,7 +812,7 @@ void BM_mesh_elem_flag_disable_all(BMesh *bm, const char htype, const char hflag
        }
 }
 
-void BM_mesh_elem_flag_enable_all(BMesh *bm, const char htype, const char hflag)
+void BM_mesh_elem_flag_enable_all(BMesh *bm, const char htype, const char hflag, int respecthide)
 {
        const char iter_types[3] = {BM_VERTS_OF_MESH,
                                    BM_EDGES_OF_MESH,
@@ -812,6 +820,11 @@ void BM_mesh_elem_flag_enable_all(BMesh *bm, const char htype, const char hflag)
 
        const char flag_types[3] = {BM_VERT, BM_EDGE, BM_FACE};
 
+       /* use the nosel version when setting so under no
+        * condition may a hidden face become selected.
+        * Applying other flags to hidden faces is OK. */
+       const char hflag_nosel = hflag & ~BM_ELEM_SELECT;
+
        BMIter iter;
        BMElem *ele;
        int i;
@@ -828,10 +841,15 @@ void BM_mesh_elem_flag_enable_all(BMesh *bm, const char htype, const char hflag)
                if (htype & flag_types[i]) {
                        ele = BM_iter_new(&iter, bm, iter_types[i], NULL);
                        for ( ; ele; ele = BM_iter_step(&iter)) {
+
+                               if (respecthide && BM_elem_flag_test(ele, BM_ELEM_HIDDEN)) {
+                                       continue;
+                               }
+
                                if (hflag & BM_ELEM_SELECT) {
                                        BM_elem_select_set(bm, ele, TRUE);
                                }
-                               BM_elem_flag_enable(ele, hflag);
+                               BM_elem_flag_enable(ele, hflag_nosel);
                        }
                }
        }
index a02931b0e886d6caceac2ee36e11b11e69575c99..fa078c74b2ebf2cc7c6aac86dca879471f71c1d7 100644 (file)
@@ -45,8 +45,8 @@ void BM_face_hide_set(BMesh *bm, BMFace *f, int hide);
 #define BM_elem_select_set(bm, ele, hide) _bm_elem_select_set(bm, &(ele)->head, hide)
 void _bm_elem_select_set(BMesh *bm, BMHeader *ele, int select);
 
-void BM_mesh_elem_flag_enable_all(BMesh *bm, const char htype, const char hflag);
-void BM_mesh_elem_flag_disable_all(BMesh *bm, const char htype, const char hflag);
+void BM_mesh_elem_flag_enable_all(BMesh *bm, const char htype, const char hflag, int respecthide);
+void BM_mesh_elem_flag_disable_all(BMesh *bm, const char htype, const char hflag, int respecthide);
 
 /* individual element select functions, BM_elem_select_set is a shortcut for these
  * that automatically detects which one to use*/
index 4a426b40995e93a22795aa4455bb55595f181dcb..23255d1c5147752fbe00d69bc88e3b0b63a6f66b 100644 (file)
@@ -119,11 +119,11 @@ void bmo_inset_exec(BMesh *bm, BMOperator *op)
        int i, j, k;
 
        if (use_outset == FALSE) {
-               BM_mesh_elem_flag_disable_all(bm, BM_FACE, BM_ELEM_TAG);
+               BM_mesh_elem_flag_disable_all(bm, BM_FACE, BM_ELEM_TAG, FALSE);
                BMO_slot_buffer_hflag_enable(bm, op, "faces", BM_FACE, BM_ELEM_TAG, FALSE);
        }
        else {
-               BM_mesh_elem_flag_enable_all(bm, BM_FACE, BM_ELEM_TAG);
+               BM_mesh_elem_flag_enable_all(bm, BM_FACE, BM_ELEM_TAG, FALSE);
                BMO_slot_buffer_hflag_disable(bm, op, "faces", BM_FACE, BM_ELEM_TAG, FALSE);
        }
 
index 03f9fe04394b4a49bfa74256c22f42d2372e2e19..bcd9566ce98b24cb5aea8416cf71d15ff26d45d8 100644 (file)
@@ -1053,7 +1053,7 @@ void BM_mesh_esubdivideflag(Object *UNUSED(obedit), BMesh *bm, int flag, float s
                // int i;
                
                /* deselect input */
-               BM_mesh_elem_flag_disable_all(bm, BM_VERT | BM_EDGE | BM_FACE, BM_ELEM_SELECT);
+               BM_mesh_elem_flag_disable_all(bm, BM_VERT | BM_EDGE | BM_FACE, BM_ELEM_SELECT, FALSE);
 
                ele = BMO_iter_new(&iter, bm, &op, "outinner", BM_EDGE|BM_VERT);
                for ( ; ele; ele = BMO_iter_step(&iter)) {
index 45cef5ca7ef1f98cd8c03dcce76c368576de6fb4..a2d73eaa6bd280dfd0872f4843a74305ece03aa8 100644 (file)
@@ -3463,7 +3463,7 @@ static int edbm_split_exec(bContext *C, wmOperator *op)
 
        EDBM_op_init(em, &bmop, op, "split geom=%hvef use_only_faces=%b", BM_ELEM_SELECT, FALSE);
        BMO_op_exec(em->bm, &bmop);
-       BM_mesh_elem_flag_disable_all(em->bm, BM_VERT | BM_EDGE | BM_FACE, BM_ELEM_SELECT);
+       BM_mesh_elem_flag_disable_all(em->bm, BM_VERT | BM_EDGE | BM_FACE, BM_ELEM_SELECT, FALSE);
        BMO_slot_buffer_hflag_enable(em->bm, &bmop, "geomout", BM_ALL, BM_ELEM_SELECT, TRUE);
        if (!EDBM_op_finish(em, &bmop, op, TRUE)) {
                return OPERATOR_CANCELLED;
index f824a9062c9492b198ba7c7e13f3b7e104659889..40ca1e64fad302056fc2200a7f0bb58bd6761091 100644 (file)
@@ -225,7 +225,7 @@ int EDBM_op_call_and_selectf(BMEditMesh *em, wmOperator *op, const char *selects
 
        BMO_op_exec(bm, &bmop);
 
-       BM_mesh_elem_flag_disable_all(em->bm, BM_VERT | BM_EDGE | BM_FACE, BM_ELEM_SELECT);
+       BM_mesh_elem_flag_disable_all(em->bm, BM_VERT | BM_EDGE | BM_FACE, BM_ELEM_SELECT, FALSE);
 
        BMO_slot_buffer_hflag_enable(em->bm, &bmop, selectslot, BM_ALL, BM_ELEM_SELECT, TRUE);
 
@@ -490,12 +490,12 @@ int EDBM_editselection_active_get(BMEditMesh *em, BMEditSelection *ese)
 
 void EDBM_flag_disable_all(BMEditMesh *em, const char hflag)
 {
-       BM_mesh_elem_flag_disable_all(em->bm, BM_VERT | BM_EDGE | BM_FACE, hflag);
+       BM_mesh_elem_flag_disable_all(em->bm, BM_VERT | BM_EDGE | BM_FACE, hflag, FALSE);
 }
 
 void EDBM_flag_enable_all(BMEditMesh *em, const char hflag)
 {
-       BM_mesh_elem_flag_enable_all(em->bm, BM_VERT | BM_EDGE | BM_FACE, hflag);
+       BM_mesh_elem_flag_enable_all(em->bm, BM_VERT | BM_EDGE | BM_FACE, hflag, TRUE);
 }
 
 /**************-------------- Undo ------------*****************/
index d552e73bc32dc07d0cfdd2d96de6db3e22253e2d..ba74eba04a580c0573aba15da526089efe5a5450 100644 (file)
@@ -474,20 +474,20 @@ static DerivedMesh *arrayModifier_doArray(ArrayModifierData *amd,
        }
 
        if ((amd->flags & MOD_ARR_MERGE) &&
-               (amd->flags & MOD_ARR_MERGEFINAL) &&
-               (count > 1)) {
+           (amd->flags & MOD_ARR_MERGEFINAL) &&
+           (count > 1))
+       {
                /* Merge first and last copies. Note that we can't use the
-                  indexMap for this because (unless the array is forming a
-                  loop) the offset between first and last is different from
-                  dupe X to dupe X+1. */
+                * indexMap for this because (unless the array is forming a
+                * loop) the offset between first and last is different from
+                * dupe X to dupe X+1. */
 
                merge_first_last(em->bm, amd, &first_dupe_op, &dupe_op, &weld_op);
        }
 
        /* start capping */
-       if (start_cap || end_cap)
-       {
-               BM_mesh_elem_flag_enable_all(em->bm, BM_VERT, BM_ELEM_TAG);
+       if (start_cap || end_cap) {
+               BM_mesh_elem_flag_enable_all(em->bm, BM_VERT, BM_ELEM_TAG, FALSE);
 
                if (start_cap) {
                        float startoffset[4][4];