diff options
Diffstat (limited to 'source/blender/bmesh/operators/bmo_dupe.c')
-rw-r--r-- | source/blender/bmesh/operators/bmo_dupe.c | 81 |
1 files changed, 39 insertions, 42 deletions
diff --git a/source/blender/bmesh/operators/bmo_dupe.c b/source/blender/bmesh/operators/bmo_dupe.c index 9a87acbb84f..4b559400bb8 100644 --- a/source/blender/bmesh/operators/bmo_dupe.c +++ b/source/blender/bmesh/operators/bmo_dupe.c @@ -29,7 +29,7 @@ #include "bmesh.h" /* local flag define */ -#define DUPE_INPUT 1 /* input from operato */ +#define DUPE_INPUT 1 /* input from operator */ #define DUPE_NEW 2 #define DUPE_DONE 4 #define DUPE_MAPPED 8 @@ -44,16 +44,16 @@ static BMVert *copy_vertex(BMesh *source_mesh, BMVert *source_vertex, BMesh *tar { BMVert *target_vertex = NULL; - /* Create a new verte */ + /* Create a new vertex */ target_vertex = BM_vert_create(target_mesh, source_vertex->co, NULL); - /* Insert new vertex into the vert has */ + /* Insert new vertex into the vert hash */ BLI_ghash_insert(vhash, source_vertex, target_vertex); - /* Copy attribute */ + /* Copy attributes */ BM_elem_attrs_copy(source_mesh, target_mesh, source_vertex, target_vertex); - /* Set internal op flag */ + /* Set internal op flags */ BMO_elem_flag_enable(target_mesh, target_vertex, DUPE_NEW); return target_vertex; @@ -92,10 +92,10 @@ static BMEdge *copy_edge(BMOperator *op, BMesh *source_mesh, target_vert1 = BLI_ghash_lookup(vhash, source_edge->v1); target_vert2 = BLI_ghash_lookup(vhash, source_edge->v2); - /* Create a new edg */ + /* Create a new edge */ target_edge = BM_edge_create(target_mesh, target_vert1, target_vert2, NULL, FALSE); - /* add to new/old edge map if necassar */ + /* add to new/old edge map if necassary */ if (rlen < 2) { /* not sure what non-manifold cases of greater then three * radial should do. */ @@ -149,7 +149,7 @@ static BMFace *copy_face(BMOperator *op, BMesh *source_mesh, edar[i] = BLI_ghash_lookup(ehash, source_loop->e); } - /* create new fac */ + /* create new face */ target_face = BM_face_create(target_mesh, vtar, edar, source_face->len, FALSE); BMO_slot_map_ptr_insert(source_mesh, op, "facemap", source_face, target_face); @@ -158,10 +158,10 @@ static BMFace *copy_face(BMOperator *op, BMesh *source_mesh, BM_elem_attrs_copy(source_mesh, target_mesh, source_face, target_face); - /* mark the face for outpu */ + /* mark the face for output */ BMO_elem_flag_enable(target_mesh, target_face, DUPE_NEW); - /* copy per-loop custom dat */ + /* copy per-loop custom data */ BM_ITER(source_loop, &iter, source_mesh, BM_LOOPS_OF_FACE, source_face) { BM_ITER(target_loop, &iter2, target_mesh, BM_LOOPS_OF_FACE, target_face) { if (BLI_ghash_lookup(vhash, source_loop->v) == target_loop->v) { @@ -191,43 +191,41 @@ static void copy_mesh(BMOperator *op, BMesh *source, BMesh *target) BMVert **vtar = NULL; BMEdge **edar = NULL; - BMIter verts; - BMIter edges; - BMIter faces; - - GHash *vhash; - GHash *ehash; + BMIter viter, eiter, fiter; + GHash *vhash, *ehash; /* initialize pointer hashes */ - vhash = BLI_ghash_new(BLI_ghashutil_ptrhash, BLI_ghashutil_ptrcmp, "bmesh dupeops v"); - ehash = BLI_ghash_new(BLI_ghashutil_ptrhash, BLI_ghashutil_ptrcmp, "bmesh dupeops e"); - - for (v = BM_iter_new(&verts, source, BM_VERTS_OF_MESH, source); v; v = BM_iter_step(&verts)) { - if ( BMO_elem_flag_test(source, v, DUPE_INPUT) && - !BMO_elem_flag_test(source, v, DUPE_DONE)) - { + vhash = BLI_ghash_new(BLI_ghashutil_ptrhash, BLI_ghashutil_ptrcmp, + "bmesh dupeops v"); + ehash = BLI_ghash_new(BLI_ghashutil_ptrhash, BLI_ghashutil_ptrcmp, + "bmesh dupeops e"); + + /* duplicate flagged vertices */ + BM_ITER(v, &viter, source, BM_VERTS_OF_MESH, source) { + if (BMO_elem_flag_test(source, v, DUPE_INPUT) && + !BMO_elem_flag_test(source, v, DUPE_DONE)) { BMIter iter; - int iso = 1; + int isolated = 1; v2 = copy_vertex(source, v, target, vhash); BM_ITER(f, &iter, source, BM_FACES_OF_VERT, v) { if (BMO_elem_flag_test(source, f, DUPE_INPUT)) { - iso = 0; + isolated = 0; break; } } - if (iso) { + if (isolated) { BM_ITER(e, &iter, source, BM_EDGES_OF_VERT, v) { if (BMO_elem_flag_test(source, e, DUPE_INPUT)) { - iso = 0; + isolated = 0; break; } } } - if (iso) { + if (isolated) { BMO_slot_map_ptr_insert(source, op, "isovertmap", v, v2); } @@ -236,10 +234,9 @@ static void copy_mesh(BMOperator *op, BMesh *source, BMesh *target) } /* now we dupe all the edges */ - for (e = BM_iter_new(&edges, source, BM_EDGES_OF_MESH, source); e; e = BM_iter_step(&edges)) { - if ( BMO_elem_flag_test(source, e, DUPE_INPUT) && - !BMO_elem_flag_test(source, e, DUPE_DONE)) - { + BM_ITER(e, &eiter, source, BM_EDGES_OF_MESH, source) { + if (BMO_elem_flag_test(source, e, DUPE_INPUT) && + !BMO_elem_flag_test(source, e, DUPE_DONE)) { /* make sure that verts are copied */ if (!BMO_elem_flag_test(source, e->v1, DUPE_DONE)) { copy_vertex(source, e->v1, target, vhash); @@ -249,17 +246,17 @@ static void copy_mesh(BMOperator *op, BMesh *source, BMesh *target) copy_vertex(source, e->v2, target, vhash); BMO_elem_flag_enable(source, e->v2, DUPE_DONE); } - /* now copy the actual edge*/ + /* now copy the actual edge */ copy_edge(op, source, e, target, vhash, ehash); BMO_elem_flag_enable(source, e, DUPE_DONE); } } /* first we dupe all flagged faces and their elements from source */ - for (f = BM_iter_new(&faces, source, BM_FACES_OF_MESH, source); f; f = BM_iter_step(&faces)) { + BM_ITER(f, &fiter, source, BM_FACES_OF_MESH, source) { if (BMO_elem_flag_test(source, f, DUPE_INPUT)) { - /* vertex pas */ - for (v = BM_iter_new(&verts, source, BM_VERTS_OF_FACE, f); v; v = BM_iter_step(&verts)) { + /* vertex pass */ + BM_ITER(v, &viter, source, BM_VERTS_OF_FACE, f) { if (!BMO_elem_flag_test(source, v, DUPE_DONE)) { copy_vertex(source, v, target, vhash); BMO_elem_flag_enable(source, v, DUPE_DONE); @@ -267,7 +264,7 @@ static void copy_mesh(BMOperator *op, BMesh *source, BMesh *target) } /* edge pass */ - for (e = BM_iter_new(&edges, source, BM_EDGES_OF_FACE, f); e; e = BM_iter_step(&edges)) { + BM_ITER(e, &eiter, source, BM_EDGES_OF_FACE, f) { if (!BMO_elem_flag_test(source, e, DUPE_DONE)) { copy_edge(op, source, e, target, vhash, ehash); BMO_elem_flag_enable(source, e, DUPE_DONE); @@ -324,18 +321,18 @@ void bmo_dupe_exec(BMesh *bm, BMOperator *op) if (!bm2) bm2 = bm; - /* flag inpu */ + /* flag input */ BMO_slot_buffer_flag_enable(bm, dupeop, "geom", BM_ALL, DUPE_INPUT); /* use the internal copy function */ copy_mesh(dupeop, bm, bm2); - /* Outpu */ + /* Output */ /* First copy the input buffers to output buffers - original data */ BMO_slot_copy(dupeop, dupeop, "geom", "origout"); /* Now alloc the new output buffers */ - BMO_slot_buffer_from_flag(bm, dupeop, "newout", BM_ALL, DUPE_NEW); + BMO_slot_buffer_from_enabled_flag(bm, dupeop, "newout", BM_ALL, DUPE_NEW); } #if 0 /* UNUSED */ @@ -348,7 +345,7 @@ void BMO_dupe_from_flag(BMesh *bm, int htype, const char hflag) BMOperator dupeop; BMO_op_init(bm, &dupeop, "dupe"); - BMO_slot_buffer_from_hflag(bm, &dupeop, "geom", htype, hflag); + BMO_slot_buffer_from_enabled_hflag(bm, &dupeop, "geom", htype, hflag); BMO_op_exec(bm, &dupeop); BMO_op_finish(bm, &dupeop); @@ -429,7 +426,7 @@ void bmo_split_exec(BMesh *bm, BMOperator *op) /* connect outputs of dupe to delete, exluding keep geometry */ BMO_slot_int_set(&delop, "context", DEL_FACES); - BMO_slot_buffer_from_flag(bm, &delop, "geom", BM_ALL, SPLIT_INPUT); + BMO_slot_buffer_from_enabled_flag(bm, &delop, "geom", BM_ALL, SPLIT_INPUT); BMO_op_exec(bm, &delop); |