[Bf-blender-cvs] [548a2cbe06b] master: Cleanup: Clang tidy

Hans Goudey noreply at git.blender.org
Wed Oct 5 20:51:55 CEST 2022


Commit: 548a2cbe06b23d90b0e09da49fc854178c270b8a
Author: Hans Goudey
Date:   Wed Oct 5 13:44:02 2022 -0500
Branches: master
https://developer.blender.org/rB548a2cbe06b23d90b0e09da49fc854178c270b8a

Cleanup: Clang tidy

Also remove unnecessary struct keywords in C++ files.

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

M	source/blender/blenkernel/BKE_idprop.hh
M	source/blender/blenkernel/BKE_mball.h
M	source/blender/blenkernel/intern/editmesh_tangent.cc
M	source/blender/blenkernel/intern/geometry_fields.cc
M	source/blender/blenkernel/intern/mball_tessellate.cc
M	source/blender/blenkernel/intern/mesh_mapping.cc
M	source/blender/blenkernel/intern/mesh_tangent.cc
M	source/blender/blenkernel/intern/modifier.cc
M	source/blender/blenkernel/intern/node.cc
M	source/blender/blenkernel/intern/outliner_treehash.cc
M	source/blender/blenkernel/intern/paint.cc
M	source/blender/blenkernel/intern/subdiv_mesh.cc
M	source/blender/blenkernel/intern/viewer_path.cc
M	source/blender/blenkernel/intern/workspace.cc
M	source/blender/blenloader/intern/blend_validate.cc
M	source/blender/blenloader/intern/readblenentry.cc
M	source/blender/blenloader/intern/readfile.cc
M	source/blender/blenloader/intern/versioning_300.cc
M	source/blender/blenloader/intern/versioning_common.cc
M	source/blender/blenloader/intern/writefile.cc
M	source/blender/draw/engines/eevee_next/eevee_engine.cc
M	source/blender/draw/engines/overlay/overlay_antialiasing.cc
M	source/blender/draw/engines/overlay/overlay_armature.cc
M	source/blender/draw/engines/overlay/overlay_edit_uv.cc
M	source/blender/draw/engines/overlay/overlay_engine.cc
M	source/blender/draw/engines/overlay/overlay_extra.cc
M	source/blender/draw/intern/draw_cache_impl_pointcloud.cc
M	source/blender/draw/intern/draw_manager_data.cc
M	source/blender/draw/intern/draw_pbvh.cc
M	source/blender/editors/gpencil/gpencil_bake_animation.cc
M	source/blender/editors/include/ED_uvedit.h
M	source/blender/editors/interface/interface_ops.cc
M	source/blender/editors/mesh/editmesh_select.cc
M	source/blender/editors/mesh/mesh_data.cc
M	source/blender/editors/sculpt_paint/sculpt.c
M	source/blender/editors/sculpt_paint/sculpt_automasking.cc
M	source/blender/editors/sculpt_paint/sculpt_face_set.cc
M	source/blender/editors/sculpt_paint/sculpt_intern.h
M	source/blender/editors/space_file/filelist.cc
M	source/blender/editors/space_file/folder_history.cc
M	source/blender/editors/space_info/info_stats.cc
M	source/blender/editors/space_node/node_add.cc
M	source/blender/editors/space_node/node_group.cc
M	source/blender/editors/space_outliner/outliner_dragdrop.cc
M	source/blender/editors/space_spreadsheet/space_spreadsheet.cc
M	source/blender/editors/space_view3d/space_view3d.cc
M	source/blender/editors/space_view3d/view3d_draw.cc
M	source/blender/editors/uvedit/uvedit_islands.cc
M	source/blender/geometry/GEO_trim_curves.hh
M	source/blender/geometry/intern/trim_curves.cc
M	source/blender/modifiers/intern/MOD_normal_edit.cc
M	source/blender/modifiers/intern/MOD_subsurf.cc
M	source/blender/render/intern/pipeline.cc

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

diff --git a/source/blender/blenkernel/BKE_idprop.hh b/source/blender/blenkernel/BKE_idprop.hh
index e8ac4119970..ce11a56ad5f 100644
--- a/source/blender/blenkernel/BKE_idprop.hh
+++ b/source/blender/blenkernel/BKE_idprop.hh
@@ -46,7 +46,7 @@ std::unique_ptr<IDProperty, IDPropertyDeleter> create(StringRefNull prop_name,
                                                       const StringRefNull value);
 
 /** \brief Allocate a new IDProperty of type IDP_ID, set its name and value. */
-std::unique_ptr<IDProperty, IDPropertyDeleter> create(StringRefNull prop_name, ID *id);
+std::unique_ptr<IDProperty, IDPropertyDeleter> create(StringRefNull prop_name, ID *value);
 
 /**
  * \brief Allocate a new IDProperty of type IDP_ARRAY and sub-type IDP_INT.
diff --git a/source/blender/blenkernel/BKE_mball.h b/source/blender/blenkernel/BKE_mball.h
index 5ffaa13d9d2..beed524df4c 100644
--- a/source/blender/blenkernel/BKE_mball.h
+++ b/source/blender/blenkernel/BKE_mball.h
@@ -68,7 +68,7 @@ struct BoundBox *BKE_mball_boundbox_get(struct Object *ob);
  * `MBall`, `MBall.001`, `MBall.002`, etc). The most important is to copy properties to the base
  * meta-ball, because this meta-ball influences polygonization of meta-balls.
  */
-void BKE_mball_properties_copy(struct Main *bmain, struct MetaBall *active_metaball);
+void BKE_mball_properties_copy(struct Main *bmain, struct MetaBall *metaball_src);
 
 bool BKE_mball_minmax_ex(
     const struct MetaBall *mb, float min[3], float max[3], const float obmat[4][4], short flag);
diff --git a/source/blender/blenkernel/intern/editmesh_tangent.cc b/source/blender/blenkernel/intern/editmesh_tangent.cc
index 016cf6acbcc..12799afd2f7 100644
--- a/source/blender/blenkernel/intern/editmesh_tangent.cc
+++ b/source/blender/blenkernel/intern/editmesh_tangent.cc
@@ -94,12 +94,10 @@ struct SGLSLEditMeshToTangent {
       const float *uv = (const float *)BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset);
       return mikk::float3(uv[0], uv[1], 1.0f);
     }
-    else {
-      const float *orco_p = orco[BM_elem_index_get(l->v)];
-      float u, v;
-      map_to_sphere(&u, &v, orco_p[0], orco_p[1], orco_p[2]);
-      return mikk::float3(u, v, 1.0f);
-    }
+    const float *orco_p = orco[BM_elem_index_get(l->v)];
+    float u, v;
+    map_to_sphere(&u, &v, orco_p[0], orco_p[1], orco_p[2]);
+    return mikk::float3(u, v, 1.0f);
   }
 
   mikk::float3 GetNormal(const uint face_num, const uint vert_index)
@@ -108,17 +106,13 @@ struct SGLSLEditMeshToTangent {
     if (precomputedLoopNormals) {
       return mikk::float3(precomputedLoopNormals[BM_elem_index_get(l)]);
     }
-    else if (BM_elem_flag_test(l->f, BM_ELEM_SMOOTH) == 0) { /* flat */
+    if (BM_elem_flag_test(l->f, BM_ELEM_SMOOTH) == 0) { /* flat */
       if (precomputedFaceNormals) {
         return mikk::float3(precomputedFaceNormals[BM_elem_index_get(l->f)]);
       }
-      else {
-        return mikk::float3(l->f->no);
-      }
-    }
-    else {
-      return mikk::float3(l->v->no);
+      return mikk::float3(l->f->no);
     }
+    return mikk::float3(l->v->no);
   }
 
   void SetTangentSpace(const uint face_num,
diff --git a/source/blender/blenkernel/intern/geometry_fields.cc b/source/blender/blenkernel/intern/geometry_fields.cc
index 00913905c1c..b492af4af77 100644
--- a/source/blender/blenkernel/intern/geometry_fields.cc
+++ b/source/blender/blenkernel/intern/geometry_fields.cc
@@ -490,12 +490,13 @@ std::optional<eAttrDomain> try_detect_field_domain(const GeometryComponent &comp
       return std::nullopt;
     }
     for (const fn::FieldInput &field_input : field_inputs->deduplicated_nodes) {
-      if (auto geometry_field_input = dynamic_cast<const GeometryFieldInput *>(&field_input)) {
+      if (const auto *geometry_field_input = dynamic_cast<const GeometryFieldInput *>(
+              &field_input)) {
         if (!handle_domain(geometry_field_input->preferred_domain(component))) {
           return std::nullopt;
         }
       }
-      else if (auto mesh_field_input = dynamic_cast<const MeshFieldInput *>(&field_input)) {
+      else if (const auto *mesh_field_input = dynamic_cast<const MeshFieldInput *>(&field_input)) {
         if (!handle_domain(mesh_field_input->preferred_domain(*mesh))) {
           return std::nullopt;
         }
@@ -512,12 +513,14 @@ std::optional<eAttrDomain> try_detect_field_domain(const GeometryComponent &comp
       return std::nullopt;
     }
     for (const fn::FieldInput &field_input : field_inputs->deduplicated_nodes) {
-      if (auto geometry_field_input = dynamic_cast<const GeometryFieldInput *>(&field_input)) {
+      if (const auto *geometry_field_input = dynamic_cast<const GeometryFieldInput *>(
+              &field_input)) {
         if (!handle_domain(geometry_field_input->preferred_domain(component))) {
           return std::nullopt;
         }
       }
-      else if (auto curves_field_input = dynamic_cast<const CurvesFieldInput *>(&field_input)) {
+      else if (const auto *curves_field_input = dynamic_cast<const CurvesFieldInput *>(
+                   &field_input)) {
         if (!handle_domain(
                 curves_field_input->preferred_domain(CurvesGeometry::wrap(curves->geometry)))) {
           return std::nullopt;
diff --git a/source/blender/blenkernel/intern/mball_tessellate.cc b/source/blender/blenkernel/intern/mball_tessellate.cc
index 9b32456c6c1..5e8d2bc6d76 100644
--- a/source/blender/blenkernel/intern/mball_tessellate.cc
+++ b/source/blender/blenkernel/intern/mball_tessellate.cc
@@ -5,12 +5,12 @@
  * \ingroup bke
  */
 
-#include <ctype.h>
-#include <float.h>
-#include <math.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
+#include <cctype>
+#include <cfloat>
+#include <cmath>
+#include <cstdio>
+#include <cstdlib>
+#include <cstring>
 
 #include "MEM_guardedalloc.h"
 
@@ -169,7 +169,7 @@ static uint partition_mainb(MetaElem **mainb, uint start, uint end, uint s, floa
   uint i = start, j = end - 1;
   div *= 2.0f;
 
-  while (1) {
+  while (true) {
     while (i < j && div > (mainb[i]->bb->vec[6][s] + mainb[i]->bb->vec[0][s])) {
       i++;
     }
@@ -222,7 +222,7 @@ static void build_bvh_spatial(
   part = partition_mainb(process->mainb, start, end, s, div);
 
   make_box_from_metaelem(&node->bb[0], process->mainb[start]);
-  node->child[0] = NULL;
+  node->child[0] = nullptr;
 
   if (part > start + 1) {
     for (j = start; j < part; j++) {
@@ -234,7 +234,7 @@ static void build_bvh_spatial(
     build_bvh_spatial(process, node->child[0], start, part, &node->bb[0]);
   }
 
-  node->child[1] = NULL;
+  node->child[1] = nullptr;
   if (part < end) {
     make_box_from_metaelem(&node->bb[1], process->mainb[part]);
 
@@ -461,12 +461,12 @@ static void make_face(PROCESS *process, int i1, int i2, int i3, int i4)
     accumulate_vertex_normals_v3(process->no[i1],
                                  process->no[i2],
                                  process->no[i3],
-                                 NULL,
+                                 nullptr,
                                  n,
                                  process->co[i1],
                                  process->co[i2],
                                  process->co[i3],
-                                 NULL);
+                                 nullptr);
   }
   else {
     normal_quad_v3(n, process->co[i1], process->co[i2], process->co[i3], process->co[i4]);
@@ -677,7 +677,7 @@ static CORNER *setcorner(PROCESS *process, int i, int j, int k)
   index = HASH(i, j, k);
   c = process->corners[index];
 
-  for (; c != NULL; c = c->next) {
+  for (; c != nullptr; c = c->next) {
     if (c->i == i && c->j == j && c->k == k) {
       return c;
     }
@@ -746,7 +746,7 @@ static int otherface(int edge, int face)
 /**
  * create the 256 entry table for cubical polygonization
  */
-static void makecubetable(void)
+static void makecubetable()
 {
   static bool is_done = false;
   int i, e, c, done[12], pos[8];
@@ -765,14 +765,14 @@ static void makecubetable(void)
     }
     for (e = 0; e < 12; e++) {
       if (!done[e] && (pos[corner1[e]] != pos[corner2[e]])) {
-        INTLIST *ints = NULL;
+        INTLIST *ints = nullptr;
         INTLISTS *lists = static_cast<INTLISTS *>(MEM_callocN(sizeof(INTLISTS), "mball_intlist"));
         int start = e, edge = e;
 
         /* get face that is to right of edge from pos to neg corner: */
         int face = pos[corner1[e]] ? rightface[e] : leftface[e];
 
-        while (1) {
+        while (true) {
           edge = nextcwedge(edge, face);
           done[edge] = 1;
           if (pos[corner1[edge]] != pos[corner2[edge]]) {
@@ -842,7 +842,7 @@ void BKE_mball_cubeTable_free(void)
       MEM_freeN(lists);
       lists = nlists;
     }
-    cubetable[i] = NULL;
+    cubetable[i] = nullptr;
   }
 }
 
@@ -859,7 +859,7 @@ static int setcenter(PROCESS *process, CENTERLIST *table[], const int i, const i
   index = HASH(i, j, k);
   q = table[index];
 
-  for (l = q; l != NULL; l = l->next) {
+  for (l = q; l != nullptr; l = l->next) {
     if (l->i == i && l->j == j && l->k == k) {
       return 1;
     }
@@ -927,7 +927,7 @@ static int getedge(EDGELIST *table[], int i1, int j1, int k1, int i2, int j2, in
     k2 = t;
   }
   q = table[HASH(i1, j1, k1) + HASH(i2, j2, k2)];
-  for (; q != NULL; q = q->next) {
+  for (; q != nullptr; q = q->next) {
     if (q->i1 == i1 && q->j1 == j1 && q->k1 == k1 && q->i2 == i2 && q->j2 == j2 && q->k2 == k2) {
       return q->vid;
     }
@@ -1160,7 +1160,7 @@ static void polygonize(PROCESS *process)
     find_first_points(process, i);
   }
 
-  while (process->cubes != NULL) {
+  while (process->cubes != nullptr) {
     c = process->cubes->cube;
     process->cubes = process->cubes->next;
 
@@ -1194,15 +1194,15 @@ static void init_meta(Depsgraph *depsgraph, PROCESS *process, Scene *scene, Obje
   BLI_split_name_num(obname, &obnr, ob->id.name + 2, '.');
 
   /* make main array */
-  BKE_scene_base_iter_next(depsgraph, &iter, &sce_iter, 0, NULL, NULL);
+  BKE_scene_base_iter_next(depsgraph, &iter, &sce_iter, 0, nullptr, nullptr);
   while (BKE_scene_base_iter_next(depsgraph, &iter, &sce_iter, 1, &base, &bob)) {
     if (bob->type == OB_MBALL) {
       zero_size = 0;
-      

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list