From 7daa921359a182e00a6bba5b654ace41f26033a2 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 14 Apr 2015 18:32:10 +1000 Subject: BMesh: avoid customdata copy for new dyntopo verts --- source/blender/blenkernel/intern/pbvh_bmesh.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/intern/pbvh_bmesh.c b/source/blender/blenkernel/intern/pbvh_bmesh.c index ce26df4ee3a..b6e5fcfb405 100644 --- a/source/blender/blenkernel/intern/pbvh_bmesh.c +++ b/source/blender/blenkernel/intern/pbvh_bmesh.c @@ -331,11 +331,15 @@ static BMVert *pbvh_bmesh_vert_create( const BMVert *example, const int cd_vert_mask_offset) { - BMVert *v = BM_vert_create(bvh->bm, co, example, BM_CREATE_NOP); PBVHNode *node = &bvh->nodes[node_index]; + BMVert *v; BLI_assert((bvh->totnode == 1 || node_index) && node_index <= bvh->totnode); + /* avoid initializing customdata because its quite involved */ + v = BM_vert_create(bvh->bm, co, example, BM_CREATE_SKIP_CD); + CustomData_bmesh_set_default(&bvh->bm->vdata, &v->head.data); + BLI_gset_insert(node->bm_unique_verts, v); BM_ELEM_CD_SET_INT(v, bvh->cd_vert_node_offset, node_index); @@ -1167,14 +1171,14 @@ static bool pbvh_bmesh_collapse_short_edges( continue; } - if (len_squared_v3v3(v1->co, v2->co) >= min_len_squared) - continue; - /* Check that the edge still exists */ if (!(e = BM_edge_exists(v1, v2))) { continue; } + if (len_squared_v3v3(v1->co, v2->co) >= min_len_squared) + continue; + /* Check that the edge's vertices are still in the PBVH. It's * possible that an edge collapse has deleted adjacent faces * and the node has been split, thus leaving wire edges and -- cgit v1.2.3