diff options
author | Campbell Barton <campbell@blender.org> | 2022-03-25 04:04:20 +0300 |
---|---|---|
committer | Campbell Barton <campbell@blender.org> | 2022-03-25 04:04:20 +0300 |
commit | 4d46fac65d9946382c4be5b3842660e77468f00b (patch) | |
tree | c2910a4ca0b2d345007bf853d6484a1b9e53e4e1 /source/blender/blenkernel | |
parent | c594cfbe50497fdc365b3f327b643de507cda02f (diff) |
Cleanup: use count or num instead of nbr
Follow conventions from T85728.
Diffstat (limited to 'source/blender/blenkernel')
-rw-r--r-- | source/blender/blenkernel/BKE_scene.h | 2 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/appdir.c | 12 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/image.cc | 25 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/mesh_mapping.c | 8 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/mesh_normals.cc | 36 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/mesh_validate.cc | 3 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/particle_system.c | 8 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/scene.c | 8 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/studiolight.c | 14 |
9 files changed, 59 insertions, 57 deletions
diff --git a/source/blender/blenkernel/BKE_scene.h b/source/blender/blenkernel/BKE_scene.h index 8c50a89ec90..a6402a1e8a1 100644 --- a/source/blender/blenkernel/BKE_scene.h +++ b/source/blender/blenkernel/BKE_scene.h @@ -225,7 +225,7 @@ bool BKE_scene_remove_render_view(struct Scene *scene, struct SceneRenderView *s /* Render profile. */ int get_render_subsurf_level(const struct RenderData *r, int lvl, bool for_render); -int get_render_child_particle_number(const struct RenderData *r, int num, bool for_render); +int get_render_child_particle_number(const struct RenderData *r, int child_num, bool for_render); bool BKE_scene_use_shading_nodes_custom(struct Scene *scene); bool BKE_scene_use_spherical_stereo(struct Scene *scene); diff --git a/source/blender/blenkernel/intern/appdir.c b/source/blender/blenkernel/intern/appdir.c index b0393ed723d..8d3649fef08 100644 --- a/source/blender/blenkernel/intern/appdir.c +++ b/source/blender/blenkernel/intern/appdir.c @@ -1022,16 +1022,16 @@ void BKE_appdir_app_templates(ListBase *templates) continue; } - struct direntry *dir; - uint totfile = BLI_filelist_dir_contents(subdir, &dir); - for (int f = 0; f < totfile; f++) { - if (!FILENAME_IS_CURRPAR(dir[f].relname) && S_ISDIR(dir[f].type)) { - char *template = BLI_strdup(dir[f].relname); + struct direntry *dirs; + const uint dir_num = BLI_filelist_dir_contents(subdir, &dirs); + for (int f = 0; f < dir_num; f++) { + if (!FILENAME_IS_CURRPAR(dirs[f].relname) && S_ISDIR(dirs[f].type)) { + char *template = BLI_strdup(dirs[f].relname); BLI_addtail(templates, BLI_genericNodeN(template)); } } - BLI_filelist_free(dir, totfile); + BLI_filelist_free(dirs, dir_num); } } diff --git a/source/blender/blenkernel/intern/image.cc b/source/blender/blenkernel/intern/image.cc index c4f8677d199..b65f3416f0f 100644 --- a/source/blender/blenkernel/intern/image.cc +++ b/source/blender/blenkernel/intern/image.cc @@ -3113,14 +3113,15 @@ bool BKE_image_get_tile_info(char *filepath, ListBase *tiles, int *tile_start, i int max_udim = 0; int id; - struct direntry *dir; - uint totfile = BLI_filelist_dir_contents(dirname, &dir); - for (int i = 0; i < totfile; i++) { - if (!(dir[i].type & S_IFREG)) { + struct direntry *dirs; + const uint dirs_num = BLI_filelist_dir_contents(dirname, &dirs); + for (int i = 0; i < dirs_num; i++) { + if (!(dirs[i].type & S_IFREG)) { continue; } - if (!BKE_image_get_tile_number_from_filepath(dir[i].relname, udim_pattern, tile_format, &id)) { + if (!BKE_image_get_tile_number_from_filepath( + dirs[i].relname, udim_pattern, tile_format, &id)) { continue; } @@ -3133,7 +3134,7 @@ bool BKE_image_get_tile_info(char *filepath, ListBase *tiles, int *tile_start, i min_udim = min_ii(min_udim, id); max_udim = max_ii(max_udim, id); } - BLI_filelist_free(dir, totfile); + BLI_filelist_free(dirs, dirs_num); MEM_SAFE_FREE(udim_pattern); if (is_udim && min_udim <= IMA_UDIM_MAX) { @@ -3350,15 +3351,15 @@ bool BKE_image_tile_filepath_exists(const char *filepath) char *udim_pattern = BKE_image_get_tile_strformat(filepath, &tile_format); bool found = false; - struct direntry *dir; - uint totfile = BLI_filelist_dir_contents(dirname, &dir); - for (int i = 0; i < totfile; i++) { - if (!(dir[i].type & S_IFREG)) { + struct direntry *dirs; + const uint dirs_num = BLI_filelist_dir_contents(dirname, &dirs); + for (int i = 0; i < dirs_num; i++) { + if (!(dirs[i].type & S_IFREG)) { continue; } int id; - if (!BKE_image_get_tile_number_from_filepath(dir[i].path, udim_pattern, tile_format, &id)) { + if (!BKE_image_get_tile_number_from_filepath(dirs[i].path, udim_pattern, tile_format, &id)) { continue; } @@ -3369,7 +3370,7 @@ bool BKE_image_tile_filepath_exists(const char *filepath) found = true; break; } - BLI_filelist_free(dir, totfile); + BLI_filelist_free(dirs, dirs_num); MEM_SAFE_FREE(udim_pattern); return found; diff --git a/source/blender/blenkernel/intern/mesh_mapping.c b/source/blender/blenkernel/intern/mesh_mapping.c index e9c26c80141..9c4098e2db6 100644 --- a/source/blender/blenkernel/intern/mesh_mapping.c +++ b/source/blender/blenkernel/intern/mesh_mapping.c @@ -561,7 +561,7 @@ void BKE_mesh_origindex_map_create_looptri(MeshElemMap **r_map, typedef bool (*MeshRemap_CheckIslandBoundary)(const struct MPoly *mpoly, const struct MLoop *mloop, const struct MEdge *medge, - const int nbr_edge_users, + const int edge_user_count, const struct MPoly *mpoly_array, const struct MeshElemMap *edge_poly_map, void *user_data); @@ -764,14 +764,14 @@ static void poly_edge_loop_islands_calc(const MEdge *medge, static bool poly_is_island_boundary_smooth_cb(const MPoly *mp, const MLoop *UNUSED(ml), const MEdge *me, - const int nbr_edge_users, + const int edge_user_count, const MPoly *mpoly_array, const MeshElemMap *edge_poly_map, void *UNUSED(user_data)) { /* Edge is sharp if one of its polys is flat, or edge itself is sharp, * or edge is not used by exactly two polygons. */ - if ((mp->flag & ME_SMOOTH) && !(me->flag & ME_SHARP) && (nbr_edge_users == 2)) { + if ((mp->flag & ME_SMOOTH) && !(me->flag & ME_SHARP) && (edge_user_count == 2)) { /* In that case, edge appears to be smooth, but we need to check its other poly too. */ const MPoly *mp_other = (mp == &mpoly_array[edge_poly_map->indices[0]]) ? &mpoly_array[edge_poly_map->indices[1]] : @@ -935,7 +935,7 @@ typedef struct MeshCheckIslandBoundaryUv { static bool mesh_check_island_boundary_uv(const MPoly *UNUSED(mp), const MLoop *ml, const MEdge *me, - const int UNUSED(nbr_edge_users), + const int UNUSED(edge_user_count), const MPoly *UNUSED(mpoly_array), const MeshElemMap *UNUSED(edge_poly_map), void *user_data) diff --git a/source/blender/blenkernel/intern/mesh_normals.cc b/source/blender/blenkernel/intern/mesh_normals.cc index 7633a3155ba..4448bedb57a 100644 --- a/source/blender/blenkernel/intern/mesh_normals.cc +++ b/source/blender/blenkernel/intern/mesh_normals.cc @@ -613,19 +613,19 @@ void BKE_lnor_space_define(MLoopNorSpace *lnor_space, /* Compute ref alpha, average angle of all available edge vectors to lnor. */ if (edge_vectors) { float alpha = 0.0f; - int nbr = 0; + int count = 0; while (!BLI_stack_is_empty(edge_vectors)) { const float *vec = (const float *)BLI_stack_peek(edge_vectors); alpha += saacosf(dot_v3v3(vec, lnor)); BLI_stack_discard(edge_vectors); - nbr++; + count++; } - /* NOTE: In theory, this could be `nbr > 2`, + /* NOTE: In theory, this could be `count > 2`, * but there is one case where we only have two edges for two loops: * a smooth vertex with only two edges and two faces (our Monkey's nose has that, e.g.). */ - BLI_assert(nbr >= 2); /* This piece of code shall only be called for more than one loop. */ - lnor_space->ref_alpha = alpha / (float)nbr; + BLI_assert(count >= 2); /* This piece of code shall only be called for more than one loop. */ + lnor_space->ref_alpha = alpha / (float)count; } else { lnor_space->ref_alpha = (saacosf(dot_v3v3(vec_ref, lnor)) + @@ -1134,7 +1134,7 @@ static void split_loop_nor_fan_do(LoopSplitTaskDataCommon *common_data, LoopSpli /* We validate clnors data on the fly - cheapest way to do! */ int clnors_avg[2] = {0, 0}; short(*clnor_ref)[2] = nullptr; - int clnors_nbr = 0; + int clnors_count = 0; bool clnors_invalid = false; /* Temp loop normal stack. */ @@ -1194,7 +1194,7 @@ static void split_loop_nor_fan_do(LoopSplitTaskDataCommon *common_data, LoopSpli if (clnors_data) { /* Accumulate all clnors, if they are not all equal we have to fix that! */ short(*clnor)[2] = &clnors_data[mlfan_vert_index]; - if (clnors_nbr) { + if (clnors_count) { clnors_invalid |= ((*clnor_ref)[0] != (*clnor)[0] || (*clnor_ref)[1] != (*clnor)[1]); } else { @@ -1202,7 +1202,7 @@ static void split_loop_nor_fan_do(LoopSplitTaskDataCommon *common_data, LoopSpli } clnors_avg[0] += (*clnor)[0]; clnors_avg[1] += (*clnor)[1]; - clnors_nbr++; + clnors_count++; /* We store here a pointer to all custom lnors processed. */ BLI_SMALLSTACK_PUSH(clnors, (short *)*clnor); } @@ -1262,8 +1262,8 @@ static void split_loop_nor_fan_do(LoopSplitTaskDataCommon *common_data, LoopSpli if (clnors_invalid) { short *clnor; - clnors_avg[0] /= clnors_nbr; - clnors_avg[1] /= clnors_nbr; + clnors_avg[0] /= clnors_count; + clnors_avg[1] /= clnors_count; /* Fix/update all clnors of this fan with computed average value. */ if (G.debug & G_DEBUG) { printf("Invalid clnors in this fan!\n"); @@ -1952,7 +1952,7 @@ static void mesh_normals_loop_custom_set(const MVert *mverts, BLI_BITMAP_DISABLE(done_loops, i); } else { - int nbr_nors = 0; + int avg_nor_count = 0; float avg_nor[3]; short clnor_data_tmp[2], *clnor_data; @@ -1962,7 +1962,7 @@ static void mesh_normals_loop_custom_set(const MVert *mverts, const int nidx = use_vertices ? (int)mloops[lidx].v : lidx; float *nor = r_custom_loopnors[nidx]; - nbr_nors++; + avg_nor_count++; add_v3_v3(avg_nor, nor); BLI_SMALLSTACK_PUSH(clnors_data, (short *)r_clnors_data[lidx]); @@ -1970,7 +1970,7 @@ static void mesh_normals_loop_custom_set(const MVert *mverts, BLI_BITMAP_DISABLE(done_loops, lidx); } - mul_v3_fl(avg_nor, 1.0f / (float)nbr_nors); + mul_v3_fl(avg_nor, 1.0f / (float)avg_nor_count); BKE_lnor_space_custom_normal_to_data(lnors_spacearr.lspacearr[i], avg_nor, clnor_data_tmp); while ((clnor_data = (short *)BLI_SMALLSTACK_POP(clnors_data))) { @@ -2088,8 +2088,8 @@ void BKE_mesh_normals_loop_to_vertex(const int numVerts, const float (*clnors)[3], float (*r_vert_clnors)[3]) { - int *vert_loops_nbr = (int *)MEM_calloc_arrayN( - (size_t)numVerts, sizeof(*vert_loops_nbr), __func__); + int *vert_loops_count = (int *)MEM_calloc_arrayN( + (size_t)numVerts, sizeof(*vert_loops_count), __func__); copy_vn_fl((float *)r_vert_clnors, 3 * numVerts, 0.0f); @@ -2099,14 +2099,14 @@ void BKE_mesh_normals_loop_to_vertex(const int numVerts, const uint v = ml->v; add_v3_v3(r_vert_clnors[v], clnors[i]); - vert_loops_nbr[v]++; + vert_loops_count[v]++; } for (i = 0; i < numVerts; i++) { - mul_v3_fl(r_vert_clnors[i], 1.0f / (float)vert_loops_nbr[i]); + mul_v3_fl(r_vert_clnors[i], 1.0f / (float)vert_loops_count[i]); } - MEM_freeN(vert_loops_nbr); + MEM_freeN(vert_loops_count); } #undef LNOR_SPACE_TRIGO_THRESHOLD diff --git a/source/blender/blenkernel/intern/mesh_validate.cc b/source/blender/blenkernel/intern/mesh_validate.cc index 4374659bff8..6af765d7de5 100644 --- a/source/blender/blenkernel/intern/mesh_validate.cc +++ b/source/blender/blenkernel/intern/mesh_validate.cc @@ -577,7 +577,8 @@ bool BKE_mesh_validate_arrays(Mesh *mesh, else if (mp->loopstart + mp->totloop > totloop) { /* Invalid loop data. */ PRINT_ERR( - "\tPoly %u uses loops out of range (loopstart: %d, loopend: %d, max nbr of loops: %u)", + "\tPoly %u uses loops out of range " + "(loopstart: %d, loopend: %d, max number of loops: %u)", sp->index, mp->loopstart, mp->loopstart + mp->totloop - 1, diff --git a/source/blender/blenkernel/intern/particle_system.c b/source/blender/blenkernel/intern/particle_system.c index 3a1aefec2d3..1a74008c405 100644 --- a/source/blender/blenkernel/intern/particle_system.c +++ b/source/blender/blenkernel/intern/particle_system.c @@ -280,20 +280,20 @@ static void realloc_particles(ParticleSimulationData *sim, int new_totpart) int psys_get_child_number(Scene *scene, ParticleSystem *psys, const bool use_render_params) { - int nbr; + int child_num; if (!psys->part->childtype) { return 0; } if (use_render_params) { - nbr = psys->part->ren_child_nbr; + child_num = psys->part->ren_child_nbr; } else { - nbr = psys->part->child_nbr; + child_num = psys->part->child_nbr; } - return get_render_child_particle_number(&scene->r, nbr, use_render_params); + return get_render_child_particle_number(&scene->r, child_num, use_render_params); } int psys_get_tot_child(Scene *scene, ParticleSystem *psys, const bool use_render_params) diff --git a/source/blender/blenkernel/intern/scene.c b/source/blender/blenkernel/intern/scene.c index 6797538d190..b98c82e365e 100644 --- a/source/blender/blenkernel/intern/scene.c +++ b/source/blender/blenkernel/intern/scene.c @@ -2751,17 +2751,17 @@ int get_render_subsurf_level(const RenderData *r, int lvl, bool for_render) return lvl; } -int get_render_child_particle_number(const RenderData *r, int num, bool for_render) +int get_render_child_particle_number(const RenderData *r, int child_num, bool for_render) { if (r->mode & R_SIMPLIFY) { if (for_render) { - return (int)(r->simplify_particles_render * num); + return (int)(r->simplify_particles_render * child_num); } - return (int)(r->simplify_particles * num); + return (int)(r->simplify_particles * child_num); } - return num; + return child_num; } Base *_setlooper_base_step(Scene **sce_iter, ViewLayer *view_layer, Base *base) diff --git a/source/blender/blenkernel/intern/studiolight.c b/source/blender/blenkernel/intern/studiolight.c index 7d0c6598440..f17450ac3f4 100644 --- a/source/blender/blenkernel/intern/studiolight.c +++ b/source/blender/blenkernel/intern/studiolight.c @@ -1166,18 +1166,18 @@ static void studiolight_add_files_from_datafolder(const int folder_id, const char *subfolder, int flag) { - struct direntry *dir; + struct direntry *dirs; const char *folder = BKE_appdir_folder_id(folder_id, subfolder); if (folder) { - uint totfile = BLI_filelist_dir_contents(folder, &dir); + const uint dirs_num = BLI_filelist_dir_contents(folder, &dirs); int i; - for (i = 0; i < totfile; i++) { - if (dir[i].type & S_IFREG) { - studiolight_add_file(dir[i].path, flag); + for (i = 0; i < dirs_num; i++) { + if (dirs[i].type & S_IFREG) { + studiolight_add_file(dirs[i].path, flag); } } - BLI_filelist_free(dir, totfile); - dir = NULL; + BLI_filelist_free(dirs, dirs_num); + dirs = NULL; } } |