Dyntopo: minor speedup collapsing edges

This commit is contained in:
Campbell Barton 2014-10-06 12:16:06 +02:00
parent 9e53a97ddf
commit 9cfcddc8f4
2 changed files with 15 additions and 18 deletions

View File

@ -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);

View File

@ -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);