[Bf-blender-cvs] [ab344775c2c] master: Cleanup: code-comments

Campbell Barton noreply at git.blender.org
Fri Aug 13 06:47:29 CEST 2021


Commit: ab344775c2c5aa6553981469a27062fd9b15dc87
Author: Campbell Barton
Date:   Fri Aug 13 13:53:27 2021 +1000
Branches: master
https://developer.blender.org/rBab344775c2c5aa6553981469a27062fd9b15dc87

Cleanup: code-comments

Use capitalization, remove unnecessary ellipsis.

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

M	source/blender/blenkernel/intern/mesh_normals.cc

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

diff --git a/source/blender/blenkernel/intern/mesh_normals.cc b/source/blender/blenkernel/intern/mesh_normals.cc
index fe28f10d2db..a1c34be4a74 100644
--- a/source/blender/blenkernel/intern/mesh_normals.cc
+++ b/source/blender/blenkernel/intern/mesh_normals.cc
@@ -197,8 +197,8 @@ static void mesh_calc_normals_poly_and_vertex_accum_fn(
 
   const int i_end = mp->totloop - 1;
 
-  /* Polygon Normal and edge-vector */
-  /* inline version of #BKE_mesh_calc_poly_normal, also does edge-vectors */
+  /* Polygon Normal and edge-vector. */
+  /* Inline version of #BKE_mesh_calc_poly_normal, also does edge-vectors. */
   {
     zero_v3(pnor);
     /* Newell's Method */
@@ -209,12 +209,12 @@ static void mesh_calc_normals_poly_and_vertex_accum_fn(
       v_curr = v_next;
     }
     if (UNLIKELY(normalize_v3(pnor) == 0.0f)) {
-      pnor[2] = 1.0f; /* other axes set to 0.0 */
+      pnor[2] = 1.0f; /* Other axes set to zero. */
     }
   }
 
   /* Accumulate angle weighted face normal into the vertex normal. */
-  /* inline version of #accumulate_vertex_normals_poly_v3. */
+  /* Inline version of #accumulate_vertex_normals_poly_v3. */
   {
     float edvec_prev[3], edvec_next[3], edvec_end[3];
     const float *v_curr = mverts[ml[i_end].v].co;
@@ -254,7 +254,7 @@ static void mesh_calc_normals_poly_and_vertex_finalize_fn(
   float *no = data->vnors[vidx];
 
   if (UNLIKELY(normalize_v3(no) == 0.0f)) {
-    /* following Mesh convention; we use vertex coordinate itself for normal in this case */
+    /* Following Mesh convention; we use vertex coordinate itself for normal in this case. */
     normalize_v3_v3(no, mv->co);
   }
 
@@ -277,7 +277,7 @@ void BKE_mesh_calc_normals_poly_and_vertex(MVert *mvert,
   float(*vnors)[3] = r_vert_normals;
   bool free_vnors = false;
 
-  /* first go through and calculate normals for all the polys */
+  /* First go through and calculate normals for all the polys. */
   if (vnors == nullptr) {
     vnors = (float(*)[3])MEM_calloc_arrayN((size_t)mvert_len, sizeof(*vnors), __func__);
     free_vnors = true;
@@ -375,7 +375,9 @@ void BKE_mesh_calc_normals_mapping(MVert *mverts,
                                    r_faceNors,
                                    false);
 }
-/* extended version of 'BKE_mesh_calc_normals_poly' with option not to calc vertex normals */
+/**
+ * Extended version of 'BKE_mesh_calc_normals_poly' with option not to calc vertex normals.
+ */
 void BKE_mesh_calc_normals_mapping_ex(MVert *mverts,
                                       int numVerts,
                                       const MLoop *mloop,
@@ -398,7 +400,7 @@ void BKE_mesh_calc_normals_mapping_ex(MVert *mverts,
     return;
   }
 
-  /* if we are not calculating verts and no verts were passes then we have nothing to do */
+  /* If we are not calculating verts and no verts were passes then we have nothing to do. */
   if ((only_face_normals == true) && (r_polyNors == nullptr) && (r_faceNors == nullptr)) {
     CLOG_WARN(&LOG, "called with nothing to do");
     return;
@@ -411,13 +413,12 @@ void BKE_mesh_calc_normals_mapping_ex(MVert *mverts,
   // if (!fnors) {fnors = MEM_calloc_arrayN(numFaces, sizeof(float[3]), "face nors mesh.c"); }
 
   if (only_face_normals == false) {
-    /* vertex normals are optional, they require some extra calculations,
-     * so make them optional */
+    /* Vertex normals are optional, they require some extra calculations, so make them optional. */
     BKE_mesh_calc_normals_poly_and_vertex(
         mverts, numVerts, mloop, numLoops, mpolys, numPolys, pnors, nullptr);
   }
   else {
-    /* only calc poly normals */
+    /* Only calc poly normals. */
     const MPoly *mp = mpolys;
     for (int i = 0; i < numPolys; i++, mp++) {
       BKE_mesh_calc_poly_normal(mp, mloop + mp->loopstart, mverts, pnors[i]);
@@ -425,7 +426,7 @@ void BKE_mesh_calc_normals_mapping_ex(MVert *mverts,
   }
 
   if (origIndexFace &&
-      /* fnors == r_faceNors */ /* NO NEED TO ALLOC YET */
+      /* `fnors == r_faceNors` */ /* NO NEED TO ALLOC YET */
           fnors != nullptr &&
       numFaces) {
     const MFace *mf = mfaces;
@@ -434,8 +435,8 @@ void BKE_mesh_calc_normals_mapping_ex(MVert *mverts,
         copy_v3_v3(fnors[i], pnors[*origIndexFace]);
       }
       else {
-        /* eek, we're not corresponding to polys */
-        CLOG_ERROR(&LOG, "tessellation face indices are incorrect.  normals may look bad.");
+        /* Yikes, we're not corresponding to polys. */
+        CLOG_ERROR(&LOG, "tessellation face indices are incorrect. Normals may look bad.");
       }
     }
   }
@@ -488,7 +489,7 @@ void BKE_mesh_ensure_normals_for_display(Mesh *mesh)
           (size_t)mesh->totpoly, sizeof(*poly_nors), __func__);
     }
 
-    /* calculate poly/vert normals */
+    /* Calculate poly/vert normals. */
     if (do_vert_normals) {
       BKE_mesh_calc_normals_poly_and_vertex(mesh->mvert,
                                             mesh->totvert,
@@ -518,8 +519,10 @@ void BKE_mesh_ensure_normals_for_display(Mesh *mesh)
   }
 }
 
-/* Note that this does not update the CD_NORMAL layer,
- * but does update the normals in the CD_MVERT layer. */
+/**
+ * NOTE: this does not update the #CD_NORMAL layer,
+ * but does update the normals in the #CD_MVERT layer.
+ */
 void BKE_mesh_calc_normals(Mesh *mesh)
 {
 #ifdef DEBUG_TIME
@@ -575,7 +578,7 @@ void BKE_mesh_calc_normals_looptri(MVert *mverts,
                                      mverts[vtri[2]].co);
   }
 
-  /* following Mesh convention; we use vertex coordinate itself for normal in this case */
+  /* Following Mesh convention; we use vertex coordinate itself for normal in this case. */
   for (int i = 0; i < numVerts; i++) {
     MVert *mv = &mverts[i];
     float *no = tnorms[i];
@@ -715,11 +718,11 @@ void BKE_lnor_space_define(MLoopNorSpace *lnor_space,
       BLI_stack_discard(edge_vectors);
       nbr++;
     }
-    /* NOTE: In theory, this could be 'nbr > 2',
-     *       but there is one case where we only have two edges for two loops:
-     *       a smooth vertex with only two edges and two faces (our Monkey's nose has that, e.g.).
+    /* NOTE: In theory, this could be `nbr > 2`,
+     * but there is one case where we only have two edges for two loops:
+     * a smooth vertex with only two edges and two faces (our Monkey's nose has that, e.g.).
      */
-    BLI_assert(nbr >= 2); /* This piece of code shall only be called for more than one loop... */
+    BLI_assert(nbr >= 2); /* This piece of code shall only be called for more than one loop. */
     lnor_space->ref_alpha = alpha / (float)nbr;
   }
   else {
@@ -791,7 +794,7 @@ MINLINE float unit_short_to_float(const short val)
 
 MINLINE short unit_float_to_short(const float val)
 {
-  /* Rounding... */
+  /* Rounding. */
   return (short)floorf(val * (float)SHRT_MAX + 0.5f);
 }
 
@@ -1002,7 +1005,7 @@ static void mesh_edges_sharp_tag(LoopSplitTaskDataCommon *data,
           e2l[1] = INDEX_INVALID;
 
           /* We want to avoid tagging edges as sharp when it is already defined as such by
-           * other causes than angle threshold... */
+           * other causes than angle threshold. */
           if (do_sharp_edges_tag && is_angle_sharp) {
             BLI_BITMAP_SET(sharp_edges, ml_curr->e, true);
           }
@@ -1016,7 +1019,7 @@ static void mesh_edges_sharp_tag(LoopSplitTaskDataCommon *data,
         e2l[1] = INDEX_INVALID;
 
         /* We want to avoid tagging edges as sharp when it is already defined as such by
-         * other causes than angle threshold... */
+         * other causes than angle threshold. */
         if (do_sharp_edges_tag) {
           BLI_BITMAP_SET(sharp_edges, ml_curr->e, false);
         }
@@ -1098,14 +1101,13 @@ void BKE_mesh_loop_manifold_fan_around_vert_next(const MLoop *mloops,
   const MLoop *mlfan_next;
   const MPoly *mpfan_next;
 
-  /* Warning! This is rather complex!
+  /* WARNING: This is rather complex!
    * We have to find our next edge around the vertex (fan mode).
    * First we find the next loop, which is either previous or next to mlfan_curr_index, depending
    * whether both loops using current edge are in the same direction or not, and whether
    * mlfan_curr_index actually uses the vertex we are fanning around!
    * mlfan_curr_index is the index of mlfan_next here, and mlfan_next is not the real next one
-   * (i.e. not the future mlfan_curr)...
-   */
+   * (i.e. not the future `mlfan_curr`). */
   *r_mlfan_curr_index = (e2lfan_curr[0] == *r_mlfan_curr_index) ? e2lfan_curr[1] : e2lfan_curr[0];
   *r_mpfan_curr_index = loop_to_poly[*r_mlfan_curr_index];
 
@@ -1130,7 +1132,7 @@ void BKE_mesh_loop_manifold_fan_around_vert_next(const MLoop *mloops,
     *r_mlfan_vert_index = *r_mlfan_curr_index;
   }
   *r_mlfan_curr = &mloops[*r_mlfan_curr_index];
-  /* And now we are back in sync, mlfan_curr_index is the index of mlfan_curr! Pff! */
+  /* And now we are back in sync, mlfan_curr_index is the index of `mlfan_curr`! Pff! */
 }
 
 static void split_loop_nor_single_do(LoopSplitTaskDataCommon *common_data, LoopSplitTaskData *data)
@@ -1185,8 +1187,7 @@ static void split_loop_nor_single_do(LoopSplitTaskDataCommon *common_data, LoopS
     normalize_v3(vec_prev);
 
     BKE_lnor_space_define(lnor_space, *lnor, vec_curr, vec_prev, nullptr);
-    /* We know there is only one loop in this space,
-     * no need to create a linklist in this case... */
+    /* We know there is only one loop in this space, no need to create a link-list in this case. */
     BKE_lnor_space_add_loop(lnors_spacearr, lnor_space, ml_curr_index, nullptr, true);
 
     if (clnors_data) {
@@ -1222,24 +1223,24 @@ static void split_loop_nor_fan_do(LoopSplitTaskDataCommon *common_data, LoopSpli
 
   BLI_Stack *edge_vectors = data->edge_vectors;
 
-  /* Gah... We have to fan around current vertex, until we find the other non-smooth edge,
+  /* Sigh! we have to fan around current vertex, until we find the other non-smooth edge,
    * and accumulate face normals into the vertex!
    * Note in case this vertex has only one sharp edges, this is a waste because the normal is the
    * same as the vertex normal, but I do not see any easy way to detect that (would need to count
    * number of sharp edge

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list