diff options
author | Tamito Kajiyama <rd6t-kjym@asahi-net.or.jp> | 2012-12-23 04:23:11 +0400 |
---|---|---|
committer | Tamito Kajiyama <rd6t-kjym@asahi-net.or.jp> | 2012-12-23 04:23:11 +0400 |
commit | 40449b1994301081f96d014df626a5375e020c76 (patch) | |
tree | 20220d8b071310fda8a0ab851c7a8f7bcc3ed8a2 /source/blender/bmesh | |
parent | fa0211df269a3398dd70467982f9e129c79e501b (diff) | |
parent | 3ca00cbf541d0283e91dc454866a5f24576271be (diff) |
Merged changes in the trunk up to revision 53280.
Diffstat (limited to 'source/blender/bmesh')
-rw-r--r-- | source/blender/bmesh/bmesh_class.h | 2 | ||||
-rw-r--r-- | source/blender/bmesh/intern/bmesh_construct.c | 38 | ||||
-rw-r--r-- | source/blender/bmesh/intern/bmesh_marking.c | 59 | ||||
-rw-r--r-- | source/blender/bmesh/intern/bmesh_mesh.c | 12 | ||||
-rw-r--r-- | source/blender/bmesh/operators/bmo_extrude.c | 22 | ||||
-rw-r--r-- | source/blender/bmesh/tools/bmesh_bevel.c | 4 |
6 files changed, 94 insertions, 43 deletions
diff --git a/source/blender/bmesh/bmesh_class.h b/source/blender/bmesh/bmesh_class.h index 5af9690b47e..0961106f141 100644 --- a/source/blender/bmesh/bmesh_class.h +++ b/source/blender/bmesh/bmesh_class.h @@ -280,6 +280,6 @@ enum { * but should not error on valid cases */ #define BM_LOOP_RADIAL_MAX 10000 #define BM_NGON_MAX 100000 -#define BM_OMP_LIMIT 10000 +#define BM_OMP_LIMIT 0 /* setting zero so we can catch bugs in OpenMP/BMesh */ #endif /* __BMESH_CLASS_H__ */ diff --git a/source/blender/bmesh/intern/bmesh_construct.c b/source/blender/bmesh/intern/bmesh_construct.c index d23443daa7f..2362ae7237a 100644 --- a/source/blender/bmesh/intern/bmesh_construct.c +++ b/source/blender/bmesh/intern/bmesh_construct.c @@ -173,8 +173,8 @@ void BM_face_copy_shared(BMesh *bm, BMFace *f) */ BMFace *BM_face_create_ngon(BMesh *bm, BMVert *v1, BMVert *v2, BMEdge **edges, int len, const int create_flag) { - BMEdge **edges2 = BLI_array_alloca_and_count(edges2, len); - BMVert **verts = BLI_array_alloca_and_count(verts, len + 1); + BMEdge **edges2 = BLI_array_alloca(edges2, len); + BMVert **verts = BLI_array_alloca(verts, len + 1); int e2_index = 0; int v_index = 0; @@ -235,7 +235,7 @@ BMFace *BM_face_create_ngon(BMesh *bm, BMVert *v1, BMVert *v2, BMEdge **edges, i e = e2; } while (e != edges[0]); - if (BLI_array_count(edges2) != len) { + if (e2_index != len) { goto err; /* we didn't use all edges in forming the boundary loop */ } @@ -296,10 +296,9 @@ BMFace *BM_face_create_ngon(BMesh *bm, BMVert *v1, BMVert *v2, BMEdge **edges, i err: for (i = 0; i < len; i++) { BM_ELEM_API_FLAG_DISABLE(edges[i], _FLAG_MF); - /* vert count may != len */ - if (i < BLI_array_count(verts)) { - BM_ELEM_API_FLAG_DISABLE(verts[i], _FLAG_MV); - } + } + for (i = 0; i < v_index; i++) { + BM_ELEM_API_FLAG_DISABLE(verts[i], _FLAG_MV); } return NULL; @@ -817,6 +816,8 @@ void BM_elem_attrs_copy(BMesh *source_mesh, BMesh *target_mesh, const void *sour BMesh *BM_mesh_copy(BMesh *bm_old) { +#define USE_FAST_FACE_COPY + BMesh *bm_new; BMVert *v, *v2, **vtable = NULL; BMEdge *e, *e2, **edges = NULL, **etable = NULL; @@ -824,6 +825,10 @@ BMesh *BM_mesh_copy(BMesh *bm_old) BLI_array_declare(edges); BMLoop *l, /* *l2, */ **loops = NULL; BLI_array_declare(loops); +#ifdef USE_FAST_FACE_COPY + BMVert **verts = NULL; + BLI_array_declare(verts); +#endif BMFace *f, *f2, **ftable = NULL; BMEditSelection *ese; BMIter iter, liter; @@ -891,12 +896,24 @@ BMesh *BM_mesh_copy(BMesh *bm_old) BLI_array_grow_items(loops, f->len); BLI_array_grow_items(edges, f->len); +#ifdef USE_FAST_FACE_COPY + BLI_array_empty(verts); + BLI_array_grow_items(verts, f->len); +#endif + l = BM_iter_new(&liter, bm_old, BM_LOOPS_OF_FACE, f); for (j = 0; j < f->len; j++, l = BM_iter_step(&liter)) { loops[j] = l; edges[j] = etable[BM_elem_index_get(l->e)]; + +#ifdef USE_FAST_FACE_COPY + verts[j] = vtable[BM_elem_index_get(l->v)]; +#endif } +#ifdef USE_FAST_FACE_COPY + f2 = BM_face_create(bm_new, verts, edges, f->len, BM_CREATE_SKIP_CD); +#else v = vtable[BM_elem_index_get(loops[0]->v)]; v2 = vtable[BM_elem_index_get(loops[1]->v)]; @@ -906,6 +923,8 @@ BMesh *BM_mesh_copy(BMesh *bm_old) } f2 = BM_face_create_ngon(bm_new, v, v2, edges, f->len, BM_CREATE_SKIP_CD); +#endif + if (UNLIKELY(f2 == NULL)) { continue; } @@ -961,9 +980,12 @@ BMesh *BM_mesh_copy(BMesh *bm_old) MEM_freeN(vtable); MEM_freeN(ftable); +#ifdef USE_FAST_FACE_COPY + BLI_array_free(verts); +#endif + BLI_array_free(loops); BLI_array_free(edges); - return bm_new; } diff --git a/source/blender/bmesh/intern/bmesh_marking.c b/source/blender/bmesh/intern/bmesh_marking.c index b1ec4cde44b..669be315cc6 100644 --- a/source/blender/bmesh/intern/bmesh_marking.c +++ b/source/blender/bmesh/intern/bmesh_marking.c @@ -86,41 +86,50 @@ void BM_mesh_select_mode_flush_ex(BMesh *bm, const short selectmode) BMIter eiter; BMIter fiter; - int ok; - if (selectmode & SCE_SELECT_VERTEX) { - BM_ITER_MESH (e, &eiter, bm, BM_EDGES_OF_MESH) { - if (BM_elem_flag_test(e->v1, BM_ELEM_SELECT) && - BM_elem_flag_test(e->v2, BM_ELEM_SELECT) && - !BM_elem_flag_test(e, BM_ELEM_HIDDEN)) + /* both loops only set edge/face flags and read off verts */ +#pragma omp parallel sections if (bm->totedge + bm->totface >= BM_OMP_LIMIT) + { +#pragma omp section { - BM_elem_flag_enable(e, BM_ELEM_SELECT); - } - else { - BM_elem_flag_disable(e, BM_ELEM_SELECT); + BM_ITER_MESH (e, &eiter, bm, BM_EDGES_OF_MESH) { + if (BM_elem_flag_test(e->v1, BM_ELEM_SELECT) && + BM_elem_flag_test(e->v2, BM_ELEM_SELECT) && + !BM_elem_flag_test(e, BM_ELEM_HIDDEN)) + { + BM_elem_flag_enable(e, BM_ELEM_SELECT); + } + else { + BM_elem_flag_disable(e, BM_ELEM_SELECT); + } + } } - } - BM_ITER_MESH (f, &fiter, bm, BM_FACES_OF_MESH) { - ok = TRUE; - if (!BM_elem_flag_test(f, BM_ELEM_HIDDEN)) { - l_iter = l_first = BM_FACE_FIRST_LOOP(f); - do { - if (!BM_elem_flag_test(l_iter->v, BM_ELEM_SELECT)) { +#pragma omp section + { + BM_ITER_MESH (f, &fiter, bm, BM_FACES_OF_MESH) { + int ok = TRUE; + if (!BM_elem_flag_test(f, BM_ELEM_HIDDEN)) { + l_iter = l_first = BM_FACE_FIRST_LOOP(f); + do { + if (!BM_elem_flag_test(l_iter->v, BM_ELEM_SELECT)) { + ok = FALSE; + break; + } + } while ((l_iter = l_iter->next) != l_first); + } + else { ok = FALSE; - break; } - } while ((l_iter = l_iter->next) != l_first); - } - else { - ok = FALSE; - } - BM_elem_flag_set(f, BM_ELEM_SELECT, ok); + BM_elem_flag_set(f, BM_ELEM_SELECT, ok); + } + } } + /* end sections */ } else if (selectmode & SCE_SELECT_EDGE) { BM_ITER_MESH (f, &fiter, bm, BM_FACES_OF_MESH) { - ok = TRUE; + int ok = TRUE; if (!BM_elem_flag_test(f, BM_ELEM_HIDDEN)) { l_iter = l_first = BM_FACE_FIRST_LOOP(f); do { diff --git a/source/blender/bmesh/intern/bmesh_mesh.c b/source/blender/bmesh/intern/bmesh_mesh.c index 015c040dc95..769ede0c2ca 100644 --- a/source/blender/bmesh/intern/bmesh_mesh.c +++ b/source/blender/bmesh/intern/bmesh_mesh.c @@ -461,9 +461,6 @@ void bmesh_edit_end(BMesh *bm, int UNUSED(flag)) void BM_mesh_elem_index_ensure(BMesh *bm, const char hflag) { - BMIter iter; - BMElem *ele; - #ifdef DEBUG BM_ELEM_INDEX_VALIDATE(bm, "Should Never Fail!", __func__); #endif @@ -474,6 +471,9 @@ void BM_mesh_elem_index_ensure(BMesh *bm, const char hflag) { if (hflag & BM_VERT) { if (bm->elem_index_dirty & BM_VERT) { + BMIter iter; + BMElem *ele; + int index; BM_ITER_MESH_INDEX (ele, &iter, bm, BM_VERTS_OF_MESH, index) { BM_elem_index_set(ele, index); /* set_ok */ @@ -490,6 +490,9 @@ void BM_mesh_elem_index_ensure(BMesh *bm, const char hflag) { if (hflag & BM_EDGE) { if (bm->elem_index_dirty & BM_EDGE) { + BMIter iter; + BMElem *ele; + int index; BM_ITER_MESH_INDEX (ele, &iter, bm, BM_EDGES_OF_MESH, index) { BM_elem_index_set(ele, index); /* set_ok */ @@ -506,6 +509,9 @@ void BM_mesh_elem_index_ensure(BMesh *bm, const char hflag) { if (hflag & BM_FACE) { if (bm->elem_index_dirty & BM_FACE) { + BMIter iter; + BMElem *ele; + int index; BM_ITER_MESH_INDEX (ele, &iter, bm, BM_FACES_OF_MESH, index) { BM_elem_index_set(ele, index); /* set_ok */ diff --git a/source/blender/bmesh/operators/bmo_extrude.c b/source/blender/bmesh/operators/bmo_extrude.c index bf3bafc57fb..956d9e5767e 100644 --- a/source/blender/bmesh/operators/bmo_extrude.c +++ b/source/blender/bmesh/operators/bmo_extrude.c @@ -51,28 +51,35 @@ enum { void bmo_extrude_discrete_faces_exec(BMesh *bm, BMOperator *op) { + BMVert **verts = NULL; + BLI_array_declare(verts); + BMEdge **edges = NULL; + BLI_array_declare(edges); + BMOIter siter; BMIter liter, liter2; BMFace *f, *f2, *f3; BMLoop *l, *l2, *l3, *l4, *l_tmp; - BMEdge **edges = NULL, *e, *laste; + BMEdge *e, *laste; BMVert *v, *lastv, *firstv; - BLI_array_declare(edges); int i; BMO_ITER (f, &siter, op->slots_in, "faces", BM_FACE) { + BLI_array_empty(verts); BLI_array_empty(edges); + BLI_array_grow_items(verts, f->len); BLI_array_grow_items(edges, f->len); i = 0; firstv = lastv = NULL; BM_ITER_ELEM (l, &liter, f, BM_LOOPS_OF_FACE) { v = BM_vert_create(bm, l->v->co, l->v, 0); - /* skip on the first iteration */ if (lastv) { e = BM_edge_create(bm, lastv, v, l->e, 0); - edges[i++] = e; + edges[i] = e; + verts[i] = lastv; + i++; } lastv = v; @@ -82,11 +89,13 @@ void bmo_extrude_discrete_faces_exec(BMesh *bm, BMOperator *op) /* this fits in the array because we skip one in the loop above */ e = BM_edge_create(bm, v, firstv, laste, 0); - edges[i++] = e; + edges[i] = e; + verts[i] = lastv; + i++; BMO_elem_flag_enable(bm, f, EXT_DEL); - f2 = BM_face_create_ngon(bm, firstv, BM_edge_other_vert(edges[0], firstv), edges, f->len, 0); + f2 = BM_face_create(bm, verts, edges, f->len, 0); if (UNLIKELY(f2 == NULL)) { BMO_error_raise(bm, op, BMERR_MESH_ERROR, "Extrude failed: could not create face"); BLI_array_free(edges); @@ -117,6 +126,7 @@ void bmo_extrude_discrete_faces_exec(BMesh *bm, BMOperator *op) } } + BLI_array_free(verts); BLI_array_free(edges); BMO_op_callf(bm, op->flag, diff --git a/source/blender/bmesh/tools/bmesh_bevel.c b/source/blender/bmesh/tools/bmesh_bevel.c index cc472e4a501..fbac538eb7f 100644 --- a/source/blender/bmesh/tools/bmesh_bevel.c +++ b/source/blender/bmesh/tools/bmesh_bevel.c @@ -269,7 +269,11 @@ static BMFace *bev_create_ngon(BMesh *bm, BMVert **vert_arr, const int totv, BMF for (i = 0; i < totv; i++) { ee[i] = BM_edge_create(bm, vert_arr[i], vert_arr[(i + 1) % totv], NULL, BM_CREATE_NO_DOUBLE); } +#if 0 f = BM_face_create_ngon(bm, vert_arr[0], vert_arr[1], ee, totv, 0); +#else + f = BM_face_create(bm, vert_arr, ee, totv, 0); +#endif } if (facerep && f) { int has_mdisps = CustomData_has_layer(&bm->ldata, CD_MDISPS); |