diff options
Diffstat (limited to 'source/blender/bmesh/intern')
-rw-r--r-- | source/blender/bmesh/intern/bmesh_core.c | 10 | ||||
-rw-r--r-- | source/blender/bmesh/intern/bmesh_core.h | 4 | ||||
-rw-r--r-- | source/blender/bmesh/intern/bmesh_mesh.c | 113 | ||||
-rw-r--r-- | source/blender/bmesh/intern/bmesh_mesh_conv.c | 9 | ||||
-rw-r--r-- | source/blender/bmesh/intern/bmesh_mesh_conv.h | 5 | ||||
-rw-r--r-- | source/blender/bmesh/intern/bmesh_polygon_edgenet.c | 23 |
6 files changed, 63 insertions, 101 deletions
diff --git a/source/blender/bmesh/intern/bmesh_core.c b/source/blender/bmesh/intern/bmesh_core.c index c6836187eee..97f1bad08b7 100644 --- a/source/blender/bmesh/intern/bmesh_core.c +++ b/source/blender/bmesh/intern/bmesh_core.c @@ -2508,19 +2508,17 @@ void BM_vert_separate_hflag( } } -void BM_vert_separate_wire_hflag( +void BM_vert_separate_tested_edges( BMesh *UNUSED(bm), BMVert *v_dst, BMVert *v_src, - const char hflag) + bool (*testfn)(BMEdge *, void *arg), void *arg) { LinkNode *edges_hflag = NULL; BMEdge *e_iter, *e_first; e_iter = e_first = v_src->e; do { - if (BM_elem_flag_test(e_iter, hflag)) { - if (BM_edge_is_wire(e_iter)) { - BLI_linklist_prepend_alloca(&edges_hflag, e_iter); - } + if (testfn(e_iter, arg)) { + BLI_linklist_prepend_alloca(&edges_hflag, e_iter); } } while ((e_iter = BM_DISK_EDGE_NEXT(e_iter, v_src)) != e_first); diff --git a/source/blender/bmesh/intern/bmesh_core.h b/source/blender/bmesh/intern/bmesh_core.h index fb6b66809f3..93bb12fe742 100644 --- a/source/blender/bmesh/intern/bmesh_core.h +++ b/source/blender/bmesh/intern/bmesh_core.h @@ -81,9 +81,9 @@ void BM_vert_separate( void BM_vert_separate_hflag( BMesh *bm, BMVert *v, const char hflag, const bool copy_select, BMVert ***r_vout, int *r_vout_len); -void BM_vert_separate_wire_hflag( +void BM_vert_separate_tested_edges( BMesh *bm, BMVert *v_dst, BMVert *v_src, - const char hflag); + bool (*testfn)(BMEdge *, void *arg), void *arg); /** * BMesh Kernel: For modifying structure. diff --git a/source/blender/bmesh/intern/bmesh_mesh.c b/source/blender/bmesh/intern/bmesh_mesh.c index 4d0f259b4e3..96707335081 100644 --- a/source/blender/bmesh/intern/bmesh_mesh.c +++ b/source/blender/bmesh/intern/bmesh_mesh.c @@ -1108,43 +1108,43 @@ void BM_lnorspace_invalidate(BMesh *bm, const bool do_invalidate_all) * - all smooth fans of all immediate loop-neighbors vertices; * This can be simplified as 'all loops of selected vertices and their immediate neighbors' * need to be tagged for update. -*/ -BM_ITER_MESH(v, &viter, bm, BM_VERTS_OF_MESH) { - if (BM_elem_flag_test(v, BM_ELEM_SELECT)) { - BM_ITER_ELEM(l, &liter, v, BM_LOOPS_OF_VERT) { - BM_ELEM_API_FLAG_ENABLE(l, BM_LNORSPACE_UPDATE); - - /* Note that we only handle unselected neighbor vertices here, main loop will take care of - * selected ones. */ - if (!BM_elem_flag_test(l->prev->v, BM_ELEM_SELECT) && - !BLI_BITMAP_TEST(done_verts, BM_elem_index_get(l->prev->v))) - { - BMLoop *l_prev; - BMIter liter_prev; - BM_ITER_ELEM(l_prev, &liter_prev, l->prev->v, BM_LOOPS_OF_VERT) { - BM_ELEM_API_FLAG_ENABLE(l_prev, BM_LNORSPACE_UPDATE); + */ + BM_ITER_MESH(v, &viter, bm, BM_VERTS_OF_MESH) { + if (BM_elem_flag_test(v, BM_ELEM_SELECT)) { + BM_ITER_ELEM(l, &liter, v, BM_LOOPS_OF_VERT) { + BM_ELEM_API_FLAG_ENABLE(l, BM_LNORSPACE_UPDATE); + + /* Note that we only handle unselected neighbor vertices here, main loop will take care of + * selected ones. */ + if (!BM_elem_flag_test(l->prev->v, BM_ELEM_SELECT) && + !BLI_BITMAP_TEST(done_verts, BM_elem_index_get(l->prev->v))) + { + BMLoop *l_prev; + BMIter liter_prev; + BM_ITER_ELEM(l_prev, &liter_prev, l->prev->v, BM_LOOPS_OF_VERT) { + BM_ELEM_API_FLAG_ENABLE(l_prev, BM_LNORSPACE_UPDATE); + } + BLI_BITMAP_ENABLE(done_verts, BM_elem_index_get(l_prev->v)); } - BLI_BITMAP_ENABLE(done_verts, BM_elem_index_get(l_prev->v)); - } - if (!BM_elem_flag_test(l->next->v, BM_ELEM_SELECT) && - !BLI_BITMAP_TEST(done_verts, BM_elem_index_get(l->next->v))) - { - BMLoop *l_next; - BMIter liter_next; - BM_ITER_ELEM(l_next, &liter_next, l->next->v, BM_LOOPS_OF_VERT) { - BM_ELEM_API_FLAG_ENABLE(l_next, BM_LNORSPACE_UPDATE); + if (!BM_elem_flag_test(l->next->v, BM_ELEM_SELECT) && + !BLI_BITMAP_TEST(done_verts, BM_elem_index_get(l->next->v))) + { + BMLoop *l_next; + BMIter liter_next; + BM_ITER_ELEM(l_next, &liter_next, l->next->v, BM_LOOPS_OF_VERT) { + BM_ELEM_API_FLAG_ENABLE(l_next, BM_LNORSPACE_UPDATE); + } + BLI_BITMAP_ENABLE(done_verts, BM_elem_index_get(l_next->v)); } - BLI_BITMAP_ENABLE(done_verts, BM_elem_index_get(l_next->v)); } - } - BLI_BITMAP_ENABLE(done_verts, BM_elem_index_get(v)); + BLI_BITMAP_ENABLE(done_verts, BM_elem_index_get(v)); + } } -} -MEM_freeN(done_verts); -bm->spacearr_dirty |= BM_SPACEARR_DIRTY; + MEM_freeN(done_verts); + bm->spacearr_dirty |= BM_SPACEARR_DIRTY; } void BM_lnorspace_rebuild(BMesh *bm, bool preserve_clnor) @@ -1471,59 +1471,6 @@ int BM_total_loop_select(BMesh *bm) return r_sel; } -static void UNUSED_FUNCTION(bm_mdisps_space_set)( - Object *ob, BMesh *bm, int from, int to) -{ - /* switch multires data out of tangent space */ - if (CustomData_has_layer(&bm->ldata, CD_MDISPS)) { - BMEditMesh *em = BKE_editmesh_create(bm, false); - DerivedMesh *dm = CDDM_from_editbmesh(em, true, false); - MDisps *mdisps; - BMFace *f; - BMIter iter; - // int i = 0; // UNUSED - - multires_set_space(dm, ob, from, to); - - mdisps = CustomData_get_layer(&dm->loopData, CD_MDISPS); - - BM_ITER_MESH (f, &iter, bm, BM_FACES_OF_MESH) { - BMLoop *l; - BMIter liter; - BM_ITER_ELEM (l, &liter, f, BM_LOOPS_OF_FACE) { - MDisps *lmd = CustomData_bmesh_get(&bm->ldata, l->head.data, CD_MDISPS); - - if (!lmd->disps) { - printf("%s: warning - 'lmd->disps' == NULL\n", __func__); - } - - if (lmd->disps && lmd->totdisp == mdisps->totdisp) { - memcpy(lmd->disps, mdisps->disps, sizeof(float) * 3 * lmd->totdisp); - } - else if (mdisps->disps) { - if (lmd->disps) - MEM_freeN(lmd->disps); - - lmd->disps = MEM_dupallocN(mdisps->disps); - lmd->totdisp = mdisps->totdisp; - lmd->level = mdisps->level; - } - - mdisps++; - // i += 1; - } - } - - dm->needsFree = 1; - dm->release(dm); - - /* setting this to NULL prevents BKE_editmesh_free from freeing it */ - em->bm = NULL; - BKE_editmesh_free(em); - MEM_freeN(em); - } -} - /** * \brief BMesh Begin Edit * diff --git a/source/blender/bmesh/intern/bmesh_mesh_conv.c b/source/blender/bmesh/intern/bmesh_mesh_conv.c index 5ba3f149689..00bb0110e74 100644 --- a/source/blender/bmesh/intern/bmesh_mesh_conv.c +++ b/source/blender/bmesh/intern/bmesh_mesh_conv.c @@ -548,8 +548,12 @@ BLI_INLINE void bmesh_quick_edgedraw_flag(MEdge *med, BMEdge *e) } } +/** + * + * \param bmain May be NULL in case \a calc_object_remap parameter option is set. + */ void BM_mesh_bm_to_me( - BMesh *bm, Mesh *me, + Main *bmain, BMesh *bm, Mesh *me, const struct BMeshToMeshParams *params) { MLoop *mloop; @@ -710,11 +714,12 @@ void BM_mesh_bm_to_me( /* patch hook indices and vertex parents */ if (params->calc_object_remap && (ototvert > 0)) { + BLI_assert(bmain != NULL); Object *ob; ModifierData *md; BMVert **vertMap = NULL; - for (ob = G.main->object.first; ob; ob = ob->id.next) { + for (ob = bmain->object.first; ob; ob = ob->id.next) { if ((ob->parent) && (ob->parent->data == me) && ELEM(ob->partype, PARVERT1, PARVERT3)) { if (vertMap == NULL) { diff --git a/source/blender/bmesh/intern/bmesh_mesh_conv.h b/source/blender/bmesh/intern/bmesh_mesh_conv.h index 6e9d62349ea..008960e7f6e 100644 --- a/source/blender/bmesh/intern/bmesh_mesh_conv.h +++ b/source/blender/bmesh/intern/bmesh_mesh_conv.h @@ -32,6 +32,7 @@ * \ingroup bmesh */ +struct Main; struct Mesh; void BM_mesh_cd_validate(BMesh *bm); @@ -60,8 +61,8 @@ struct BMeshToMeshParams { int64_t cd_mask_extra; }; void BM_mesh_bm_to_me( - BMesh *bm, struct Mesh *me, + struct Main *bmain, BMesh *bm, struct Mesh *me, const struct BMeshToMeshParams *params) -ATTR_NONNULL(1, 2, 3); +ATTR_NONNULL(2, 3, 4); #endif /* __BMESH_MESH_CONV_H__ */ diff --git a/source/blender/bmesh/intern/bmesh_polygon_edgenet.c b/source/blender/bmesh/intern/bmesh_polygon_edgenet.c index 85dfd3f58e2..4703dbf3bcd 100644 --- a/source/blender/bmesh/intern/bmesh_polygon_edgenet.c +++ b/source/blender/bmesh/intern/bmesh_polygon_edgenet.c @@ -1051,6 +1051,16 @@ static int bm_face_split_edgenet_find_connection( #ifdef USE_PARTIAL_CONNECT /** + * Used to identify edges that get split off when making island from partial connection. + * fptr should be a BMFace*, but is a void* for general interface to BM_vert_separate_tested_edges + */ +static bool test_tagged_and_notface(BMEdge *e, void *fptr) +{ + BMFace *f = (BMFace *)fptr; + return BM_elem_flag_test(e, BM_ELEM_INTERNAL_TAG) && !BM_edge_in_face(e, f); +} + +/** * Split vertices which are part of a partial connection * (only a single vertex connecting an island). * @@ -1058,7 +1068,7 @@ static int bm_face_split_edgenet_find_connection( * This function leaves all the flags set as well. * */ -static BMVert *bm_face_split_edgenet_partial_connect(BMesh *bm, BMVert *v_delimit) +static BMVert *bm_face_split_edgenet_partial_connect(BMesh *bm, BMVert *v_delimit, BMFace *f) { /* -------------------------------------------------------------------- */ /* Initial check that we may be a delimiting vert (keep this fast) */ @@ -1084,7 +1094,7 @@ static BMVert *bm_face_split_edgenet_partial_connect(BMesh *bm, BMVert *v_delimi BLI_assert(BM_elem_flag_test(BM_edge_other_vert(e_iter, v_delimit), VERT_NOT_IN_STACK)); BLI_linklist_prepend_alloca(&e_delimit_list, e_iter); e_delimit_list_len++; - if (e_iter->l != NULL) { + if (e_iter->l != NULL && BM_edge_in_face(e_iter, f)) { e_face_init = e_iter; } } @@ -1133,7 +1143,7 @@ static BMVert *bm_face_split_edgenet_partial_connect(BMesh *bm, BMVert *v_delimi bool is_delimit = false; FOREACH_VERT_EDGE(v_delimit, e_iter, { BMVert *v_step = BM_edge_other_vert(e_iter, v_delimit); - if (BM_elem_flag_test(v_step, VERT_NOT_IN_STACK) && BM_edge_is_wire(e_iter)) { + if (BM_elem_flag_test(v_step, VERT_NOT_IN_STACK) && !BM_edge_in_face(e_iter, f)) { is_delimit = true; /* if one vertex is valid - we have a mix */ } else { @@ -1148,7 +1158,7 @@ static BMVert *bm_face_split_edgenet_partial_connect(BMesh *bm, BMVert *v_delimi BMVert *v_split = NULL; if (is_delimit) { v_split = BM_vert_create(bm, v_delimit->co, NULL, 0); - BM_vert_separate_wire_hflag(bm, v_split, v_delimit, EDGE_NOT_IN_STACK); + BM_vert_separate_tested_edges(bm, v_split, v_delimit, test_tagged_and_notface, f); BM_elem_flag_enable(v_split, VERT_NOT_IN_STACK); BLI_assert(v_delimit->e != NULL); @@ -1224,6 +1234,7 @@ bool BM_face_split_edgenet_connect_islands( const uint edge_arr_len = (uint)edge_net_init_len + (uint)f->len; BMEdge **edge_arr = BLI_array_alloca(edge_arr, edge_arr_len); bool ok = false; + uint edge_net_new_len = (uint)edge_net_init_len; memcpy(edge_arr, edge_net_init, sizeof(*edge_arr) * (size_t)edge_net_init_len); @@ -1272,7 +1283,7 @@ bool BM_face_split_edgenet_connect_islands( BMVert *v_other; /* note, remapping will _never_ map a vertex to an already mapped vertex */ - while (UNLIKELY((v_other = bm_face_split_edgenet_partial_connect(bm, v_delimit)))) { + while (UNLIKELY((v_other = bm_face_split_edgenet_partial_connect(bm, v_delimit, f)))) { struct TempVertPair *tvp = BLI_memarena_alloc(mem_arena, sizeof(*tvp)); tvp->next = temp_vert_pairs.list; tvp->v_orig = v_delimit; @@ -1509,7 +1520,7 @@ bool BM_face_split_edgenet_connect_islands( /* Create connections between groups */ /* may be an over-alloc, but not by much */ - uint edge_net_new_len = (uint)edge_net_init_len + ((group_arr_len - 1) * 2); + edge_net_new_len = (uint)edge_net_init_len + ((group_arr_len - 1) * 2); BMEdge **edge_net_new = BLI_memarena_alloc(mem_arena, sizeof(*edge_net_new) * edge_net_new_len); memcpy(edge_net_new, edge_net_init, sizeof(*edge_net_new) * (size_t)edge_net_init_len); |