diff options
author | Campbell Barton <campbell@blender.org> | 2022-09-25 11:33:28 +0300 |
---|---|---|
committer | Campbell Barton <campbell@blender.org> | 2022-09-25 13:17:08 +0300 |
commit | f68cfd6bb078482c4a779a6e26a56e2734edb5b8 (patch) | |
tree | 2878e5b80dba5bdeba186d99661d604eb38879cd /source/blender/blenkernel/intern/mesh_normals.cc | |
parent | c7b247a118e302a3afc6473797e53b6af28b69e2 (diff) |
Cleanup: replace C-style casts with functional casts for numeric types
Diffstat (limited to 'source/blender/blenkernel/intern/mesh_normals.cc')
-rw-r--r-- | source/blender/blenkernel/intern/mesh_normals.cc | 40 |
1 files changed, 20 insertions, 20 deletions
diff --git a/source/blender/blenkernel/intern/mesh_normals.cc b/source/blender/blenkernel/intern/mesh_normals.cc index 21dd39586ec..3eeebc8485a 100644 --- a/source/blender/blenkernel/intern/mesh_normals.cc +++ b/source/blender/blenkernel/intern/mesh_normals.cc @@ -320,7 +320,7 @@ void BKE_mesh_calc_normals_poly_and_vertex(const MVert *mvert, BLI_parallel_range_settings_defaults(&settings); settings.min_iter_per_thread = 1024; - memset(r_vert_normals, 0, sizeof(*r_vert_normals) * (size_t)mvert_len); + memset(r_vert_normals, 0, sizeof(*r_vert_normals) * size_t(mvert_len)); MeshCalcNormalsData_PolyAndVertex data = {}; data.mpoly = mpoly; @@ -476,10 +476,10 @@ void BKE_mesh_calc_normals_looptri(MVert *mverts, int looptri_num, float (*r_tri_nors)[3]) { - float(*tnorms)[3] = (float(*)[3])MEM_calloc_arrayN((size_t)numVerts, sizeof(*tnorms), "tnorms"); + float(*tnorms)[3] = (float(*)[3])MEM_calloc_arrayN(size_t(numVerts), sizeof(*tnorms), "tnorms"); float(*fnors)[3] = (r_tri_nors) ? r_tri_nors : (float(*)[3])MEM_calloc_arrayN( - (size_t)looptri_num, sizeof(*fnors), "meshnormals"); + size_t(looptri_num), sizeof(*fnors), "meshnormals"); if (!tnorms || !fnors) { goto cleanup; @@ -535,9 +535,9 @@ void BKE_lnor_spacearr_init(MLoopNorSpaceArray *lnors_spacearr, } mem = lnors_spacearr->mem; lnors_spacearr->lspacearr = (MLoopNorSpace **)BLI_memarena_calloc( - mem, sizeof(MLoopNorSpace *) * (size_t)numLoops); + mem, sizeof(MLoopNorSpace *) * size_t(numLoops)); lnors_spacearr->loops_pool = (LinkNode *)BLI_memarena_alloc( - mem, sizeof(LinkNode) * (size_t)numLoops); + mem, sizeof(LinkNode) * size_t(numLoops)); lnors_spacearr->spaces_num = 0; } @@ -598,7 +598,7 @@ void BKE_lnor_space_define(MLoopNorSpace *lnor_space, float vec_other[3], BLI_Stack *edge_vectors) { - const float pi2 = (float)M_PI * 2.0f; + const float pi2 = float(M_PI) * 2.0f; float tvec[3], dtp; const float dtp_ref = dot_v3v3(vec_ref, lnor); const float dtp_other = dot_v3v3(vec_other, lnor); @@ -632,7 +632,7 @@ void BKE_lnor_space_define(MLoopNorSpace *lnor_space, * a smooth vertex with only two edges and two faces (our Monkey's nose has that, e.g.). */ BLI_assert(count >= 2); /* This piece of code shall only be called for more than one loop. */ - lnor_space->ref_alpha = alpha / (float)count; + lnor_space->ref_alpha = alpha / float(count); } else { lnor_space->ref_alpha = (saacosf(dot_v3v3(vec_ref, lnor)) + @@ -690,13 +690,13 @@ void BKE_lnor_space_add_loop(MLoopNorSpaceArray *lnors_spacearr, MINLINE float unit_short_to_float(const short val) { - return (float)val / (float)SHRT_MAX; + return float(val) / float(SHRT_MAX); } MINLINE short unit_float_to_short(const float val) { /* Rounding. */ - return (short)floorf(val * (float)SHRT_MAX + 0.5f); + return short(floorf(val * float(SHRT_MAX) + 0.5f)); } void BKE_lnor_space_custom_data_to_normal(MLoopNorSpace *lnor_space, @@ -712,7 +712,7 @@ void BKE_lnor_space_custom_data_to_normal(MLoopNorSpace *lnor_space, { /* TODO: Check whether using #sincosf() gives any noticeable benefit * (could not even get it working under linux though)! */ - const float pi2 = (float)(M_PI * 2.0); + const float pi2 = float(M_PI * 2.0); const float alphafac = unit_short_to_float(clnor_data[0]); const float alpha = (alphafac > 0.0f ? lnor_space->ref_alpha : pi2 - lnor_space->ref_alpha) * alphafac; @@ -745,7 +745,7 @@ void BKE_lnor_space_custom_normal_to_data(MLoopNorSpace *lnor_space, } { - const float pi2 = (float)(M_PI * 2.0); + const float pi2 = float(M_PI * 2.0); const float cos_alpha = dot_v3v3(lnor_space->vec_lnor, custom_lnor); float vec[3], cos_beta; float alpha; @@ -955,17 +955,17 @@ void BKE_edges_sharp_from_angle_set(const struct MVert *mverts, const int numPolys, const float split_angle) { - if (split_angle >= (float)M_PI) { + if (split_angle >= float(M_PI)) { /* Nothing to do! */ return; } /* Mapping edge -> loops. See BKE_mesh_normals_loop_split() for details. */ int(*edge_to_loops)[2] = (int(*)[2])MEM_calloc_arrayN( - (size_t)numEdges, sizeof(*edge_to_loops), __func__); + size_t(numEdges), sizeof(*edge_to_loops), __func__); /* Simple mapping from a loop to its polygon index. */ - int *loop_to_poly = (int *)MEM_malloc_arrayN((size_t)numLoops, sizeof(*loop_to_poly), __func__); + int *loop_to_poly = (int *)MEM_malloc_arrayN(size_t(numLoops), sizeof(*loop_to_poly), __func__); LoopSplitTaskDataCommon common_data = {}; common_data.mverts = mverts; @@ -1278,8 +1278,8 @@ static void split_loop_nor_fan_do(LoopSplitTaskDataCommon *common_data, LoopSpli } while ((clnor = (short *)BLI_SMALLSTACK_POP(clnors))) { // print_v2("org clnor", clnor); - clnor[0] = (short)clnors_avg[0]; - clnor[1] = (short)clnors_avg[1]; + clnor[0] = short(clnors_avg[0]); + clnor[1] = short(clnors_avg[1]); } // print_v2("new clnors", clnors_avg); } @@ -1952,7 +1952,7 @@ static void mesh_normals_loop_custom_set(const MVert *mverts, LinkNode *loops = lnors_spacearr.lspacearr[i]->loops; if (lnors_spacearr.lspacearr[i]->flags & MLNOR_SPACE_IS_SINGLE) { BLI_assert(POINTER_AS_INT(loops) == i); - const int nidx = use_vertices ? (int)mloops[i].v : i; + const int nidx = use_vertices ? int(mloops[i].v) : i; float *nor = r_custom_loopnors[nidx]; BKE_lnor_space_custom_normal_to_data(lnors_spacearr.lspacearr[i], nor, r_clnors_data[i]); @@ -1966,7 +1966,7 @@ static void mesh_normals_loop_custom_set(const MVert *mverts, zero_v3(avg_nor); while (loops) { const int lidx = POINTER_AS_INT(loops->link); - const int nidx = use_vertices ? (int)mloops[lidx].v : lidx; + const int nidx = use_vertices ? int(mloops[lidx].v) : lidx; float *nor = r_custom_loopnors[nidx]; avg_nor_count++; @@ -1977,7 +1977,7 @@ static void mesh_normals_loop_custom_set(const MVert *mverts, done_loops[lidx].reset(); } - mul_v3_fl(avg_nor, 1.0f / (float)avg_nor_count); + 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))) { @@ -2113,7 +2113,7 @@ void BKE_mesh_normals_loop_to_vertex(const int numVerts, } for (i = 0; i < numVerts; i++) { - mul_v3_fl(r_vert_clnors[i], 1.0f / (float)vert_loops_count[i]); + mul_v3_fl(r_vert_clnors[i], 1.0f / float(vert_loops_count[i])); } MEM_freeN(vert_loops_count); |