[Bf-blender-cvs] [ec8118a59e0] master: Cleanup: replace UNUSED() with commented arguments

Campbell Barton noreply at git.blender.org
Thu Sep 29 02:26:31 CEST 2022


Commit: ec8118a59e02260945050febf8b7c0080e8c1c4e
Author: Campbell Barton
Date:   Thu Sep 29 10:25:01 2022 +1000
Branches: master
https://developer.blender.org/rBec8118a59e02260945050febf8b7c0080e8c1c4e

Cleanup: replace UNUSED() with commented arguments

This is the conventional way of dealing with unused arguments in C++.

Also quiet enum conversion warnings.

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

M	source/blender/blenkernel/intern/pbvh.c
M	source/blender/draw/intern/draw_manager_data.c
M	source/blender/draw/intern/draw_pbvh.cc
M	source/blender/editors/sculpt_paint/sculpt_ops.c

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

diff --git a/source/blender/blenkernel/intern/pbvh.c b/source/blender/blenkernel/intern/pbvh.c
index a1de8e40fe3..5061fecbccb 100644
--- a/source/blender/blenkernel/intern/pbvh.c
+++ b/source/blender/blenkernel/intern/pbvh.c
@@ -1366,7 +1366,7 @@ static void pbvh_update_draw_buffer_cb(void *__restrict userdata,
   }
 }
 
-void pbvh_free_draw_buffers(PBVH *pbvh, PBVHNode *node)
+void pbvh_free_draw_buffers(PBVH *UNUSED(pbvh), PBVHNode *node)
 {
   if (node->draw_batches) {
     DRW_pbvh_node_free(node->draw_batches);
diff --git a/source/blender/draw/intern/draw_manager_data.c b/source/blender/draw/intern/draw_manager_data.c
index 060617764f7..eb05e03402c 100644
--- a/source/blender/draw/intern/draw_manager_data.c
+++ b/source/blender/draw/intern/draw_manager_data.c
@@ -1349,15 +1349,16 @@ void DRW_shgroup_call_sculpt(DRWShadingGroup *shgroup,
 
   memset(attrs, 0, sizeof(attrs));
 
-  attrs[attrs_num++].type = CD_PBVH_CO_TYPE;
-  attrs[attrs_num++].type = CD_PBVH_NO_TYPE;
+  /* NOTE: these are NOT #eCustomDataType, they are extended values, ASAN may warn about this. */
+  attrs[attrs_num++].type = (eCustomDataType)CD_PBVH_CO_TYPE;
+  attrs[attrs_num++].type = (eCustomDataType)CD_PBVH_NO_TYPE;
 
   if (use_mask) {
-    attrs[attrs_num++].type = CD_PBVH_MASK_TYPE;
+    attrs[attrs_num++].type = (eCustomDataType)CD_PBVH_MASK_TYPE;
   }
 
   if (use_fset) {
-    attrs[attrs_num++].type = CD_PBVH_FSET_TYPE;
+    attrs[attrs_num++].type = (eCustomDataType)CD_PBVH_FSET_TYPE;
   }
 
   Mesh *me = BKE_object_get_original_mesh(ob);
@@ -1421,8 +1422,9 @@ void DRW_shgroup_call_sculpt_with_materials(DRWShadingGroup **shgroups,
   memset(attrs, 0, sizeof(PBVHAttrReq) * attrs_num);
   int attrs_i = 0;
 
-  attrs[attrs_i++].type = CD_PBVH_CO_TYPE;
-  attrs[attrs_i++].type = CD_PBVH_NO_TYPE;
+  /* NOTE: these are NOT #eCustomDataType, they are extended values, ASAN may warn about this. */
+  attrs[attrs_i++].type = (eCustomDataType)CD_PBVH_CO_TYPE;
+  attrs[attrs_i++].type = (eCustomDataType)CD_PBVH_NO_TYPE;
 
   for (int i = 0; i < draw_attrs.num_requests; i++) {
     DRW_AttributeRequest *req = draw_attrs.requests + i;
diff --git a/source/blender/draw/intern/draw_pbvh.cc b/source/blender/draw/intern/draw_pbvh.cc
index 2e92598a955..94965c25950 100644
--- a/source/blender/draw/intern/draw_pbvh.cc
+++ b/source/blender/draw/intern/draw_pbvh.cc
@@ -289,8 +289,10 @@ struct PBVHBatches {
   }
 
   void fill_vbo_normal_faces(
+      PBVHVbo & /*vbo*/,
       PBVH_GPU_Args *args,
-      std::function<void(std::function<void(int, int, const MLoopTri *)> callback)> foreach_faces,
+      std::function<void(std::function<void(int, int, int, const MLoopTri *)> callback)>
+          foreach_faces,
       GPUVertBufRaw *access)
   {
     float fno[3];
@@ -298,7 +300,7 @@ struct PBVHBatches {
     int last_poly = -1;
     bool smooth = false;
 
-    foreach_faces([&](int UNUSED(tri_i), int vertex_i, const MLoopTri *tri) {
+    foreach_faces([&](int /*buffer_i*/, int /*tri_i*/, int vertex_i, const MLoopTri *tri) {
       const MPoly *mp = args->mpoly + tri->poly;
 
       if (tri->poly != last_poly) {
@@ -335,7 +337,7 @@ struct PBVHBatches {
     int existing_num = GPU_vertbuf_get_vertex_len(vbo.vert_buf);
     void *existing_data = GPU_vertbuf_get_data(vbo.vert_buf);
 
-    if (existing_data == NULL || existing_num != vert_count) {
+    if (existing_data == nullptr || existing_num != vert_count) {
       /* Allocate buffer if not allocated yet or size changed. */
       GPU_vertbuf_data_alloc(vbo.vert_buf, vert_count);
     }
@@ -345,48 +347,44 @@ struct PBVHBatches {
 
     switch (vbo.type) {
       case CD_PBVH_CO_TYPE:
-        foreach_grids(
-            [&](int UNUSED(x), int UNUSED(y), int UNUSED(grid_index), CCGElem *elems[4], int i) {
-              float *co = CCG_elem_co(&args->ccg_key, elems[i]);
+        foreach_grids([&](int /*x*/, int /*y*/, int /*grid_index*/, CCGElem *elems[4], int i) {
+          float *co = CCG_elem_co(&args->ccg_key, elems[i]);
 
-              *static_cast<float3 *>(GPU_vertbuf_raw_step(&access)) = co;
-            });
+          *static_cast<float3 *>(GPU_vertbuf_raw_step(&access)) = co;
+        });
         break;
 
       case CD_PBVH_NO_TYPE:
-        foreach_grids(
-            [&](int UNUSED(x), int UNUSED(y), int grid_index, CCGElem *elems[4], int UNUSED(i)) {
-              float3 no(0.0f, 0.0f, 0.0f);
+        foreach_grids([&](int /*x*/, int /*y*/, int grid_index, CCGElem *elems[4], int /*i*/) {
+          float3 no(0.0f, 0.0f, 0.0f);
 
-              const bool smooth = args->grid_flag_mats[grid_index].flag & ME_SMOOTH;
+          const bool smooth = args->grid_flag_mats[grid_index].flag & ME_SMOOTH;
 
-              if (smooth) {
-                no = CCG_elem_no(&args->ccg_key, elems[0]);
-              }
-              else {
-                for (int j = 0; j < 4; j++) {
-                  no += CCG_elem_no(&args->ccg_key, elems[j]);
-                }
-              }
+          if (smooth) {
+            no = CCG_elem_no(&args->ccg_key, elems[0]);
+          }
+          else {
+            for (int j = 0; j < 4; j++) {
+              no += CCG_elem_no(&args->ccg_key, elems[j]);
+            }
+          }
 
-              normalize_v3(no);
-              short sno[3];
+          normalize_v3(no);
+          short sno[3];
 
-              normal_float_to_short_v3(sno, no);
+          normal_float_to_short_v3(sno, no);
 
-              *static_cast<short3 *>(GPU_vertbuf_raw_step(&access)) = sno;
-            });
+          *static_cast<short3 *>(GPU_vertbuf_raw_step(&access)) = sno;
+        });
         break;
 
       case CD_PBVH_MASK_TYPE:
-        foreach_grids(
-            [&](int UNUSED(x), int UNUSED(y), int UNUSED(grid_index), CCGElem *elems[4], int i) {
-              float *mask = CCG_elem_mask(&args->ccg_key, elems[i]);
+        foreach_grids([&](int /*x*/, int /*y*/, int /*grid_index*/, CCGElem *elems[4], int i) {
+          float *mask = CCG_elem_mask(&args->ccg_key, elems[i]);
 
-              *static_cast<uchar *>(GPU_vertbuf_raw_step(&access)) = mask ?
-                                                                         (uchar)(*mask * 255.0f) :
-                                                                         255;
-            });
+          *static_cast<uchar *>(GPU_vertbuf_raw_step(&access)) = mask ? (uchar)(*mask * 255.0f) :
+                                                                        255;
+        });
         break;
 
       case CD_PBVH_FSET_TYPE: {
@@ -395,36 +393,30 @@ struct PBVHBatches {
         if (!face_sets) {
           uchar white[3] = {UCHAR_MAX, UCHAR_MAX, UCHAR_MAX};
 
-          foreach_grids([&](int UNUSED(x),
-                            int UNUSED(y),
-                            int UNUSED(grid_index),
-                            CCGElem *UNUSED(elems)[4],
-                            int UNUSED(i)) {
-            *static_cast<uchar4 *>(GPU_vertbuf_raw_step(&access)) = white;
-          });
+          foreach_grids(
+              [&](int /*x*/, int /*y*/, int /*grid_index*/, CCGElem * /*elems*/[4], int /*i*/) {
+                *static_cast<uchar4 *>(GPU_vertbuf_raw_step(&access)) = white;
+              });
         }
         else {
-          foreach_grids([&](int UNUSED(x),
-                            int UNUSED(y),
-                            int grid_index,
-                            CCGElem *UNUSED(elems)[4],
-                            int UNUSED(i)) {
-            uchar face_set_color[3] = {UCHAR_MAX, UCHAR_MAX, UCHAR_MAX};
-
-            if (face_sets) {
-              const int face_index = BKE_subdiv_ccg_grid_to_face_index(args->subdiv_ccg,
-                                                                       grid_index);
-              const int fset = face_sets[face_index];
-
-              /* Skip for the default color Face Set to render it white. */
-              if (fset != args->face_sets_color_default) {
-                BKE_paint_face_set_overlay_color_get(
-                    fset, args->face_sets_color_seed, face_set_color);
-              }
-            }
+          foreach_grids(
+              [&](int /*x*/, int /*y*/, int grid_index, CCGElem * /*elems*/[4], int /*i*/) {
+                uchar face_set_color[3] = {UCHAR_MAX, UCHAR_MAX, UCHAR_MAX};
+
+                if (face_sets) {
+                  const int face_index = BKE_subdiv_ccg_grid_to_face_index(args->subdiv_ccg,
+                                                                           grid_index);
+                  const int fset = face_sets[face_index];
+
+                  /* Skip for the default color Face Set to render it white. */
+                  if (fset != args->face_sets_color_default) {
+                    BKE_paint_face_set_overlay_color_get(
+                        fset, args->face_sets_color_seed, face_set_color);
+                  }
+                }
 
-            *static_cast<uchar3 *>(GPU_vertbuf_raw_step(&access)) = face_set_color;
-          });
+                *static_cast<uchar3 *>(GPU_vertbuf_raw_step(&access)) = face_set_color;
+              });
         }
         break;
       }
@@ -497,7 +489,7 @@ struct PBVHBatches {
     int totvert = args->totprim * 3;
 
     auto foreach_faces =
-        [&](std::function<void(int tri_i, int vertex_i, const MLoopTri *tri)> func) {
+        [&](std::function<void(int buffer_i, int tri_i, int vertex_i, const MLoopTri *tri)> func) {
           int buffer_i = 0;
           const MLoop *mloop = args->mloop;
 
@@ -511,7 +503,7 @@ struct PBVHBatches {
             const MLoopTri *tri = args->mlooptri + args->prim_indices[i];
 
             for (int j : IndexRange(3)) {
-              func(j, mloop[tri->tri[j]].v, tri);
+              func(buffer_i, j, mloop[tri->tri[j]].v, tri);
               buffer_i++;
             }
           }
@@ -520,7 +512,7 @@ struct PBVHBatches {
     int existing_num = GPU_vertbuf_get_vertex_len(vbo.vert_buf);
     void *existing_data = GPU_vertbuf_get_data(vbo.vert_buf);
 
-    if (existing_data == NULL || existing_num != totvert) {
+    if (existing_data == nullptr || existing_num != totvert) {
       /* Allocate buffer if not allocated yet or size changed. */
 

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list