From f68cfd6bb078482c4a779a6e26a56e2734edb5b8 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 25 Sep 2022 18:33:28 +1000 Subject: Cleanup: replace C-style casts with functional casts for numeric types --- source/blender/blenkernel/intern/attribute.cc | 6 +- source/blender/blenkernel/intern/brush.cc | 2 +- source/blender/blenkernel/intern/curve.cc | 22 ++++---- source/blender/blenkernel/intern/curveprofile.cc | 10 ++-- source/blender/blenkernel/intern/customdata.cc | 42 +++++++------- source/blender/blenkernel/intern/displist.cc | 20 +++---- .../blender/blenkernel/intern/editmesh_tangent.cc | 12 ++-- source/blender/blenkernel/intern/gpencil_geom.cc | 64 +++++++++++----------- source/blender/blenkernel/intern/icons.cc | 2 +- source/blender/blenkernel/intern/image.cc | 16 +++--- source/blender/blenkernel/intern/image_gpu.cc | 10 ++-- source/blender/blenkernel/intern/main_namemap.cc | 2 +- source/blender/blenkernel/intern/mball.cc | 2 +- source/blender/blenkernel/intern/mesh.cc | 4 +- source/blender/blenkernel/intern/mesh_convert.cc | 16 +++--- source/blender/blenkernel/intern/mesh_evaluate.cc | 22 ++++---- source/blender/blenkernel/intern/mesh_fair.cc | 2 +- .../blenkernel/intern/mesh_legacy_convert.cc | 30 +++++----- source/blender/blenkernel/intern/mesh_mapping.cc | 48 ++++++++-------- .../blenkernel/intern/mesh_merge_customdata.cc | 2 +- source/blender/blenkernel/intern/mesh_normals.cc | 40 +++++++------- .../blender/blenkernel/intern/mesh_remesh_voxel.cc | 10 ++-- source/blender/blenkernel/intern/mesh_tangent.cc | 42 +++++++------- .../blender/blenkernel/intern/mesh_tessellate.cc | 22 ++++---- source/blender/blenkernel/intern/mesh_validate.cc | 2 +- source/blender/blenkernel/intern/node.cc | 2 +- .../blender/blenkernel/intern/node_tree_update.cc | 4 +- source/blender/blenkernel/intern/object_dupli.cc | 14 ++--- source/blender/blenkernel/intern/paint.cc | 2 +- source/blender/blenkernel/intern/pbvh.cc | 2 +- source/blender/blenkernel/intern/scene.cc | 24 ++++---- source/blender/blenkernel/intern/subdiv_mesh.cc | 4 +- .../blender/blenkernel/intern/type_conversions.cc | 28 +++++----- source/blender/blenkernel/intern/volume.cc | 4 +- 34 files changed, 267 insertions(+), 267 deletions(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/intern/attribute.cc b/source/blender/blenkernel/intern/attribute.cc index c69a7b4b2c7..1a54454bf9a 100644 --- a/source/blender/blenkernel/intern/attribute.cc +++ b/source/blender/blenkernel/intern/attribute.cc @@ -354,7 +354,7 @@ CustomDataLayer *BKE_id_attribute_search(ID *id, get_domains(id, info); for (eAttrDomain domain = ATTR_DOMAIN_POINT; domain < ATTR_DOMAIN_NUM; - domain = static_cast((int(domain)) + 1)) { + domain = static_cast(int(domain) + 1)) { if (!(domain_mask & ATTR_DOMAIN_AS_MASK(domain))) { continue; } @@ -388,7 +388,7 @@ int BKE_id_attributes_length(const ID *id, eAttrDomainMask domain_mask, eCustomD continue; } - if ((1 << (int)domain) & domain_mask) { + if ((1 << int(domain)) & domain_mask) { length += CustomData_number_of_layers_typemask(customdata, mask); } } @@ -574,7 +574,7 @@ CustomDataLayer *BKE_id_attribute_from_index(ID *id, for (const int domain : IndexRange(ATTR_DOMAIN_NUM)) { CustomData *customdata = info[domain].customdata; - if (!customdata || !((1 << (int)domain) & domain_mask)) { + if (!customdata || !((1 << int(domain)) & domain_mask)) { continue; } diff --git a/source/blender/blenkernel/intern/brush.cc b/source/blender/blenkernel/intern/brush.cc index a998fc0a75f..3708090f8ed 100644 --- a/source/blender/blenkernel/intern/brush.cc +++ b/source/blender/blenkernel/intern/brush.cc @@ -2358,7 +2358,7 @@ void BKE_brush_scale_unprojected_radius(float *unprojected_radius, float scale = new_brush_size; /* avoid division by zero */ if (old_brush_size != 0) { - scale /= (float)old_brush_size; + scale /= float(old_brush_size); } (*unprojected_radius) *= scale; } diff --git a/source/blender/blenkernel/intern/curve.cc b/source/blender/blenkernel/intern/curve.cc index 652315e74f9..ddd1f000644 100644 --- a/source/blender/blenkernel/intern/curve.cc +++ b/source/blender/blenkernel/intern/curve.cc @@ -1682,7 +1682,7 @@ void BKE_curve_calc_coords_axis(const BezTriple *bezt_array, bezt_next->vec[0][axis], bezt_next->vec[1][axis], r_points_offset, - (int)resolu, + int(resolu), stride); r_points_offset = (float *)POINTER_OFFSET(r_points_offset, resolu_stride); } @@ -1695,7 +1695,7 @@ void BKE_curve_calc_coords_axis(const BezTriple *bezt_array, bezt_next->vec[0][axis], bezt_next->vec[1][axis], r_points_offset, - (int)resolu, + int(resolu), stride); r_points_offset = (float *)POINTER_OFFSET(r_points_offset, resolu_stride); if (use_cyclic_duplicate_endpoint) { @@ -1719,7 +1719,7 @@ void BKE_curve_forward_diff_bezier( float rt0, rt1, rt2, rt3, f; int a; - f = (float)it; + f = float(it); rt0 = q0; rt1 = 3.0f * (q1 - q0) / f; f *= f; @@ -1747,7 +1747,7 @@ void BKE_curve_forward_diff_tangent_bezier( float rt0, rt1, rt2, f; int a; - f = 1.0f / (float)it; + f = 1.0f / float(it); rt0 = 3.0f * (q1 - q0); rt1 = f * (3.0f * (q3 - q0) + 9.0f * (q1 - q2)); @@ -1778,7 +1778,7 @@ static void forward_diff_bezier_cotangent(const float p0[3], * * This could also be optimized like BKE_curve_forward_diff_bezier */ for (int a = 0; a <= it; a++) { - float t = (float)a / (float)it; + float t = float(a) / float(it); for (int i = 0; i < 3; i++) { p[i] = (-6.0f * t + 6.0f) * p0[i] + (18.0f * t - 12.0f) * p1[i] + @@ -2005,7 +2005,7 @@ static void tilt_bezpart(const BezTriple *prevbezt, } fac = 0.0; - dfac = 1.0f / (float)resolu; + dfac = 1.0f / float(resolu); for (a = 0; a < resolu; a++, fac += dfac) { if (tilt_array) { @@ -2328,7 +2328,7 @@ static void make_bevel_list_3D_minimum_twist(BevList *bl) nr = bl->nr; while (nr--) { - ang_fac = angle * (1.0f - ((float)nr / bl->nr)); /* also works */ + ang_fac = angle * (1.0f - (float(nr) / bl->nr)); /* also works */ axis_angle_to_quat(q, bevp1->dir, ang_fac); mul_qt_qtqt(bevp1->quat, q, bevp1->quat); @@ -2515,7 +2515,7 @@ static void make_bevel_list_2D(BevList *bl) /* first */ bevp = bl->bevpoints; - angle = atan2f(bevp->dir[0], bevp->dir[1]) - (float)M_PI_2; + angle = atan2f(bevp->dir[0], bevp->dir[1]) - float(M_PI_2); bevp->sina = sinf(angle); bevp->cosa = cosf(angle); vec_to_quat(bevp->quat, bevp->dir, 5, 1); @@ -2523,7 +2523,7 @@ static void make_bevel_list_2D(BevList *bl) /* last */ bevp = bl->bevpoints; bevp += (bl->nr - 1); - angle = atan2f(bevp->dir[0], bevp->dir[1]) - (float)M_PI_2; + angle = atan2f(bevp->dir[0], bevp->dir[1]) - float(M_PI_2); bevp->sina = sinf(angle); bevp->cosa = cosf(angle); vec_to_quat(bevp->quat, bevp->dir, 5, 1); @@ -5153,7 +5153,7 @@ bool BKE_curve_center_median(Curve *cu, float cent[3]) } if (total) { - mul_v3_fl(cent, 1.0f / (float)total); + mul_v3_fl(cent, 1.0f / float(total)); } return (total != 0); @@ -5392,7 +5392,7 @@ bool BKE_curve_material_index_validate(Curve *cu) void BKE_curve_material_remap(Curve *cu, const uint *remap, uint remap_len) { const int curvetype = BKE_curve_type_get(cu); - const short remap_len_short = (short)remap_len; + const short remap_len_short = short(remap_len); #define MAT_NR_REMAP(n) \ if (n < remap_len_short) { \ diff --git a/source/blender/blenkernel/intern/curveprofile.cc b/source/blender/blenkernel/intern/curveprofile.cc index 0e34e4a55dd..5cff804cb18 100644 --- a/source/blender/blenkernel/intern/curveprofile.cc +++ b/source/blender/blenkernel/intern/curveprofile.cc @@ -207,7 +207,7 @@ bool BKE_curveprofile_remove_point(CurveProfile *profile, CurveProfilePoint *poi CurveProfilePoint *new_path = (CurveProfilePoint *)MEM_mallocN( sizeof(CurveProfilePoint) * profile->path_len, __func__); - int i_delete = (int)(point - profile->path); + int i_delete = int(point - profile->path); BLI_assert(i_delete > 0); /* Copy the before and after the deleted point. */ @@ -379,8 +379,8 @@ static void curveprofile_build_supports(CurveProfile *profile) point_init(&profile->path[0], 1.0f, 0.0f, 0, HD_VECT, HD_VECT); point_init(&profile->path[1], 1.0f, 0.5f, 0, HD_VECT, HD_VECT); for (int i = 1; i < n - 2; i++) { - const float x = 1.0f - (0.5f * (1.0f - cosf((float)(i / (float)(n - 3)) * M_PI_2))); - const float y = 0.5f + 0.5f * sinf((float)((i / (float)(n - 3)) * M_PI_2)); + const float x = 1.0f - (0.5f * (1.0f - cosf(float(i / float(n - 3)) * M_PI_2))); + const float y = 0.5f + 0.5f * sinf(float((i / float(n - 3)) * M_PI_2)); point_init(&profile->path[i], x, y, 0, HD_AUTO, HD_AUTO); } point_init(&profile->path[n - 2], 0.5f, 1.0f, 0, HD_VECT, HD_VECT); @@ -408,8 +408,8 @@ static void curveprofile_build_steps(CurveProfile *profile) for (int i = 0; i < n; i++) { int step_x = (i + 1) / 2; int step_y = i / 2; - const float x = 1.0f - ((float)(2 * step_x) / n_steps_x); - const float y = (float)(2 * step_y) / n_steps_y; + const float x = 1.0f - (float(2 * step_x) / n_steps_x); + const float y = float(2 * step_y) / n_steps_y; point_init(&profile->path[i], x, y, 0, HD_VECT, HD_VECT); } } diff --git a/source/blender/blenkernel/intern/customdata.cc b/source/blender/blenkernel/intern/customdata.cc index c07b4c7964e..0968f9a8a01 100644 --- a/source/blender/blenkernel/intern/customdata.cc +++ b/source/blender/blenkernel/intern/customdata.cc @@ -841,7 +841,7 @@ static void layerCopyValue_mloopcol(const void *source, /* Modes that do a full copy or nothing. */ if (ELEM(mixmode, CDT_MIX_REPLACE_ABOVE_THRESHOLD, CDT_MIX_REPLACE_BELOW_THRESHOLD)) { /* TODO: Check for a real valid way to get 'factor' value of our dest color? */ - const float f = ((float)m2->r + (float)m2->g + (float)m2->b) / 3.0f; + const float f = (float(m2->r) + float(m2->g) + float(m2->b)) / 3.0f; if (mixmode == CDT_MIX_REPLACE_ABOVE_THRESHOLD && f < mixfactor) { return; /* Do Nothing! */ } @@ -876,10 +876,10 @@ static void layerCopyValue_mloopcol(const void *source, blend_color_interpolate_byte(dst, dst, tmp_col, mixfactor); - m2->r = (char)dst[0]; - m2->g = (char)dst[1]; - m2->b = (char)dst[2]; - m2->a = (char)dst[3]; + m2->r = char(dst[0]); + m2->g = char(dst[1]); + m2->b = char(dst[2]); + m2->a = char(dst[3]); } } @@ -901,10 +901,10 @@ static void layerMultiply_mloopcol(void *data, const float fac) { MLoopCol *m = static_cast(data); - m->r = (float)m->r * fac; - m->g = (float)m->g * fac; - m->b = (float)m->b * fac; - m->a = (float)m->a * fac; + m->r = float(m->r) * fac; + m->g = float(m->g) * fac; + m->b = float(m->b) * fac; + m->a = float(m->a) * fac; } static void layerAdd_mloopcol(void *data1, const void *data2) @@ -3119,7 +3119,7 @@ static void *customData_duplicate_referenced_layer_index(CustomData *data, if (typeInfo->copy) { void *dst_data = MEM_malloc_arrayN( - (size_t)totelem, typeInfo->size, "CD duplicate ref layer"); + size_t(totelem), typeInfo->size, "CD duplicate ref layer"); typeInfo->copy(layer->data, dst_data, totelem); layer->data = dst_data; } @@ -3250,7 +3250,7 @@ void CustomData_copy_elements(const int type, typeInfo->copy(src_data_ofs, dst_data_ofs, count); } else { - memcpy(dst_data_ofs, src_data_ofs, (size_t)count * typeInfo->size); + memcpy(dst_data_ofs, src_data_ofs, size_t(count) * typeInfo->size); } } @@ -3269,8 +3269,8 @@ void CustomData_copy_data_layer(const CustomData *source, typeInfo = layerType_getInfo(source->layers[src_layer_index].type); - const size_t src_offset = (size_t)src_index * typeInfo->size; - const size_t dst_offset = (size_t)dst_index * typeInfo->size; + const size_t src_offset = size_t(src_index) * typeInfo->size; + const size_t dst_offset = size_t(dst_index) * typeInfo->size; if (!count || !src_data || !dst_data) { if (count && !(src_data == nullptr && dst_data == nullptr)) { @@ -3290,7 +3290,7 @@ void CustomData_copy_data_layer(const CustomData *source, else { memcpy(POINTER_OFFSET(dst_data, dst_offset), POINTER_OFFSET(src_data, src_offset), - (size_t)count * typeInfo->size); + size_t(count) * typeInfo->size); } } @@ -3379,7 +3379,7 @@ void CustomData_free_elem(CustomData *data, const int index, const int count) const LayerTypeInfo *typeInfo = layerType_getInfo(data->layers[i].type); if (typeInfo->free) { - size_t offset = (size_t)index * typeInfo->size; + size_t offset = size_t(index) * typeInfo->size; typeInfo->free(POINTER_OFFSET(data->layers[i].data, offset), count, typeInfo->size); } @@ -3415,7 +3415,7 @@ void CustomData_interp(const CustomData *source, if (weights == nullptr) { default_weights = (count > SOURCE_BUF_SIZE) ? static_cast( - MEM_mallocN(sizeof(*weights) * (size_t)count, __func__)) : + MEM_mallocN(sizeof(*weights) * size_t(count), __func__)) : default_weights_buf; copy_vn_fl(default_weights, count, 1.0f / count); weights = default_weights; @@ -3446,7 +3446,7 @@ void CustomData_interp(const CustomData *source, void *src_data = source->layers[src_i].data; for (int j = 0; j < count; j++) { - sources[j] = POINTER_OFFSET(src_data, (size_t)src_indices[j] * typeInfo->size); + sources[j] = POINTER_OFFSET(src_data, size_t(src_indices[j]) * typeInfo->size); } typeInfo->interp( @@ -3454,7 +3454,7 @@ void CustomData_interp(const CustomData *source, weights, sub_weights, count, - POINTER_OFFSET(dest->layers[dest_i].data, (size_t)dest_index * typeInfo->size)); + POINTER_OFFSET(dest->layers[dest_i].data, size_t(dest_index) * typeInfo->size)); /* if there are multiple source & dest layers of the same type, * we don't want to copy all source layers to the same dest, so @@ -3478,7 +3478,7 @@ void CustomData_swap_corners(CustomData *data, const int index, const int *corne const LayerTypeInfo *typeInfo = layerType_getInfo(data->layers[i].type); if (typeInfo->swap) { - const size_t offset = (size_t)index * typeInfo->size; + const size_t offset = size_t(index) * typeInfo->size; typeInfo->swap(POINTER_OFFSET(data->layers[i].data, offset), corner_indices); } @@ -3523,7 +3523,7 @@ void *CustomData_get(const CustomData *data, const int index, const int type) } /* get the offset of the desired element */ - const size_t offset = (size_t)index * layerType_getInfo(type)->size; + const size_t offset = size_t(index) * layerType_getInfo(type)->size; return POINTER_OFFSET(data->layers[layer_index].data, offset); } @@ -3538,7 +3538,7 @@ void *CustomData_get_n(const CustomData *data, const int type, const int index, return nullptr; } - const size_t offset = (size_t)index * layerType_getInfo(type)->size; + const size_t offset = size_t(index) * layerType_getInfo(type)->size; return POINTER_OFFSET(data->layers[layer_index + n].data, offset); } diff --git a/source/blender/blenkernel/intern/displist.cc b/source/blender/blenkernel/intern/displist.cc index 279166297ec..2b4bd3eb8f6 100644 --- a/source/blender/blenkernel/intern/displist.cc +++ b/source/blender/blenkernel/intern/displist.cc @@ -503,7 +503,7 @@ static float displist_calc_taper(Depsgraph *depsgraph, float BKE_displist_calc_taper( Depsgraph *depsgraph, const Scene *scene, Object *taperobj, int cur, int tot) { - const float fac = ((float)cur) / (float)(tot - 1); + const float fac = float(cur) / float(tot - 1); return displist_calc_taper(depsgraph, scene, taperobj, fac); } @@ -518,7 +518,7 @@ static ModifierData *curve_get_tessellate_point(const Scene *scene, ModifierMode required_mode = for_render ? eModifierMode_Render : eModifierMode_Realtime; if (editmode) { - required_mode = (ModifierMode)((int)required_mode | eModifierMode_Editmode); + required_mode = (ModifierMode)(int(required_mode) | eModifierMode_Editmode); } ModifierData *pretessellatePoint = nullptr; @@ -562,7 +562,7 @@ void BKE_curve_calc_modifiers_pre(Depsgraph *depsgraph, const bool editmode = (!for_render && (cu->editnurb || cu->editfont)); ModifierMode required_mode = for_render ? eModifierMode_Render : eModifierMode_Realtime; if (editmode) { - required_mode = (ModifierMode)((int)required_mode | eModifierMode_Editmode); + required_mode = (ModifierMode)(int(required_mode) | eModifierMode_Editmode); } ModifierApplyFlag apply_flag = (ModifierApplyFlag)0; @@ -689,7 +689,7 @@ static GeometrySet curve_calc_modifiers_post(Depsgraph *depsgraph, ModifierApplyFlag apply_flag = for_render ? MOD_APPLY_RENDER : (ModifierApplyFlag)0; ModifierMode required_mode = for_render ? eModifierMode_Render : eModifierMode_Realtime; if (editmode) { - required_mode = (ModifierMode)((int)required_mode | eModifierMode_Editmode); + required_mode = (ModifierMode)(int(required_mode) | eModifierMode_Editmode); } const ModifierEvalContext mectx_deform = { @@ -970,13 +970,13 @@ static void calc_bevfac_segment_mapping( int bevcount = 0, nr = bl->nr; float bev_fl = bevfac * (bl->nr - 1); - *r_bev = (int)bev_fl; + *r_bev = int(bev_fl); while (bevcount < nr - 1) { float normlen = *seglen / spline_length; if (normsum + normlen > bevfac) { bev_fl = bevcount + (bevfac - normsum) / normlen * *segbevcount; - *r_bev = (int)bev_fl; + *r_bev = int(bev_fl); *r_blend = bev_fl - *r_bev; break; } @@ -1046,7 +1046,7 @@ static void calc_bevfac_mapping(const Curve *cu, switch (cu->bevfac1_mapping) { case CU_BEVFAC_MAP_RESOLU: { const float start_fl = cu->bevfac1 * (bl->nr - 1); - *r_start = (int)start_fl; + *r_start = int(start_fl); *r_firstblend = 1.0f - (start_fl - (*r_start)); break; } @@ -1065,7 +1065,7 @@ static void calc_bevfac_mapping(const Curve *cu, switch (cu->bevfac2_mapping) { case CU_BEVFAC_MAP_RESOLU: { const float end_fl = cu->bevfac2 * (bl->nr - 1); - end = (int)end_fl; + end = int(end_fl); *r_steps = 2 + end - *r_start; *r_lastblend = end_fl - end; @@ -1238,12 +1238,12 @@ static GeometrySet evaluate_curve_type_object(Depsgraph *depsgraph, taper_factor = 1.0f; } else { - taper_factor = ((float)a - (1.0f - first_blend)) / len; + taper_factor = (float(a) - (1.0f - first_blend)) / len; } } else { float len = bl->nr - 1; - taper_factor = (float)i / len; + taper_factor = float(i) / len; if (a == 0) { taper_factor += (1.0f - first_blend) / len; diff --git a/source/blender/blenkernel/intern/editmesh_tangent.cc b/source/blender/blenkernel/intern/editmesh_tangent.cc index a65532d083d..6ce9d3c7bb5 100644 --- a/source/blender/blenkernel/intern/editmesh_tangent.cc +++ b/source/blender/blenkernel/intern/editmesh_tangent.cc @@ -33,9 +33,9 @@ struct SGLSLEditMeshToTangent { uint GetNumFaces() { #ifdef USE_LOOPTRI_DETECT_QUADS - return (uint)num_face_as_quad_map; + return uint(num_face_as_quad_map); #else - return (uint)numTessFaces; + return uint(numTessFaces); #endif } @@ -194,21 +194,21 @@ void BKE_editmesh_loop_tangent_calc(BMEditMesh *em, for (int i = 0; i < tangent_names_len; i++) { if (tangent_names[i][0]) { BKE_mesh_add_loop_tangent_named_layer_for_uv( - &bm->ldata, loopdata_out, (int)loopdata_out_len, tangent_names[i]); + &bm->ldata, loopdata_out, int(loopdata_out_len), tangent_names[i]); } } if ((tangent_mask & DM_TANGENT_MASK_ORCO) && CustomData_get_named_layer_index(loopdata_out, CD_TANGENT, "") == -1) { CustomData_add_layer_named( - loopdata_out, CD_TANGENT, CD_SET_DEFAULT, nullptr, (int)loopdata_out_len, ""); + loopdata_out, CD_TANGENT, CD_SET_DEFAULT, nullptr, int(loopdata_out_len), ""); } if (calc_act && act_uv_name[0]) { BKE_mesh_add_loop_tangent_named_layer_for_uv( - &bm->ldata, loopdata_out, (int)loopdata_out_len, act_uv_name); + &bm->ldata, loopdata_out, int(loopdata_out_len), act_uv_name); } if (calc_ren && ren_uv_name[0]) { BKE_mesh_add_loop_tangent_named_layer_for_uv( - &bm->ldata, loopdata_out, (int)loopdata_out_len, ren_uv_name); + &bm->ldata, loopdata_out, int(loopdata_out_len), ren_uv_name); } int totface = em->tottri; #ifdef USE_LOOPTRI_DETECT_QUADS diff --git a/source/blender/blenkernel/intern/gpencil_geom.cc b/source/blender/blenkernel/intern/gpencil_geom.cc index 4d0db4d5386..563f05691ae 100644 --- a/source/blender/blenkernel/intern/gpencil_geom.cc +++ b/source/blender/blenkernel/intern/gpencil_geom.cc @@ -746,7 +746,7 @@ bool BKE_gpencil_stroke_stretch(bGPDstroke *gps, * `curvature = delta angle/delta arclength = len_v3(total_angle) / overshoot_length` */ float curvature = normalize_v3(total_angle) / overshoot_length; /* Compensate for the weights powf(added_len, segment_influence). */ - curvature /= powf(overshoot_length / fminf(overshoot_parameter, (float)j), segment_influence); + curvature /= powf(overshoot_length / fminf(overshoot_parameter, float(j)), segment_influence); if (invert_curvature) { curvature = -curvature; } @@ -1044,14 +1044,14 @@ bool BKE_gpencil_stroke_smooth_point(bGPDstroke *gps, (iterations * iterations) / 4 + 2 * iterations + 12; double w = keep_shape ? 2.0 : 1.0; double w2 = keep_shape ? - (1.0 / M_SQRT3) * exp((2 * iterations * iterations) / (double)(n_half * 3)) : + (1.0 / M_SQRT3) * exp((2 * iterations * iterations) / double(n_half * 3)) : 0.0; double total_w = 0.0; for (int step = iterations; step > 0; step--) { int before = point_index - step; int after = point_index + step; - float w_before = (float)(w - w2); - float w_after = (float)(w - w2); + float w_before = float(w - w2); + float w_after = float(w - w2); if (is_cyclic) { before = (before % gps->totpoints + gps->totpoints) % gps->totpoints; @@ -1060,13 +1060,13 @@ bool BKE_gpencil_stroke_smooth_point(bGPDstroke *gps, else { if (before < 0) { if (!smooth_caps) { - w_before *= -before / (float)point_index; + w_before *= -before / float(point_index); } before = 0; } if (after > gps->totpoints - 1) { if (!smooth_caps) { - w_after *= (after - (gps->totpoints - 1)) / (float)(gps->totpoints - 1 - point_index); + w_after *= (after - (gps->totpoints - 1)) / float(gps->totpoints - 1 - point_index); } after = gps->totpoints - 1; } @@ -1081,14 +1081,14 @@ bool BKE_gpencil_stroke_smooth_point(bGPDstroke *gps, total_w += w_before; total_w += w_after; - w *= (n_half + step) / (double)(n_half + 1 - step); - w2 *= (n_half * 3 + step) / (double)(n_half * 3 + 1 - step); + w *= (n_half + step) / double(n_half + 1 - step); + w2 *= (n_half * 3 + step) / double(n_half * 3 + 1 - step); } total_w += w - w2; /* The accumulated weight total_w should be * ~sqrt(M_PI * n_half) * exp((iterations * iterations) / n_half) < 100 * here, but sometimes not quite. */ - mul_v3_fl(sco, (float)(1.0 / total_w)); + mul_v3_fl(sco, float(1.0 / total_w)); /* Shift back to global coordinates. */ add_v3_v3(sco, &pt->x); @@ -1123,8 +1123,8 @@ bool BKE_gpencil_stroke_smooth_strength( for (int step = iterations; step > 0; step--) { int before = point_index - step; int after = point_index + step; - float w_before = (float)w; - float w_after = (float)w; + float w_before = float(w); + float w_after = float(w); if (is_cyclic) { before = (before % gps->totpoints + gps->totpoints) % gps->totpoints; @@ -1142,7 +1142,7 @@ bool BKE_gpencil_stroke_smooth_strength( total_w += w_before; total_w += w_after; - w *= (n_half + step) / (double)(n_half + 1 - step); + w *= (n_half + step) / double(n_half + 1 - step); } total_w += w; /* The accumulated weight total_w should be @@ -1181,8 +1181,8 @@ bool BKE_gpencil_stroke_smooth_thickness( for (int step = iterations; step > 0; step--) { int before = point_index - step; int after = point_index + step; - float w_before = (float)w; - float w_after = (float)w; + float w_before = float(w); + float w_after = float(w); if (is_cyclic) { before = (before % gps->totpoints + gps->totpoints) % gps->totpoints; @@ -1200,7 +1200,7 @@ bool BKE_gpencil_stroke_smooth_thickness( total_w += w_before; total_w += w_after; - w *= (n_half + step) / (double)(n_half + 1 - step); + w *= (n_half + step) / double(n_half + 1 - step); } total_w += w; /* The accumulated weight total_w should be @@ -1251,8 +1251,8 @@ bool BKE_gpencil_stroke_smooth_uv(struct bGPDstroke *gps, for (int step = iterations; step > 0; step--) { int before = point_index - step; int after = point_index + step; - float w_before = (float)w; - float w_after = (float)w; + float w_before = float(w); + float w_after = float(w); if (is_cyclic) { before = (before % gps->totpoints + gps->totpoints) % gps->totpoints; @@ -1260,11 +1260,11 @@ bool BKE_gpencil_stroke_smooth_uv(struct bGPDstroke *gps, } else { if (before < 0) { - w_before *= -before / (float)point_index; + w_before *= -before / float(point_index); before = 0; } if (after > gps->totpoints - 1) { - w_after *= (after - (gps->totpoints - 1)) / (float)(gps->totpoints - 1 - point_index); + w_after *= (after - (gps->totpoints - 1)) / float(gps->totpoints - 1 - point_index); after = gps->totpoints - 1; } } @@ -1278,7 +1278,7 @@ bool BKE_gpencil_stroke_smooth_uv(struct bGPDstroke *gps, total_w += w_before; total_w += w_after; - w *= (n_half + step) / (double)(n_half + 1 - step); + w *= (n_half + step) / double(n_half + 1 - step); } total_w += w; /* The accumulated weight total_w should be @@ -1353,7 +1353,7 @@ void BKE_gpencil_stroke_2d_flat(const bGPDspoint *points, const bGPDspoint *pt0 = &points[0]; const bGPDspoint *pt1 = &points[1]; - const bGPDspoint *pt3 = &points[(int)(totpoints * 0.75)]; + const bGPDspoint *pt3 = &points[int(totpoints * 0.75)]; float locx[3]; float locy[3]; @@ -1430,7 +1430,7 @@ void BKE_gpencil_stroke_2d_flat_ref(const bGPDspoint *ref_points, const bGPDspoint *pt0 = &ref_points[0]; const bGPDspoint *pt1 = &ref_points[1]; - const bGPDspoint *pt3 = &ref_points[(int)(ref_totpoints * 0.75)]; + const bGPDspoint *pt3 = &ref_points[int(ref_totpoints * 0.75)]; float locx[3]; float locy[3]; @@ -1499,7 +1499,7 @@ void BKE_gpencil_stroke_2d_flat_ref(const bGPDspoint *ref_points, } /* Concave (-1), Convex (1), or Auto-detect (0)? */ - *r_direction = (int)locy[2]; + *r_direction = int(locy[2]); } /* Calc texture coordinates using flat projected points. */ @@ -1564,7 +1564,7 @@ void BKE_gpencil_stroke_fill_triangulate(bGPDstroke *gps) /* convert to 2d and triangulate */ BKE_gpencil_stroke_2d_flat(gps->points, gps->totpoints, points2d, &direction); - BLI_polyfill_calc(points2d, (uint)gps->totpoints, direction, tmp_triangles); + BLI_polyfill_calc(points2d, uint(gps->totpoints), direction, tmp_triangles); /* calc texture coordinates automatically */ float minv[2]; @@ -1844,7 +1844,7 @@ bool BKE_gpencil_stroke_close(bGPDstroke *gps) pt2 = &gps->points[0]; bGPDspoint *pt = &gps->points[old_tot]; for (int i = 1; i < tot_newpoints + 1; i++, pt++) { - float step = (tot_newpoints > 1) ? ((float)i / (float)tot_newpoints) : 0.99f; + float step = (tot_newpoints > 1) ? (float(i) / float(tot_newpoints)) : 0.99f; /* Clamp last point to be near, but not on top of first point. */ if ((tot_newpoints > 1) && (i == tot_newpoints)) { step *= 0.99f; @@ -1988,7 +1988,7 @@ void BKE_gpencil_stroke_normal(const bGPDstroke *gps, float r_normal[3]) const bGPDspoint *pt0 = &points[0]; const bGPDspoint *pt1 = &points[1]; - const bGPDspoint *pt3 = &points[(int)(totpoints * 0.75)]; + const bGPDspoint *pt3 = &points[int(totpoints * 0.75)]; float vec1[3]; float vec2[3]; @@ -3117,7 +3117,7 @@ bGPDstroke *BKE_gpencil_stroke_delete_tagged_points(bGPdata *gpd, bGPDstroke *new_stroke = nullptr; bGPDstroke *gps_first = nullptr; - const bool is_cyclic = (bool)(gps->flag & GP_STROKE_CYCLIC); + const bool is_cyclic = bool(gps->flag & GP_STROKE_CYCLIC); /* First Pass: Identify start/end of islands */ bGPDspoint *pt = gps->points; @@ -3210,7 +3210,7 @@ bGPDstroke *BKE_gpencil_stroke_delete_tagged_points(bGPdata *gpd, float delta = gps->points[island->start_idx].time; int j; - new_stroke->inittime += (double)delta; + new_stroke->inittime += double(delta); pts = new_stroke->points; for (j = 0; j < new_stroke->totpoints; j++, pts++) { @@ -3502,7 +3502,7 @@ void BKE_gpencil_stroke_join(bGPDstroke *gps_a, /* Ratio to apply in the points to keep the same thickness in the joined stroke using the * destination stroke thickness. */ const float ratio = (fit_thickness && gps_a->thickness > 0.0f) ? - (float)gps_b->thickness / (float)gps_a->thickness : + float(gps_b->thickness) / float(gps_a->thickness) : 1.0f; /* 3rd: add all points */ @@ -3863,7 +3863,7 @@ static int generate_arc_from_point_to_point(ListBase *list, * points to insert. */ int num_points = (int)(((1 << (subdivisions + 1)) - 1) * (angle / M_PI)); if (num_points > 0) { - float angle_incr = angle / (float)num_points; + float angle_incr = angle / float(num_points); float vec_p[3]; float vec_t[3]; @@ -3918,7 +3918,7 @@ static int generate_semi_circle_from_point_to_point(ListBase *list, } float vec_p[3]; - float angle_incr = M_PI / ((float)num_points - 1); + float angle_incr = M_PI / (float(num_points) - 1); tPerimeterPoint *last_point = from; for (int i = 1; i < num_points; i++) { @@ -4324,7 +4324,7 @@ float BKE_gpencil_stroke_average_pressure_get(bGPDstroke *gps) tot += pt->pressure; } - return tot / (float)gps->totpoints; + return tot / float(gps->totpoints); } bool BKE_gpencil_stroke_is_pressure_constant(bGPDstroke *gps) diff --git a/source/blender/blenkernel/intern/icons.cc b/source/blender/blenkernel/intern/icons.cc index 76a02316e9f..82023c23ca5 100644 --- a/source/blender/blenkernel/intern/icons.cc +++ b/source/blender/blenkernel/intern/icons.cc @@ -479,7 +479,7 @@ PreviewImage *BKE_previewimg_cached_thumbnail_read(const char *name, if (prv && force_update) { const char *prv_deferred_data = (char *)PRV_DEFERRED_DATA(prv); - if (((int)prv_deferred_data[0] == source) && STREQ(&prv_deferred_data[1], filepath)) { + if ((int(prv_deferred_data[0]) == source) && STREQ(&prv_deferred_data[1], filepath)) { /* If same filepath, no need to re-allocate preview, just clear it up. */ BKE_previewimg_clear(prv); } diff --git a/source/blender/blenkernel/intern/image.cc b/source/blender/blenkernel/intern/image.cc index b06317fa511..567b99216e5 100644 --- a/source/blender/blenkernel/intern/image.cc +++ b/source/blender/blenkernel/intern/image.cc @@ -256,7 +256,7 @@ static void image_foreach_cache(ID *id, function_callback(id, &key, (void **)&image->rr, 0, user_data); LISTBASE_FOREACH (RenderSlot *, slot, &image->renderslots) { - key.offset_in_ID = (size_t)BLI_ghashutil_strhash_p(slot->name); + key.offset_in_ID = size_t(BLI_ghashutil_strhash_p(slot->name)); function_callback(id, &key, (void **)&slot->render, 0, user_data); } } @@ -846,8 +846,8 @@ int BKE_image_get_tile_from_pos(Image *ima, const float uv[2], float r_uv[2], fl return 0; } - int ix = (int)uv[0]; - int iy = (int)uv[1]; + int ix = int(uv[0]); + int iy = int(uv[1]); int tile_number = 1001 + 10 * iy + ix; if (BKE_image_get_tile(ima, tile_number) == nullptr) { @@ -1534,14 +1534,14 @@ void BKE_image_print_memlist(Main *bmain) totsize += image_mem_size(ima); } - printf("\ntotal image memory len: %.3f MB\n", (double)totsize / (double)(1024 * 1024)); + printf("\ntotal image memory len: %.3f MB\n", double(totsize) / double(1024 * 1024)); for (ima = static_cast(bmain->images.first); ima; ima = static_cast(ima->id.next)) { size = image_mem_size(ima); if (size) { - printf("%s len: %.3f MB\n", ima->id.name + 2, (double)size / (double)(1024 * 1024)); + printf("%s len: %.3f MB\n", ima->id.name + 2, double(size) / double(1024 * 1024)); } } } @@ -1967,7 +1967,7 @@ void BKE_image_stamp_buf(Scene *scene, * for now though this is only used for renders which use scene settings */ #define TEXT_SIZE_CHECK(str, w, h) \ - ((str[0]) && ((void)(h = h_fixed), (w = (int)BLF_width(mono, str, sizeof(str))))) + ((str[0]) && ((void)(h = h_fixed), (w = int(BLF_width(mono, str, sizeof(str)))))) /* must enable BLF_WORD_WRAP before using */ #define TEXT_SIZE_CHECK_WORD_WRAP(str, w, h) \ @@ -5187,8 +5187,8 @@ void BKE_image_get_size_fl(Image *image, ImageUser *iuser, float r_size[2]) int width, height; BKE_image_get_size(image, iuser, &width, &height); - r_size[0] = (float)width; - r_size[1] = (float)height; + r_size[0] = float(width); + r_size[1] = float(height); } void BKE_image_get_aspect(Image *image, float *r_aspx, float *r_aspy) diff --git a/source/blender/blenkernel/intern/image_gpu.cc b/source/blender/blenkernel/intern/image_gpu.cc index 08fdd715512..6893a50638a 100644 --- a/source/blender/blenkernel/intern/image_gpu.cc +++ b/source/blender/blenkernel/intern/image_gpu.cc @@ -551,7 +551,7 @@ void BKE_image_free_anim_gputextures(Main *bmain) void BKE_image_free_old_gputextures(Main *bmain) { static int lasttime = 0; - int ctime = (int)PIL_check_seconds_timer(); + int ctime = int(PIL_check_seconds_timer()); /* * Run garbage collector once for every collecting period of time @@ -602,8 +602,8 @@ static ImBuf *update_do_scale(uchar *rect, int full_h) { /* Partial update with scaling. */ - float xratio = limit_w / (float)full_w; - float yratio = limit_h / (float)full_h; + float xratio = limit_w / float(full_w); + float yratio = limit_h / float(full_h); int part_w = *w, part_h = *h; @@ -611,8 +611,8 @@ static ImBuf *update_do_scale(uchar *rect, * losing 1 pixel due to rounding errors in x,y. */ *x *= xratio; *y *= yratio; - *w = (int)ceil(xratio * (*w)); - *h = (int)ceil(yratio * (*h)); + *w = int(ceil(xratio * (*w))); + *h = int(ceil(yratio * (*h))); /* ...but take back if we are over the limit! */ if (*x + *w > limit_w) { diff --git a/source/blender/blenkernel/intern/main_namemap.cc b/source/blender/blenkernel/intern/main_namemap.cc index 82133204e19..5a8f90ea10a 100644 --- a/source/blender/blenkernel/intern/main_namemap.cc +++ b/source/blender/blenkernel/intern/main_namemap.cc @@ -62,7 +62,7 @@ static bool id_name_final_build(char *name, char *base_name, size_t base_name_le /* Code above may have generated invalid utf-8 string, due to raw truncation. * Ensure we get a valid one now. */ - base_name_len -= (size_t)BLI_str_utf8_invalid_strip(base_name, base_name_len); + base_name_len -= size_t(BLI_str_utf8_invalid_strip(base_name, base_name_len)); /* Also truncate orig name, and start the whole check again. */ name[base_name_len] = '\0'; diff --git a/source/blender/blenkernel/intern/mball.cc b/source/blender/blenkernel/intern/mball.cc index 91797f8ed2f..7c83bed85b0 100644 --- a/source/blender/blenkernel/intern/mball.cc +++ b/source/blender/blenkernel/intern/mball.cc @@ -529,7 +529,7 @@ bool BKE_mball_center_median(const MetaBall *mb, float r_cent[3]) } if (total) { - mul_v3_fl(r_cent, 1.0f / (float)total); + mul_v3_fl(r_cent, 1.0f / float(total)); } return (total != 0); diff --git a/source/blender/blenkernel/intern/mesh.cc b/source/blender/blenkernel/intern/mesh.cc index 6df6cd31cf4..7079a3e1ae8 100644 --- a/source/blender/blenkernel/intern/mesh.cc +++ b/source/blender/blenkernel/intern/mesh.cc @@ -1396,7 +1396,7 @@ void BKE_mesh_material_remap(Mesh *me, const uint *remap, uint remap_len) { using namespace blender; using namespace blender::bke; - const short remap_len_short = (short)remap_len; + const short remap_len_short = short(remap_len); #define MAT_NR_REMAP(n) \ if (n < remap_len_short) { \ @@ -1832,7 +1832,7 @@ void BKE_mesh_calc_normals_split_ex(Mesh *mesh, * only in case auto-smooth is enabled. */ const bool use_split_normals = (r_lnors_spacearr != nullptr) || ((mesh->flag & ME_AUTOSMOOTH) != 0); - const float split_angle = (mesh->flag & ME_AUTOSMOOTH) != 0 ? mesh->smoothresh : (float)M_PI; + const float split_angle = (mesh->flag & ME_AUTOSMOOTH) != 0 ? mesh->smoothresh : float(M_PI); /* may be nullptr */ clnors = (short(*)[2])CustomData_get_layer(&mesh->ldata, CD_CUSTOMLOOPNORMAL); diff --git a/source/blender/blenkernel/intern/mesh_convert.cc b/source/blender/blenkernel/intern/mesh_convert.cc index 1ad74ef693a..05ef6dc0b54 100644 --- a/source/blender/blenkernel/intern/mesh_convert.cc +++ b/source/blender/blenkernel/intern/mesh_convert.cc @@ -274,13 +274,13 @@ static Mesh *mesh_nurbs_displist_to_mesh(const Curve *cu, const ListBase *dispba mloop[0].v = startvert + index[0]; mloop[1].v = startvert + index[2]; mloop[2].v = startvert + index[1]; - mpoly->loopstart = (int)(mloop - loops.data()); + mpoly->loopstart = int(mloop - loops.data()); mpoly->totloop = 3; material_indices.span[mpoly - polys.data()] = dl->col; if (mloopuv) { for (int i = 0; i < 3; i++, mloopuv++) { - mloopuv->uv[0] = (mloop[i].v - startvert) / (float)(dl->nr - 1); + mloopuv->uv[0] = (mloop[i].v - startvert) / float(dl->nr - 1); mloopuv->uv[1] = 0.0f; } } @@ -334,7 +334,7 @@ static Mesh *mesh_nurbs_displist_to_mesh(const Curve *cu, const ListBase *dispba mloop[1].v = p3; mloop[2].v = p4; mloop[3].v = p2; - mpoly->loopstart = (int)(mloop - loops.data()); + mpoly->loopstart = int(mloop - loops.data()); mpoly->totloop = 4; material_indices.span[mpoly - polys.data()] = dl->col; @@ -357,8 +357,8 @@ static Mesh *mesh_nurbs_displist_to_mesh(const Curve *cu, const ListBase *dispba /* find uv based on vertex index into grid array */ int v = mloop[i].v - startvert; - mloopuv->uv[0] = (v / dl->nr) / (float)orco_sizev; - mloopuv->uv[1] = (v % dl->nr) / (float)orco_sizeu; + mloopuv->uv[0] = (v / dl->nr) / float(orco_sizev); + mloopuv->uv[1] = (v % dl->nr) / float(orco_sizeu); /* cyclic correction */ if ((ELEM(i, 1, 2)) && mloopuv->uv[0] == 0.0f) { @@ -1133,11 +1133,11 @@ static void add_shapekey_layers(Mesh *mesh_dest, Mesh *mesh_src) mesh_src->totvert, kb->name, kb->totelem); - array = (float *)MEM_calloc_arrayN((size_t)mesh_src->totvert, sizeof(float[3]), __func__); + array = (float *)MEM_calloc_arrayN(size_t(mesh_src->totvert), sizeof(float[3]), __func__); } else { - array = (float *)MEM_malloc_arrayN((size_t)mesh_src->totvert, sizeof(float[3]), __func__); - memcpy(array, kb->data, sizeof(float[3]) * (size_t)mesh_src->totvert); + array = (float *)MEM_malloc_arrayN(size_t(mesh_src->totvert), sizeof(float[3]), __func__); + memcpy(array, kb->data, sizeof(float[3]) * size_t(mesh_src->totvert)); } CustomData_add_layer_named( diff --git a/source/blender/blenkernel/intern/mesh_evaluate.cc b/source/blender/blenkernel/intern/mesh_evaluate.cc index 4f8391263a1..ae0d5efa112 100644 --- a/source/blender/blenkernel/intern/mesh_evaluate.cc +++ b/source/blender/blenkernel/intern/mesh_evaluate.cc @@ -150,7 +150,7 @@ static void mesh_calc_ngon_center(const MPoly *mpoly, const MVert *mvert, float cent[3]) { - const float w = 1.0f / (float)mpoly->totloop; + const float w = 1.0f / float(mpoly->totloop); zero_v3(cent); @@ -190,7 +190,7 @@ float BKE_mesh_calc_poly_area(const MPoly *mpoly, const MLoop *loopstart, const } const MLoop *l_iter = loopstart; - float(*vertexcos)[3] = (float(*)[3])BLI_array_alloca(vertexcos, (size_t)mpoly->totloop); + float(*vertexcos)[3] = (float(*)[3])BLI_array_alloca(vertexcos, size_t(mpoly->totloop)); /* pack vertex cos into an array for area_poly_v3 */ for (int i = 0; i < mpoly->totloop; i++, l_iter++) { @@ -198,7 +198,7 @@ float BKE_mesh_calc_poly_area(const MPoly *mpoly, const MLoop *loopstart, const } /* finally calculate the area */ - float area = area_poly_v3((const float(*)[3])vertexcos, (uint)mpoly->totloop); + float area = area_poly_v3((const float(*)[3])vertexcos, uint(mpoly->totloop)); return area; } @@ -221,7 +221,7 @@ float BKE_mesh_calc_poly_uv_area(const MPoly *mpoly, const MLoopUV *uv_array) int i, l_iter = mpoly->loopstart; float area; - float(*vertexcos)[2] = (float(*)[2])BLI_array_alloca(vertexcos, (size_t)mpoly->totloop); + float(*vertexcos)[2] = (float(*)[2])BLI_array_alloca(vertexcos, size_t(mpoly->totloop)); /* pack vertex cos into an array for area_poly_v2 */ for (i = 0; i < mpoly->totloop; i++, l_iter++) { @@ -229,7 +229,7 @@ float BKE_mesh_calc_poly_uv_area(const MPoly *mpoly, const MLoopUV *uv_array) } /* finally calculate the area */ - area = area_poly_v2(vertexcos, (uint)mpoly->totloop); + area = area_poly_v2(vertexcos, uint(mpoly->totloop)); return area; } @@ -407,7 +407,7 @@ bool BKE_mesh_center_median(const Mesh *me, float r_cent[3]) } /* otherwise we get NAN for 0 verts */ if (me->totvert) { - mul_v3_fl(r_cent, 1.0f / (float)me->totvert); + mul_v3_fl(r_cent, 1.0f / float(me->totvert)); } return (me->totvert != 0); } @@ -428,7 +428,7 @@ bool BKE_mesh_center_median_from_polys(const Mesh *me, float r_cent[3]) } /* otherwise we get NAN for 0 verts */ if (me->totpoly) { - mul_v3_fl(r_cent, 1.0f / (float)tot); + mul_v3_fl(r_cent, 1.0f / float(tot)); } return (me->totpoly != 0); } @@ -638,7 +638,7 @@ void BKE_mesh_mdisp_flip(MDisps *md, const bool use_loop_mdisp_flip) return; } - const int sides = (int)sqrt(md->totdisp); + const int sides = int(sqrt(md->totdisp)); float(*co)[3] = md->disps; for (int x = 0; x < sides; x++) { @@ -922,9 +922,9 @@ void BKE_mesh_calc_relative_deform(const MPoly *mpoly, const MPoly *mp; int i; - int *vert_accum = (int *)MEM_calloc_arrayN((size_t)totvert, sizeof(*vert_accum), __func__); + int *vert_accum = (int *)MEM_calloc_arrayN(size_t(totvert), sizeof(*vert_accum), __func__); - memset(vert_cos_new, '\0', sizeof(*vert_cos_new) * (size_t)totvert); + memset(vert_cos_new, '\0', sizeof(*vert_cos_new) * size_t(totvert)); for (i = 0, mp = mpoly; i < totpoly; i++, mp++) { const MLoop *loopstart = mloop + mp->loopstart; @@ -952,7 +952,7 @@ void BKE_mesh_calc_relative_deform(const MPoly *mpoly, for (i = 0; i < totvert; i++) { if (vert_accum[i]) { - mul_v3_fl(vert_cos_new[i], 1.0f / (float)vert_accum[i]); + mul_v3_fl(vert_cos_new[i], 1.0f / float(vert_accum[i])); } else { copy_v3_v3(vert_cos_new[i], vert_cos_org[i]); diff --git a/source/blender/blenkernel/intern/mesh_fair.cc b/source/blender/blenkernel/intern/mesh_fair.cc index 41dcb3501cc..bb0a5610cf4 100644 --- a/source/blender/blenkernel/intern/mesh_fair.cc +++ b/source/blender/blenkernel/intern/mesh_fair.cc @@ -82,7 +82,7 @@ class FairingContext { LoopWeight *loop_weight) { - fair_verts_ex(affected, (int)depth, vertex_weight, loop_weight); + fair_verts_ex(affected, int(depth), vertex_weight, loop_weight); } protected: diff --git a/source/blender/blenkernel/intern/mesh_legacy_convert.cc b/source/blender/blenkernel/intern/mesh_legacy_convert.cc index 2c75c477b9a..b68117b7eb2 100644 --- a/source/blender/blenkernel/intern/mesh_legacy_convert.cc +++ b/source/blender/blenkernel/intern/mesh_legacy_convert.cc @@ -110,24 +110,24 @@ static void bm_corners_to_loops_ex(ID *id, BLI_assert(fd->totdisp == 0); } else { - const int side = (int)sqrtf((float)(fd->totdisp / corners)); + const int side = int(sqrtf(float(fd->totdisp / corners))); const int side_sq = side * side; for (int i = 0; i < tot; i++, disps += side_sq, ld++) { ld->totdisp = side_sq; - ld->level = (int)(logf((float)side - 1.0f) / (float)M_LN2) + 1; + ld->level = int(logf(float(side) - 1.0f) / float(M_LN2)) + 1; if (ld->disps) { MEM_freeN(ld->disps); } ld->disps = (float(*)[3])MEM_malloc_arrayN( - (size_t)side_sq, sizeof(float[3]), "converted loop mdisps"); + size_t(side_sq), sizeof(float[3]), "converted loop mdisps"); if (fd->disps) { - memcpy(ld->disps, disps, (size_t)side_sq * sizeof(float[3])); + memcpy(ld->disps, disps, size_t(side_sq) * sizeof(float[3])); } else { - memset(ld->disps, 0, (size_t)side_sq * sizeof(float[3])); + memset(ld->disps, 0, size_t(side_sq) * sizeof(float[3])); } } } @@ -212,7 +212,7 @@ static void convert_mfaces_to_mpolys(ID *id, CustomData_external_read(fdata, id, CD_MASK_MDISPS, totface_i); } - eh = BLI_edgehash_new_ex(__func__, (uint)totedge_i); + eh = BLI_edgehash_new_ex(__func__, uint(totedge_i)); /* build edge hash */ me = medge; @@ -609,15 +609,15 @@ static int mesh_tessface_calc(CustomData *fdata, * if all faces are triangles it will be correct, `quads == 2x` allocations. */ /* Take care since memory is _not_ zeroed so be sure to initialize each field. */ mface_to_poly_map = (int *)MEM_malloc_arrayN( - (size_t)looptri_num, sizeof(*mface_to_poly_map), __func__); - mface = (MFace *)MEM_malloc_arrayN((size_t)looptri_num, sizeof(*mface), __func__); - lindices = (uint(*)[4])MEM_malloc_arrayN((size_t)looptri_num, sizeof(*lindices), __func__); + size_t(looptri_num), sizeof(*mface_to_poly_map), __func__); + mface = (MFace *)MEM_malloc_arrayN(size_t(looptri_num), sizeof(*mface), __func__); + lindices = (uint(*)[4])MEM_malloc_arrayN(size_t(looptri_num), sizeof(*lindices), __func__); mface_index = 0; mp = mpoly; for (poly_index = 0; poly_index < totpoly; poly_index++, mp++) { - const uint mp_loopstart = (uint)mp->loopstart; - const uint mp_totloop = (uint)mp->totloop; + const uint mp_loopstart = uint(mp->loopstart); + const uint mp_totloop = uint(mp->totloop); uint l1, l2, l3, l4; uint *lidx; if (mp_totloop < 3) { @@ -701,8 +701,8 @@ static int mesh_tessface_calc(CustomData *fdata, arena = BLI_memarena_new(BLI_MEMARENA_STD_BUFSIZE, __func__); } - tris = (uint(*)[3])BLI_memarena_alloc(arena, sizeof(*tris) * (size_t)totfilltri); - projverts = (float(*)[2])BLI_memarena_alloc(arena, sizeof(*projverts) * (size_t)mp_totloop); + tris = (uint(*)[3])BLI_memarena_alloc(arena, sizeof(*tris) * size_t(totfilltri)); + projverts = (float(*)[2])BLI_memarena_alloc(arena, sizeof(*projverts) * size_t(mp_totloop)); zero_v3(normal); @@ -774,9 +774,9 @@ static int mesh_tessface_calc(CustomData *fdata, /* Not essential but without this we store over-allocated memory in the #CustomData layers. */ if (LIKELY(looptri_num != totface)) { - mface = (MFace *)MEM_reallocN(mface, sizeof(*mface) * (size_t)totface); + mface = (MFace *)MEM_reallocN(mface, sizeof(*mface) * size_t(totface)); mface_to_poly_map = (int *)MEM_reallocN(mface_to_poly_map, - sizeof(*mface_to_poly_map) * (size_t)totface); + sizeof(*mface_to_poly_map) * size_t(totface)); } CustomData_add_layer(fdata, CD_MFACE, CD_ASSIGN, mface, totface); diff --git a/source/blender/blenkernel/intern/mesh_mapping.cc b/source/blender/blenkernel/intern/mesh_mapping.cc index e7f5ce03c40..bd3902298b2 100644 --- a/source/blender/blenkernel/intern/mesh_mapping.cc +++ b/source/blender/blenkernel/intern/mesh_mapping.cc @@ -64,7 +64,7 @@ UvVertMap *BKE_mesh_uv_vert_map_create(const MPoly *mpoly, } vmap = (UvVertMap *)MEM_callocN(sizeof(*vmap), "UvVertMap"); - buf = vmap->buf = (UvMapVert *)MEM_callocN(sizeof(*vmap->buf) * (size_t)totuv, "UvMapVert"); + buf = vmap->buf = (UvMapVert *)MEM_callocN(sizeof(*vmap->buf) * size_t(totuv), "UvMapVert"); vmap->vert = (UvMapVert **)MEM_callocN(sizeof(*vmap->vert) * totvert, "UvMapVert*"); if (use_winding) { winding = static_cast(MEM_callocN(sizeof(*winding) * totpoly, "winding")); @@ -81,13 +81,13 @@ UvVertMap *BKE_mesh_uv_vert_map_create(const MPoly *mpoly, float(*tf_uv)[2] = NULL; if (use_winding) { - tf_uv = (float(*)[2])BLI_buffer_reinit_data(&tf_uv_buf, vec2f, (size_t)mp->totloop); + tf_uv = (float(*)[2])BLI_buffer_reinit_data(&tf_uv_buf, vec2f, size_t(mp->totloop)); } nverts = mp->totloop; for (i = 0; i < nverts; i++) { - buf->loop_of_poly_index = (ushort)i; + buf->loop_of_poly_index = ushort(i); buf->poly_index = a; buf->separate = 0; buf->next = vmap->vert[mloop[mp->loopstart + i].v]; @@ -101,7 +101,7 @@ UvVertMap *BKE_mesh_uv_vert_map_create(const MPoly *mpoly, } if (use_winding) { - winding[a] = cross_poly_v2(tf_uv, (uint)nverts) > 0; + winding[a] = cross_poly_v2(tf_uv, uint(nverts)) > 0; } } } @@ -196,11 +196,11 @@ static void mesh_vert_poly_or_loop_map_create(MeshElemMap **r_map, int totloop, const bool do_loops) { - MeshElemMap *map = MEM_cnew_array((size_t)totvert, __func__); + MeshElemMap *map = MEM_cnew_array(size_t(totvert), __func__); int *indices, *index_iter; int i, j; - indices = static_cast(MEM_mallocN(sizeof(int) * (size_t)totloop, __func__)); + indices = static_cast(MEM_mallocN(sizeof(int) * size_t(totloop), __func__)); index_iter = indices; /* Count number of polys for each vertex */ @@ -268,8 +268,8 @@ void BKE_mesh_vert_looptri_map_create(MeshElemMap **r_map, const MLoop *mloop, const int UNUSED(totloop)) { - MeshElemMap *map = MEM_cnew_array((size_t)totvert, __func__); - int *indices = static_cast(MEM_mallocN(sizeof(int) * (size_t)totlooptri * 3, __func__)); + MeshElemMap *map = MEM_cnew_array(size_t(totvert), __func__); + int *indices = static_cast(MEM_mallocN(sizeof(int) * size_t(totlooptri) * 3, __func__)); int *index_step; const MLoopTri *mlt; int i; @@ -306,8 +306,8 @@ void BKE_mesh_vert_looptri_map_create(MeshElemMap **r_map, void BKE_mesh_vert_edge_map_create( MeshElemMap **r_map, int **r_mem, const MEdge *medge, int totvert, int totedge) { - MeshElemMap *map = MEM_cnew_array((size_t)totvert, __func__); - int *indices = static_cast(MEM_mallocN(sizeof(int[2]) * (size_t)totedge, __func__)); + MeshElemMap *map = MEM_cnew_array(size_t(totvert), __func__); + int *indices = static_cast(MEM_mallocN(sizeof(int[2]) * size_t(totedge), __func__)); int *i_pt = indices; int i; @@ -345,8 +345,8 @@ void BKE_mesh_vert_edge_map_create( void BKE_mesh_vert_edge_vert_map_create( MeshElemMap **r_map, int **r_mem, const MEdge *medge, int totvert, int totedge) { - MeshElemMap *map = MEM_cnew_array((size_t)totvert, __func__); - int *indices = static_cast(MEM_mallocN(sizeof(int[2]) * (size_t)totedge, __func__)); + MeshElemMap *map = MEM_cnew_array(size_t(totvert), __func__); + int *indices = static_cast(MEM_mallocN(sizeof(int[2]) * size_t(totedge), __func__)); int *i_pt = indices; int i; @@ -370,8 +370,8 @@ void BKE_mesh_vert_edge_vert_map_create( for (i = 0; i < totedge; i++) { const uint v[2] = {medge[i].v1, medge[i].v2}; - map[v[0]].indices[map[v[0]].count] = (int)v[1]; - map[v[1]].indices[map[v[1]].count] = (int)v[0]; + map[v[0]].indices[map[v[0]].count] = int(v[1]); + map[v[1]].indices[map[v[1]].count] = int(v[0]); map[v[0]].count++; map[v[1]].count++; @@ -390,8 +390,8 @@ void BKE_mesh_edge_loop_map_create(MeshElemMap **r_map, const MLoop *mloop, const int totloop) { - MeshElemMap *map = MEM_cnew_array((size_t)totedge, __func__); - int *indices = static_cast(MEM_mallocN(sizeof(int) * (size_t)totloop * 2, __func__)); + MeshElemMap *map = MEM_cnew_array(size_t(totedge), __func__); + int *indices = static_cast(MEM_mallocN(sizeof(int) * size_t(totloop) * 2, __func__)); int *index_step; const MPoly *mp; int i; @@ -443,8 +443,8 @@ void BKE_mesh_edge_poly_map_create(MeshElemMap **r_map, const MLoop *mloop, const int totloop) { - MeshElemMap *map = MEM_cnew_array((size_t)totedge, __func__); - int *indices = static_cast(MEM_mallocN(sizeof(int) * (size_t)totloop, __func__)); + MeshElemMap *map = MEM_cnew_array(size_t(totedge), __func__); + int *indices = static_cast(MEM_mallocN(sizeof(int) * size_t(totloop), __func__)); int *index_step; const MPoly *mp; int i; @@ -488,8 +488,8 @@ void BKE_mesh_origindex_map_create(MeshElemMap **r_map, const int *final_origindex, const int totfinal) { - MeshElemMap *map = MEM_cnew_array((size_t)totsource, __func__); - int *indices = static_cast(MEM_mallocN(sizeof(int) * (size_t)totfinal, __func__)); + MeshElemMap *map = MEM_cnew_array(size_t(totsource), __func__); + int *indices = static_cast(MEM_mallocN(sizeof(int) * size_t(totfinal), __func__)); int *index_step; int i; @@ -530,8 +530,8 @@ void BKE_mesh_origindex_map_create_looptri(MeshElemMap **r_map, const MLoopTri *looptri, const int looptri_num) { - MeshElemMap *map = MEM_cnew_array((size_t)mpoly_num, __func__); - int *indices = static_cast(MEM_mallocN(sizeof(int) * (size_t)looptri_num, __func__)); + MeshElemMap *map = MEM_cnew_array(size_t(mpoly_num), __func__); + int *indices = static_cast(MEM_mallocN(sizeof(int) * size_t(looptri_num), __func__)); int *index_step; int i; @@ -662,7 +662,7 @@ static void poly_edge_loop_islands_calc(const MEdge *medge, mp = &mpoly[poly]; for (ml = &mloop[mp->loopstart], j = mp->totloop; j--; ml++) { /* loop over poly users */ - const int me_idx = (int)ml->e; + const int me_idx = int(ml->e); const MEdge *me = &medge[me_idx]; const MeshElemMap *map_ele = &edge_poly_map[me_idx]; const int *p = map_ele->indices; @@ -1097,7 +1097,7 @@ static bool mesh_calc_islands_loop_poly_uv(const MVert *UNUSED(verts), (edge_border_count[ml->e] < 2)) { edge_border_count[ml->e]++; if (edge_border_count[ml->e] == 2) { - edge_innercut_indices[num_einnercuts++] = (int)ml->e; + edge_innercut_indices[num_einnercuts++] = int(ml->e); } } } diff --git a/source/blender/blenkernel/intern/mesh_merge_customdata.cc b/source/blender/blenkernel/intern/mesh_merge_customdata.cc index f7936d8a4da..2c500f4d972 100644 --- a/source/blender/blenkernel/intern/mesh_merge_customdata.cc +++ b/source/blender/blenkernel/intern/mesh_merge_customdata.cc @@ -69,7 +69,7 @@ static void merge_uvs_for_vertex(const Span loops_for_vert, Span BLI_assert(loops_merge.is_empty()); loops_merge.extend_unchecked(loops_for_vert); while (loops_merge.size() > 1) { - uint i_last = (uint)loops_merge.size() - 1; + uint i_last = uint(loops_merge.size()) - 1; const float *uv_src = mloopuv[loops_merge[0]].uv; for (uint i = 1; i <= i_last;) { float *uv_dst = mloopuv[loops_merge[i]].uv; 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); diff --git a/source/blender/blenkernel/intern/mesh_remesh_voxel.cc b/source/blender/blenkernel/intern/mesh_remesh_voxel.cc index 3c492e2e167..62354c83df1 100644 --- a/source/blender/blenkernel/intern/mesh_remesh_voxel.cc +++ b/source/blender/blenkernel/intern/mesh_remesh_voxel.cc @@ -407,8 +407,8 @@ void BKE_remesh_reproject_vertex_paint(Mesh *target, const Mesh *source) bvhtree.tree, target_verts[i].co, &nearest, bvhtree.nearest_callback, &bvhtree); if (nearest.index != -1) { - memcpy(POINTER_OFFSET(target_data, (size_t)i * data_size), - POINTER_OFFSET(source_data, (size_t)nearest.index * data_size), + memcpy(POINTER_OFFSET(target_data, size_t(i) * data_size), + POINTER_OFFSET(source_data, size_t(nearest.index) * data_size), data_size); } } @@ -469,11 +469,11 @@ void BKE_remesh_reproject_vertex_paint(Mesh *target, const Mesh *source) source_loops->count, target_loops->indices[0]); - void *elem = POINTER_OFFSET(target_data, (size_t)target_loops->indices[0] * data_size); + void *elem = POINTER_OFFSET(target_data, size_t(target_loops->indices[0]) * data_size); /* Copy to rest of target loops. */ for (int j = 1; j < target_loops->count; j++) { - memcpy(POINTER_OFFSET(target_data, (size_t)target_loops->indices[j] * data_size), + memcpy(POINTER_OFFSET(target_data, size_t(target_loops->indices[j]) * data_size), elem, data_size); } @@ -586,7 +586,7 @@ struct Mesh *BKE_mesh_remesh_voxel_fix_poles(const Mesh *mesh) BMVert *vert = BM_edge_other_vert(ed, v); add_v3_v3(co, vert->co); } - mul_v3_fl(co, 1.0f / (float)BM_vert_edge_count(v)); + mul_v3_fl(co, 1.0f / float(BM_vert_edge_count(v))); mid_v3_v3v3(v->co, v->co, co); } } diff --git a/source/blender/blenkernel/intern/mesh_tangent.cc b/source/blender/blenkernel/intern/mesh_tangent.cc index 8f9af5e9258..7c12e15ca7b 100644 --- a/source/blender/blenkernel/intern/mesh_tangent.cc +++ b/source/blender/blenkernel/intern/mesh_tangent.cc @@ -36,34 +36,34 @@ struct BKEMeshToTangent { uint GetNumFaces() { - return (uint)num_polys; + return uint(num_polys); } uint GetNumVerticesOfFace(const uint face_num) { - return (uint)mpolys[face_num].totloop; + return uint(mpolys[face_num].totloop); } mikk::float3 GetPosition(const uint face_num, const uint vert_num) { - const uint loop_idx = (uint)mpolys[face_num].loopstart + vert_num; + const uint loop_idx = uint(mpolys[face_num].loopstart) + vert_num; return mikk::float3(mverts[mloops[loop_idx].v].co); } mikk::float3 GetTexCoord(const uint face_num, const uint vert_num) { - const float *uv = luvs[(uint)mpolys[face_num].loopstart + vert_num].uv; + const float *uv = luvs[uint(mpolys[face_num].loopstart) + vert_num].uv; return mikk::float3(uv[0], uv[1], 1.0f); } mikk::float3 GetNormal(const uint face_num, const uint vert_num) { - return mikk::float3(lnors[(uint)mpolys[face_num].loopstart + vert_num]); + return mikk::float3(lnors[uint(mpolys[face_num].loopstart) + vert_num]); } void SetTangentSpace(const uint face_num, const uint vert_num, mikk::float3 T, bool orientation) { - float *p_res = tangents[(uint)mpolys[face_num].loopstart + vert_num]; + float *p_res = tangents[uint(mpolys[face_num].loopstart) + vert_num]; copy_v4_fl4(p_res, T.x, T.y, T.z, orientation ? 1.0f : -1.0f); } @@ -166,9 +166,9 @@ struct SGLSLMeshToTangent { uint GetNumFaces() { #ifdef USE_LOOPTRI_DETECT_QUADS - return (uint)num_face_as_quad_map; + return uint(num_face_as_quad_map); #else - return (uint)numTessFaces; + return uint(numTessFaces); #endif } @@ -196,7 +196,7 @@ struct SGLSLMeshToTangent { lt = &looptri[face_as_quad_map[face_num]]; const MPoly *mp = &mpoly[lt->poly]; if (mp->totloop == 4) { - return ((uint)mp->loopstart + vert_num); + return (uint(mp->loopstart) + vert_num); } /* fall through to regular triangle */ } @@ -382,7 +382,7 @@ void BKE_mesh_calc_loop_tangent_step_0(const CustomData *loopData, add = true; } if (add) { - *rtangent_mask |= (short)(1 << n); + *rtangent_mask |= short(1 << n); } } @@ -437,21 +437,21 @@ void BKE_mesh_calc_loop_tangent_ex(const MVert *mvert, for (int i = 0; i < tangent_names_len; i++) { if (tangent_names[i][0]) { BKE_mesh_add_loop_tangent_named_layer_for_uv( - loopdata, loopdata_out, (int)loopdata_out_len, tangent_names[i]); + loopdata, loopdata_out, int(loopdata_out_len), tangent_names[i]); } } if ((tangent_mask & DM_TANGENT_MASK_ORCO) && CustomData_get_named_layer_index(loopdata, CD_TANGENT, "") == -1) { CustomData_add_layer_named( - loopdata_out, CD_TANGENT, CD_SET_DEFAULT, nullptr, (int)loopdata_out_len, ""); + loopdata_out, CD_TANGENT, CD_SET_DEFAULT, nullptr, int(loopdata_out_len), ""); } if (calc_act && act_uv_name[0]) { BKE_mesh_add_loop_tangent_named_layer_for_uv( - loopdata, loopdata_out, (int)loopdata_out_len, act_uv_name); + loopdata, loopdata_out, int(loopdata_out_len), act_uv_name); } if (calc_ren && ren_uv_name[0]) { BKE_mesh_add_loop_tangent_named_layer_for_uv( - loopdata, loopdata_out, (int)loopdata_out_len, ren_uv_name); + loopdata, loopdata_out, int(loopdata_out_len), ren_uv_name); } #ifdef USE_LOOPTRI_DETECT_QUADS @@ -465,7 +465,7 @@ void BKE_mesh_calc_loop_tangent_ex(const MVert *mvert, /* map fake face index to looptri */ face_as_quad_map = static_cast(MEM_mallocN(sizeof(int) * looptri_len, __func__)); int k, j; - for (k = 0, j = 0; j < (int)looptri_len; k++, j++) { + for (k = 0, j = 0; j < int(looptri_len); k++, j++) { face_as_quad_map[k] = j; /* step over all quads */ if (mpoly[looptri[j].poly].totloop == 4) { @@ -475,7 +475,7 @@ void BKE_mesh_calc_loop_tangent_ex(const MVert *mvert, num_face_as_quad_map = k; } else { - num_face_as_quad_map = (int)looptri_len; + num_face_as_quad_map = int(looptri_len); } #endif @@ -491,7 +491,7 @@ void BKE_mesh_calc_loop_tangent_ex(const MVert *mvert, int index = CustomData_get_layer_index_n(loopdata_out, CD_TANGENT, n); BLI_assert(n < MAX_MTFACE); SGLSLMeshToTangent *mesh2tangent = &data_array[n]; - mesh2tangent->numTessFaces = (int)looptri_len; + mesh2tangent->numTessFaces = int(looptri_len); #ifdef USE_LOOPTRI_DETECT_QUADS mesh2tangent->face_as_quad_map = face_as_quad_map; mesh2tangent->num_face_as_quad_map = num_face_as_quad_map; @@ -525,7 +525,7 @@ void BKE_mesh_calc_loop_tangent_ex(const MVert *mvert, int uv_start = CustomData_get_layer_index(loopdata, CD_MLOOPUV); BLI_assert(uv_ind != -1 && uv_start != -1); BLI_assert(uv_ind - uv_start < MAX_MTFACE); - tangent_mask_curr |= (short)(1 << (uv_ind - uv_start)); + tangent_mask_curr |= short(1 << (uv_ind - uv_start)); } mesh2tangent->tangent = static_cast(loopdata_out->layers[index].data); @@ -583,10 +583,10 @@ void BKE_mesh_calc_loop_tangents(Mesh *me_eval, BKE_mesh_calc_loop_tangent_ex( BKE_mesh_verts(me_eval), BKE_mesh_polys(me_eval), - (uint)me_eval->totpoly, + uint(me_eval->totpoly), BKE_mesh_loops(me_eval), me_eval->runtime.looptris.array, - (uint)me_eval->runtime.looptris.len, + uint(me_eval->runtime.looptris.len), &me_eval->ldata, calc_active_tangent, tangent_names, @@ -598,7 +598,7 @@ void BKE_mesh_calc_loop_tangents(Mesh *me_eval, static_cast(CustomData_get_layer(&me_eval->vdata, CD_ORCO)), /* result */ &me_eval->ldata, - (uint)me_eval->totloop, + uint(me_eval->totloop), &tangent_mask); } diff --git a/source/blender/blenkernel/intern/mesh_tessellate.cc b/source/blender/blenkernel/intern/mesh_tessellate.cc index de4c60b28db..88f78197566 100644 --- a/source/blender/blenkernel/intern/mesh_tessellate.cc +++ b/source/blender/blenkernel/intern/mesh_tessellate.cc @@ -49,8 +49,8 @@ BLI_INLINE void mesh_calc_tessellation_for_face_impl(const MLoop *mloop, const bool face_normal, const float normal_precalc[3]) { - const uint mp_loopstart = (uint)mpoly[poly_index].loopstart; - const uint mp_totloop = (uint)mpoly[poly_index].totloop; + const uint mp_loopstart = uint(mpoly[poly_index].loopstart); + const uint mp_totloop = uint(mpoly[poly_index].totloop); #define ML_TO_MLT(i1, i2, i3) \ { \ @@ -125,9 +125,9 @@ BLI_INLINE void mesh_calc_tessellation_for_face_impl(const MLoop *mloop, } uint(*tris)[3] = static_cast( - BLI_memarena_alloc(pf_arena, sizeof(*tris) * (size_t)totfilltri)); + BLI_memarena_alloc(pf_arena, sizeof(*tris) * size_t(totfilltri))); float(*projverts)[2] = static_cast( - BLI_memarena_alloc(pf_arena, sizeof(*projverts) * (size_t)mp_totloop)); + BLI_memarena_alloc(pf_arena, sizeof(*projverts) * size_t(mp_totloop))); ml = mloop + mp_loopstart; for (uint j = 0; j < mp_totloop; j++, ml++) { @@ -186,7 +186,7 @@ static void mesh_recalc_looptri__single_threaded(const MLoop *mloop, uint tri_index = 0; if (poly_normals != nullptr) { - for (uint poly_index = 0; poly_index < (uint)totpoly; poly_index++, mp++) { + for (uint poly_index = 0; poly_index < uint(totpoly); poly_index++, mp++) { mesh_calc_tessellation_for_face_with_normal(mloop, mpoly, mvert, @@ -194,14 +194,14 @@ static void mesh_recalc_looptri__single_threaded(const MLoop *mloop, &mlooptri[tri_index], &pf_arena, poly_normals[poly_index]); - tri_index += (uint)(mp->totloop - 2); + tri_index += uint(mp->totloop - 2); } } else { - for (uint poly_index = 0; poly_index < (uint)totpoly; poly_index++, mp++) { + for (uint poly_index = 0; poly_index < uint(totpoly); poly_index++, mp++) { mesh_calc_tessellation_for_face( mloop, mpoly, mvert, poly_index, &mlooptri[tri_index], &pf_arena); - tri_index += (uint)(mp->totloop - 2); + tri_index += uint(mp->totloop - 2); } } @@ -209,7 +209,7 @@ static void mesh_recalc_looptri__single_threaded(const MLoop *mloop, BLI_memarena_free(pf_arena); pf_arena = nullptr; } - BLI_assert(tri_index == (uint)poly_to_tri_count(totpoly, totloop)); + BLI_assert(tri_index == uint(poly_to_tri_count(totpoly, totloop))); UNUSED_VARS_NDEBUG(totloop); } @@ -239,7 +239,7 @@ static void mesh_calc_tessellation_for_face_fn(void *__restrict userdata, mesh_calc_tessellation_for_face_impl(data->mloop, data->mpoly, data->mvert, - (uint)index, + uint(index), &data->mlooptri[tri_index], &tls_data->pf_arena, false, @@ -256,7 +256,7 @@ static void mesh_calc_tessellation_for_face_with_normal_fn(void *__restrict user mesh_calc_tessellation_for_face_impl(data->mloop, data->mpoly, data->mvert, - (uint)index, + uint(index), &data->mlooptri[tri_index], &tls_data->pf_arena, true, diff --git a/source/blender/blenkernel/intern/mesh_validate.cc b/source/blender/blenkernel/intern/mesh_validate.cc index 47de7245ccc..95f885c45dd 100644 --- a/source/blender/blenkernel/intern/mesh_validate.cc +++ b/source/blender/blenkernel/intern/mesh_validate.cc @@ -987,7 +987,7 @@ static bool mesh_validate_customdata(CustomData *data, } } - PRINT_MSG("%s: Finished (is_valid=%d)\n\n", __func__, (int)!has_fixes); + PRINT_MSG("%s: Finished (is_valid=%d)\n\n", __func__, int(!has_fixes)); *r_change = has_fixes; diff --git a/source/blender/blenkernel/intern/node.cc b/source/blender/blenkernel/intern/node.cc index 081f30c4329..bc4fb3191e3 100644 --- a/source/blender/blenkernel/intern/node.cc +++ b/source/blender/blenkernel/intern/node.cc @@ -374,7 +374,7 @@ static void node_foreach_cache(ID *id, if (nodetree->type == NTREE_COMPOSIT) { LISTBASE_FOREACH (bNode *, node, &nodetree->nodes) { if (node->type == CMP_NODE_MOVIEDISTORTION) { - key.offset_in_ID = (size_t)BLI_ghashutil_strhash_p(node->name); + key.offset_in_ID = size_t(BLI_ghashutil_strhash_p(node->name)); function_callback(id, &key, (void **)&node->storage, 0, user_data); } } diff --git a/source/blender/blenkernel/intern/node_tree_update.cc b/source/blender/blenkernel/intern/node_tree_update.cc index f9bab0959c9..44ca2752782 100644 --- a/source/blender/blenkernel/intern/node_tree_update.cc +++ b/source/blender/blenkernel/intern/node_tree_update.cc @@ -1432,7 +1432,7 @@ class NodeTreeMainUpdater { } /* When the hashes for the linked sockets are ready, combine them into a hash for the input * socket. */ - const uint64_t socket_ptr = (uintptr_t)&socket; + const uint64_t socket_ptr = uintptr_t(&socket); uint32_t socket_hash = noise::hash(socket_ptr, socket_ptr >> 32); for (const bNodeSocket *origin_socket : socket.logically_linked_sockets()) { const uint32_t origin_socket_hash = *hash_by_socket_id[origin_socket->index_in_tree()]; @@ -1457,7 +1457,7 @@ class NodeTreeMainUpdater { } /* When all input socket hashes have been computed, combine them into a hash for the output * socket. */ - const uint64_t socket_ptr = (uintptr_t)&socket; + const uint64_t socket_ptr = uintptr_t(&socket); uint32_t socket_hash = noise::hash(socket_ptr, socket_ptr >> 32); for (const bNodeSocket *input_socket : node.input_sockets()) { if (input_socket->is_available()) { diff --git a/source/blender/blenkernel/intern/object_dupli.cc b/source/blender/blenkernel/intern/object_dupli.cc index e7410b06deb..4d9b4baaffc 100644 --- a/source/blender/blenkernel/intern/object_dupli.cc +++ b/source/blender/blenkernel/intern/object_dupli.cc @@ -211,7 +211,7 @@ static DupliObject *make_dupli( if (dob->persistent_id[0] != INT_MAX) { for (i = 0; i < MAX_DUPLI_RECUR; i++) { - dob->random_id = BLI_hash_int_2d(dob->random_id, (uint)dob->persistent_id[i]); + dob->random_id = BLI_hash_int_2d(dob->random_id, uint(dob->persistent_id[i])); } } else { @@ -727,7 +727,7 @@ static void make_duplis_font(const DupliContext *ctx) /* XXX That G.main is *really* ugly, but not sure what to do here. * Definitively don't think it would be safe to put back `Main *bmain` pointer * in #DupliContext as done in 2.7x? */ - ob = find_family_object(G.main, cu->family, family_len, (uint)text[a], family_gh); + ob = find_family_object(G.main, cu->family, family_len, uint(text[a]), family_gh); if (is_eval_curve) { /* Workaround for the above hack. */ @@ -953,7 +953,7 @@ static void get_dupliface_transform_from_coords(Span coords, for (const float3 &coord : coords) { location += coord; } - location *= 1.0f / (float)coords.size(); + location *= 1.0f / float(coords.size()); /* Rotation. */ float quat[4]; @@ -964,7 +964,7 @@ static void get_dupliface_transform_from_coords(Span coords, /* Scale. */ float scale; if (use_scale) { - const float area = area_poly_v3((const float(*)[3])coords.data(), (uint)coords.size()); + const float area = area_poly_v3((const float(*)[3])coords.data(), uint(coords.size())); scale = sqrtf(area) * scale_fac; } else { @@ -1094,7 +1094,7 @@ static void make_child_duplis_faces_from_mesh(const DupliContext *ctx, DupliObject *dob = face_dupli_from_mesh( fdd->params.ctx, inst_ob, child_imat, a, use_scale, scale_fac, mp, loopstart, mvert); - const float w = 1.0f / (float)mp->totloop; + const float w = 1.0f / float(mp->totloop); if (orco) { for (int j = 0; j < mp->totloop; j++) { madd_v3_v3fl(dob->orco, orco[loopstart[j].v], w); @@ -1134,7 +1134,7 @@ static void make_child_duplis_faces_from_editmesh(const DupliContext *ctx, fdd->params.ctx, inst_ob, child_imat, a, use_scale, scale_fac, f, vert_coords); if (fdd->has_orco) { - const float w = 1.0f / (float)f->len; + const float w = 1.0f / float(f->len); BMLoop *l_first, *l_iter; l_iter = l_first = BM_FACE_FIRST_LOOP(f); do { @@ -1294,7 +1294,7 @@ static void make_duplis_particle_system(const DupliContext *ctx, ParticleSystem totpart = psys->totcached; } - RNG *rng = BLI_rng_new_srandom(31415926u + (uint)psys->seed); + RNG *rng = BLI_rng_new_srandom(31415926u + uint(psys->seed)); psys->lattice_deform_data = psys_create_lattice_deform_data(&sim); diff --git a/source/blender/blenkernel/intern/paint.cc b/source/blender/blenkernel/intern/paint.cc index 171a7b41373..a735250fd2a 100644 --- a/source/blender/blenkernel/intern/paint.cc +++ b/source/blender/blenkernel/intern/paint.cc @@ -2031,7 +2031,7 @@ int BKE_sculpt_mask_layers_ensure(Object *ob, MultiresModifierData *mmd) const MLoop *l = &loops[p->loopstart + j]; avg += paint_mask[l->v]; } - avg /= (float)p->totloop; + avg /= float(p->totloop); /* fill in multires mask corner */ for (j = 0; j < p->totloop; j++) { diff --git a/source/blender/blenkernel/intern/pbvh.cc b/source/blender/blenkernel/intern/pbvh.cc index 215d04fdc4d..b2f32a38f23 100644 --- a/source/blender/blenkernel/intern/pbvh.cc +++ b/source/blender/blenkernel/intern/pbvh.cc @@ -112,7 +112,7 @@ static void pbvh_vertex_color_get(const PBVH &pbvh, PBVHVertRef vertex, float r_ } if (count) { - mul_v4_fl(r_color, 1.0f / (float)count); + mul_v4_fl(r_color, 1.0f / float(count)); } } else { diff --git a/source/blender/blenkernel/intern/scene.cc b/source/blender/blenkernel/intern/scene.cc index fc36e3d00e7..bc2235f9205 100644 --- a/source/blender/blenkernel/intern/scene.cc +++ b/source/blender/blenkernel/intern/scene.cc @@ -137,7 +137,7 @@ static void scene_init_data(ID *id) scene->toolsettings = DNA_struct_default_alloc(ToolSettings); - scene->toolsettings->autokey_mode = (uchar)U.autokey_mode; + scene->toolsettings->autokey_mode = uchar(U.autokey_mode); /* Grease pencil multi-frame falloff curve. */ scene->toolsettings->gp_sculpt.cur_falloff = BKE_curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f); @@ -156,9 +156,9 @@ static void scene_init_data(ID *id) scene->unit.system = USER_UNIT_METRIC; scene->unit.scale_length = 1.0f; - scene->unit.length_unit = (uchar)BKE_unit_base_of_type_get(USER_UNIT_METRIC, B_UNIT_LENGTH); - scene->unit.mass_unit = (uchar)BKE_unit_base_of_type_get(USER_UNIT_METRIC, B_UNIT_MASS); - scene->unit.time_unit = (uchar)BKE_unit_base_of_type_get(USER_UNIT_METRIC, B_UNIT_TIME); + scene->unit.length_unit = uchar(BKE_unit_base_of_type_get(USER_UNIT_METRIC, B_UNIT_LENGTH)); + scene->unit.mass_unit = uchar(BKE_unit_base_of_type_get(USER_UNIT_METRIC, B_UNIT_MASS)); + scene->unit.time_unit = uchar(BKE_unit_base_of_type_get(USER_UNIT_METRIC, B_UNIT_TIME)); scene->unit.temperature_unit = (uchar)BKE_unit_base_of_type_get(USER_UNIT_METRIC, B_UNIT_TEMPERATURE); @@ -880,7 +880,7 @@ static bool seq_foreach_path_callback(Sequence *seq, void *user_data) } else if ((seq->type == SEQ_TYPE_IMAGE) && se) { /* NOTE: An option not to loop over all strips could be useful? */ - uint len = (uint)MEM_allocN_len(se) / (uint)sizeof(*se); + uint len = uint(MEM_allocN_len(se)) / uint(sizeof(*se)); uint i; if (bpath_data->flag & BKE_BPATH_FOREACH_PATH_SKIP_MULTIFILE) { @@ -1005,10 +1005,10 @@ static void scene_blend_write(BlendWriter *writer, ID *id, const void *id_addres if (sce->r.avicodecdata) { BLO_write_struct(writer, AviCodecData, sce->r.avicodecdata); if (sce->r.avicodecdata->lpFormat) { - BLO_write_raw(writer, (size_t)sce->r.avicodecdata->cbFormat, sce->r.avicodecdata->lpFormat); + BLO_write_raw(writer, size_t(sce->r.avicodecdata->cbFormat), sce->r.avicodecdata->lpFormat); } if (sce->r.avicodecdata->lpParms) { - BLO_write_raw(writer, (size_t)sce->r.avicodecdata->cbParms, sce->r.avicodecdata->lpParms); + BLO_write_raw(writer, size_t(sce->r.avicodecdata->cbParms), sce->r.avicodecdata->lpParms); } } @@ -1207,8 +1207,8 @@ static void scene_blend_read_data(BlendDataReader *reader, ID *id) intptr_t seqbase_offset; intptr_t channels_offset; - seqbase_offset = ((intptr_t) & (temp.seqbase)) - ((intptr_t)&temp); - channels_offset = ((intptr_t) & (temp.channels)) - ((intptr_t)&temp); + seqbase_offset = intptr_t(&(temp).seqbase) - intptr_t(&temp); + channels_offset = intptr_t(&(temp).channels) - intptr_t(&temp); /* seqbase root pointer */ if (ed->seqbasep == old_seqbasep) { @@ -1326,7 +1326,7 @@ static void scene_blend_read_data(BlendDataReader *reader, ID *id) /* make sure simulation starts from the beginning after loading file */ if (rbw->pointcache) { - rbw->ltime = (float)rbw->pointcache->startframe; + rbw->ltime = float(rbw->pointcache->startframe); } } else { @@ -1340,7 +1340,7 @@ static void scene_blend_read_data(BlendDataReader *reader, ID *id) /* make sure simulation starts from the beginning after loading file */ if (rbw->shared->pointcache) { - rbw->ltime = (float)rbw->shared->pointcache->startframe; + rbw->ltime = float(rbw->shared->pointcache->startframe); } } rbw->objects = nullptr; @@ -2426,7 +2426,7 @@ void BKE_scene_frame_set(Scene *scene, float frame) { double intpart; scene->r.subframe = modf((double)frame, &intpart); - scene->r.cfra = (int)intpart; + scene->r.cfra = int(intpart); } /* -------------------------------------------------------------------- */ diff --git a/source/blender/blenkernel/intern/subdiv_mesh.cc b/source/blender/blenkernel/intern/subdiv_mesh.cc index d716a7228c0..651e58d9ca4 100644 --- a/source/blender/blenkernel/intern/subdiv_mesh.cc +++ b/source/blender/blenkernel/intern/subdiv_mesh.cc @@ -222,7 +222,7 @@ static void vertex_interpolation_init(const SubdivMeshContext *ctx, vertex_interpolation->vertex_data_storage_allocated = true; /* Interpolate center of poly right away, it stays unchanged for all * ptex faces. */ - const float weight = 1.0f / (float)coarse_poly->totloop; + const float weight = 1.0f / float(coarse_poly->totloop); blender::Array weights(coarse_poly->totloop); blender::Array indices(coarse_poly->totloop); for (int i = 0; i < coarse_poly->totloop; i++) { @@ -355,7 +355,7 @@ static void loop_interpolation_init(const SubdivMeshContext *ctx, loop_interpolation->loop_data_storage_allocated = true; /* Interpolate center of poly right away, it stays unchanged for all * ptex faces. */ - const float weight = 1.0f / (float)coarse_poly->totloop; + const float weight = 1.0f / float(coarse_poly->totloop); blender::Array weights(coarse_poly->totloop); blender::Array indices(coarse_poly->totloop); for (int i = 0; i < coarse_poly->totloop; i++) { diff --git a/source/blender/blenkernel/intern/type_conversions.cc b/source/blender/blenkernel/intern/type_conversions.cc index 852fe38c92f..ffc5442af2d 100644 --- a/source/blender/blenkernel/intern/type_conversions.cc +++ b/source/blender/blenkernel/intern/type_conversions.cc @@ -49,7 +49,7 @@ static float3 float_to_float3(const float &a) } static int32_t float_to_int(const float &a) { - return (int32_t)a; + return int32_t(a); } static bool float_to_bool(const float &a) { @@ -79,7 +79,7 @@ static float float2_to_float(const float2 &a) } static int float2_to_int(const float2 &a) { - return (int32_t)((a.x + a.y) / 2.0f); + return int32_t((a.x + a.y) / 2.0f); } static bool float2_to_bool(const float2 &a) { @@ -112,7 +112,7 @@ static float float3_to_float(const float3 &a) } static int float3_to_int(const float3 &a) { - return (int)((a.x + a.y + a.z) / 3.0f); + return int((a.x + a.y + a.z) / 3.0f); } static float2 float3_to_float2(const float3 &a) { @@ -138,19 +138,19 @@ static int8_t int_to_int8(const int32_t &a) } static float int_to_float(const int32_t &a) { - return (float)a; + return float(a); } static float2 int_to_float2(const int32_t &a) { - return float2((float)a); + return float2(float(a)); } static float3 int_to_float3(const int32_t &a) { - return float3((float)a); + return float3(float(a)); } static ColorGeometry4f int_to_color(const int32_t &a) { - return ColorGeometry4f((float)a, (float)a, (float)a, 1.0f); + return ColorGeometry4f(float(a), float(a), float(a), 1.0f); } static ColorGeometry4b int_to_byte_color(const int32_t &a) { @@ -167,19 +167,19 @@ static int int8_to_int(const int8_t &a) } static float int8_to_float(const int8_t &a) { - return (float)a; + return float(a); } static float2 int8_to_float2(const int8_t &a) { - return float2((float)a); + return float2(float(a)); } static float3 int8_to_float3(const int8_t &a) { - return float3((float)a); + return float3(float(a)); } static ColorGeometry4f int8_to_color(const int8_t &a) { - return ColorGeometry4f((float)a, (float)a, (float)a, 1.0f); + return ColorGeometry4f(float(a), float(a), float(a), 1.0f); } static ColorGeometry4b int8_to_byte_color(const int8_t &a) { @@ -188,7 +188,7 @@ static ColorGeometry4b int8_to_byte_color(const int8_t &a) static float bool_to_float(const bool &a) { - return (bool)a; + return bool(a); } static int8_t bool_to_int8(const bool &a) { @@ -196,7 +196,7 @@ static int8_t bool_to_int8(const bool &a) } static int32_t bool_to_int(const bool &a) { - return (int32_t)a; + return int32_t(a); } static float2 bool_to_float2(const bool &a) { @@ -225,7 +225,7 @@ static float color_to_float(const ColorGeometry4f &a) } static int32_t color_to_int(const ColorGeometry4f &a) { - return (int)rgb_to_grayscale(a); + return int(rgb_to_grayscale(a)); } static int8_t color_to_int8(const ColorGeometry4f &a) { diff --git a/source/blender/blenkernel/intern/volume.cc b/source/blender/blenkernel/intern/volume.cc index 9c2e88f730a..6418523a614 100644 --- a/source/blender/blenkernel/intern/volume.cc +++ b/source/blender/blenkernel/intern/volume.cc @@ -1636,8 +1636,8 @@ bool BKE_volume_grid_bounds(openvdb::GridBase::ConstPtr grid, float3 &r_min, flo openvdb::BBoxd bbox = grid->transform().indexToWorld(coordbbox); - r_min = float3((float)bbox.min().x(), (float)bbox.min().y(), (float)bbox.min().z()); - r_max = float3((float)bbox.max().x(), (float)bbox.max().y(), (float)bbox.max().z()); + r_min = float3(float(bbox.min().x()), float(bbox.min().y()), float(bbox.min().z())); + r_max = float3(float(bbox.max().x()), float(bbox.max().y()), float(bbox.max().z())); return true; } -- cgit v1.2.3