~ubuntu-branches/ubuntu/trusty/blender/trusty

« back to all changes in this revision

Viewing changes to source/blender/bmesh/operators/bmo_create.c

  • Committer: Package Import Robot
  • Author(s): Jeremy Bicha
  • Date: 2013-03-06 12:08:47 UTC
  • mfrom: (1.5.1) (14.1.8 experimental)
  • Revision ID: package-import@ubuntu.com-20130306120847-frjfaryb2zrotwcg
Tags: 2.66a-1ubuntu1
* Resynchronize with Debian (LP: #1076930, #1089256, #1052743, #999024,
  #1122888, #1147084)
* debian/control:
  - Lower build-depends on libavcodec-dev since we're not
    doing the libav9 transition in Ubuntu yet

Show diffs side-by-side

added added

removed removed

Lines of Context:
83
83
 
84
84
BLI_INLINE BMDiskLink *rs_edge_link_get(BMEdge *e, BMVert *v, EdgeData *e_data)
85
85
{
86
 
        return  v == ((BMEdge *)e)->v1 ? &(((EdgeData *)e_data)->v1_disk_link) :
87
 
                                         &(((EdgeData *)e_data)->v2_disk_link) ;
 
86
        return v == ((BMEdge *)e)->v1 ? &(((EdgeData *)e_data)->v1_disk_link) :
 
87
                                        &(((EdgeData *)e_data)->v2_disk_link);
88
88
}
89
89
 
90
 
static int rotsys_append_edge(BMEdge *e, BMVert *v,
91
 
                              EdgeData *edata, VertData *vdata)
 
90
static bool rotsys_append_edge(BMEdge *e, BMVert *v,
 
91
                               EdgeData *edata, VertData *vdata)
92
92
{
93
93
        EdgeData *ed = &edata[BM_elem_index_get(e)];
94
94
        VertData *vd = &vdata[BM_elem_index_get(v)];
116
116
                }
117
117
        }
118
118
 
119
 
        return TRUE;
 
119
        return true;
120
120
}
121
121
 
122
122
static void UNUSED_FUNCTION(rotsys_remove_edge)(BMEdge *e, BMVert *v,
168
168
        BMEdge **edges = NULL;
169
169
        BMEdge *e_first;
170
170
        BMEdge *e;
171
 
        BLI_array_staticdeclare(edges, BM_NGON_STACK_SIZE);
 
171
        BLI_array_staticdeclare(edges, BM_DEFAULT_NGON_STACK_SIZE);
172
172
        int i, totedge;
173
173
        
174
174
        e = e_first = vdata[BM_elem_index_get(v)].e;
274
274
                        if (!ok || BLI_array_count(edges) < 3)
275
275
                                continue;
276
276
                        
277
 
                        f = BM_face_create_ngon(bm, verts[0], verts[1], edges, BLI_array_count(edges), TRUE);
278
 
                        if (!f)
 
277
                        f = BM_face_create_ngon(bm, verts[0], verts[1], edges, BLI_array_count(edges), BM_CREATE_NO_DOUBLE);
 
278
                        if (UNLIKELY(f == NULL)) {
279
279
                                continue;
 
280
                        }
280
281
                }
281
282
        }
282
283
        
358
359
        BMIter iter;
359
360
        BMEdge *e;
360
361
        BMEdge **edges = NULL;
361
 
        BLI_array_staticdeclare(edges, BM_NGON_STACK_SIZE);
 
362
        BLI_array_staticdeclare(edges, BM_DEFAULT_NGON_STACK_SIZE);
362
363
        BMVert *v;
363
364
        /* BMVert **verts = NULL; */
364
 
        /* BLI_array_staticdeclare(verts, BM_NGON_STACK_SIZE); */ /* UNUSE */
 
365
        /* BLI_array_staticdeclare(verts, BM_DEFAULT_NGON_STACK_SIZE); */ /* UNUSE */
365
366
        int i;
366
367
        
367
 
#define SIGN(n) ((n)<0.0f)
368
 
        
369
368
        BM_ITER_MESH (v, &iter, bm, BM_VERTS_OF_MESH) {
370
369
                BMIter eiter;
371
370
                float no[3], cent[3];
579
578
        //rotsys_fill_faces(bm, edata, vdata);
580
579
 
581
580
#if 0
582
 
        /* create visualizing geometr */
 
581
        /* create visualizing geometry */
583
582
        BMVert *lastv;
584
583
        BM_ITER_MESH (v, &iter, bm, BM_VERTS_OF_MESH) {
585
584
                BMVert *v2;
612
611
                        
613
612
                        v2 = BM_vert_create(bm, co, NULL);
614
613
                        BM_elem_index_set(v2, -1); /* set_dirty! */
615
 
                        //BM_edge_create(bm, cv, v2, NULL, FALSE);
 
614
                        //BM_edge_create(bm, cv, v2, NULL, 0);
616
615
                        
617
 
                        BM_vert_select_set(bm, v2, TRUE);
 
616
                        BM_vert_select_set(bm, v2, true);
618
617
                        if (lastv) {
619
 
                                e2 = BM_edge_create(bm, lastv, v2, NULL, FALSE);
620
 
                                BM_edge_select_set(bm, e2, TRUE);
 
618
                                e2 = BM_edge_create(bm, lastv, v2, NULL, 0);
 
619
                                BM_edge_select_set(bm, e2, true);
621
620
                        }
622
621
                        
623
622
                        lastv = v2;
733
732
                                      VertData *vdata, PathBase *pathbase, int group)
734
733
{
735
734
        BMEdge *e;
736
 
        GHash *gh = BLI_ghash_new(BLI_ghashutil_ptrhash, BLI_ghashutil_ptrcmp, "createops find shortest path");
 
735
        GHash *gh = BLI_ghash_ptr_new("createops find shortest path");
737
736
        BMVert *v1, *v2;
738
737
        BMVert **verts = NULL;
739
738
        BLI_array_staticdeclare(verts, 1024);
742
741
        BMVert *startv;
743
742
        BMVert *endv;
744
743
        EPathNode *node;
745
 
        int i, use_restrict = BMO_slot_bool_get(op, "use_restrict");
 
744
        int i;
 
745
        const bool use_restrict = BMO_slot_bool_get(op->slots_in, "use_restrict");
 
746
        BMOpSlot *slot_restrict = BMO_slot_get(op->slots_in, "restrict");
 
747
 
746
748
 
747
749
        startv = edata[BM_elem_index_get(edge)].ftag ? edge->v2 : edge->v1;
748
750
        endv = edata[BM_elem_index_get(edge)].ftag ? edge->v1 : edge->v2;
766
768
                        i = 0;
767
769
                        BLI_array_empty(verts);
768
770
                        for (i = 0, node = path->nodes.first; node; node = node->next, i++) {
769
 
                                BLI_array_growone(verts);
 
771
                                BLI_array_grow_one(verts);
770
772
                                verts[i] = node->v;
771
773
                        }
772
774
 
773
 
                        if (BM_face_exists(bm, verts, i, &f)) {
 
775
                        if (BM_face_exists(verts, i, &f)) {
774
776
                                if (!BMO_elem_flag_test(bm, f, FACE_IGNORE)) {
775
777
                                        BLI_ghash_remove(gh, endv, NULL, NULL);
776
778
                                        continue;
807
809
                                continue;
808
810
                        }
809
811
                        
810
 
                        if (use_restrict && BMO_slot_map_contains(bm, op, "restrict", e)) {
811
 
                                int group = BMO_slot_map_int_get(bm, op, "restrict", e);
812
 
                                
813
 
                                if (!(group & path->group)) {
814
 
                                        v2 = NULL;
815
 
                                        continue;
 
812
                        if (use_restrict) {
 
813
                                int *group = (int *)BMO_slot_map_data_get(slot_restrict, e);
 
814
                                if (group) {
 
815
                                        if (!(*group & path->group)) {
 
816
                                                v2 = NULL;
 
817
                                                continue;
 
818
                                        }
816
819
                                }
817
820
                        }
818
821
 
896
899
        BMEdge **edges = NULL;
897
900
        PathBase *pathbase;
898
901
        BLI_array_declare(edges);
899
 
        int use_restrict       = BMO_slot_bool_get(op, "use_restrict");
900
 
        int use_fill_check     = BMO_slot_bool_get(op, "use_fill_check");
901
 
        const short mat_nr     = BMO_slot_int_get(op,  "mat_nr");
902
 
        const short use_smooth = BMO_slot_bool_get(op, "use_smooth");
 
902
        const bool use_restrict   = BMO_slot_bool_get(op->slots_in, "use_restrict");
 
903
        const bool use_fill_check = BMO_slot_bool_get(op->slots_in, "use_fill_check");
 
904
        const short mat_nr        = BMO_slot_int_get(op->slots_in,  "mat_nr");
 
905
        const bool use_smooth     = BMO_slot_bool_get(op->slots_in, "use_smooth");
903
906
        int i, j, group = 0;
904
907
        unsigned int winding[2]; /* accumulte winding directions for each edge which has a face */
 
908
        BMOpSlot *slot_restrict          = BMO_slot_get(op->slots_in, "restrict");
 
909
        BMOpSlot *slot_face_groupmap_out = BMO_slot_get(op->slots_out, "face_groupmap.out");
905
910
 
906
911
        if (!bm->totvert || !bm->totedge)
907
912
                return;
911
916
        edata = MEM_callocN(sizeof(EdgeData) * bm->totedge, "EdgeData");
912
917
        vdata = MEM_callocN(sizeof(VertData) * bm->totvert, "VertData");
913
918
        
914
 
        BMO_slot_buffer_flag_enable(bm, op, "edges", BM_EDGE, EDGE_MARK);
915
 
        BMO_slot_buffer_flag_enable(bm, op, "excludefaces", BM_FACE, FACE_IGNORE);
 
919
        BMO_slot_buffer_flag_enable(bm, op->slots_in, "edges", BM_EDGE, EDGE_MARK);
 
920
        BMO_slot_buffer_flag_enable(bm, op->slots_in, "exclude_faces", BM_FACE, FACE_IGNORE);
916
921
        
917
922
        BM_mesh_elem_index_ensure(bm, BM_VERT);
918
923
 
933
938
        bm->elem_index_dirty &= ~BM_EDGE;
934
939
 
935
940
        init_rotsys(bm, edata, vdata);
936
 
        
 
941
 
937
942
        while (1) {
938
943
                edge = NULL;
939
944
                group = 0;
940
945
                
941
 
                BMO_ITER (e, &siter, bm, op, "edges", BM_EDGE) {
 
946
                BMO_ITER (e, &siter, op->slots_in, "edges", BM_EDGE) {
942
947
                        /* if restrict is on, only start on faces in the restrict map */
943
 
                        if (use_restrict && !BMO_slot_map_contains(bm, op, "restrict", e))
 
948
                        if (use_restrict && !BMO_slot_map_contains(slot_restrict, e))
944
949
                                continue;
945
950
 
946
951
                        if (edata[BM_elem_index_get(e)].tag < 2) {
949
954
                                if (use_restrict) {
950
955
                                        int i = 0, j = 0, gi = 0;
951
956
                                        
952
 
                                        group = BMO_slot_map_int_get(bm, op, "restrict", e);
 
957
                                        group = BMO_slot_map_int_get(slot_restrict, e);
953
958
                                        
954
959
                                        for (i = 0; i < 30; i++) {
955
960
                                                if (group & (1 << i)) {
999
1004
                        }
1000
1005
 
1001
1006
                        edata[BM_elem_index_get(e)].ftag++;
1002
 
                        BLI_array_growone(edges);
 
1007
                        BLI_array_grow_one(edges);
1003
1008
                        edges[i++] = e;
1004
1009
 
1005
1010
                        BLI_array_append(verts, node->v);
1009
1014
                        vote_on_winding(edge, path->nodes.last, winding);
1010
1015
                }
1011
1016
 
1012
 
                BLI_array_growone(edges);
 
1017
                BLI_array_grow_one(edges);
1013
1018
                edges[i++] = edge;
1014
1019
                edata[BM_elem_index_get(edge)].ftag++;
1015
1020
                
1042
1047
                                v2 = verts[0];
1043
1048
                        }
1044
1049
 
1045
 
                        if ((use_fill_check == FALSE) ||
 
1050
                        if ((use_fill_check == false) ||
1046
1051
                            /* fairly expensive check - see if there are already faces filling this area */
1047
 
                            (BM_face_exists_multi_edge(edges, i) == FALSE))
 
1052
                            (BM_face_exists_multi_edge(edges, i) == false))
1048
1053
                        {
1049
 
                                f = BM_face_create_ngon(bm, v1, v2, edges, i, TRUE);
 
1054
                                f = BM_face_create_ngon(bm, v1, v2, edges, i, BM_CREATE_NO_DOUBLE);
1050
1055
                                if (f && !BMO_elem_flag_test(bm, f, ELE_ORIG)) {
1051
1056
                                        BMO_elem_flag_enable(bm, f, FACE_NEW);
1052
1057
                                        f->mat_nr = mat_nr;
1056
1061
                                }
1057
1062
 
1058
1063
                                if (use_restrict) {
1059
 
                                        BMO_slot_map_int_insert(bm, op, "faceout_groupmap", f, path->group);
 
1064
                                        BMO_slot_map_int_insert(op, slot_face_groupmap_out, f, path->group);
1060
1065
                                }
1061
1066
                        }
1062
1067
                }
1064
1069
                edge_free_path(pathbase, path);
1065
1070
        }
1066
1071
 
1067
 
        BMO_slot_buffer_from_enabled_flag(bm, op, "faceout", BM_FACE, FACE_NEW);
 
1072
        BMO_slot_buffer_from_enabled_flag(bm, op, op->slots_out, "faces.out", BM_FACE, FACE_NEW);
1068
1073
 
1069
1074
        BLI_array_free(edges);
1070
1075
        BLI_array_free(verts);
1093
1098
        return NULL;
1094
1099
}
1095
1100
 
1096
 
void bmo_edgenet_prepare(BMesh *bm, BMOperator *op)
 
1101
void bmo_edgenet_prepare_exec(BMesh *bm, BMOperator *op)
1097
1102
{
1098
1103
        BMOIter siter;
1099
1104
        BMEdge *e;
1104
1109
        int ok = 1;
1105
1110
        int i, count;
1106
1111
 
1107
 
        BMO_slot_buffer_flag_enable(bm, op, "edges", BM_EDGE, EDGE_MARK);
 
1112
        BMO_slot_buffer_flag_enable(bm, op->slots_in, "edges", BM_EDGE, EDGE_MARK);
1108
1113
        
1109
1114
        /* validate that each edge has at most one other tagged edge in the
1110
1115
         * disk cycle around each of it's vertices */
1111
 
        BMO_ITER (e, &siter, bm, op, "edges", BM_EDGE) {
 
1116
        BMO_ITER (e, &siter, op->slots_in, "edges", BM_EDGE) {
1112
1117
                for (i = 0; i < 2; i++) {
1113
1118
                        count = BMO_vert_edge_flags_count(bm, i ? e->v2 : e->v1, EDGE_MARK);
1114
1119
                        if (count > 2) {
1130
1135
        /* find connected loops within the input edge */
1131
1136
        count = 0;
1132
1137
        while (1) {
1133
 
                BMO_ITER (e, &siter, bm, op, "edges", BM_EDGE) {
 
1138
                BMO_ITER (e, &siter, op->slots_in, "edges", BM_EDGE) {
1134
1139
                        if (!BMO_elem_flag_test(bm, e, EDGE_VIS)) {
1135
1140
                                if (BMO_vert_edge_flags_count(bm, e->v1, EDGE_MARK) == 1 ||
1136
1141
                                    BMO_vert_edge_flags_count(bm, e->v2, EDGE_MARK) == 1)
1157
1162
                i = 0;
1158
1163
                while (e) {
1159
1164
                        BMO_elem_flag_enable(bm, e, EDGE_VIS);
1160
 
                        BLI_array_growone(edges);
 
1165
                        BLI_array_grow_one(edges);
1161
1166
                        edges[i] = e;
1162
1167
 
1163
1168
                        e = edge_next(bm, e);
1166
1171
 
1167
1172
                if (!count) {
1168
1173
                        edges1 = edges;
1169
 
                        BLI_array_set_length(edges1, BLI_array_count(edges));
 
1174
                        BLI_array_length_set(edges1, BLI_array_count(edges));
1170
1175
                }
1171
1176
                else {
1172
1177
                        edges2 = edges;
1173
 
                        BLI_array_set_length(edges2, BLI_array_count(edges));
 
1178
                        BLI_array_length_set(edges2, BLI_array_count(edges));
1174
1179
                }
1175
1180
 
1176
1181
                BLI_array_empty(edges);
1178
1183
        }
1179
1184
 
1180
1185
        if (edges1 && BLI_array_count(edges1) > 2 &&
1181
 
            BM_edge_share_vert_count(edges1[0], edges1[BLI_array_count(edges1) - 1]))
 
1186
            BM_edge_share_vert_check(edges1[0], edges1[BLI_array_count(edges1) - 1]))
1182
1187
        {
1183
1188
                if (edges2 && BLI_array_count(edges2) > 2 &&
1184
 
                    BM_edge_share_vert_count(edges2[0], edges2[BLI_array_count(edges2) - 1]))
 
1189
                    BM_edge_share_vert_check(edges2[0], edges2[BLI_array_count(edges2) - 1]))
1185
1190
                {
1186
1191
                        BLI_array_free(edges1);
1187
1192
                        BLI_array_free(edges2);
1194
1199
        }
1195
1200
 
1196
1201
        if (edges2 && BLI_array_count(edges2) > 2 &&
1197
 
            BM_edge_share_vert_count(edges2[0], edges2[BLI_array_count(edges2) - 1]))
 
1202
            BM_edge_share_vert_check(edges2[0], edges2[BLI_array_count(edges2) - 1]))
1198
1203
        {
1199
1204
                edges2 = NULL;
1200
1205
        }
1225
1230
                        v4 = BM_vert_in_edge(edges2[i - 1], edges2[i]->v1) ? edges2[i]->v2 : edges2[i]->v1;
1226
1231
                }
1227
1232
 
1228
 
                /* if there is ever bowtie quads between two edges the problem is here! [#30367] */
 
1233
                /* if there is ever bow-tie quads between two edges the problem is here! [#30367] */
1229
1234
#if 0
1230
1235
                normal_tri_v3(dvec1, v1->co, v2->co, v4->co);
1231
1236
                normal_tri_v3(dvec2, v1->co, v4->co, v3->co);
1244
1249
                        SWAP(BMVert *, v3, v4);
1245
1250
                }
1246
1251
 
1247
 
                e = BM_edge_create(bm, v1, v3, NULL, TRUE);
 
1252
                e = BM_edge_create(bm, v1, v3, NULL, BM_CREATE_NO_DOUBLE);
1248
1253
                BMO_elem_flag_enable(bm, e, ELE_NEW);
1249
 
                e = BM_edge_create(bm, v2, v4, NULL, TRUE);
 
1254
                e = BM_edge_create(bm, v2, v4, NULL, BM_CREATE_NO_DOUBLE);
1250
1255
                BMO_elem_flag_enable(bm, e, ELE_NEW);
1251
1256
        }
1252
1257
        else if (edges1) {
1256
1261
                        v1 = BM_vert_in_edge(edges1[1], edges1[0]->v1) ? edges1[0]->v2 : edges1[0]->v1;
1257
1262
                        i  = BLI_array_count(edges1) - 1;
1258
1263
                        v2 = BM_vert_in_edge(edges1[i - 1], edges1[i]->v1) ? edges1[i]->v2 : edges1[i]->v1;
1259
 
                        e  = BM_edge_create(bm, v1, v2, NULL, TRUE);
 
1264
                        e  = BM_edge_create(bm, v1, v2, NULL, BM_CREATE_NO_DOUBLE);
1260
1265
                        BMO_elem_flag_enable(bm, e, ELE_NEW);
1261
1266
                }
1262
1267
        }
1263
1268
        
1264
 
        BMO_slot_buffer_from_enabled_flag(bm, op, "edgeout", BM_EDGE, ELE_NEW);
 
1269
        BMO_slot_buffer_from_enabled_flag(bm, op, op->slots_out, "edges.out", BM_EDGE, ELE_NEW);
1265
1270
 
1266
1271
        BLI_array_free(edges1);
1267
1272
        BLI_array_free(edges2);
1281
1286
        BMEdge *e;
1282
1287
        BMFace *f;
1283
1288
        int totv = 0, tote = 0, totf = 0, amount;
1284
 
        const short mat_nr = BMO_slot_int_get(op, "mat_nr");
1285
 
        const short use_smooth = BMO_slot_bool_get(op, "use_smooth");
 
1289
        const short mat_nr     = BMO_slot_int_get(op->slots_in,  "mat_nr");
 
1290
        const bool use_smooth  = BMO_slot_bool_get(op->slots_in, "use_smooth");
1286
1291
 
1287
1292
        /* count number of each element type we were passe */
1288
 
        BMO_ITER (h, &oiter, bm, op, "geom", BM_VERT|BM_EDGE|BM_FACE) {
 
1293
        BMO_ITER (h, &oiter, op->slots_in, "geom", BM_VERT | BM_EDGE | BM_FACE) {
1289
1294
                switch (h->htype) {
1290
1295
                        case BM_VERT: totv++; break;
1291
1296
                        case BM_EDGE: tote++; break;
1312
1317
         *
1313
1318
         */
1314
1319
 
1315
 
        /* Here we check for consistancy and create 2 edges */
 
1320
        /* Here we check for consistency and create 2 edges */
1316
1321
        if (totf == 0 && totv >= 4 && totv == tote + 2) {
1317
1322
                /* find a free standing vertex and 2 endpoint verts */
1318
1323
                BMVert *v_free = NULL, *v_a = NULL, *v_b = NULL;
1319
 
                int ok = TRUE;
1320
 
 
1321
 
 
1322
 
                BMO_ITER (v, &oiter, bm, op, "geom", BM_VERT) {
 
1324
                bool ok = true;
 
1325
 
 
1326
 
 
1327
                BMO_ITER (v, &oiter, op->slots_in, "geom", BM_VERT) {
1323
1328
                        /* count how many flagged edges this vertex uses */
1324
1329
                        int tot_edges = 0;
1325
1330
                        BM_ITER_ELEM (e, &iter, v, BM_EDGES_OF_VERT) {
1334
1339
                        if (tot_edges == 0) {
1335
1340
                                /* only accept 1 free vert */
1336
1341
                                if (v_free == NULL)  v_free = v;
1337
 
                                else                 ok = FALSE;  /* only ever want one of these */
 
1342
                                else                 ok = false;  /* only ever want one of these */
1338
1343
                        }
1339
1344
                        else if (tot_edges == 1) {
1340
1345
                                if (v_a == NULL)       v_a = v;
1341
1346
                                else if (v_b == NULL)  v_b = v;
1342
 
                                else                   ok = FALSE;  /* only ever want 2 of these */
 
1347
                                else                   ok = false;  /* only ever want 2 of these */
1343
1348
                        }
1344
1349
                        else if (tot_edges == 2) {
1345
1350
                                /* do nothing, regular case */
1346
1351
                        }
1347
1352
                        else {
1348
 
                                ok = FALSE; /* if a vertex has 3+ edge users then cancel - this is only simple cases */
 
1353
                                ok = false; /* if a vertex has 3+ edge users then cancel - this is only simple cases */
1349
1354
                        }
1350
1355
 
1351
 
                        if (ok == FALSE) {
 
1356
                        if (ok == false) {
1352
1357
                                break;
1353
1358
                        }
1354
1359
                }
1355
1360
 
1356
 
                if (ok == TRUE && v_free && v_a && v_b) {
1357
 
                        e = BM_edge_create(bm, v_free, v_a, NULL, TRUE);
 
1361
                if (ok == true && v_free && v_a && v_b) {
 
1362
                        e = BM_edge_create(bm, v_free, v_a, NULL, BM_CREATE_NO_DOUBLE);
1358
1363
                        BMO_elem_flag_enable(bm, e, ELE_NEW);
1359
1364
 
1360
 
                        e = BM_edge_create(bm, v_free, v_b, NULL, TRUE);
 
1365
                        e = BM_edge_create(bm, v_free, v_b, NULL, BM_CREATE_NO_DOUBLE);
1361
1366
                        BMO_elem_flag_enable(bm, e, ELE_NEW);
1362
1367
                }
1363
1368
        }
1365
1370
 
1366
1371
        /* call edgenet create */
1367
1372
        /* call edgenet prepare op so additional face creation cases wore */
1368
 
        BMO_op_initf(bm, &op2, "edgenet_prepare edges=%fe", ELE_NEW);
 
1373
        BMO_op_initf(bm, &op2, op->flag, "edgenet_prepare edges=%fe", ELE_NEW);
1369
1374
        BMO_op_exec(bm, &op2);
1370
 
        BMO_slot_buffer_flag_enable(bm, &op2, "edgeout", BM_EDGE, ELE_NEW);
 
1375
        BMO_slot_buffer_flag_enable(bm, op2.slots_out, "edges.out", BM_EDGE, ELE_NEW);
1371
1376
        BMO_op_finish(bm, &op2);
1372
1377
 
1373
 
        BMO_op_initf(bm, &op2,
 
1378
        BMO_op_initf(bm, &op2, op->flag,
1374
1379
                     "edgenet_fill edges=%fe use_fill_check=%b mat_nr=%i use_smooth=%b",
1375
 
                     ELE_NEW, TRUE, mat_nr, use_smooth);
 
1380
                     ELE_NEW, true, mat_nr, use_smooth);
1376
1381
 
1377
1382
        BMO_op_exec(bm, &op2);
1378
1383
 
1379
1384
        /* return if edge net create did something */
1380
 
        if (BMO_slot_buffer_count(bm, &op2, "faceout")) {
1381
 
                BMO_slot_copy(&op2, op, "faceout", "faceout");
 
1385
        if (BMO_slot_buffer_count(op2.slots_out, "faces.out")) {
 
1386
                BMO_slot_copy(&op2, slots_out, "faces.out",
 
1387
                              op,   slots_out, "faces.out");
1382
1388
                BMO_op_finish(bm, &op2);
1383
1389
                return;
1384
1390
        }
1386
1392
        BMO_op_finish(bm, &op2);
1387
1393
        
1388
1394
        /* now call dissolve face */
1389
 
        BMO_op_initf(bm, &op2, "dissolve_faces faces=%ff", ELE_NEW);
 
1395
        BMO_op_initf(bm, &op2, op->flag, "dissolve_faces faces=%ff", ELE_NEW);
1390
1396
        BMO_op_exec(bm, &op2);
1391
1397
        
1392
1398
        /* if we dissolved anything, then return */
1393
 
        if (BMO_slot_buffer_count(bm, &op2, "regionout")) {
1394
 
                BMO_slot_copy(&op2, op, "regionout", "faceout");
 
1399
        if (BMO_slot_buffer_count(op2.slots_out, "region.out")) {
 
1400
                BMO_slot_copy(&op2, slots_out, "region.out",
 
1401
                              op,   slots_out,  "faces.out");
1395
1402
                BMO_op_finish(bm, &op2);
1396
1403
                return;
1397
1404
        }
1403
1410
        BM_ITER_MESH (v, &iter, bm, BM_VERTS_OF_MESH) {
1404
1411
                if (BMO_elem_flag_test(bm, v, ELE_NEW)) {
1405
1412
                        verts[amount] = v;
 
1413
                        if (amount == 3) {
 
1414
                                break;
 
1415
                        }
1406
1416
                        amount++;
1407
1417
 
1408
 
                        if (amount > 4) break;
1409
1418
                }
1410
1419
        }
1411
1420
 
1412
1421
        if (amount == 2) {
1413
1422
                /* create edge */
1414
 
                e = BM_edge_create(bm, verts[0], verts[1], NULL, TRUE);
 
1423
                e = BM_edge_create(bm, verts[0], verts[1], NULL, BM_CREATE_NO_DOUBLE);
1415
1424
                BMO_elem_flag_enable(bm, e, ELE_OUT);
 
1425
                BMO_slot_buffer_from_enabled_flag(bm, op, op->slots_out, "edges.out", BM_EDGE, ELE_OUT);
1416
1426
        }
1417
1427
        else if (0) { /* nice feature but perhaps it should be a different tool? */
1418
1428
 
1451
1461
                                if (ese->htype == BM_VERT) {
1452
1462
                                        v = (BMVert *)ese->ele;
1453
1463
                                        if (v_prev) {
1454
 
                                                e = BM_edge_create(bm, v, v_prev, NULL, TRUE);
 
1464
                                                e = BM_edge_create(bm, v, v_prev, NULL, BM_CREATE_NO_DOUBLE);
1455
1465
                                                BMO_elem_flag_enable(bm, e, ELE_OUT);
1456
1466
                                        }
1457
1467
                                        v_prev = v;
1458
1468
                                }
1459
1469
                        }
1460
1470
                }
 
1471
                BMO_slot_buffer_from_enabled_flag(bm, op, op->slots_out, "edges.out", BM_EDGE, ELE_OUT);
1461
1472
                /* done creating edges */
1462
1473
        }
1463
1474
        else if (amount > 2) {
1467
1478
                BMVert **vert_arr = MEM_mallocN(sizeof(BMVert **) * totv, __func__);
1468
1479
                int i = 0;
1469
1480
 
1470
 
                BMO_ITER (v, &oiter, bm, op, "geom", BM_VERT) {
 
1481
                BMO_ITER (v, &oiter, op->slots_in, "geom", BM_VERT) {
1471
1482
                        vert_arr[i] = v;
1472
1483
                        i++;
1473
1484
                }
1474
1485
 
1475
 
                f = BM_face_create_ngon_vcloud(bm, vert_arr, totv, TRUE);
 
1486
                f = BM_face_create_ngon_vcloud(bm, vert_arr, totv, BM_CREATE_NO_DOUBLE);
1476
1487
 
1477
1488
                if (f) {
1478
1489
                        BMO_elem_flag_enable(bm, f, ELE_OUT);