[Bf-blender-cvs] [e6a5e548d5f] master: Cleanup: correct and update comments for bmesh walkers

Campbell Barton noreply at git.blender.org
Sun Jan 31 07:43:46 CET 2021


Commit: e6a5e548d5f979fea4b1bb5348ce4c3d3599fb19
Author: Campbell Barton
Date:   Sun Jan 31 17:42:11 2021 +1100
Branches: master
https://developer.blender.org/rBe6a5e548d5f979fea4b1bb5348ce4c3d3599fb19

Cleanup: correct and update comments for bmesh walkers

- Correct variable names which were missed when refactoring.
- Use full sentences.

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

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

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

diff --git a/source/blender/bmesh/intern/bmesh_walkers_impl.c b/source/blender/bmesh/intern/bmesh_walkers_impl.c
index c23551ecca7..647a22baaeb 100644
--- a/source/blender/bmesh/intern/bmesh_walkers_impl.c
+++ b/source/blender/bmesh/intern/bmesh_walkers_impl.c
@@ -29,7 +29,7 @@
 #include "bmesh.h"
 #include "intern/bmesh_walkers_private.h"
 
-/* pop into stack memory (common operation) */
+/* Pop into stack memory (common operation). */
 #define BMW_state_remove_r(walker, owalk) \
   { \
     memcpy(owalk, BMW_current_state(walker), sizeof(*(owalk))); \
@@ -86,7 +86,7 @@ static bool bmw_mask_check_face(BMWalker *walker, BMFace *f)
 static bool bmw_edge_is_wire(const BMWalker *walker, const BMEdge *e)
 {
   if (walker->flag & BMW_FLAG_TEST_HIDDEN) {
-    /* check if this is a wire edge, ignoring hidden faces */
+    /* Check if this is a wire edge, ignoring hidden faces. */
     if (BM_edge_is_wire(e)) {
       return true;
     }
@@ -137,8 +137,7 @@ static void bmw_VertShellWalker_begin(BMWalker *walker, void *data)
 
   switch (h->htype) {
     case BM_VERT: {
-      /* starting the walk at a vert, add all the edges
-       * to the worklist */
+      /* Starting the walk at a vert, add all the edges to the work-list. */
       v = (BMVert *)h;
       BM_ITER_ELEM (e, &eiter, v, BM_EDGES_OF_VERT) {
         bmw_VertShellWalker_visitEdge(walker, e);
@@ -147,8 +146,7 @@ static void bmw_VertShellWalker_begin(BMWalker *walker, void *data)
     }
 
     case BM_EDGE: {
-      /* starting the walk at an edge, add the single edge
-       * to the worklist */
+      /* Starting the walk at an edge, add the single edge to the work-list. */
       e = (BMEdge *)h;
       bmw_VertShellWalker_visitEdge(walker, e);
       break;
@@ -201,7 +199,7 @@ static void *bmw_VertShellWalker_step(BMWalker *walker)
 
   BMW_state_remove(walker);
 
-  /* find the next edge whose other vertex has not been visite */
+  /* Find the next edge whose other vertex has not been visited. */
   curedge = shellWalk.curedge;
   do {
     if (!BLI_gset_haskey(walker->visit_set, curedge)) {
@@ -212,11 +210,11 @@ static void *bmw_VertShellWalker_step(BMWalker *walker)
 
         v_old = BM_edge_other_vert(curedge, shellWalk.base);
 
-        /* push a new state onto the stac */
+        /* Push a new state onto the stack. */
         newState = BMW_state_add(walker);
         BLI_gset_insert(walker->visit_set, curedge);
 
-        /* populate the new stat */
+        /* Populate the new state. */
 
         newState->base = v_old;
         newState->curedge = curedge;
@@ -266,8 +264,7 @@ static void bmw_LoopShellWalker_begin(BMWalker *walker, void *data)
 
   switch (h->htype) {
     case BM_LOOP: {
-      /* starting the walk at a vert, add all the edges
-       * to the worklist */
+      /* Starting the walk at a vert, add all the edges to the work-list. */
       BMLoop *l = (BMLoop *)h;
       bmw_LoopShellWalker_visitLoop(walker, l);
       break;
@@ -292,7 +289,7 @@ static void bmw_LoopShellWalker_begin(BMWalker *walker, void *data)
     case BM_FACE: {
       BMFace *f = (BMFace *)h;
       BMLoop *l = BM_FACE_FIRST_LOOP(f);
-      /* walker will handle other loops within the face */
+      /* Walker will handle other loops within the face. */
       bmw_LoopShellWalker_visitLoop(walker, l);
       break;
     }
@@ -312,7 +309,7 @@ static void bmw_LoopShellWalker_step_impl(BMWalker *walker, BMLoop *l)
   BMEdge *e_edj_pair[2];
   int i;
 
-  /* seems paranoid, but one caller also walks edges */
+  /* Seems paranoid, but one caller also walks edges. */
   BLI_assert(l->head.htype == BM_LOOP);
 
   bmw_LoopShellWalker_visitLoop(walker, l->next);
@@ -409,7 +406,7 @@ static void bmw_LoopShellWireWalker_visitVert(BMWalker *walker, BMVert *v, const
 
       bmw_LoopShellWalker_visitEdgeWire(walker, e);
 
-      /* check if we step onto a non-wire vertex */
+      /* Check if we step onto a non-wire vertex. */
       v_other = BM_edge_other_vert(e, v);
       BM_ITER_ELEM (l, &iter, v_other, BM_LOOPS_OF_VERT) {
 
@@ -463,7 +460,7 @@ static void bmw_LoopShellWireWalker_begin(BMWalker *walker, void *data)
       break;
     }
     case BM_FACE: {
-      /* wire verts will be walked over */
+      /* Wire verts will be walked over. */
       break;
     }
     default:
@@ -581,12 +578,12 @@ static void bmw_ConnectedVertexWalker_visitVertex(BMWalker *walker, BMVert *v)
   BMwConnectedVertexWalker *vwalk;
 
   if (BLI_gset_haskey(walker->visit_set, v)) {
-    /* already visited */
+    /* Already visited. */
     return;
   }
 
   if (!bmw_mask_check_vert(walker, v)) {
-    /* not flagged for walk */
+    /* Not flagged for walk. */
     return;
   }
 
@@ -670,10 +667,9 @@ static void *bmw_IslandboundWalker_step(BMWalker *walker)
   BMEdge *e;
   BMFace *f;
   BMLoop *l;
-  /* int found = 0; */
 
   memcpy(&owalk, BMW_current_state(walker), sizeof(owalk));
-  /* normally we'd remove here, but delay until after error checking */
+  /* Normally we'd remove here, but delay until after error checking. */
   iwalk = &owalk;
 
   l = iwalk->curloop;
@@ -681,7 +677,7 @@ static void *bmw_IslandboundWalker_step(BMWalker *walker)
 
   v = BM_edge_other_vert(e, iwalk->lastv);
 
-  /* pop off current state */
+  /* Pop off current state. */
   BMW_state_remove(walker);
 
   f = l->f;
@@ -699,7 +695,7 @@ static void *bmw_IslandboundWalker_step(BMWalker *walker)
       }
     }
     else {
-      /* treat non-manifold edges as boundaries */
+      /* Treat non-manifold edges as boundaries. */
       f = l->f;
       e = l->e;
       break;
@@ -717,9 +713,16 @@ static void *bmw_IslandboundWalker_step(BMWalker *walker)
   iwalk = BMW_state_add(walker);
   iwalk->base = owalk.base;
 
-  // if (!BMO_face_flag_test(walker->bm, l->f, walker->restrictflag))
-  //  iwalk->curloop = l->radial_next;
-  iwalk->curloop = l;  // else iwalk->curloop = l;
+#if 0
+  if (!BMO_face_flag_test(walker->bm, l->f, walker->restrictflag)) {
+    iwalk->curloop = l->radial_next;
+  }
+  else {
+    iwalk->curloop = l;
+  }
+#else
+  iwalk->curloop = l;
+#endif
   iwalk->lastv = v;
 
   return owalk.curloop;
@@ -763,7 +766,7 @@ static void *bmw_IslandWalker_step_ex(BMWalker *walker, bool only_manifold)
 
   l_iter = l_first = BM_FACE_FIRST_LOOP(iwalk->cur);
   do {
-    /* could skip loop here too, but don't add unless we need it */
+    /* Could skip loop here too, but don't add unless we need it. */
     if (!bmw_mask_check_edge(walker, l_iter->e)) {
       continue;
     }
@@ -772,7 +775,7 @@ static void *bmw_IslandWalker_step_ex(BMWalker *walker, bool only_manifold)
 
     if (only_manifold && (l_iter->radial_next != l_iter)) {
       int face_count = 1;
-      /* check other faces (not this one), ensure only one other can be walked onto. */
+      /* Check other faces (not this one), ensure only one other Can be walked onto. */
       l_radial_iter = l_iter->radial_next;
       do {
         if (bmw_mask_check_face(walker, l_radial_iter->f)) {
@@ -796,7 +799,7 @@ static void *bmw_IslandWalker_step_ex(BMWalker *walker, bool only_manifold)
         continue;
       }
 
-      /* saves checking BLI_gset_haskey below (manifold edges there's a 50% chance) */
+      /* Saves checking #BLI_gset_haskey below (manifold edges there's a 50% chance). */
       if (f == iwalk->cur) {
         continue;
       }
@@ -947,12 +950,12 @@ static void bmw_EdgeLoopWalker_begin(BMWalker *walker, void *data)
     }
 
     if (f_best) {
-      /* only use hub selection for 5+ sides else this could
+      /* Only use hub selection for 5+ sides else this could
        * conflict with normal edge loop selection. */
       lwalk->f_hub = f_best->len > 4 ? f_best : NULL;
     }
     else {
-      /* edge doesn't have any faces connected to it */
+      /* Edge doesn't have any faces connected to it. */
       lwalk->f_hub = NULL;
     }
   }
@@ -960,7 +963,7 @@ static void bmw_EdgeLoopWalker_begin(BMWalker *walker, void *data)
     lwalk->f_hub = NULL;
   }
 
-  /* rewind */
+  /* Rewind. */
   while ((owalk_pt = BMW_current_state(walker))) {
     owalk = *((BMwEdgeLoopWalker *)owalk_pt);
     BMW_walk(walker);
@@ -1007,7 +1010,7 @@ static void *bmw_EdgeLoopWalker_step(BMWalker *walker)
       nexte = BM_edge_exists(v, l->v);
 
       if (bmw_mask_check_edge(walker, nexte) && !BLI_gset_haskey(walker->visit_set, nexte) &&
-          /* never step onto a boundary edge, this gives odd-results */
+          /* Never step onto a boundary edge, this gives odd-results. */
           (BM_edge_is_boundary(nexte) == false)) {
         lwalk = BMW_state_add(walker);
         lwalk->cur = nexte;
@@ -1024,7 +1027,7 @@ static void *bmw_EdgeLoopWalker_step(BMWalker *walker)
   else if (l == NULL) { /* WIRE EDGE */
     BMIter eiter;
 
-    /* match trunk: mark all connected wire edges */
+    /* Match trunk: mark all connected wire edges. */
     for (int i = 0; i < 2; i++) {
       v = i ? e->v2 : e->v1;
 
@@ -1051,9 +1054,8 @@ static void *bmw_EdgeLoopWalker_step(BMWalker *walker)
 
     vert_edge_tot = BM_vert_edge_count_nonwire(v);
 
-    /* Typical loopiong over edges in the middle of a mesh */
-    /* However, why use 2 here at all?
-     * I guess for internal ngon loops it can be useful. Antony R. */
+    /* Typical looping over edges in the middle of a mesh.
+     * Why use 2 here at all? - for internal ngon loops it can be useful. */
     if (ELEM(vert_edge_tot, 4, 2)) {
       int i_opposite = vert_edge_tot / 2;
       int i = 0;
@@ -1094,15 +1096,15 @@ static void *bmw_EdgeLoopWalker_step(BMWalker *walker)
 
     vert_edge_tot = BM_vert_edge_count_nonwire(v);
 
-    /* check if we should step, this is fairly involved */
+    /* Check if we should step, this is fairly involved. */
     if (
-        /* walk over boundary of faces but stop at corners */
+        /* Walk over boundary of faces but stop at corners. */
         (owalk.is_single == false && vert_edge_tot > 2) ||
 
-        /* initial edge was a boundary, so is this edge and vertex is only a part of this face
-         * this lets us walk over the boundary of an ngon which is handy */
+        /* Initial edge was a boundary, so is this edge and vertex is only a part of this face
+         * thi

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list