diff options
author | Campbell Barton <ideasman42@gmail.com> | 2014-10-06 14:16:06 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2014-10-06 14:16:06 +0400 |
commit | 9cfcddc8f4877e5ad22dc289f8a3be11bc30e110 (patch) | |
tree | e4e45abf44862b4917a2f738b4d7ad18b64b67ae | |
parent | 9e53a97ddfbbe1bff3be585937318554f9c0eec6 (diff) |
Dyntopo: minor speedup collapsing edges
-rw-r--r-- | source/blender/blenkernel/intern/pbvh_bmesh.c | 31 | ||||
-rw-r--r-- | source/blender/bmesh/intern/bmesh_queries.c | 2 |
2 files changed, 15 insertions, 18 deletions
diff --git a/source/blender/blenkernel/intern/pbvh_bmesh.c b/source/blender/blenkernel/intern/pbvh_bmesh.c index 14a2ee0c3e7..1a0ddac03d7 100644 --- a/source/blender/blenkernel/intern/pbvh_bmesh.c +++ b/source/blender/blenkernel/intern/pbvh_bmesh.c @@ -823,15 +823,16 @@ static bool pbvh_bmesh_subdivide_long_edges(EdgeQueueContext *eq_ctx, PBVH *bvh, return any_subdivided; } -static void pbvh_bmesh_collapse_edge(PBVH *bvh, BMEdge *e, - BMVert *v1, BMVert *v2, - GSet *deleted_verts, - BLI_Buffer *edge_loops, - BLI_Buffer *deleted_faces, - EdgeQueueContext *eq_ctx) +static void pbvh_bmesh_collapse_edge( + PBVH *bvh, BMEdge *e, + BMVert *v1, BMVert *v2, + GSet *deleted_verts, + BLI_Buffer *deleted_faces, + EdgeQueueContext *eq_ctx) { BMIter bm_iter; BMFace *f; + BMLoop *l_adj; BMVert *v_del, *v_conn; int i; float mask_v1 = BM_ELEM_CD_GET_FLOAT(v1, eq_ctx->cd_vert_mask_offset); @@ -846,15 +847,11 @@ static void pbvh_bmesh_collapse_edge(PBVH *bvh, BMEdge *e, v_conn = v1; } - /* Get all faces adjacent to the edge */ - pbvh_bmesh_edge_loops(edge_loops, e); - /* Remove the merge vertex from the PBVH */ pbvh_bmesh_vert_remove(bvh, v_del, eq_ctx->cd_vert_node_offset, eq_ctx->cd_face_node_offset); /* Remove all faces adjacent to the edge */ - for (i = 0; i < edge_loops->count; i++) { - BMLoop *l_adj = BLI_buffer_at(edge_loops, BMLoop *, i); + while ((l_adj = e->l)) { BMFace *f_adj = l_adj->f; pbvh_bmesh_face_remove(bvh, f_adj, eq_ctx->cd_vert_node_offset, eq_ctx->cd_face_node_offset); @@ -973,10 +970,10 @@ static void pbvh_bmesh_collapse_edge(PBVH *bvh, BMEdge *e, BM_vert_kill(bvh->bm, v_del); } -static bool pbvh_bmesh_collapse_short_edges(EdgeQueueContext *eq_ctx, - PBVH *bvh, - BLI_Buffer *edge_loops, - BLI_Buffer *deleted_faces) +static bool pbvh_bmesh_collapse_short_edges( + EdgeQueueContext *eq_ctx, + PBVH *bvh, + BLI_Buffer *deleted_faces) { float min_len_squared = bvh->bm_min_edge_len * bvh->bm_min_edge_len; GSet *deleted_verts; @@ -1020,7 +1017,7 @@ static bool pbvh_bmesh_collapse_short_edges(EdgeQueueContext *eq_ctx, any_collapsed = true; pbvh_bmesh_collapse_edge(bvh, e, v1, v2, - deleted_verts, edge_loops, + deleted_verts, deleted_faces, eq_ctx); } @@ -1230,7 +1227,7 @@ bool BKE_pbvh_bmesh_update_topology(PBVH *bvh, PBVHTopologyUpdateMode mode, short_edge_queue_create(&eq_ctx, bvh, center, radius); modified |= !BLI_heap_is_empty(q.heap); - pbvh_bmesh_collapse_short_edges(&eq_ctx, bvh, &edge_loops, + pbvh_bmesh_collapse_short_edges(&eq_ctx, bvh, &deleted_faces); BLI_heap_free(q.heap, NULL); BLI_mempool_destroy(queue_pool); diff --git a/source/blender/bmesh/intern/bmesh_queries.c b/source/blender/bmesh/intern/bmesh_queries.c index 685e5443583..40e0356e14c 100644 --- a/source/blender/bmesh/intern/bmesh_queries.c +++ b/source/blender/bmesh/intern/bmesh_queries.c @@ -311,7 +311,7 @@ BMLoop *BM_vert_find_first_loop(BMVert *v) { BMEdge *e; - if (!v || !v->e) + if (!v->e) return NULL; e = bmesh_disk_faceedge_find_first(v->e, v); |