From 6644e96f01da353de1dba8c3e38c61de83a8d516 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 14 Jul 2021 14:18:58 +1000 Subject: Cleanup: use BMLoop.next/prev for BMesh auto-smooth logic Use more direct access to next/previous vertices. - `BM_edge_other_vert(l_curr->e, l_curr->v)` -> `l_curr->next->v`. - `BM_edge_other_vert(l_curr->prev->e, l_curr->v)` -> `l_curr->prev->v`. Add asserts to keep the intention clear. --- source/blender/bmesh/intern/bmesh_mesh_normals.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'source') diff --git a/source/blender/bmesh/intern/bmesh_mesh_normals.c b/source/blender/bmesh/intern/bmesh_mesh_normals.c index f13b9a19533..dea6561fe9a 100644 --- a/source/blender/bmesh/intern/bmesh_mesh_normals.c +++ b/source/blender/bmesh/intern/bmesh_mesh_normals.c @@ -631,11 +631,14 @@ static void bm_mesh_loops_calc_normals(BMesh *bm, { const BMVert *v_pivot = l_curr->v; const float *co_pivot = vcos ? vcos[BM_elem_index_get(v_pivot)] : v_pivot->co; - const BMVert *v_1 = BM_edge_other_vert(l_curr->e, v_pivot); + const BMVert *v_1 = l_curr->next->v; const float *co_1 = vcos ? vcos[BM_elem_index_get(v_1)] : v_1->co; - const BMVert *v_2 = BM_edge_other_vert(l_curr->prev->e, v_pivot); + const BMVert *v_2 = l_curr->prev->v; const float *co_2 = vcos ? vcos[BM_elem_index_get(v_2)] : v_2->co; + BLI_assert(v_1 == BM_edge_other_vert(l_curr->e, v_pivot)); + BLI_assert(v_2 == BM_edge_other_vert(l_curr->prev->e, v_pivot)); + sub_v3_v3v3(vec_curr, co_1, co_pivot); normalize_v3(vec_curr); sub_v3_v3v3(vec_prev, co_2, co_pivot); @@ -701,9 +704,11 @@ static void bm_mesh_loops_calc_normals(BMesh *bm, /* Only need to compute previous edge's vector once, * then we can just reuse old current one! */ { - const BMVert *v_2 = BM_edge_other_vert(e_next, v_pivot); + const BMVert *v_2 = lfan_pivot->next->v; const float *co_2 = vcos ? vcos[BM_elem_index_get(v_2)] : v_2->co; + BLI_assert(v_2 == BM_edge_other_vert(e_next, v_pivot)); + sub_v3_v3v3(vec_org, co_2, co_pivot); normalize_v3(vec_org); copy_v3_v3(vec_curr, vec_org); -- cgit v1.2.3