[Bf-blender-cvs] [556384ca1d7] master: Cleanup: use "num" as a suffix in: source/blender/render

Campbell Barton noreply at git.blender.org
Mon Mar 28 05:42:13 CEST 2022


Commit: 556384ca1d7fcc84b4a92d4d45b3d1d3409c836b
Author: Campbell Barton
Date:   Mon Mar 28 11:12:57 2022 +1100
Branches: master
https://developer.blender.org/rB556384ca1d7fcc84b4a92d4d45b3d1d3409c836b

Cleanup: use "num" as a suffix in: source/blender/render

See T85728

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

M	source/blender/editors/object/object_bake_api.c
M	source/blender/render/RE_bake.h
M	source/blender/render/intern/bake.c
M	source/blender/render/intern/engine.c
M	source/blender/render/intern/multires_bake.c

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

diff --git a/source/blender/editors/object/object_bake_api.c b/source/blender/editors/object/object_bake_api.c
index efcb47f76ab..44f05600d7d 100644
--- a/source/blender/editors/object/object_bake_api.c
+++ b/source/blender/editors/object/object_bake_api.c
@@ -180,7 +180,7 @@ static bool write_internal_bake_pixels(Image *image,
   void *lock;
   bool is_float;
   char *mask_buffer = NULL;
-  const size_t num_pixels = (size_t)width * (size_t)height;
+  const size_t pixels_num = (size_t)width * (size_t)height;
 
   ibuf = BKE_image_acquire_ibuf(image, NULL, &lock);
 
@@ -189,8 +189,8 @@ static bool write_internal_bake_pixels(Image *image,
   }
 
   if (margin > 0 || !is_clear) {
-    mask_buffer = MEM_callocN(sizeof(char) * num_pixels, "Bake Mask");
-    RE_bake_mask_fill(pixel_array, num_pixels, mask_buffer);
+    mask_buffer = MEM_callocN(sizeof(char) * pixels_num, "Bake Mask");
+    RE_bake_mask_fill(pixel_array, pixels_num, mask_buffer);
   }
 
   is_float = (ibuf->rect_float != NULL);
@@ -298,7 +298,7 @@ static bool write_internal_bake_pixels(Image *image,
 /* force OpenGL reload */
 static void bake_targets_refresh(BakeTargets *targets)
 {
-  for (int i = 0; i < targets->num_images; i++) {
+  for (int i = 0; i < targets->images_num; i++) {
     Image *ima = targets->images[i].image;
 
     if (ima) {
@@ -374,10 +374,10 @@ static bool write_external_bake_pixels(const char *filepath,
   /* margins */
   if (margin > 0) {
     char *mask_buffer = NULL;
-    const size_t num_pixels = (size_t)width * (size_t)height;
+    const size_t pixels_num = (size_t)width * (size_t)height;
 
-    mask_buffer = MEM_callocN(sizeof(char) * num_pixels, "Bake Mask");
-    RE_bake_mask_fill(pixel_array, num_pixels, mask_buffer);
+    mask_buffer = MEM_callocN(sizeof(char) * pixels_num, "Bake Mask");
+    RE_bake_mask_fill(pixel_array, pixels_num, mask_buffer);
     RE_bake_margin(ibuf, mask_buffer, margin, margin_type, mesh_eval, uv_layer);
 
     if (mask_buffer) {
@@ -670,9 +670,9 @@ static bool bake_targets_init_image_textures(const BakeAPIRender *bkr,
                                              Object *ob,
                                              ReportList *reports)
 {
-  int num_materials = ob->totcol;
+  int materials_num = ob->totcol;
 
-  if (num_materials == 0) {
+  if (materials_num == 0) {
     if (bkr->save_mode == R_BAKE_SAVE_INTERNAL) {
       BKE_report(
           reports, RPT_ERROR, "No active image found, add a material or bake to an external file");
@@ -688,15 +688,15 @@ static bool bake_targets_init_image_textures(const BakeAPIRender *bkr,
   }
 
   /* Over-allocate in case there is more materials than images. */
-  targets->num_materials = num_materials;
-  targets->images = MEM_callocN(sizeof(BakeImage) * targets->num_materials, "BakeTargets.images");
-  targets->material_to_image = MEM_callocN(sizeof(int) * targets->num_materials,
+  targets->materials_num = materials_num;
+  targets->images = MEM_callocN(sizeof(BakeImage) * targets->materials_num, "BakeTargets.images");
+  targets->material_to_image = MEM_callocN(sizeof(int) * targets->materials_num,
                                            "BakeTargets.material_to_image");
 
   /* Error handling and tag (in case multiple materials share the same image). */
   BKE_main_id_tag_idcode(bkr->main, ID_IM, LIB_TAG_DOIT, false);
 
-  for (int i = 0; i < num_materials; i++) {
+  for (int i = 0; i < materials_num; i++) {
     Image *image;
     ED_object_get_active_image(ob, i + 1, &image, NULL, NULL, NULL);
 
@@ -713,10 +713,10 @@ static bool bake_targets_init_image_textures(const BakeAPIRender *bkr,
       }
     }
     else {
-      targets->material_to_image[i] = targets->num_images;
-      targets->images[targets->num_images].image = image;
+      targets->material_to_image[i] = targets->images_num;
+      targets->images[targets->images_num].image = image;
       image->id.tag |= LIB_TAG_DOIT;
-      targets->num_images++;
+      targets->images_num++;
     }
   }
 
@@ -733,7 +733,7 @@ static bool bake_targets_init_internal(const BakeAPIRender *bkr,
   }
 
   /* Saving to image datablocks. */
-  for (int i = 0; i < targets->num_images; i++) {
+  for (int i = 0; i < targets->images_num; i++) {
     BakeImage *bk_image = &targets->images[i];
     void *lock;
     ImBuf *ibuf = BKE_image_acquire_ibuf(bk_image->image, NULL, &lock);
@@ -741,9 +741,9 @@ static bool bake_targets_init_internal(const BakeAPIRender *bkr,
     if (ibuf) {
       bk_image->width = ibuf->x;
       bk_image->height = ibuf->y;
-      bk_image->offset = targets->num_pixels;
+      bk_image->offset = targets->pixels_num;
 
-      targets->num_pixels += (size_t)ibuf->x * (size_t)ibuf->y;
+      targets->pixels_num += (size_t)ibuf->x * (size_t)ibuf->y;
     }
     else {
       BKE_image_release_ibuf(bk_image->image, ibuf, lock);
@@ -765,12 +765,12 @@ static bool bake_targets_output_internal(const BakeAPIRender *bkr,
 {
   bool all_ok = true;
 
-  for (int i = 0; i < targets->num_images; i++) {
+  for (int i = 0; i < targets->images_num; i++) {
     BakeImage *bk_image = &targets->images[i];
     const bool ok = write_internal_bake_pixels(bk_image->image,
                                                pixel_array + bk_image->offset,
                                                targets->result +
-                                                   bk_image->offset * targets->num_channels,
+                                                   bk_image->offset * targets->channels_num,
                                                bk_image->width,
                                                bk_image->height,
                                                bkr->margin,
@@ -809,15 +809,15 @@ static bool bake_targets_init_external(const BakeAPIRender *bkr,
   }
 
   /* Saving to disk. */
-  for (int i = 0; i < targets->num_images; i++) {
+  for (int i = 0; i < targets->images_num; i++) {
     BakeImage *bk_image = &targets->images[i];
 
     bk_image->width = bkr->width;
     bk_image->height = bkr->height;
-    bk_image->offset = targets->num_pixels;
+    bk_image->offset = targets->pixels_num;
     bk_image->image = NULL;
 
-    targets->num_pixels += (size_t)bkr->width * (size_t)bkr->height;
+    targets->pixels_num += (size_t)bkr->width * (size_t)bkr->height;
 
     if (!bkr->is_split_materials) {
       break;
@@ -826,7 +826,7 @@ static bool bake_targets_init_external(const BakeAPIRender *bkr,
 
   if (!bkr->is_split_materials) {
     /* saving a single image */
-    for (int i = 0; i < targets->num_materials; i++) {
+    for (int i = 0; i < targets->materials_num; i++) {
       targets->material_to_image[i] = 0;
     }
   }
@@ -844,7 +844,7 @@ static bool bake_targets_output_external(const BakeAPIRender *bkr,
 {
   bool all_ok = true;
 
-  for (int i = 0; i < targets->num_images; i++) {
+  for (int i = 0; i < targets->images_num; i++) {
     BakeImage *bk_image = &targets->images[i];
 
     BakeData *bake = &bkr->scene->r.bake;
@@ -888,7 +888,7 @@ static bool bake_targets_output_external(const BakeAPIRender *bkr,
     const bool ok = write_external_bake_pixels(name,
                                                pixel_array + bk_image->offset,
                                                targets->result +
-                                                   bk_image->offset * targets->num_channels,
+                                                   bk_image->offset * targets->channels_num,
                                                bk_image->width,
                                                bk_image->height,
                                                bkr->margin,
@@ -934,11 +934,11 @@ static bool bake_targets_init_vertex_colors(BakeTargets *targets, Object *ob, Re
   }
 
   targets->images = MEM_callocN(sizeof(BakeImage), "BakeTargets.images");
-  targets->num_images = 1;
+  targets->images_num = 1;
 
   targets->material_to_image = MEM_callocN(sizeof(int) * ob->totcol,
                                            "BakeTargets.material_to_image");
-  targets->num_materials = ob->totcol;
+  targets->materials_num = ob->totcol;
 
   BakeImage *bk_image = &targets->images[0];
   bk_image->width = me->totloop;
@@ -946,7 +946,7 @@ static bool bake_targets_init_vertex_colors(BakeTargets *targets, Object *ob, Re
   bk_image->offset = 0;
   bk_image->image = NULL;
 
-  targets->num_pixels = bk_image->width * bk_image->height;
+  targets->pixels_num = bk_image->width * bk_image->height;
 
   return true;
 }
@@ -984,10 +984,10 @@ static void bake_targets_populate_pixels_vertex_colors(BakeTargets *targets,
                                                        BakePixel *pixel_array)
 {
   Mesh *me = ob->data;
-  const int num_pixels = targets->num_pixels;
+  const int pixels_num = targets->pixels_num;
 
   /* Initialize blank pixels. */
-  for (int i = 0; i < num_pixels; i++) {
+  for (int i = 0; i < pixels_num; i++) {
     BakePixel *pixel = &pixel_array[i];
 
     pixel->primitive_id = -1;
@@ -1059,12 +1059,12 @@ static void bake_targets_populate_pixels_vertex_colors(BakeTargets *targets,
   MEM_freeN(looptri);
 }
 
-static void bake_result_add_to_rgba(float rgba[4], const float *result, const int num_channels)
+static void bake_result_add_to_rgba(float rgba[4], const float *result, const int channels_num)
 {
-  if (num_channels == 4) {
+  if (channels_num == 4) {
     add_v4_v4(rgba, result);
   }
-  else if (num_channels == 3) {
+  else if (channels_num == 3) {
     add_v3_v3(rgba, result);
     rgba[3] += 1.0f;
   }
@@ -1082,7 +1082,7 @@ static bool bake_targets_output_vertex_colors(BakeTargets *targets, Object *ob)
   MPropCol *mcol = CustomData_get_layer(&me->vdata, CD_PROP_COLOR);
   const bool mcol_valid = (mcol != NULL && U.experimental.use_sculpt_vertex_colors);
   MLoopCol *mloopcol = CustomData_get_layer(&me->ldata, CD_MLOOPCOL);
-  const int num_channels = targets->num_channels;
+  const int channels_num = targets->channels_num;
   const float *result = targets->result;
 
   if (mcol_valid) {
@@ -1096,7 +1096,7 @@ static bool bake_targets_output_vertex_colors(BakeTargets *targets, Object *ob)
     MLoop *mloop = me->mloop;
     for (int i = 0; i < totloop; i++, mloop++) {
       const int

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list