From a8a60c6566c1097355f55d64d9861ed850040a1c Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 2 Jan 2013 02:12:10 +0000 Subject: [PATCH] dyntopo speedup for smooth brush, no need to search for the shared vert-face loop, instead just iterate over the loops. --- source/blender/editors/sculpt_paint/sculpt.c | 32 +++++++------------- 1 file changed, 11 insertions(+), 21 deletions(-) diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c index 098d8e5006f..54ae2ebf588 100644 --- a/source/blender/editors/sculpt_paint/sculpt.c +++ b/source/blender/editors/sculpt_paint/sculpt.c @@ -1353,24 +1353,19 @@ static float neighbor_average_mask(SculptSession *ss, unsigned vert) /* Same logic as neighbor_average(), but for bmesh rather than mesh */ static void bmesh_neighbor_average(float avg[3], BMVert *v) { - int vfcount = BM_vert_face_count(v); + const int vfcount = BM_vert_face_count(v); zero_v3(avg); /* Don't modify corner vertices */ if (vfcount > 1) { - BMIter iter; - BMFace *f; + BMIter liter; + BMLoop *l; int i, total = 0; - BM_ITER_ELEM (f, &iter, v, BM_FACES_OF_VERT) { - BMLoop *l1 = BM_face_vert_share_loop(f, v); - BMLoop *l2 = BM_loop_other_vert_loop(l1, v); - BMVert *adj_v[3] = { - BM_edge_other_vert(l1->e, v), - v, - BM_edge_other_vert(l2->e, v)}; - + BM_ITER_ELEM (l, &liter, v, BM_LOOPS_OF_VERT) { + BMVert *adj_v[3] = {l->prev->v, v, l->next->v}; + for (i = 0; i < 3; i++) { if (vfcount != 2 || BM_vert_face_count(adj_v[i]) <= 2) { add_v3_v3(avg, adj_v[i]->co); @@ -1391,19 +1386,14 @@ static void bmesh_neighbor_average(float avg[3], BMVert *v) /* Same logic as neighbor_average_mask(), but for bmesh rather than mesh */ static float bmesh_neighbor_average_mask(BMesh *bm, BMVert *v) { - BMIter iter; - BMFace *f; + BMIter liter; + BMLoop *l; float avg = 0; int i, total = 0; - BM_ITER_ELEM (f, &iter, v, BM_FACES_OF_VERT) { - BMLoop *l1 = BM_face_vert_share_loop(f, v); - BMLoop *l2 = BM_loop_other_vert_loop(l1, v); - BMVert *adj_v[3] = { - BM_edge_other_vert(l1->e, v), - v, - BM_edge_other_vert(l2->e, v)}; - + BM_ITER_ELEM (l, &liter, v, BM_LOOPS_OF_VERT) { + BMVert *adj_v[3] = {l->prev->v, v, l->next->v}; + for (i = 0; i < 3; i++) { BMVert *v2 = adj_v[i]; float *vmask = CustomData_bmesh_get(&bm->vdata,