[Bf-blender-cvs] [8367f2bffc5] master: Cleanup: function style casts for C++

Campbell Barton noreply at git.blender.org
Wed Jan 11 03:06:46 CET 2023


Commit: 8367f2bffc58a8f591ed2e6d67f6dd625dc5041c
Author: Campbell Barton
Date:   Wed Jan 11 13:03:53 2023 +1100
Branches: master
https://developer.blender.org/rB8367f2bffc58a8f591ed2e6d67f6dd625dc5041c

Cleanup: function style casts for C++

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

M	source/blender/blenkernel/intern/customdata.cc
M	source/blender/blenkernel/intern/modifier.cc
M	source/blender/blenkernel/intern/particle.cc
M	source/blender/blenlib/intern/math_boolean.cc
M	source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_edituv_stretch_angle.cc
M	source/blender/editors/mesh/editmesh_select.cc
M	source/blender/editors/mesh/editmesh_undo.cc
M	source/blender/editors/render/render_shading.cc
M	source/blender/editors/space_file/filesel.cc
M	source/blender/render/intern/multires_bake.cc

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

diff --git a/source/blender/blenkernel/intern/customdata.cc b/source/blender/blenkernel/intern/customdata.cc
index 433c4355d97..1d970d35148 100644
--- a/source/blender/blenkernel/intern/customdata.cc
+++ b/source/blender/blenkernel/intern/customdata.cc
@@ -5249,7 +5249,7 @@ void CustomData_debug_info_from_layers(const CustomData *data, const char *inden
       const char *name = CustomData_layertype_name(type);
       const int size = CustomData_sizeof(type);
       const void *pt = CustomData_get_layer(data, type);
-      const int pt_size = pt ? (int)(MEM_allocN_len(pt) / size) : 0;
+      const int pt_size = pt ? int(MEM_allocN_len(pt) / size) : 0;
       const char *structname;
       int structnum;
       CustomData_file_write_info(type, &structname, &structnum);
diff --git a/source/blender/blenkernel/intern/modifier.cc b/source/blender/blenkernel/intern/modifier.cc
index 50c9c13a9ac..508c1fe2331 100644
--- a/source/blender/blenkernel/intern/modifier.cc
+++ b/source/blender/blenkernel/intern/modifier.cc
@@ -349,7 +349,7 @@ void BKE_modifier_copydata_generic(const ModifierData *md_src,
   const size_t data_size = sizeof(ModifierData);
   const char *md_src_data = ((const char *)md_src) + data_size;
   char *md_dst_data = ((char *)md_dst) + data_size;
-  BLI_assert(data_size <= (size_t)mti->structSize);
+  BLI_assert(data_size <= size_t(mti->structSize));
   memcpy(md_dst_data, md_src_data, size_t(mti->structSize) - data_size);
 
   /* Runtime fields are never to be preserved. */
diff --git a/source/blender/blenkernel/intern/particle.cc b/source/blender/blenkernel/intern/particle.cc
index 5e3b393ce6b..484cb343a97 100644
--- a/source/blender/blenkernel/intern/particle.cc
+++ b/source/blender/blenkernel/intern/particle.cc
@@ -521,8 +521,8 @@ void BKE_particle_init_rng(void)
   RNG *rng = BLI_rng_new_srandom(5831); /* arbitrary */
   for (int i = 0; i < PSYS_FRAND_COUNT; i++) {
     PSYS_FRAND_BASE[i] = BLI_rng_get_float(rng);
-    PSYS_FRAND_SEED_OFFSET[i] = (uint)BLI_rng_get_int(rng);
-    PSYS_FRAND_SEED_MULTIPLIER[i] = (uint)BLI_rng_get_int(rng);
+    PSYS_FRAND_SEED_OFFSET[i] = uint(BLI_rng_get_int(rng));
+    PSYS_FRAND_SEED_MULTIPLIER[i] = uint(BLI_rng_get_int(rng));
   }
   BLI_rng_free(rng);
 }
diff --git a/source/blender/blenlib/intern/math_boolean.cc b/source/blender/blenlib/intern/math_boolean.cc
index 977b4ca5365..689c23ce092 100644
--- a/source/blender/blenlib/intern/math_boolean.cc
+++ b/source/blender/blenlib/intern/math_boolean.cc
@@ -201,7 +201,7 @@ static RobustInitCaller init_caller;
   y = bvirt - b
 
 #define Fast_Two_Diff(a, b, x, y) \
-  x = (double)(a - b); \
+  x = double(a - b); \
   Fast_Two_Diff_Tail(a, b, x, y)
 
 #define Two_Sum_Tail(a, b, x, y) \
@@ -253,7 +253,7 @@ static RobustInitCaller init_caller;
   y = (alo * blo) - err3
 
 #define Two_Product_2Presplit(a, ahi, alo, b, bhi, blo, x, y) \
-  x = (double)(a * b); \
+  x = double(a * b); \
   err1 = x - (ahi * bhi); \
   err2 = err1 - (alo * bhi); \
   err3 = err2 - (ahi * blo); \
diff --git a/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_edituv_stretch_angle.cc b/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_edituv_stretch_angle.cc
index a7b0331769c..b295a314883 100644
--- a/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_edituv_stretch_angle.cc
+++ b/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_edituv_stretch_angle.cc
@@ -70,7 +70,7 @@ static void edituv_get_edituv_stretch_angle(float auv[2][2],
 #if 0 /* here for reference, this is done in shader now. */
   float uvang = angle_normalized_v2v2(auv0, auv1);
   float ang = angle_normalized_v3v3(av0, av1);
-  float stretch = fabsf(uvang - ang) / (float)M_PI;
+  float stretch = fabsf(uvang - ang) / float(M_PI);
   return 1.0f - pow2f(1.0f - stretch);
 #endif
 }
diff --git a/source/blender/editors/mesh/editmesh_select.cc b/source/blender/editors/mesh/editmesh_select.cc
index 6955db63fe8..b911da376b4 100644
--- a/source/blender/editors/mesh/editmesh_select.cc
+++ b/source/blender/editors/mesh/editmesh_select.cc
@@ -266,8 +266,8 @@ BMVert *EDBM_vert_find_nearest_ex(ViewContext *vc,
   uint base_index = 0;
 
   if (!XRAY_FLAG_ENABLED(vc->v3d)) {
-    uint dist_px_manhattan_test = (uint)ED_view3d_backbuf_sample_size_clamp(vc->region,
-                                                                            *dist_px_manhattan_p);
+    uint dist_px_manhattan_test = uint(
+        ED_view3d_backbuf_sample_size_clamp(vc->region, *dist_px_manhattan_p));
     uint index;
     BMVert *eve;
 
@@ -492,8 +492,8 @@ BMEdge *EDBM_edge_find_nearest_ex(ViewContext *vc,
   uint base_index = 0;
 
   if (!XRAY_FLAG_ENABLED(vc->v3d)) {
-    uint dist_px_manhattan_test = (uint)ED_view3d_backbuf_sample_size_clamp(vc->region,
-                                                                            *dist_px_manhattan_p);
+    uint dist_px_manhattan_test = uint(
+        ED_view3d_backbuf_sample_size_clamp(vc->region, *dist_px_manhattan_p));
     uint index;
     BMEdge *eed;
 
@@ -713,8 +713,8 @@ BMFace *EDBM_face_find_nearest_ex(ViewContext *vc,
     {
       uint dist_px_manhattan_test = 0;
       if (*dist_px_manhattan_p != 0.0f && (use_zbuf_single_px == false)) {
-        dist_px_manhattan_test = (uint)ED_view3d_backbuf_sample_size_clamp(vc->region,
-                                                                           *dist_px_manhattan_p);
+        dist_px_manhattan_test = uint(
+            ED_view3d_backbuf_sample_size_clamp(vc->region, *dist_px_manhattan_p));
       }
 
       DRW_select_buffer_context_create(bases, bases_len, SCE_SELECT_FACE);
diff --git a/source/blender/editors/mesh/editmesh_undo.cc b/source/blender/editors/mesh/editmesh_undo.cc
index 5c837e61a79..565ce28a3c1 100644
--- a/source/blender/editors/mesh/editmesh_undo.cc
+++ b/source/blender/editors/mesh/editmesh_undo.cc
@@ -398,13 +398,13 @@ static void um_arraystore_compact_with_info(UndoMesh *um, const UndoMesh *um_ref
         &um_arraystore.bs_stride, &size_expanded, &size_compacted);
 
     const double percent_total = size_expanded ?
-                                     (((double)size_compacted / (double)size_expanded) * 100.0) :
+                                     ((double(size_compacted) / double(size_expanded)) * 100.0) :
                                      -1.0;
 
     size_t size_expanded_step = size_expanded - size_expanded_prev;
     size_t size_compacted_step = size_compacted - size_compacted_prev;
     const double percent_step = size_expanded_step ?
-                                    (((double)size_compacted_step / (double)size_expanded_step) *
+                                    ((double(size_compacted_step) / double(size_expanded_step)) *
                                      100.0) :
                                     -1.0;
 
diff --git a/source/blender/editors/render/render_shading.cc b/source/blender/editors/render/render_shading.cc
index e5c2b9702e5..c62483daf6b 100644
--- a/source/blender/editors/render/render_shading.cc
+++ b/source/blender/editors/render/render_shading.cc
@@ -2603,10 +2603,10 @@ static void copy_mtex_copybuf(ID *id)
 
   switch (GS(id->name)) {
     case ID_PA:
-      mtex = &(((ParticleSettings *)id)->mtex[(int)((ParticleSettings *)id)->texact]);
+      mtex = &(((ParticleSettings *)id)->mtex[int(((ParticleSettings *)id)->texact)]);
       break;
     case ID_LS:
-      mtex = &(((FreestyleLineStyle *)id)->mtex[(int)((FreestyleLineStyle *)id)->texact]);
+      mtex = &(((FreestyleLineStyle *)id)->mtex[int(((FreestyleLineStyle *)id)->texact)]);
       break;
     default:
       break;
@@ -2631,10 +2631,10 @@ static void paste_mtex_copybuf(ID *id)
 
   switch (GS(id->name)) {
     case ID_PA:
-      mtex = &(((ParticleSettings *)id)->mtex[(int)((ParticleSettings *)id)->texact]);
+      mtex = &(((ParticleSettings *)id)->mtex[int(((ParticleSettings *)id)->texact)]);
       break;
     case ID_LS:
-      mtex = &(((FreestyleLineStyle *)id)->mtex[(int)((FreestyleLineStyle *)id)->texact]);
+      mtex = &(((FreestyleLineStyle *)id)->mtex[int(((FreestyleLineStyle *)id)->texact)]);
       break;
     default:
       BLI_assert_msg(0, "invalid id type");
diff --git a/source/blender/editors/space_file/filesel.cc b/source/blender/editors/space_file/filesel.cc
index 446e5434edf..12d05054e9b 100644
--- a/source/blender/editors/space_file/filesel.cc
+++ b/source/blender/editors/space_file/filesel.cc
@@ -701,16 +701,16 @@ int ED_fileselect_layout_numfiles(FileLayout *layout, ARegion *region)
    */
   if (layout->flag & FILE_LAYOUT_HOR) {
     const int x_item = layout->tile_w + (2 * layout->tile_border_x);
-    const int x_view = (int)BLI_rctf_size_x(&region->v2d.cur);
+    const int x_view = int(BLI_rctf_size_x(&region->v2d.cur));
     const int x_over = x_item - (x_view % x_item);
-    numfiles = (int)((float)(x_view + x_over) / (float)(x_item));
+    numfiles = int(float(x_view + x_over) / float(x_item));
     return numfiles * layout->rows;
   }
 
   const int y_item = layout->tile_h + (2 * layout->tile_border_y);
-  const int y_view = (int)BLI_rctf_size_y(&region->v2d.cur) - layout->offset_top;
+  const int y_view = int(BLI_rctf_size_y(&region->v2d.cur)) - layout->offset_top;
   const int y_over = y_item - (y_view % y_item);
-  numfiles = (int)((float)(y_view + y_over) / (float)(y_item));
+  numfiles = int(float(y_view + y_over) / float(y_item));
   return numfiles * layout->flow_columns;
 }
 
@@ -871,7 +871,7 @@ FileAttributeColumnType file_attribute_column_type_find_isect(const View2D *v2d,
 
   UI_view2d_region_to_view(v2d, x, v2d->mask.ymax - layout->offset_top - 1, &mx, &my);
   offset_tile = ED_fileselect_layout_offset(
-      layout, (int)(v2d->tot.xmin + mx), (int)(v2d->tot.ymax - my));
+      layout, int(v2d->tot.xmin + mx), int(v2d->tot.ymax - my));
   if (offset_tile > -1) {
     int tile_x, tile_y;
     int pos_x = 0;
@@ -939,7 +939,7 @@ static void file_attribute_columns_widths(const FileSelectParams *params, FileLa
                                    pad;
   columns[COLUMN_SIZE].width = file_string_width(small_size ? "98.7 M" : "098.7 MiB") + pad;
   if (params->display == FILE_IMGDISPLAY) {
-    columns[COLUMN_NAME].width = ((float)params->t

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list