[Bf-blender-cvs] [98fc998c70c] master: Cleanup: Clang tidy

Hans Goudey noreply at git.blender.org
Mon Apr 18 19:36:49 CEST 2022


Commit: 98fc998c70c172b70557e69eb3b832661d23bf1a
Author: Hans Goudey
Date:   Mon Apr 18 12:36:37 2022 -0500
Branches: master
https://developer.blender.org/rB98fc998c70c172b70557e69eb3b832661d23bf1a

Cleanup: Clang tidy

- Inconsistent parameter names
- Else after return
- Braces around statements
- Qualified auto
- Also (not clang tidy): Pass StringRef by value, unused parameter

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

M	source/blender/blenkernel/BKE_layer.h
M	source/blender/blenkernel/intern/gpencil_geom.cc
M	source/blender/draw/engines/eevee/eevee_shaders_extra.cc
M	source/blender/editors/include/ED_armature.h
M	source/blender/editors/object/object_modifier.c
M	source/blender/gpu/intern/gpu_shader_dependency.cc
M	source/blender/io/wavefront_obj/importer/obj_import_file_reader.cc

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

diff --git a/source/blender/blenkernel/BKE_layer.h b/source/blender/blenkernel/BKE_layer.h
index cad6f6d6645..3e4f2fe154e 100644
--- a/source/blender/blenkernel/BKE_layer.h
+++ b/source/blender/blenkernel/BKE_layer.h
@@ -594,9 +594,9 @@ void BKE_view_layer_rename_lightgroup(ViewLayer *view_layer,
                                       ViewLayerLightgroup *lightgroup,
                                       const char *name);
 
-void BKE_lightgroup_membership_get(struct LightgroupMembership *lgm, char *value);
+void BKE_lightgroup_membership_get(struct LightgroupMembership *lgm, char *name);
 int BKE_lightgroup_membership_length(struct LightgroupMembership *lgm);
-void BKE_lightgroup_membership_set(struct LightgroupMembership **lgm, const char *value);
+void BKE_lightgroup_membership_set(struct LightgroupMembership **lgm, const char *name);
 
 #ifdef __cplusplus
 }
diff --git a/source/blender/blenkernel/intern/gpencil_geom.cc b/source/blender/blenkernel/intern/gpencil_geom.cc
index e1a79986719..041696fa8d3 100644
--- a/source/blender/blenkernel/intern/gpencil_geom.cc
+++ b/source/blender/blenkernel/intern/gpencil_geom.cc
@@ -981,7 +981,7 @@ bool BKE_gpencil_stroke_shrink(bGPDstroke *gps, const float dist, const short mo
  * \{ */
 
 bool BKE_gpencil_stroke_smooth_point(bGPDstroke *gps,
-                                     int i,
+                                     int point_index,
                                      float influence,
                                      int iterations,
                                      const bool smooth_caps,
@@ -995,7 +995,7 @@ bool BKE_gpencil_stroke_smooth_point(bGPDstroke *gps,
 
   /* Overview of the algorithm here and in the following smooth functions:
    *  The smooth functions return the new attribute in question for a single point.
-   *  The result is stored in r_gps->points[i], while the data is read from gps.
+   *  The result is stored in r_gps->points[point_index], while the data is read from gps.
    *  To get a correct result, duplicate the stroke point data and read from the copy,
    *  while writing to the real stroke. Not doing that will result in acceptable, but
    *  asymmetric results.
@@ -1004,16 +1004,16 @@ bool BKE_gpencil_stroke_smooth_point(bGPDstroke *gps,
    * the parameter "iterations" set to 1 or 2. (2 matches the old algorithm).
    */
 
-  const bGPDspoint *pt = &gps->points[i];
+  const bGPDspoint *pt = &gps->points[point_index];
   const bool is_cyclic = (gps->flag & GP_STROKE_CYCLIC) != 0;
   /* If smooth_caps is false, the caps will not be translated by smoothing. */
-  if (!smooth_caps && !is_cyclic && ELEM(i, 0, gps->totpoints - 1)) {
-    copy_v3_v3(&r_gps->points[i].x, &pt->x);
+  if (!smooth_caps && !is_cyclic && ELEM(point_index, 0, gps->totpoints - 1)) {
+    copy_v3_v3(&r_gps->points[point_index].x, &pt->x);
     return true;
   }
 
   /* This function uses a binomial kernel, which is the discrete version of gaussian blur.
-   * The weight for a vertex at the relative index i is
+   * The weight for a vertex at the relative index point_index is
    * w = nCr(n, j + n/2) / 2^n = (n/1 * (n-1)/2 * ... * (n-j-n/2)/(j+n/2)) / 2^n
    * All weights together sum up to 1
    * This is equivalent to doing multiple iterations of averaging neighbors,
@@ -1044,8 +1044,8 @@ bool BKE_gpencil_stroke_smooth_point(bGPDstroke *gps,
                   0.0;
   double total_w = 0.0;
   for (int step = iterations; step > 0; step--) {
-    int before = i - step;
-    int after = i + step;
+    int before = point_index - step;
+    int after = point_index + step;
     float w_before = (float)(w - w2);
     float w_after = (float)(w - w2);
 
@@ -1056,13 +1056,13 @@ bool BKE_gpencil_stroke_smooth_point(bGPDstroke *gps,
     else {
       if (before < 0) {
         if (!smooth_caps) {
-          w_before *= -before / (float)i;
+          w_before *= -before / (float)point_index;
         }
         before = 0;
       }
       if (after > gps->totpoints - 1) {
         if (!smooth_caps) {
-          w_after *= (after - (gps->totpoints - 1)) / (float)(gps->totpoints - 1 - i);
+          w_after *= (after - (gps->totpoints - 1)) / (float)(gps->totpoints - 1 - point_index);
         }
         after = gps->totpoints - 1;
       }
@@ -1089,7 +1089,7 @@ bool BKE_gpencil_stroke_smooth_point(bGPDstroke *gps,
   add_v3_v3(sco, &pt->x);
 
   /* Based on influence factor, blend between original and optimal smoothed coordinate. */
-  interp_v3_v3v3(&r_gps->points[i].x, &pt->x, sco, influence);
+  interp_v3_v3v3(&r_gps->points[point_index].x, &pt->x, sco, influence);
 
   return true;
 }
@@ -1101,7 +1101,7 @@ bool BKE_gpencil_stroke_smooth_point(bGPDstroke *gps,
  * \{ */
 
 bool BKE_gpencil_stroke_smooth_strength(
-    bGPDstroke *gps, int i, float influence, int iterations, bGPDstroke *r_gps)
+    bGPDstroke *gps, int point_index, float influence, int iterations, bGPDstroke *r_gps)
 {
   /* If nothing to do, return early */
   if (gps->totpoints <= 2 || iterations <= 0) {
@@ -1110,15 +1110,15 @@ bool BKE_gpencil_stroke_smooth_strength(
 
   /* See BKE_gpencil_stroke_smooth_point for details on the algorithm. */
 
-  const bGPDspoint *pt = &gps->points[i];
+  const bGPDspoint *pt = &gps->points[point_index];
   const bool is_cyclic = (gps->flag & GP_STROKE_CYCLIC) != 0;
   float strength = 0.0f;
   const int n_half = (iterations * iterations) / 4 + iterations;
   double w = 1.0;
   double total_w = 0.0;
   for (int step = iterations; step > 0; step--) {
-    int before = i - step;
-    int after = i + step;
+    int before = point_index - step;
+    int after = point_index + step;
     float w_before = (float)w;
     float w_after = (float)w;
 
@@ -1147,7 +1147,7 @@ bool BKE_gpencil_stroke_smooth_strength(
   strength /= total_w;
 
   /* Based on influence factor, blend between original and optimal smoothed value. */
-  r_gps->points[i].strength = pt->strength + strength * influence;
+  r_gps->points[point_index].strength = pt->strength + strength * influence;
 
   return true;
 }
@@ -1159,7 +1159,7 @@ bool BKE_gpencil_stroke_smooth_strength(
  * \{ */
 
 bool BKE_gpencil_stroke_smooth_thickness(
-    bGPDstroke *gps, int i, float influence, int iterations, bGPDstroke *r_gps)
+    bGPDstroke *gps, int point_index, float influence, int iterations, bGPDstroke *r_gps)
 {
   /* If nothing to do, return early */
   if (gps->totpoints <= 2 || iterations <= 0) {
@@ -1168,15 +1168,15 @@ bool BKE_gpencil_stroke_smooth_thickness(
 
   /* See BKE_gpencil_stroke_smooth_point for details on the algorithm. */
 
-  const bGPDspoint *pt = &gps->points[i];
+  const bGPDspoint *pt = &gps->points[point_index];
   const bool is_cyclic = (gps->flag & GP_STROKE_CYCLIC) != 0;
   float pressure = 0.0f;
   const int n_half = (iterations * iterations) / 4 + iterations;
   double w = 1.0;
   double total_w = 0.0;
   for (int step = iterations; step > 0; step--) {
-    int before = i - step;
-    int after = i + step;
+    int before = point_index - step;
+    int after = point_index + step;
     float w_before = (float)w;
     float w_after = (float)w;
 
@@ -1205,7 +1205,7 @@ bool BKE_gpencil_stroke_smooth_thickness(
   pressure /= total_w;
 
   /* Based on influence factor, blend between original and optimal smoothed value. */
-  r_gps->points[i].pressure = pt->pressure + pressure * influence;
+  r_gps->points[point_index].pressure = pt->pressure + pressure * influence;
 
   return true;
 }
@@ -1216,8 +1216,11 @@ bool BKE_gpencil_stroke_smooth_thickness(
 /** \name Stroke Smooth UV
  * \{ */
 
-bool BKE_gpencil_stroke_smooth_uv(
-    struct bGPDstroke *gps, int i, float influence, int iterations, struct bGPDstroke *r_gps)
+bool BKE_gpencil_stroke_smooth_uv(struct bGPDstroke *gps,
+                                  int point_index,
+                                  float influence,
+                                  int iterations,
+                                  struct bGPDstroke *r_gps)
 {
   /* If nothing to do, return early */
   if (gps->totpoints <= 2 || iterations <= 0) {
@@ -1226,13 +1229,13 @@ bool BKE_gpencil_stroke_smooth_uv(
 
   /* See BKE_gpencil_stroke_smooth_point for details on the algorithm. */
 
-  const bGPDspoint *pt = &gps->points[i];
+  const bGPDspoint *pt = &gps->points[point_index];
   const bool is_cyclic = (gps->flag & GP_STROKE_CYCLIC) != 0;
 
   /* If don't change the caps. */
-  if (!is_cyclic && ELEM(i, 0, gps->totpoints - 1)) {
-    r_gps->points[i].uv_rot = pt->uv_rot;
-    r_gps->points[i].uv_fac = pt->uv_fac;
+  if (!is_cyclic && ELEM(point_index, 0, gps->totpoints - 1)) {
+    r_gps->points[point_index].uv_rot = pt->uv_rot;
+    r_gps->points[point_index].uv_fac = pt->uv_fac;
     return true;
   }
 
@@ -1242,8 +1245,8 @@ bool BKE_gpencil_stroke_smooth_uv(
   double w = 1.0;
   double total_w = 0.0;
   for (int step = iterations; step > 0; step--) {
-    int before = i - step;
-    int after = i + step;
+    int before = point_index - step;
+    int after = point_index + step;
     float w_before = (float)w;
     float w_after = (float)w;
 
@@ -1253,11 +1256,11 @@ bool BKE_gpencil_stroke_smooth_uv(
     }
     else {
       if (before < 0) {
-        w_before *= -before / (float)i;
+        w_before *= -before / (float)point_index;
         before = 0;
       }
       if (after > gps->totpoints - 1) {
-        w_after *= (after - (gps->totpoints - 1)) / (float)(gps->totpoints - 1 - i);
+        w_after *= (after - (gps->totpoints - 1)) / (float)(gps->totpoints - 1 - point_index);
         after = gps->totpoints - 1;
       }
     }
@@ -1281,8 +1284,8 @@ bool BKE_gpencil_stroke_smooth_uv(
   uv_fac /= total_w;
 
   /* Based on influence factor, blend between original and optimal smoothed value. */
-  r_gps->points[i].uv_rot = pt->uv_rot + uv_rot * influence;
-  r_gps->points[i].uv_fac = pt->uv_fac + uv_fac * influence;
+  r_gps->points[point_index].uv_rot = pt->uv_rot + uv_rot * influence;
+  r_gps->points[point_index].uv_fac = pt->uv_fac + uv_fac * influence;
 
   return true;
 }
diff --git a/source/blender/draw/engines/eevee/eevee_shaders_extra.cc b/source/blender/draw/engines/eevee/eevee_shaders_extra.cc
index 1d3e07217b5..bb1a0b0abe4 100644
--- a/source/blender/draw/engines/eev

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list