diff options
Diffstat (limited to 'source/blender/editors/mesh/editmesh_knife.c')
-rw-r--r-- | source/blender/editors/mesh/editmesh_knife.c | 31 |
1 files changed, 22 insertions, 9 deletions
diff --git a/source/blender/editors/mesh/editmesh_knife.c b/source/blender/editors/mesh/editmesh_knife.c index 5b9af2fa75c..d9ee340a43b 100644 --- a/source/blender/editors/mesh/editmesh_knife.c +++ b/source/blender/editors/mesh/editmesh_knife.c @@ -169,10 +169,14 @@ typedef struct KnifeTool_OpData { MemArena *arena; + /* reused for edge-net filling */ + struct { + /* cleared each use */ + GSet *edge_visit; #ifdef USE_NET_ISLAND_CONNECT - /* cleared each use */ - MemArena *arena_edgenet; + MemArena *arena; #endif + } edgenet; GHash *origvertmap; GHash *origedgemap; @@ -2273,6 +2277,8 @@ static void knife_make_face_cuts(KnifeTool_OpData *kcd, BMFace *f, ListBase *kfe /* point to knife edges we've created edges in, edge_array aligned */ KnifeEdge **kfe_array = BLI_array_alloca(kfe_array, edge_array_len); + BLI_assert(BLI_gset_size(kcd->edgenet.edge_visit) == 0); + i = 0; for (ref = kfedges->first; ref; ref = ref->next) { bool is_new_edge = false; @@ -2309,9 +2315,11 @@ static void knife_make_face_cuts(KnifeTool_OpData *kcd, BMFace *f, ListBase *kfe BLI_assert(kfe->e); - kfe_array[i] = is_new_edge ? kfe : 0; - edge_array[i] = kfe->e; - i += 1; + if (BLI_gset_add(kcd->edgenet.edge_visit, kfe->e)) { + kfe_array[i] = is_new_edge ? kfe : 0; + edge_array[i] = kfe->e; + i += 1; + } } if (i) { @@ -2324,7 +2332,7 @@ static void knife_make_face_cuts(KnifeTool_OpData *kcd, BMFace *f, ListBase *kfe if (BM_face_split_edgenet_connect_islands( bm, f, edge_array, edge_array_len, - kcd->arena_edgenet, + kcd->edgenet.arena, &edge_array_holes, &edge_array_holes_len)) { if (BM_elem_flag_test(f, BM_ELEM_SELECT)) { @@ -2358,9 +2366,11 @@ static void knife_make_face_cuts(KnifeTool_OpData *kcd, BMFace *f, ListBase *kfe #ifdef USE_NET_ISLAND_CONNECT - BLI_memarena_clear(kcd->arena_edgenet); + BLI_memarena_clear(kcd->edgenet.arena); #endif } + + BLI_gset_clear(kcd->edgenet.edge_visit, NULL); } /* Use the network of KnifeEdges and KnifeVerts accumulated to make real BMVerts and BMEdedges */ @@ -2509,8 +2519,9 @@ static void knifetool_exit_ex(bContext *C, KnifeTool_OpData *kcd) BLI_memarena_free(kcd->arena); #ifdef USE_NET_ISLAND_CONNECT - BLI_memarena_free(kcd->arena_edgenet); + BLI_memarena_free(kcd->edgenet.arena); #endif + BLI_gset_free(kcd->edgenet.edge_visit, NULL); /* tag for redraw */ ED_region_tag_redraw(kcd->ar); @@ -2597,8 +2608,10 @@ static void knifetool_init(bContext *C, KnifeTool_OpData *kcd, kcd->arena = BLI_memarena_new(MEM_SIZE_OPTIMAL(1 << 15), "knife"); #ifdef USE_NET_ISLAND_CONNECT - kcd->arena_edgenet = BLI_memarena_new(MEM_SIZE_OPTIMAL(1 << 15), __func__); + kcd->edgenet.arena = BLI_memarena_new(MEM_SIZE_OPTIMAL(1 << 15), __func__); #endif + kcd->edgenet.edge_visit = BLI_gset_ptr_new(__func__); + kcd->vthresh = KMAXDIST - 1; kcd->ethresh = KMAXDIST; |