[Bf-blender-cvs] [6644e96f01d] master: Cleanup: use BMLoop.next/prev for BMesh auto-smooth logic

Campbell Barton noreply at git.blender.org
Wed Jul 14 06:22:46 CEST 2021


Commit: 6644e96f01da353de1dba8c3e38c61de83a8d516
Author: Campbell Barton
Date:   Wed Jul 14 14:18:58 2021 +1000
Branches: master
https://developer.blender.org/rB6644e96f01da353de1dba8c3e38c61de83a8d516

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.

===================================================================

M	source/blender/bmesh/intern/bmesh_mesh_normals.c

===================================================================

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



More information about the Bf-blender-cvs mailing list