added boolean type for bmesh operators, will make python wrapping clearer and also...
[blender.git] / source / blender / editors / mesh / bmesh_select.c
index 553d42a8854a182b616aaaadc2ca3e2e0074576c..1377970083c379e7a61dac78d62003bd2f36fbf5 100644 (file)
@@ -701,7 +701,7 @@ static int similar_face_select_exec(bContext *C, wmOperator *op)
        float thresh = CTX_data_tool_settings(C)->select_thresh;
 
        /* initialize the bmop using EDBM api, which does various ui error reporting and other stuff */
-       EDBM_InitOpf(em, &bmop, op, "similarfaces faces=%hf type=%d thresh=%f", BM_ELEM_SELECT, type, thresh);
+       EDBM_InitOpf(em, &bmop, op, "similarfaces faces=%hf type=%i thresh=%f", BM_ELEM_SELECT, type, thresh);
 
        /* execute the operator */
        BMO_op_exec(em->bm, &bmop);
@@ -742,7 +742,7 @@ static int similar_edge_select_exec(bContext *C, wmOperator *op)
        float thresh = CTX_data_tool_settings(C)->select_thresh;
 
        /* initialize the bmop using EDBM api, which does various ui error reporting and other stuff */
-       EDBM_InitOpf(em, &bmop, op, "similaredges edges=%he type=%d thresh=%f", BM_ELEM_SELECT, type, thresh);
+       EDBM_InitOpf(em, &bmop, op, "similaredges edges=%he type=%i thresh=%f", BM_ELEM_SELECT, type, thresh);
 
        /* execute the operator */
        BMO_op_exec(em->bm, &bmop);
@@ -787,7 +787,7 @@ static int similar_vert_select_exec(bContext *C, wmOperator *op)
        float thresh = CTX_data_tool_settings(C)->select_thresh;
 
        /* initialize the bmop using EDBM api, which does various ui error reporting and other stuff */
-       EDBM_InitOpf(em, &bmop, op, "similarverts verts=%hv type=%d thresh=%f", BM_ELEM_SELECT, type, thresh);
+       EDBM_InitOpf(em, &bmop, op, "similarverts verts=%hv type=%i thresh=%f", BM_ELEM_SELECT, type, thresh);
 
        /* execute the operator */
        BMO_op_exec(em->bm, &bmop);
@@ -1196,7 +1196,7 @@ static int edgetag_context_check(Scene *scene, BMEditMesh *em, BMEdge *e)
        case EDGE_MODE_TAG_SEAM:
                return BM_elem_flag_test(e, BM_ELEM_SEAM);
        case EDGE_MODE_TAG_SHARP:
-               return BM_elem_flag_test(e, BM_ELEM_SHARP);
+               return !BM_elem_flag_test(e, BM_ELEM_SMOOTH);
        case EDGE_MODE_TAG_CREASE:      
                return BM_elem_float_data_get(&em->bm->edata, e, CD_CREASE) ? 1 : 0;
        case EDGE_MODE_TAG_BEVEL:
@@ -1221,7 +1221,7 @@ static int edgetag_shortest_path(Scene *scene, BMEditMesh *em, BMEdge *source, B
        BM_mesh_elem_index_ensure(em->bm, BM_VERT /* | BM_EDGE */);
 
        BM_ITER(e, &iter, em->bm, BM_EDGES_OF_MESH, NULL) {
-               e->head.flags[0].f = 0;
+               e->oflags[0].f = 0; /* XXX, whats this for, BMESH_TODO, double check if this is needed */
                if (BM_elem_flag_test(e, BM_ELEM_HIDDEN)) {
                        BLI_smallhash_insert(&visithash, (uintptr_t)e, NULL);
                }
@@ -1694,6 +1694,38 @@ void EDBM_select_swap(BMEditMesh *em) /* exported for UV */
 //     if (EM_texFaceCheck())
 }
 
+int EDBM_select_interior_faces(struct BMEditMesh *em)
+{
+       BMesh *bm = em->bm;
+       BMIter iter;
+       BMIter eiter;
+       BMFace *efa;
+       BMEdge *eed;
+       int ok;
+       int change = FALSE;
+
+       BM_ITER(efa, &iter, em->bm, BM_FACES_OF_MESH, NULL) {
+               if (BM_elem_flag_test(efa, BM_ELEM_HIDDEN))
+                       continue;
+
+
+               ok = TRUE;
+               BM_ITER(eed, &eiter, bm, BM_EDGES_OF_FACE, efa) {
+                       if (BM_edge_face_count(eed) < 3) {
+                               ok = FALSE;
+                               break;
+                       }
+               }
+
+               if (ok) {
+                       BM_elem_select_set(bm, efa, TRUE);
+                       change = TRUE;
+               }
+       }
+
+       return change;
+}
+
 static void linked_limit_default(bContext *C, wmOperator *op)
 {
        if (!RNA_struct_property_is_set(op->ptr, "limit")) {
@@ -2012,7 +2044,7 @@ static void walker_deselect_nth(BMEditMesh *em, int nth, int offset, BMHeader *h
        BMO_push(bm, NULL);
        BM_ITER(h, &iter, bm, itertype, NULL) {
                if (BM_elem_flag_test(h, BM_ELEM_SELECT)) {
-                       BMO_elem_flag_enable(bm, h, BM_ELEM_SELECT);
+                       BMO_elem_flag_enable(bm, (BMElemF *)h, BM_ELEM_SELECT);
                }
        }
 
@@ -2328,7 +2360,7 @@ static int select_non_manifold_exec(bContext *C, wmOperator *op)
        }
        
        BM_ITER(v, &iter, em->bm, BM_VERTS_OF_MESH, NULL) {
-               if (!BM_elem_flag_test(em->bm, BM_ELEM_HIDDEN) && BM_vert_is_nonmanifold(em->bm, v)) {
+               if (!BM_elem_flag_test(em->bm, BM_ELEM_HIDDEN) && !BM_vert_is_manifold(em->bm, v)) {
                        BM_elem_select_set(em->bm, v, TRUE);
                }
        }