Cleanup: use function style casts for integer types in C++

This commit is contained in:
Campbell Barton 2022-12-08 13:04:50 +11:00
parent cb45b0bb2a
commit a0dc062816
34 changed files with 200 additions and 206 deletions

View File

@ -1186,7 +1186,7 @@ static void cloth_update_spring_lengths(ClothModifierData *clmd, Mesh *mesh)
LinkNode *search = cloth->springs;
uint struct_springs = 0;
uint i = 0;
uint mvert_num = (uint)mesh->totvert;
uint mvert_num = uint(mesh->totvert);
float shrink_factor;
clmd->sim_parms->avg_spring_len = 0.0f;
@ -1461,7 +1461,7 @@ static bool cloth_build_springs(ClothModifierData *clmd, Mesh *mesh)
ClothSpring *spring = nullptr, *tspring = nullptr, *tspring2 = nullptr;
uint struct_springs = 0, shear_springs = 0, bend_springs = 0, struct_springs_real = 0;
uint mvert_num = (uint)mesh->totvert;
uint numedges = (uint)mesh->totedge;
uint numedges = uint(mesh->totedge);
uint numpolys = (uint)mesh->totpoly;
float shrink_factor;
const MEdge *medge = BKE_mesh_edges(mesh);
@ -1647,7 +1647,7 @@ static bool cloth_build_springs(ClothModifierData *clmd, Mesh *mesh)
for (int i = 0; i < mvert_num; i++) {
if (cloth->verts[i].spring_count > 0) {
cloth->verts[i].avg_spring_len = cloth->verts[i].avg_spring_len * 0.49f /
((float)cloth->verts[i].spring_count);
(float(cloth->verts[i].spring_count));
}
}

View File

@ -585,8 +585,8 @@ static bool data_transfer_layersmapping_cdlayers_multisrc_to_dst(ListBase *r_map
if (use_delete) {
if (tot_dst) {
data_dst_to_delete = static_cast<bool *>(
MEM_mallocN(sizeof(*data_dst_to_delete) * (size_t)tot_dst, __func__));
memset(data_dst_to_delete, true, sizeof(*data_dst_to_delete) * (size_t)tot_dst);
MEM_mallocN(sizeof(*data_dst_to_delete) * size_t(tot_dst), __func__));
memset(data_dst_to_delete, true, sizeof(*data_dst_to_delete) * size_t(tot_dst));
}
}
@ -824,7 +824,7 @@ static bool data_transfer_layersmapping_cdlayers(ListBase *r_map,
else if (fromlayers == DT_LAYERS_ALL_SRC) {
int num_src = CustomData_number_of_layers(cd_src, cddata_type);
bool *use_layers_src = num_src ? static_cast<bool *>(MEM_mallocN(
sizeof(*use_layers_src) * (size_t)num_src, __func__)) :
sizeof(*use_layers_src) * size_t(num_src), __func__)) :
nullptr;
bool ret;
@ -1392,7 +1392,7 @@ bool BKE_object_data_transfer_ex(struct Depsgraph *depsgraph,
if (mdef && vg_idx != -1 && !weights[VDATA]) {
weights[VDATA] = static_cast<float *>(
MEM_mallocN(sizeof(*(weights[VDATA])) * (size_t)num_verts_dst, __func__));
MEM_mallocN(sizeof(*(weights[VDATA])) * size_t(num_verts_dst), __func__));
BKE_defvert_extract_vgroup_to_vertweights(
mdef, vg_idx, num_verts_dst, invert_vgroup, weights[VDATA]);
}
@ -1473,7 +1473,7 @@ bool BKE_object_data_transfer_ex(struct Depsgraph *depsgraph,
if (mdef && vg_idx != -1 && !weights[EDATA]) {
weights[EDATA] = static_cast<float *>(
MEM_mallocN(sizeof(*weights[EDATA]) * (size_t)num_edges_dst, __func__));
MEM_mallocN(sizeof(*weights[EDATA]) * size_t(num_edges_dst), __func__));
BKE_defvert_extract_vgroup_to_edgeweights(
mdef, vg_idx, num_verts_dst, edges_dst, num_edges_dst, invert_vgroup, weights[EDATA]);
}
@ -1570,7 +1570,7 @@ bool BKE_object_data_transfer_ex(struct Depsgraph *depsgraph,
if (mdef && vg_idx != -1 && !weights[LDATA]) {
weights[LDATA] = static_cast<float *>(
MEM_mallocN(sizeof(*weights[LDATA]) * (size_t)num_loops_dst, __func__));
MEM_mallocN(sizeof(*weights[LDATA]) * size_t(num_loops_dst), __func__));
BKE_defvert_extract_vgroup_to_loopweights(
mdef, vg_idx, num_verts_dst, loops_dst, num_loops_dst, invert_vgroup, weights[LDATA]);
}
@ -1652,7 +1652,7 @@ bool BKE_object_data_transfer_ex(struct Depsgraph *depsgraph,
if (mdef && vg_idx != -1 && !weights[PDATA]) {
weights[PDATA] = static_cast<float *>(
MEM_mallocN(sizeof(*weights[PDATA]) * (size_t)num_polys_dst, __func__));
MEM_mallocN(sizeof(*weights[PDATA]) * size_t(num_polys_dst), __func__));
BKE_defvert_extract_vgroup_to_polyweights(mdef,
vg_idx,
num_verts_dst,

View File

@ -718,7 +718,7 @@ static void cp_key(const int start,
ktot = 0.0;
flagflo = 1;
if (kb->totelem) {
kd = kb->totelem / (float)tot;
kd = kb->totelem / float(tot);
}
else {
return;
@ -1036,7 +1036,7 @@ static void do_key(const int start,
k1tot = 0.0;
flagflo |= 1;
if (k[0]->totelem) {
k1d = k[0]->totelem / (float)tot;
k1d = k[0]->totelem / float(tot);
}
else {
flagdo -= 1;
@ -1046,7 +1046,7 @@ static void do_key(const int start,
k2tot = 0.0;
flagflo |= 2;
if (k[0]->totelem) {
k2d = k[1]->totelem / (float)tot;
k2d = k[1]->totelem / float(tot);
}
else {
flagdo -= 2;
@ -1056,7 +1056,7 @@ static void do_key(const int start,
k3tot = 0.0;
flagflo |= 4;
if (k[0]->totelem) {
k3d = k[2]->totelem / (float)tot;
k3d = k[2]->totelem / float(tot);
}
else {
flagdo -= 4;
@ -1066,7 +1066,7 @@ static void do_key(const int start,
k4tot = 0.0;
flagflo |= 8;
if (k[0]->totelem) {
k4d = k[3]->totelem / (float)tot;
k4d = k[3]->totelem / float(tot);
}
else {
flagdo -= 8;
@ -2217,7 +2217,7 @@ void BKE_keyblock_convert_from_mesh(const Mesh *me, const Key *key, KeyBlock *kb
MEM_SAFE_FREE(kb->data);
kb->data = MEM_malloc_arrayN((size_t)len, (size_t)key->elemsize, __func__);
kb->data = MEM_malloc_arrayN(size_t(len), size_t(key->elemsize), __func__);
kb->totelem = len;
BKE_keyblock_update_from_mesh(me, kb);

View File

@ -588,7 +588,7 @@ void BKE_id_material_append(Main *bmain, ID *id, Material *ma)
Material *BKE_id_material_pop(Main *bmain, ID *id, int index_i)
{
short index = (short)index_i;
short index = short(index_i);
Material *ret = nullptr;
Material ***matar;
if ((matar = BKE_id_material_array_p(id))) {
@ -878,7 +878,7 @@ void BKE_object_materials_test(Main *bmain, Object *ob, ID *id)
* use object's material slots amount as reference.
* This avoids losing materials in a local object when its linked obdata goes missing.
* See T92780. */
BKE_id_material_resize(bmain, id, (short)ob->totcol, false);
BKE_id_material_resize(bmain, id, short(ob->totcol), false);
}
else {
/* Normal case: the use the obdata amount of materials slots to update the object's one. */

View File

@ -391,7 +391,7 @@ Mesh *BKE_mesh_mirror_apply_mirror_on_axis_for_modifier(MirrorModifierData *mmd,
const int totloop = result->totloop;
const int totpoly = result->totpoly;
float(*loop_normals)[3] = static_cast<float(*)[3]>(
MEM_calloc_arrayN((size_t)totloop, sizeof(*loop_normals), __func__));
MEM_calloc_arrayN(size_t(totloop), sizeof(*loop_normals), __func__));
CustomData *ldata = &result->ldata;
short(*clnors)[2] = static_cast<short(*)[2]>(CustomData_get_layer(ldata, CD_CUSTOMLOOPNORMAL));
MLoopNorSpaceArray lnors_spacearr = {nullptr};

View File

@ -180,7 +180,7 @@ static void mesh_calc_eigen_matrix(const MVert *verts,
const MVert *mv;
float(*co)[3];
cos = static_cast<float(*)[3]>(MEM_mallocN(sizeof(*cos) * (size_t)numverts, __func__));
cos = static_cast<float(*)[3]>(MEM_mallocN(sizeof(*cos) * size_t(numverts), __func__));
for (i = 0, co = cos, mv = verts; i < numverts; i++, co++, mv++) {
copy_v3_v3(*co, mv->co);
}
@ -325,7 +325,7 @@ void BKE_mesh_remap_init(MeshPairRemap *map, const int items_num)
BKE_mesh_remap_free(map);
map->items = static_cast<MeshPairRemapItem *>(
BLI_memarena_alloc(mem, sizeof(*map->items) * (size_t)items_num));
BLI_memarena_alloc(mem, sizeof(*map->items) * size_t(items_num)));
map->items_num = items_num;
map->mem = mem;
@ -356,11 +356,11 @@ static void mesh_remap_item_define(MeshPairRemap *map,
if (sources_num) {
mapit->sources_num = sources_num;
mapit->indices_src = static_cast<int *>(
BLI_memarena_alloc(mem, sizeof(*mapit->indices_src) * (size_t)sources_num));
memcpy(mapit->indices_src, indices_src, sizeof(*mapit->indices_src) * (size_t)sources_num);
BLI_memarena_alloc(mem, sizeof(*mapit->indices_src) * size_t(sources_num)));
memcpy(mapit->indices_src, indices_src, sizeof(*mapit->indices_src) * size_t(sources_num));
mapit->weights_src = static_cast<float *>(
BLI_memarena_alloc(mem, sizeof(*mapit->weights_src) * (size_t)sources_num));
memcpy(mapit->weights_src, weights_src, sizeof(*mapit->weights_src) * (size_t)sources_num);
BLI_memarena_alloc(mem, sizeof(*mapit->weights_src) * size_t(sources_num)));
memcpy(mapit->weights_src, weights_src, sizeof(*mapit->weights_src) * size_t(sources_num));
}
else {
mapit->sources_num = 0;
@ -395,8 +395,8 @@ static int mesh_remap_interp_poly_data_get(const MPoly *mp,
const int sources_num = mp->totloop;
int i;
if ((size_t)sources_num > *buff_size) {
*buff_size = (size_t)sources_num;
if (size_t(sources_num) > *buff_size) {
*buff_size = size_t(sources_num);
*vcos = static_cast<float(*)[3]>(MEM_reallocN(*vcos, sizeof(**vcos) * *buff_size));
*indices = static_cast<int *>(MEM_reallocN(*indices, sizeof(**indices) * *buff_size));
if (do_weights) {
@ -684,7 +684,7 @@ void BKE_mesh_remap_calc_verts_from_mesh(const int mode,
}
else {
CLOG_WARN(&LOG, "Unsupported mesh-to-mesh vertex mapping mode (%d)!", mode);
memset(r_map->items, 0, sizeof(*r_map->items) * (size_t)numverts_dst);
memset(r_map->items, 0, sizeof(*r_map->items) * size_t(numverts_dst));
}
free_bvhtree_from_mesh(&treedata);
@ -739,7 +739,7 @@ void BKE_mesh_remap_calc_edges_from_mesh(const int mode,
int index;
};
HitData *v_dst_to_src_map = static_cast<HitData *>(
MEM_mallocN(sizeof(*v_dst_to_src_map) * (size_t)numverts_dst, __func__));
MEM_mallocN(sizeof(*v_dst_to_src_map) * size_t(numverts_dst), __func__));
for (i = 0; i < numverts_dst; i++) {
v_dst_to_src_map[i].hit_dist = -1.0f;
@ -932,10 +932,10 @@ void BKE_mesh_remap_calc_edges_from_mesh(const int mode,
/* Subtleness - this one we can allocate only max number of cast rays per edges! */
int *indices = static_cast<int *>(
MEM_mallocN(sizeof(*indices) * (size_t)min_ii(numedges_src, num_rays_max), __func__));
MEM_mallocN(sizeof(*indices) * size_t(min_ii(numedges_src, num_rays_max)), __func__));
/* Here it's simpler to just allocate for all edges :/ */
float *weights = static_cast<float *>(
MEM_mallocN(sizeof(*weights) * (size_t)numedges_src, __func__));
MEM_mallocN(sizeof(*weights) * size_t(numedges_src), __func__));
BKE_bvhtree_from_mesh_get(&treedata, me_src, BVHTREE_FROM_EDGES, 2);
@ -1031,7 +1031,7 @@ void BKE_mesh_remap_calc_edges_from_mesh(const int mode,
}
else {
CLOG_WARN(&LOG, "Unsupported mesh-to-mesh edge mapping mode (%d)!", mode);
memset(r_map->items, 0, sizeof(*r_map->items) * (size_t)numedges_dst);
memset(r_map->items, 0, sizeof(*r_map->items) * size_t(numedges_dst));
}
free_bvhtree_from_mesh(&treedata);
@ -1118,7 +1118,7 @@ static void mesh_island_to_astar_graph(MeshIslandStore *islands,
const int node_num = islands ? island_poly_map->count : numpolys;
uchar *poly_status = static_cast<uchar *>(
MEM_callocN(sizeof(*poly_status) * (size_t)node_num, __func__));
MEM_callocN(sizeof(*poly_status) * size_t(node_num), __func__));
float(*poly_centers)[3];
int pidx_isld;
@ -1127,12 +1127,12 @@ static void mesh_island_to_astar_graph(MeshIslandStore *islands,
BLI_astar_graph_init(r_as_graph, node_num, nullptr);
/* poly_centers is owned by graph memarena. */
poly_centers = static_cast<float(*)[3]>(
BLI_memarena_calloc(r_as_graph->mem, sizeof(*poly_centers) * (size_t)node_num));
BLI_memarena_calloc(r_as_graph->mem, sizeof(*poly_centers) * size_t(node_num)));
if (islands) {
/* poly_island_index_map is owned by graph memarena. */
poly_island_index_map = static_cast<int *>(
BLI_memarena_calloc(r_as_graph->mem, sizeof(*poly_island_index_map) * (size_t)numpolys));
BLI_memarena_calloc(r_as_graph->mem, sizeof(*poly_island_index_map) * size_t(numpolys)));
for (i = island_poly_map->count; i--;) {
poly_island_index_map[island_poly_map->indices[i]] = i;
}
@ -1427,9 +1427,9 @@ void BKE_mesh_remap_calc_loops_from_mesh(const int mode,
num_loops_src);
if (use_from_vert) {
loop_to_poly_map_src = static_cast<int *>(
MEM_mallocN(sizeof(*loop_to_poly_map_src) * (size_t)num_loops_src, __func__));
MEM_mallocN(sizeof(*loop_to_poly_map_src) * size_t(num_loops_src), __func__));
poly_cents_src = static_cast<float(*)[3]>(
MEM_mallocN(sizeof(*poly_cents_src) * (size_t)num_polys_src, __func__));
MEM_mallocN(sizeof(*poly_cents_src) * size_t(num_polys_src), __func__));
for (pidx_src = 0, mp_src = polys_src; pidx_src < num_polys_src; pidx_src++, mp_src++) {
ml_src = &loops_src[mp_src->loopstart];
for (plidx_src = 0, lidx_src = mp_src->loopstart; plidx_src < mp_src->totloop;
@ -1461,10 +1461,10 @@ void BKE_mesh_remap_calc_loops_from_mesh(const int mode,
num_trees = use_islands ? island_store.islands_num : 1;
treedata = static_cast<BVHTreeFromMesh *>(
MEM_callocN(sizeof(*treedata) * (size_t)num_trees, __func__));
MEM_callocN(sizeof(*treedata) * size_t(num_trees), __func__));
if (isld_steps_src) {
as_graphdata = static_cast<BLI_AStarGraph *>(
MEM_callocN(sizeof(*as_graphdata) * (size_t)num_trees, __func__));
MEM_callocN(sizeof(*as_graphdata) * size_t(num_trees), __func__));
}
if (use_islands) {
@ -1571,7 +1571,7 @@ void BKE_mesh_remap_calc_loops_from_mesh(const int mode,
/* And check each dest poly! */
islands_res = static_cast<IslandResult **>(
MEM_mallocN(sizeof(*islands_res) * (size_t)num_trees, __func__));
MEM_mallocN(sizeof(*islands_res) * size_t(num_trees), __func__));
for (tindex = 0; tindex < num_trees; tindex++) {
islands_res[tindex] = static_cast<IslandResult *>(
MEM_mallocN(sizeof(**islands_res) * islands_res_buff_size, __func__));
@ -1593,7 +1593,7 @@ void BKE_mesh_remap_calc_loops_from_mesh(const int mode,
}
if ((size_t)mp_dst->totloop > islands_res_buff_size) {
islands_res_buff_size = (size_t)mp_dst->totloop + MREMAP_DEFAULT_BUFSIZE;
islands_res_buff_size = size_t(mp_dst->totloop) + MREMAP_DEFAULT_BUFSIZE;
for (tindex = 0; tindex < num_trees; tindex++) {
islands_res[tindex] = static_cast<IslandResult *>(
MEM_reallocN(islands_res[tindex], sizeof(**islands_res) * islands_res_buff_size));
@ -2302,8 +2302,8 @@ void BKE_mesh_remap_calc_polys_from_mesh(const int mode,
copy_vn_fl(weights, int(numpolys_src), 0.0f);
if (UNLIKELY((size_t)mp->totloop > tmp_poly_size)) {
tmp_poly_size = (size_t)mp->totloop;
if (UNLIKELY(size_t(mp->totloop) > tmp_poly_size)) {
tmp_poly_size = size_t(mp->totloop);
poly_vcos_2d = static_cast<float(*)[2]>(
MEM_reallocN(poly_vcos_2d, sizeof(*poly_vcos_2d) * tmp_poly_size));
tri_vidx_2d = static_cast<int(*)[3]>(
@ -2343,7 +2343,7 @@ void BKE_mesh_remap_calc_polys_from_mesh(const int mode,
}
tot_rays *= tot_rays;
poly_area_2d_inv = area_poly_v2(poly_vcos_2d, (uint)mp->totloop);
poly_area_2d_inv = area_poly_v2(poly_vcos_2d, uint(mp->totloop));
/* In case we have a null-area degenerated poly... */
poly_area_2d_inv = 1.0f / max_ff(poly_area_2d_inv, 1e-9f);
@ -2362,7 +2362,7 @@ void BKE_mesh_remap_calc_polys_from_mesh(const int mode,
tri_vidx_2d[1][2] = 3;
}
else {
BLI_polyfill_calc(poly_vcos_2d, (uint)mp->totloop, -1, (uint(*)[3])tri_vidx_2d);
BLI_polyfill_calc(poly_vcos_2d, uint(mp->totloop), -1, (uint(*)[3])tri_vidx_2d);
}
for (j = 0; j < tris_num; j++) {
@ -2431,7 +2431,7 @@ void BKE_mesh_remap_calc_polys_from_mesh(const int mode,
}
else {
CLOG_WARN(&LOG, "Unsupported mesh-to-mesh poly mapping mode (%d)!", mode);
memset(r_map->items, 0, sizeof(*r_map->items) * (size_t)numpolys_dst);
memset(r_map->items, 0, sizeof(*r_map->items) * size_t(numpolys_dst));
}
free_bvhtree_from_mesh(&treedata);

View File

@ -451,7 +451,7 @@ Tex *give_current_linestyle_texture(FreestyleLineStyle *linestyle)
Tex *tex = nullptr;
if (linestyle) {
mtex = linestyle->mtex[(int)(linestyle->texact)];
mtex = linestyle->mtex[int(linestyle->texact)];
if (mtex) {
tex = mtex->tex;
}
@ -555,7 +555,7 @@ Tex *give_current_particle_texture(ParticleSettings *part)
return nullptr;
}
mtex = part->mtex[(int)(part->texact)];
mtex = part->mtex[int(part->texact)];
if (mtex) {
tex = mtex->tex;
}

View File

@ -3696,8 +3696,8 @@ void blo_do_versions_300(FileData *fd, Library * /*lib*/, Main *bmain)
LISTBASE_FOREACH (MovieClip *, clip, &bmain->movieclips) {
MovieTracking *tracking = &clip->tracking;
const float frame_center_x = ((float)clip->lastsize[0]) / 2;
const float frame_center_y = ((float)clip->lastsize[1]) / 2;
const float frame_center_x = (float(clip->lastsize[0])) / 2;
const float frame_center_y = float(clip->lastsize[1]) / 2;
tracking->camera.principal_point[0] = (tracking->camera.principal_legacy[0] -
frame_center_x) /

View File

@ -405,7 +405,7 @@ static void bm_mesh_edges_sharp_tag(BMesh *bm,
void BM_edges_sharp_from_angle_set(BMesh *bm, const float split_angle)
{
if (split_angle >= (float)M_PI) {
if (split_angle >= float(M_PI)) {
/* Nothing to do! */
return;
}
@ -715,8 +715,8 @@ static int bm_mesh_loops_calc_normals_for_loop(BMesh *bm,
while ((clnor = static_cast<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);
}
@ -1382,7 +1382,7 @@ static bool bm_mesh_loops_split_lnor_fans(BMesh *bm,
MLoopNorSpaceArray *lnors_spacearr,
const float (*new_lnors)[3])
{
BLI_bitmap *done_loops = BLI_BITMAP_NEW((size_t)bm->totloop, __func__);
BLI_bitmap *done_loops = BLI_BITMAP_NEW(size_t(bm->totloop), __func__);
bool changed = false;
BLI_assert(lnors_spacearr->data_type == MLNOR_SPACEARR_BMLOOP_PTR);
@ -1480,7 +1480,7 @@ static void bm_mesh_loops_assign_normal_data(BMesh *bm,
const int cd_loop_clnors_offset,
const float (*new_lnors)[3])
{
BLI_bitmap *done_loops = BLI_BITMAP_NEW((size_t)bm->totloop, __func__);
BLI_bitmap *done_loops = BLI_BITMAP_NEW(size_t(bm->totloop), __func__);
BLI_SMALLSTACK_DECLARE(clnors_data, short *);
@ -1540,7 +1540,7 @@ static void bm_mesh_loops_assign_normal_data(BMesh *bm,
BLI_BITMAP_ENABLE(done_loops, lidx);
}
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);

View File

@ -235,7 +235,7 @@ static void gpencil_stroke_cache_populate(bGPDlayer * /*gpl*/,
if (show_stroke) {
int vfirst = gps->runtime.stroke_start * 3;
bool is_cyclic = ((gps->flag & GP_STROKE_CYCLIC) != 0) && (gps->totpoints > 2);
int vcount = (gps->totpoints + (int)is_cyclic) * 2 * 3;
int vcount = (gps->totpoints + int(is_cyclic)) * 2 * 3;
DRW_shgroup_call_range(iter->stroke_grp, iter->ob, geom, vfirst, vcount);
}
}

View File

@ -644,7 +644,7 @@ static void gpencil_sbuffer_stroke_ensure(bGPdata *gpd, bool do_fill)
}
/* Compute directly inside the IBO data buffer. */
/* OPTI: This is a bottleneck if the stroke is very long. */
BLI_polyfill_calc(tpoints2d, (uint)vert_len, 0, (uint(*)[3])ibo_builder.data);
BLI_polyfill_calc(tpoints2d, uint(vert_len), 0, (uint(*)[3])ibo_builder.data);
/* Add stroke start offset and shift. */
for (int i = 0; i < gps->tot_triangles * 3; i++) {
ibo_builder.data[i] = (ibo_builder.data[i] + 1) << GP_VERTEX_ID_SHIFT;

View File

@ -417,7 +417,7 @@ static void eyedropper_color_sample(bContext *C, Eyedropper *eye, const int m_xy
/* Apply to property. */
float accum_col[3];
if (eye->accum_tot > 1) {
mul_v3_v3fl(accum_col, eye->accum_col, 1.0f / (float)eye->accum_tot);
mul_v3_v3fl(accum_col, eye->accum_col, 1.0f / float(eye->accum_tot));
}
else {
copy_v3_v3(accum_col, eye->accum_col);

View File

@ -175,7 +175,7 @@ static void depthdropper_depth_sample_pt(bContext *C,
view3d_operator_needs_opengl(C);
if (ED_view3d_autodist(depsgraph, region, v3d, mval, co, true, nullptr)) {
const float mval_center_fl[2] = {(float)region->winx / 2, (float)region->winy / 2};
const float mval_center_fl[2] = {float(region->winx) / 2, float(region->winy) / 2};
float co_align[3];
/* quick way to get view-center aligned point */
@ -185,7 +185,7 @@ static void depthdropper_depth_sample_pt(bContext *C,
BKE_unit_value_as_string(ddr->name,
sizeof(ddr->name),
(double)*r_depth,
double(*r_depth),
4,
B_UNIT_LENGTH,
&scene->unit,
@ -215,7 +215,7 @@ static void depthdropper_depth_set_accum(bContext *C, DepthDropper *ddr)
{
float depth = ddr->accum_depth;
if (ddr->accum_tot) {
depth /= (float)ddr->accum_tot;
depth /= float(ddr->accum_tot);
}
depthdropper_depth_set(C, ddr, depth);
}

View File

@ -405,7 +405,7 @@ void ui_block_align_calc(uiBlock *block, const ARegion *region)
butal_array = static_cast<ButAlign *>(
MEM_mallocN(sizeof(*butal_array) * num_buttons, __func__));
}
memset(butal_array, 0, sizeof(*butal_array) * (size_t)num_buttons);
memset(butal_array, 0, sizeof(*butal_array) * size_t(num_buttons));
/* Second loop: we initialize our ButAlign data for each button. */
butal = butal_array;
@ -424,7 +424,7 @@ void ui_block_align_calc(uiBlock *block, const ARegion *region)
/* This will give us ButAlign items regrouped by align group, vertical and horizontal location.
* Note that, given how buttons are defined in UI code,
* butal_array shall already be "nearly sorted"... */
qsort(butal_array, (size_t)num_buttons, sizeof(*butal_array), ui_block_align_butal_cmp);
qsort(butal_array, size_t(num_buttons), sizeof(*butal_array), ui_block_align_butal_cmp);
/* Third loop: for each pair of buttons in the same align group,
* we compute their potential proximity. Note that each pair is checked only once, and that we

View File

@ -1224,7 +1224,7 @@ void ui_draw_but_COLORBAND(uiBut *but, const uiWidgetColors * /*wcol*/, const rc
immBegin(GPU_PRIM_TRI_STRIP, (sizex + 1) * 2);
for (int a = 0; a <= sizex; a++) {
const float pos = (float(a)) / sizex;
const float pos = float(a) / sizex;
BKE_colorband_evaluate(coba, pos, colf);
if (display) {
IMB_colormanagement_scene_linear_to_display_v3(colf, display);
@ -1244,7 +1244,7 @@ void ui_draw_but_COLORBAND(uiBut *but, const uiWidgetColors * /*wcol*/, const rc
immBegin(GPU_PRIM_TRI_STRIP, (sizex + 1) * 2);
for (int a = 0; a <= sizex; a++) {
const float pos = (float(a)) / sizex;
const float pos = float(a) / sizex;
BKE_colorband_evaluate(coba, pos, colf);
if (display) {
IMB_colormanagement_scene_linear_to_display_v3(colf, display);
@ -1871,7 +1871,7 @@ void ui_draw_but_CURVEPROFILE(ARegion *region,
/* Draw the handles for the selected control points. */
pts = profile->path;
const int path_len = tot_points = (uint)profile->path_len;
const int path_len = tot_points = uint(profile->path_len);
int selected_free_points = 0;
for (int i = 0; i < path_len; i++) {
if (point_draw_handles(&pts[i])) {
@ -1966,7 +1966,7 @@ void ui_draw_but_CURVEPROFILE(ARegion *region,
/* Draw the sampled points in addition to the control points if they have been created */
pts = profile->segments;
const int segments_len = (uint)profile->segments_len;
const int segments_len = uint(profile->segments_len);
if (segments_len > 0 && pts) {
GPU_point_size(max_ff(2.0f, min_ff(UI_DPI_FAC / but->block->aspect * 3.0f, 3.0f)));
immBegin(GPU_PRIM_POINTS, segments_len);

View File

@ -3283,7 +3283,7 @@ static bool ui_textedit_copypaste(uiBut *but, uiHandleButtonData *data, const in
if (pbuf) {
if (UI_but_is_utf8(but)) {
buf_len -= BLI_str_utf8_invalid_strip(pbuf, (size_t)buf_len);
buf_len -= BLI_str_utf8_invalid_strip(pbuf, size_t(buf_len));
}
ui_textedit_insert_buf(but, data, pbuf, buf_len);

View File

@ -413,7 +413,7 @@ static void vicon_collection_color_draw(
bTheme *btheme = UI_GetTheme();
const ThemeCollectionColor *collection_color = &btheme->collection_color[color_tag];
const float aspect = (float)ICON_DEFAULT_WIDTH / (float)w;
const float aspect = float(ICON_DEFAULT_WIDTH) / float(w);
UI_icon_draw_ex(x,
y,
@ -449,7 +449,7 @@ static void vicon_strip_color_draw(
bTheme *btheme = UI_GetTheme();
const ThemeStripColor *strip_color = &btheme->strip_color[color_tag];
const float aspect = (float)ICON_DEFAULT_WIDTH / (float)w;
const float aspect = float(ICON_DEFAULT_WIDTH) / float(w);
UI_icon_draw_ex(
x, y, ICON_SNAP_FACE, aspect, 1.0f, 0.0f, strip_color->color, true, UI_NO_ICON_OVERLAY_TEXT);
@ -478,7 +478,7 @@ DEF_ICON_STRIP_COLOR_DRAW(09, SEQUENCE_COLOR_09);
static void vicon_strip_color_draw_library_data_indirect(
int x, int y, int w, int UNUSED(h), float alpha)
{
const float aspect = (float)ICON_DEFAULT_WIDTH / (float)w;
const float aspect = float(ICON_DEFAULT_WIDTH) / float(w);
UI_icon_draw_ex(x,
y,
@ -494,7 +494,7 @@ static void vicon_strip_color_draw_library_data_indirect(
static void vicon_strip_color_draw_library_data_override_noneditable(
int x, int y, int w, int UNUSED(h), float alpha)
{
const float aspect = (float)ICON_DEFAULT_WIDTH / (float)w;
const float aspect = float(ICON_DEFAULT_WIDTH) / float(w);
UI_icon_draw_ex(x,
y,
@ -1543,16 +1543,16 @@ static void icon_draw_rect(float x,
/* preserve aspect ratio and center */
if (rw > rh) {
draw_w = w;
draw_h = (int)(((float)rh / (float)rw) * (float)w);
draw_h = (int)((float(rh) / float(rw)) * float(w));
draw_y += (h - draw_h) / 2;
}
else if (rw < rh) {
draw_w = (int)(((float)rw / (float)rh) * (float)h);
draw_w = (int)((float(rw) / float(rh)) * float(h));
draw_h = h;
draw_x += (w - draw_w) / 2;
}
scale_x = draw_w / (float)rw;
scale_y = draw_h / (float)rh;
scale_x = draw_w / float(rw);
scale_y = draw_h / float(rh);
/* If the image is squared, the `draw_*` initialization values are good. */
}
@ -1849,7 +1849,7 @@ static void icon_draw_size(float x,
const IconTextOverlay *text_overlay)
{
bTheme *btheme = UI_GetTheme();
const float fdraw_size = (float)draw_size;
const float fdraw_size = float(draw_size);
Icon *icon = BKE_icon_get(icon_id);
alpha *= btheme->tui.icon_alpha;
@ -1863,7 +1863,7 @@ static void icon_draw_size(float x,
/* scale width and height according to aspect */
int w = (int)(fdraw_size / aspect + 0.5f);
int h = (int)(fdraw_size / aspect + 0.5f);
int h = int(fdraw_size / aspect + 0.5f);
DrawInfo *di = icon_ensure_drawinfo(icon);
@ -1880,14 +1880,14 @@ static void icon_draw_size(float x,
else if (di->type == ICON_TYPE_VECTOR) {
/* vector icons use the uiBlock transformation, they are not drawn
* with untransformed coordinates like the other icons */
di->data.vector.func((int)x, (int)y, w, h, 1.0f);
di->data.vector.func(int(x), int(y), w, h, 1.0f);
}
else if (di->type == ICON_TYPE_GEOM) {
#ifdef USE_UI_TOOLBAR_HACK
/* TODO(@campbellbarton): scale icons up for toolbar,
* we need a way to detect larger buttons and do this automatic. */
{
float scale = (float)ICON_DEFAULT_HEIGHT_TOOLBAR / (float)ICON_DEFAULT_HEIGHT;
float scale = float(ICON_DEFAULT_HEIGHT_TOOLBAR) / float(ICON_DEFAULT_HEIGHT);
y = (y + (h / 2)) - ((h * scale) / 2);
w *= scale;
h *= scale;
@ -1926,8 +1926,8 @@ static void icon_draw_size(float x,
/* texture image use premul alpha for correct scaling */
icon_draw_texture(x,
y,
(float)w,
(float)h,
float(w),
float(h),
di->data.texture.x,
di->data.texture.y,
di->data.texture.w,
@ -1954,15 +1954,15 @@ static void icon_draw_size(float x,
uint border_texel = 0;
#ifndef WITH_HEADLESS
if (with_border) {
const float scale = (float)ICON_GRID_W / (float)ICON_DEFAULT_WIDTH;
const float scale = float(ICON_GRID_W) / float(ICON_DEFAULT_WIDTH);
border_texel = ICON_MONO_BORDER_OUTSET;
border_outset = ICON_MONO_BORDER_OUTSET / (scale * aspect);
}
#endif
icon_draw_texture(x - border_outset,
y - border_outset,
(float)w + 2 * border_outset,
(float)h + 2 * border_outset,
float(w) + 2 * border_outset,
float(h) + 2 * border_outset,
di->data.texture.x - border_texel,
di->data.texture.y - border_texel,
di->data.texture.w + 2 * border_texel,
@ -2009,7 +2009,7 @@ static void icon_draw_size(float x,
/* Just draw a colored rect - Like for vicon_colorset_draw() */
#ifndef WITH_HEADLESS
vicon_gplayer_color_draw(icon, (int)x, (int)y, w, h);
vicon_gplayer_color_draw(icon, int(x), int(y), w, h);
#endif
}
}

View File

@ -237,9 +237,9 @@ static int ui_item_fit(
return available - pos;
}
const float width = *extra_pixel + (item * available) / (float)all;
*extra_pixel = width - (int)width;
return (int)width;
const float width = *extra_pixel + (item * available) / float(all);
*extra_pixel = width - int(width);
return int(width);
}
/* contents is smaller or equal to available space */
@ -248,9 +248,9 @@ static int ui_item_fit(
return available - pos;
}
const float width = *extra_pixel + (item * available) / (float)all;
*extra_pixel = width - (int)width;
return (int)width;
const float width = *extra_pixel + (item * available) / float(all);
*extra_pixel = width - int(width);
return int(width);
}
return item;
}
@ -4316,7 +4316,7 @@ static void ui_litem_grid_flow_compute(ListBase *items,
ui_item_size(item, &item_w, &item_h);
global_avg_w += (float)(item_w * item_w);
global_totweight_w += (float)item_w;
global_totweight_w += float(item_w);
global_max_h = max_ii(global_max_h, item_h);
if (parameters->tot_rows != 0 && parameters->tot_columns != 0) {
@ -4325,8 +4325,8 @@ static void ui_litem_grid_flow_compute(ListBase *items,
const int index_row = parameters->row_major ? i / parameters->tot_columns :
i % parameters->tot_rows;
avg_w[index_col] += (float)(item_w * item_w);
totweight_w[index_col] += (float)item_w;
avg_w[index_col] += float(item_w * item_w);
totweight_w[index_col] += float(item_w);
max_h[index_row] = max_ii(max_h[index_row], item_h);
}
@ -4407,7 +4407,7 @@ static void ui_litem_grid_flow_compute(ListBase *items,
*results->global_max_h = global_max_h;
}
if (results->tot_w) {
*results->tot_w = (int)tot_w + parameters->space_x * (parameters->tot_columns - 1);
*results->tot_w = int(tot_w) + parameters->space_x * (parameters->tot_columns - 1);
}
if (results->tot_h) {
*results->tot_h = tot_h + parameters->space_y * (parameters->tot_rows - 1);
@ -4463,7 +4463,7 @@ static void ui_litem_estimate_grid_flow(uiLayout *litem)
gflow->tot_columns = min_ii(max_ii((int)(litem->w / avg_w), 1), gflow->tot_items);
}
}
gflow->tot_rows = (int)ceilf((float)gflow->tot_items / gflow->tot_columns);
gflow->tot_rows = (int)ceilf(float(gflow->tot_items) / gflow->tot_columns);
/* Try to tweak number of columns and rows to get better filling of last column or row,
* and apply 'modulo' value to number of columns or rows.
@ -4479,9 +4479,9 @@ static void ui_litem_estimate_grid_flow(uiLayout *litem)
gflow->tot_columns = gflow->tot_columns - (gflow->tot_columns % modulo);
}
/* Find smallest number of columns conserving computed optimal number of rows. */
for (gflow->tot_rows = (int)ceilf((float)gflow->tot_items / gflow->tot_columns);
for (gflow->tot_rows = (int)ceilf(float(gflow->tot_items) / gflow->tot_columns);
(gflow->tot_columns - step) > 0 &&
(int)ceilf((float)gflow->tot_items / (gflow->tot_columns - step)) <= gflow->tot_rows;
(int)ceilf(float(gflow->tot_items) / (gflow->tot_columns - step)) <= gflow->tot_rows;
gflow->tot_columns -= step) {
/* pass */
}
@ -4493,9 +4493,9 @@ static void ui_litem_estimate_grid_flow(uiLayout *litem)
gflow->tot_items);
}
/* Find smallest number of rows conserving computed optimal number of columns. */
for (gflow->tot_columns = (int)ceilf((float)gflow->tot_items / gflow->tot_rows);
for (gflow->tot_columns = (int)ceilf(float(gflow->tot_items) / gflow->tot_rows);
(gflow->tot_rows - step) > 0 &&
(int)ceilf((float)gflow->tot_items / (gflow->tot_rows - step)) <= gflow->tot_columns;
(int)ceilf(float(gflow->tot_items) / (gflow->tot_rows - step)) <= gflow->tot_columns;
gflow->tot_rows -= step) {
/* pass */
}
@ -4646,10 +4646,10 @@ static void ui_litem_layout_absolute(uiLayout *litem)
toth -= miny;
if (litem->w && totw > 0) {
scalex = (float)litem->w / (float)totw;
scalex = float(litem->w) / float(totw);
}
if (litem->h && toth > 0) {
scaley = (float)litem->h / (float)toth;
scaley = float(litem->h) / float(toth);
}
x = litem->x;
@ -4700,7 +4700,7 @@ static void ui_litem_layout_split(uiLayout *litem)
int x = litem->x;
const int y = litem->y;
const float percentage = (split->percentage == 0.0f) ? 1.0f / (float)tot : split->percentage;
const float percentage = (split->percentage == 0.0f) ? 1.0f / float(tot) : split->percentage;
const int w = (litem->w - (tot - 1) * litem->space);
int colw = w * percentage;
@ -4714,9 +4714,9 @@ static void ui_litem_layout_split(uiLayout *litem)
x += colw;
if (item->next) {
const float width = extra_pixel + (w - (int)(w * percentage)) / ((float)tot - 1);
extra_pixel = width - (int)width;
colw = (int)width;
const float width = extra_pixel + (w - (int)(w * percentage)) / (float(tot) - 1);
extra_pixel = width - int(width);
colw = int(width);
colw = MAX2(colw, 0);
x += litem->space;
@ -6010,7 +6010,7 @@ void UI_paneltype_draw(bContext *C, PanelType *pt, uiLayout *layout)
static void ui_layout_introspect_button(DynStr *ds, uiButtonItem *bitem)
{
uiBut *but = bitem->but;
BLI_dynstr_appendf(ds, "'type':%d, ", (int)but->type);
BLI_dynstr_appendf(ds, "'type':%d, ", int(but->type));
BLI_dynstr_appendf(ds, "'draw_string':'''%s''', ", but->drawstr);
/* Not exactly needed, rna has this. */
BLI_dynstr_appendf(ds, "'tip':'''%s''', ", but->tip ? but->tip : "");
@ -6136,7 +6136,7 @@ uiLayout *uiItemsAlertBox(uiBlock *block, const int size, const eAlertIcon icon)
* making the icon placement more symmetrical, between the block edge and the text. */
const float icon_padding = 5.0f * U.dpi_fac;
/* Calculate the factor of the fixed icon column depending on the block width. */
const float split_factor = ((float)icon_size + icon_padding) /
const float split_factor = (float(icon_size) + icon_padding) /
(float)(dialog_width - style->columnspace);
uiLayout *block_layout = UI_block_layout(

View File

@ -5407,8 +5407,8 @@ static void CurveProfile_buttons_layout(uiLayout *layout, PointerRNA *ptr, RNAUp
"",
0,
0,
(short)path_width,
(short)path_height,
short(path_width),
short(path_height),
profile,
0.0f,
1.0f,
@ -6106,7 +6106,7 @@ static char *progress_tooltip_func(bContext * /*C*/, void *argN, const char * /*
BLI_timecode_string_from_time_simple(elapsed_str, sizeof(elapsed_str), elapsed);
if (progress) {
const double remaining = (elapsed / (double)progress) - elapsed;
const double remaining = (elapsed / double(progress)) - elapsed;
BLI_timecode_string_from_time_simple(remaining_str, sizeof(remaining_str), remaining);
}

View File

@ -881,22 +881,22 @@ static void shape_preset_init_trias_ex(uiWidgetTrias *tria,
/* center position and size */
float centx = (float)rect->xmin + 0.4f * minsize;
float centy = (float)rect->ymin + 0.5f * minsize;
float centy = float(rect->ymin) + 0.5f * minsize;
tria->size = sizex = sizey = -0.5f * triasize * minsize;
if (where == 'r') {
centx = (float)rect->xmax - 0.4f * minsize;
centx = float(rect->xmax) - 0.4f * minsize;
sizex = -sizex;
}
else if (where == 't') {
centx = (float)rect->xmin + 0.5f * minsize;
centy = (float)rect->ymax - 0.5f * minsize;
centx = float(rect->xmin) + 0.5f * minsize;
centy = float(rect->ymax) - 0.5f * minsize;
sizey = -sizey;
i2 = 0;
i1 = 1;
}
else if (where == 'b') {
centx = (float)rect->xmin + 0.5f * minsize;
centx = float(rect->xmin) + 0.5f * minsize;
sizex = -sizex;
i2 = 0;
i1 = 1;
@ -1515,7 +1515,7 @@ static void ui_text_clip_right_ex(const uiFontStyle *fstyle,
l_end = BLF_width_to_strlen(fstyle->uifont_id, str, max_len, okwidth, nullptr);
str[l_end] = '\0';
if (r_final_len) {
*r_final_len = (size_t)l_end;
*r_final_len = size_t(l_end);
}
}
}
@ -2134,7 +2134,7 @@ static void widget_draw_text(const uiFontStyle *fstyle,
(bounds.xmax - bounds.xmin - ul_width) / 2;
int pos_y = rect->ymin + font_yofs + bounds.ymin - U.pixelsize;
/* Use text output because direct drawing doesn't always work. See T89246. */
BLF_position(fstyle->uifont_id, (float)pos_x, pos_y, 0.0f);
BLF_position(fstyle->uifont_id, float(pos_x), pos_y, 0.0f);
BLF_color4ubv(fstyle->uifont_id, wcol->text);
BLF_draw(fstyle->uifont_id, "_", 2);
}
@ -2227,7 +2227,7 @@ static void widget_draw_text_icon(const uiFontStyle *fstyle,
rcti *rect)
{
const bool show_menu_icon = ui_but_draw_menu_icon(but);
const float alpha = (float)wcol->text[3] / 255.0f;
const float alpha = float(wcol->text[3]) / 255.0f;
char password_str[UI_MAX_DRAW_STR];
bool no_text_padding = but->drawflag & UI_BUT_NO_TEXT_PADDING;
@ -2739,10 +2739,10 @@ static void widget_softshadow(const rcti *rect, int roundboxalign, const float r
immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR);
for (int step = 1; step <= (int)radout; step++) {
for (int step = 1; step <= int(radout); step++) {
const float expfac = sqrtf(step / radout);
round_box_shadow_edges(wtb.outer_v, &rect1, radin, UI_CNR_ALL, (float)step);
round_box_shadow_edges(wtb.outer_v, &rect1, radin, UI_CNR_ALL, float(step));
immUniformColor4f(0.0f, 0.0f, 0.0f, alphastep * (1.0f - expfac));
@ -2819,7 +2819,7 @@ void ui_hsvcircle_vals_from_pos(
const float dist_sq = len_squared_v2(m_delta);
*r_val_dist = (dist_sq < (radius * radius)) ? sqrtf(dist_sq) / radius : 1.0f;
*r_val_rad = atan2f(m_delta[0], m_delta[1]) / (2.0f * (float)M_PI) + 0.5f;
*r_val_rad = atan2f(m_delta[0], m_delta[1]) / (2.0f * float(M_PI)) + 0.5f;
}
void ui_hsvcircle_pos_from_vals(
@ -2830,7 +2830,7 @@ void ui_hsvcircle_pos_from_vals(
const float centy = BLI_rcti_cent_y_fl(rect);
const float radius = (float)min_ii(BLI_rcti_size_x(rect), BLI_rcti_size_y(rect)) / 2.0f;
const float ang = 2.0f * (float)M_PI * hsv[0] + (float)M_PI_2;
const float ang = 2.0f * float(M_PI) * hsv[0] + float(M_PI_2);
float radius_t;
if (cpicker->use_color_cubic && (U.color_picker_type == USER_CP_CIRCLE_HSV)) {
@ -2850,7 +2850,7 @@ static void ui_draw_but_HSVCIRCLE(uiBut *but, const uiWidgetColors *wcol, const
/* TODO(merwin): reimplement as shader for pixel-perfect colors */
const int tot = 64;
const float radstep = 2.0f * (float)M_PI / (float)tot;
const float radstep = 2.0f * float(M_PI) / float(tot);
const float centx = BLI_rcti_cent_x_fl(rect);
const float centy = BLI_rcti_cent_y_fl(rect);
const float radius = (float)min_ii(BLI_rcti_size_x(rect), BLI_rcti_size_y(rect)) / 2.0f;
@ -3685,7 +3685,7 @@ static void widget_nodesocket(uiBut *but,
rect->ymax = cent_y + radi;
wtb.draw_outline = true;
round_box_edges(&wtb, UI_CNR_ALL, rect, (float)radi);
round_box_edges(&wtb, UI_CNR_ALL, rect, float(radi));
widgetbase_draw(&wtb, wcol);
copy_v3_v3_uchar(wcol->inner, old_inner);
@ -4979,9 +4979,9 @@ static void ui_draw_clip_tri(uiBlock *block, rcti *rect, uiWidgetType *wt)
float draw_color[4];
const uchar *color = wt->wcol.text;
draw_color[0] = ((float)color[0]) / 255.0f;
draw_color[1] = ((float)color[1]) / 255.0f;
draw_color[2] = ((float)color[2]) / 255.0f;
draw_color[0] = (float(color[0])) / 255.0f;
draw_color[1] = (float(color[1])) / 255.0f;
draw_color[2] = (float(color[2])) / 255.0f;
draw_color[3] = 1.0f;
if (block->flag & UI_BLOCK_CLIPTOP) {
@ -5183,18 +5183,12 @@ void ui_draw_pie_center(uiBlock *block)
btheme->tui.wcol_pie_menu.inner,
btheme->tui.wcol_pie_menu.shadetop,
btheme->tui.wcol_pie_menu.shadedown);
draw_disk_shaded(0.0f,
(float)(M_PI * 2.0),
pie_radius_internal,
pie_radius_external,
subd,
col1,
col2,
true);
draw_disk_shaded(
0.0f, float(M_PI * 2.0), pie_radius_internal, pie_radius_external, subd, col1, col2, true);
}
else {
draw_disk_shaded(0.0f,
(float)(M_PI * 2.0),
float(M_PI * 2.0),
pie_radius_internal,
pie_radius_external,
subd,
@ -5492,7 +5486,7 @@ void ui_draw_preview_item_stateless(const uiFontStyle *fstyle,
char drawstr[UI_MAX_DRAW_STR];
const float okwidth = (float)BLI_rcti_size_x(&trect);
const size_t max_len = sizeof(drawstr);
const float minwidth = (float)(UI_DPI_ICON_SIZE);
const float minwidth = float(UI_DPI_ICON_SIZE);
BLI_strncpy(drawstr, name, sizeof(drawstr));
UI_text_clip_middle_ex(fstyle, drawstr, okwidth, minwidth, max_len, '\0');

View File

@ -175,8 +175,8 @@ static void load_tex_task_cb_ex(void *__restrict userdata,
int index = j * size + i;
float x = (float)i / size;
float y = (float)j / size;
float x = float(i) / size;
float y = float(j) / size;
float len;
if (mtex->brush_map_mode == MTEX_MAP_MODE_TILED) {
@ -375,8 +375,8 @@ static void load_tex_cursor_task_cb(void *__restrict userdata,
/* Largely duplicated from tex_strength. */
const int index = j * size + i;
const float x = (((float)i / size) - 0.5f) * 2.0f;
const float y = (((float)j / size) - 0.5f) * 2.0f;
const float x = ((float(i) / size) - 0.5f) * 2.0f;
const float y = ((float(j) / size) - 0.5f) * 2.0f;
const float len = sqrtf(x * x + y * y);
if (len <= 1.0f) {
@ -1105,7 +1105,7 @@ static void cursor_draw_point_with_symmetry(const uint gpuattr,
/* Radial Symmetry. */
for (char raxis = 0; raxis < 3; raxis++) {
for (int r = 1; r < sd->radial_symm[raxis]; r++) {
float angle = 2 * M_PI * r / sd->radial_symm[(int)raxis];
float angle = 2 * M_PI * r / sd->radial_symm[int(raxis)];
flip_v3_v3(location, true_location, ePaintSymmetryFlags(i));
unit_m4(symm_rot_mat);
rotate_m4(symm_rot_mat, raxis + 'X', angle);
@ -1286,8 +1286,8 @@ static bool paint_cursor_context_init(bContext *C,
pcontext->x = x;
pcontext->y = y;
pcontext->translation[0] = (float)x;
pcontext->translation[1] = (float)y;
pcontext->translation[0] = float(x);
pcontext->translation[1] = float(y);
float zoomx, zoomy;
get_imapaint_zoom(C, &zoomx, &zoomy);

View File

@ -540,8 +540,8 @@ static int project_paint_face_paint_tile(Image *ima, const float *uv)
}
/* Currently, faces are assumed to belong to one tile, so checking the first loop is enough. */
int tx = (int)uv[0];
int ty = (int)uv[1];
int tx = int(uv[0]);
int ty = int(uv[1]);
return 1001 + 10 * ty + tx;
}
@ -782,8 +782,8 @@ static bool project_paint_PickColor(
// if (xi < 0 || xi >= ibuf->x || yi < 0 || yi >= ibuf->y) return false;
/* wrap */
xi = mod_i((int)(uv[0] * ibuf->x), ibuf->x);
yi = mod_i((int)(uv[1] * ibuf->y), ibuf->y);
xi = mod_i(int(uv[0] * ibuf->x), ibuf->x);
yi = mod_i(int(uv[1] * ibuf->y), ibuf->y);
if (rgba) {
if (ibuf->rect_float) {
@ -1303,8 +1303,8 @@ static void uv_image_outset(const ProjPaintState *ps,
float ibuf_inv[2];
ibuf_inv[0] = 1.0f / (float)ibuf_x;
ibuf_inv[1] = 1.0f / (float)ibuf_y;
ibuf_inv[0] = 1.0f / float(ibuf_x);
ibuf_inv[1] = 1.0f / float(ibuf_y);
for (fidx[0] = 0; fidx[0] < 3; fidx[0]++) {
LoopSeamData *seam_data;
@ -1944,8 +1944,8 @@ static ProjPixel *project_paint_uvpixel_init(const ProjPaintState *ps,
}
/* which bounding box cell are we in?, needed for undo */
projPixel->bb_cell_index = (int)(((float)x_px / (float)ibuf->x) * PROJ_BOUNDBOX_DIV) +
(int)(((float)y_px / (float)ibuf->y) * PROJ_BOUNDBOX_DIV) *
projPixel->bb_cell_index = (int)((float(x_px) / float(ibuf->x)) * PROJ_BOUNDBOX_DIV) +
(int)((float(y_px) / float(ibuf->y)) * PROJ_BOUNDBOX_DIV) *
PROJ_BOUNDBOX_DIV;
/* done with view3d_project_float inline */
@ -2768,8 +2768,8 @@ static void project_bucket_clip_face(const bool is_ortho,
cent[0] += isectVCosSS[i][0];
cent[1] += isectVCosSS[i][1];
}
cent[0] = cent[0] / (float)(*tot);
cent[1] = cent[1] / (float)(*tot);
cent[0] = cent[0] / float(*tot);
cent[1] = cent[1] / float(*tot);
/* Collect angles for every point around the center point */
@ -3021,7 +3021,7 @@ static void project_paint_face_init(const ProjPaintState *ps,
/* Bucket bounds in UV space so we can init pixels only for this face. */
float lt_uv_pxoffset[3][2];
float xhalfpx, yhalfpx;
const float ibuf_xf = (float)ibuf->x, ibuf_yf = (float)ibuf->y;
const float ibuf_xf = float(ibuf->x), ibuf_yf = float(ibuf->y);
/* for early loop exit */
int has_x_isect = 0, has_isect = 0;
@ -3104,13 +3104,13 @@ static void project_paint_face_init(const ProjPaintState *ps,
for (y = bounds_px.ymin; y < bounds_px.ymax; y++) {
// uv[1] = (((float)y) + 0.5f) / (float)ibuf->y;
/* use pixel offset UV coords instead */
uv[1] = (float)y / ibuf_yf;
uv[1] = float(y) / ibuf_yf;
has_x_isect = 0;
for (x = bounds_px.xmin; x < bounds_px.xmax; x++) {
// uv[0] = (((float)x) + 0.5f) / ibuf->x;
/* use pixel offset UV coords instead */
uv[0] = (float)x / ibuf_xf;
uv[0] = float(x) / ibuf_xf;
/* Note about IsectPoly2Df_twoside, checking the face or uv flipping doesn't work,
* could check the poly direction but better to do this */
@ -3314,15 +3314,15 @@ static void project_paint_face_init(const ProjPaintState *ps,
for (y = bounds_px.ymin; y < bounds_px.ymax; y++) {
// uv[1] = (((float)y) + 0.5f) / (float)ibuf->y;
/* use offset uvs instead */
uv[1] = (float)y / ibuf_yf;
uv[1] = float(y) / ibuf_yf;
has_x_isect = 0;
for (x = bounds_px.xmin; x < bounds_px.xmax; x++) {
const float puv[2] = {(float)x, (float)y};
const float puv[2] = {float(x), float(y)};
bool in_bounds;
// uv[0] = (((float)x) + 0.5f) / (float)ibuf->x;
/* use offset uvs instead */
uv[0] = (float)x / ibuf_xf;
uv[0] = float(x) / ibuf_xf;
/* test we're inside uvspace bucket and triangle bounds */
if (equals_v2v2(seam_uvs[0], seam_uvs[1])) {
@ -3371,7 +3371,7 @@ static void project_paint_face_init(const ProjPaintState *ps,
mul_m4_v4((float(*)[4])ps->projectMat, pixel_on_edge);
pixel_on_edge[0] = (float)(ps->winx * 0.5f) +
(ps->winx * 0.5f) * pixel_on_edge[0] / pixel_on_edge[3];
pixel_on_edge[1] = (float)(ps->winy * 0.5f) +
pixel_on_edge[1] = float(ps->winy * 0.5f) +
(ps->winy * 0.5f) * pixel_on_edge[1] / pixel_on_edge[3];
/* Use the depth for bucket point occlusion */
pixel_on_edge[2] = pixel_on_edge[2] / pixel_on_edge[3];
@ -3855,21 +3855,21 @@ static void proj_paint_state_screen_coords_init(ProjPaintState *ps, const int di
if (ps->source == PROJ_SRC_VIEW) {
#ifdef PROJ_DEBUG_WINCLIP
CLAMP(ps->screenMin[0], (float)(-diameter), (float)(ps->winx + diameter));
CLAMP(ps->screenMax[0], (float)(-diameter), (float)(ps->winx + diameter));
CLAMP(ps->screenMin[0], float(-diameter), float(ps->winx + diameter));
CLAMP(ps->screenMax[0], float(-diameter), float(ps->winx + diameter));
CLAMP(ps->screenMin[1], (float)(-diameter), (float)(ps->winy + diameter));
CLAMP(ps->screenMax[1], (float)(-diameter), (float)(ps->winy + diameter));
CLAMP(ps->screenMin[1], float(-diameter), float(ps->winy + diameter));
CLAMP(ps->screenMax[1], float(-diameter), float(ps->winy + diameter));
#else
UNUSED_VARS(diameter);
#endif
}
else if (ps->source != PROJ_SRC_VIEW_FILL) { /* re-projection, use bounds */
ps->screenMin[0] = 0;
ps->screenMax[0] = (float)(ps->winx);
ps->screenMax[0] = float(ps->winx);
ps->screenMin[1] = 0;
ps->screenMax[1] = (float)(ps->winy);
ps->screenMax[1] = float(ps->winy);
}
}
@ -3900,7 +3900,7 @@ static void proj_paint_state_cavity_init(ProjPaintState *ps)
if (counter[a] > 0) {
mul_v3_fl(edges[a], 1.0f / counter[a]);
/* Augment the difference. */
cavities[a] = saacos(10.0f * dot_v3v3(ps->vert_normals[a], edges[a])) * (float)M_1_PI;
cavities[a] = saacos(10.0f * dot_v3v3(ps->vert_normals[a], edges[a])) * float(M_1_PI);
}
else {
cavities[a] = 0.0;
@ -4536,8 +4536,8 @@ static void project_paint_begin(const bContext *C,
ps->screen_width = ps->screenMax[0] - ps->screenMin[0];
ps->screen_height = ps->screenMax[1] - ps->screenMin[1];
ps->buckets_x = (int)(ps->screen_width / (((float)diameter) / PROJ_BUCKET_BRUSH_DIV));
ps->buckets_y = (int)(ps->screen_height / (((float)diameter) / PROJ_BUCKET_BRUSH_DIV));
ps->buckets_x = (int)(ps->screen_width / ((float(diameter)) / PROJ_BUCKET_BRUSH_DIV));
ps->buckets_y = int(ps->screen_height / (float(diameter) / PROJ_BUCKET_BRUSH_DIV));
// printf("\tscreenspace bucket division x:%d y:%d\n", ps->buckets_x, ps->buckets_y);
@ -4935,7 +4935,7 @@ static void do_projectpaint_soften_f(ProjPaintState *ps,
}
if (LIKELY(accum_tot != 0)) {
mul_v4_fl(rgba, 1.0f / (float)accum_tot);
mul_v4_fl(rgba, 1.0f / float(accum_tot));
if (ps->mode == BRUSH_STROKE_INVERT) {
/* subtract blurred image from normal image gives high pass filter */
@ -4998,7 +4998,7 @@ static void do_projectpaint_soften(ProjPaintState *ps,
if (LIKELY(accum_tot != 0)) {
uchar *rgba_ub = projPixel->newColor.ch;
mul_v4_fl(rgba, 1.0f / (float)accum_tot);
mul_v4_fl(rgba, 1.0f / float(accum_tot));
if (ps->mode == BRUSH_STROKE_INVERT) {
float rgba_pixel[4];
@ -5282,7 +5282,7 @@ static void do_projectpaint_thread(TaskPool *__restrict UNUSED(pool), void *ph_v
}
}
BKE_colorband_evaluate(brush->gradient, f, color_f);
color_f[3] *= ((float)projPixel->mask) * (1.0f / 65535.0f) * brush_alpha;
color_f[3] *= (float(projPixel->mask)) * (1.0f / 65535.0f) * brush_alpha;
if (is_floatbuf) {
/* Convert to premutliplied. */
@ -5312,7 +5312,7 @@ static void do_projectpaint_thread(TaskPool *__restrict UNUSED(pool), void *ph_v
else {
if (is_floatbuf) {
float newColor_f[4];
newColor_f[3] = ((float)projPixel->mask) * (1.0f / 65535.0f) * brush_alpha;
newColor_f[3] = (float(projPixel->mask)) * (1.0f / 65535.0f) * brush_alpha;
copy_v3_v3(newColor_f, ps->paint_color_linear);
IMB_blend_color_float(projPixel->pixel.f_pt,
@ -5321,7 +5321,7 @@ static void do_projectpaint_thread(TaskPool *__restrict UNUSED(pool), void *ph_v
IMB_BlendMode(ps->blend));
}
else {
float mask = ((float)projPixel->mask) * (1.0f / 65535.0f);
float mask = float(projPixel->mask) * (1.0f / 65535.0f);
projPixel->newColor.ch[3] = mask * 255 * brush_alpha;
rgb_float_to_uchar(projPixel->newColor.ch, ps->paint_color);
@ -5349,7 +5349,7 @@ static void do_projectpaint_thread(TaskPool *__restrict UNUSED(pool), void *ph_v
projPixel->projCoSS[0],
projPixel->projCoSS[1]);
if (projPixel->newColor.f[3]) {
float mask = ((float)projPixel->mask) * (1.0f / 65535.0f);
float mask = (float(projPixel->mask)) * (1.0f / 65535.0f);
mul_v4_v4fl(projPixel->newColor.f, projPixel->newColor.f, mask);
@ -5366,7 +5366,7 @@ static void do_projectpaint_thread(TaskPool *__restrict UNUSED(pool), void *ph_v
projPixel->projCoSS[0],
projPixel->projCoSS[1]);
if (projPixel->newColor.ch[3]) {
float mask = ((float)projPixel->mask) * (1.0f / 65535.0f);
float mask = (float(projPixel->mask)) * (1.0f / 65535.0f);
projPixel->newColor.ch[3] *= mask;
blend_color_mix_byte(
@ -5396,7 +5396,7 @@ static void do_projectpaint_thread(TaskPool *__restrict UNUSED(pool), void *ph_v
float mask;
/* Extra mask for normal, layer stencil, etc. */
float custom_mask = ((float)projPixel->mask) * (1.0f / 65535.0f);
float custom_mask = (float(projPixel->mask)) * (1.0f / 65535.0f);
/* Mask texture. */
if (ps->is_maskbrush) {
@ -5452,7 +5452,7 @@ static void do_projectpaint_thread(TaskPool *__restrict UNUSED(pool), void *ph_v
}
mask = min_ff(mask, 65535.0f);
mask_short = (ushort)mask;
mask_short = ushort(mask);
if (mask_short > *projPixel->mask_accum) {
*projPixel->mask_accum = mask_short;
@ -5795,7 +5795,7 @@ void paint_proj_stroke(const bContext *C,
View3D *v3d = CTX_wm_view3d(C);
ARegion *region = CTX_wm_region(C);
float *cursor = scene->cursor.location;
const int mval_i[2] = {(int)pos[0], (int)pos[1]};
const int mval_i[2] = {(int)pos[0], int(pos[1])};
view3d_operator_needs_opengl(C);
@ -5908,8 +5908,8 @@ static void project_state_init(bContext *C, Object *ob, ProjPaintState *ps, int
ps->normal_angle_inner = ps->normal_angle = settings->imapaint.normal_angle;
}
ps->normal_angle_inner *= (float)(M_PI_2 / 90);
ps->normal_angle *= (float)(M_PI_2 / 90);
ps->normal_angle_inner *= float(M_PI_2 / 90);
ps->normal_angle *= float(M_PI_2 / 90);
ps->normal_angle_range = ps->normal_angle - ps->normal_angle_inner;
if (ps->normal_angle_range <= 0.0f) {

View File

@ -824,7 +824,7 @@ static void sculpt_vertex_neighbors_get_bmesh(PBVHVertRef vertex, SculptVertexNe
const BMVert *v_other = adj_v[i];
if (v_other != v) {
sculpt_vertex_neighbor_add(
iter, BKE_pbvh_make_vref((intptr_t)v_other), BM_elem_index_get(v_other));
iter, BKE_pbvh_make_vref(intptr_t(v_other)), BM_elem_index_get(v_other));
}
}
}

View File

@ -1091,7 +1091,7 @@ static void snap_calc_uv_fn(TransInfo *t, float *UNUSED(vec))
Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data_with_uvs(
t->scene, t->view_layer, nullptr, &objects_len);
float dist_sq = square_f((float)SNAP_MIN_DISTANCE);
float dist_sq = square_f(float(SNAP_MIN_DISTANCE));
if (ED_uvedit_nearest_uv_multi(&t->region->v2d,
t->scene,
objects,

View File

@ -1787,7 +1787,7 @@ static eSnapMode snap_mesh_polygon(SnapObjectContext *sctx,
BLI_assert(nearest2d.edge != nullptr);
for (int i = mp->totloop; i--; ml++) {
cb_snap_edge(&nearest2d,
(int)ml->e,
int(ml->e),
&neasrest_precalc,
clip_planes_local,
sctx->runtime.clip_plane_len,
@ -1798,7 +1798,7 @@ static eSnapMode snap_mesh_polygon(SnapObjectContext *sctx,
elem = SCE_SNAP_MODE_VERTEX;
for (int i = mp->totloop; i--; ml++) {
cb_snap_vert(&nearest2d,
(int)ml->v,
int(ml->v),
&neasrest_precalc,
clip_planes_local,
sctx->runtime.clip_plane_len,

View File

@ -204,11 +204,11 @@ static void generate_next_domains(uint8_t domains[][BDS],
bd[LL] - l_len,
bd[RL] - r_len,
bd[ADJ],
(uint8_t)(cur_pos));
uint8_t(cur_pos));
bound += std::min(bd[LL] - l_len, bd[RL] - r_len);
}
if (l_len && r_len) {
add_bidomain(domains, bd_pos, bd[L], bd[R], l_len, r_len, true, (uint8_t)(cur_pos));
add_bidomain(domains, bd_pos, bd[L], bd[R], l_len, r_len, true, uint8_t(cur_pos));
bound += std::min(l_len, r_len);
}
}
@ -351,7 +351,7 @@ static void maximum_common_subgraph_internal(
bd[W] = w; /* Store the W used for this iteration. */
cur[bd[P]][L] = v;
cur[bd[P]][R] = w;
update_incumbent(cur, incumbent, bd[P] + (uint8_t)1, inc_pos);
update_incumbent(cur, incumbent, bd[P] + uint8_t(1), inc_pos);
generate_next_domains(
domains, &bd_pos, bd[P] + 1, left, right, v, w, *inc_pos, adjmat0, adjmat1);
}

View File

@ -42,8 +42,8 @@ static void mul_v2_m2_add_v2v2(float r[2],
const float b[2])
{
/* Compute `r = mat * (a + b)` with high precision. */
const double x = static_cast<double>(a[0]) + static_cast<double>(b[0]);
const double y = static_cast<double>(a[1]) + static_cast<double>(b[1]);
const double x = static_cast<double>(a[0]) + double(b[0]);
const double y = static_cast<double>(a[1]) + double(b[1]);
r[0] = static_cast<float>(mat[0][0] * x + mat[1][0] * y);
r[1] = static_cast<float>(mat[0][1] * x + mat[1][1] * y);

View File

@ -4602,7 +4602,7 @@ static void lineart_create_edges_from_isec_data(LineartIsecData *d)
e->t1 = is->tri1;
e->t2 = is->tri2;
/* This is so we can also match intersection edges from shadow to later viewing stage. */
e->edge_identifier = (((uint64_t)e->t1->target_reference) << 32) | e->t2->target_reference;
e->edge_identifier = ((uint64_t(e->t1->target_reference)) << 32) | e->t2->target_reference;
e->flags = LRT_EDGE_FLAG_INTERSECTION;
e->intersection_mask = (is->tri1->intersection_mask | is->tri2->intersection_mask);
BLI_addtail(&e->segments, es);

View File

@ -295,7 +295,7 @@ static void displaceModifier_do(DisplaceModifierData *dmd,
Tex *tex_target = dmd->texture;
if (tex_target != nullptr) {
tex_co = static_cast<float(*)[3]>(
MEM_calloc_arrayN((size_t)verts_num, sizeof(*tex_co), "displaceModifier_do tex_co"));
MEM_calloc_arrayN(size_t(verts_num), sizeof(*tex_co), "displaceModifier_do tex_co"));
MOD_get_texture_coords((MappingInfoModifierData *)dmd, ctx, ob, mesh, vertexCos, tex_co);
MOD_init_texture((MappingInfoModifierData *)dmd, ctx);

View File

@ -308,7 +308,7 @@ static bNodeSocket *node_find_linkable_socket(bNodeTree *ntree,
{
bNodeSocket *first = to_socket->in_out == SOCK_IN ?
static_cast<bNodeSocket *>(node->inputs.first) :
static_cast<bNodeSocket *>((node->outputs.first));
static_cast<bNodeSocket *>(node->outputs.first);
/* Wrap around the list end. */
bNodeSocket *socket_iter = to_socket->next ? to_socket->next : first;

View File

@ -36,7 +36,7 @@ static float noise(int n) /* fast integer noise */
int nn;
n = (n >> 13) ^ n;
nn = (n * (n * n * 60493 + 19990303) + 1376312589) & 0x7fffffff;
return 0.5f * ((float)nn / 1073741824.0f);
return 0.5f * (float(nn) / 1073741824.0f);
}
static void colorfn(float *out, TexParams *p, bNode *node, bNodeStack **in, short thread)

View File

@ -28,8 +28,8 @@ static void rotate(float new_co[3], float a, const float ax[3], const float co[3
float perp[3];
float cp[3];
float cos_a = cosf(a * (float)(2 * M_PI));
float sin_a = sinf(a * (float)(2 * M_PI));
float cos_a = cosf(a * float(2 * M_PI));
float sin_a = sinf(a * float(2 * M_PI));
/* `x' = xcosa + n(n.x)(1-cosa) + (x*n)sina`. */

View File

@ -777,8 +777,8 @@ void RE_bake_pixels_populate(Mesh *me,
* up our intersection tests where a pixel gets in between 2 faces or the middle of a quad,
* camera aligned quads also have this problem but they are less common.
* Add a small offset to the UVs, fixes bug T18685. */
vec[a][0] = (uv[0] - bk_image->uv_offset[0]) * (float)bk_image->width - (0.5f + 0.001f);
vec[a][1] = (uv[1] - bk_image->uv_offset[1]) * (float)bk_image->height - (0.5f + 0.002f);
vec[a][0] = (uv[0] - bk_image->uv_offset[0]) * float(bk_image->width) - (0.5f + 0.001f);
vec[a][1] = (uv[1] - bk_image->uv_offset[1]) * float(bk_image->height) - (0.5f + 0.002f);
}
/* Rasterize triangle. */

View File

@ -420,8 +420,8 @@ static void *do_multires_bake_thread(void *data_v)
}
if (bkr->progress) {
*bkr->progress = ((float)bkr->baked_objects +
(float)bkr->baked_faces / handle->queue->tot_tri) /
*bkr->progress = (float(bkr->baked_objects) +
float(bkr->baked_faces) / handle->queue->tot_tri) /
bkr->tot_obj;
}
BLI_spin_unlock(&handle->queue->spin);
@ -621,10 +621,10 @@ static void interp_bilinear_grid(
float u, v;
float data[4][3];
x0 = (int)crn_x;
x0 = int(crn_x);
x1 = x0 >= (key->grid_size - 1) ? (key->grid_size - 1) : (x0 + 1);
y0 = (int)crn_y;
y0 = int(crn_y);
y1 = y0 >= (key->grid_size - 1) ? (key->grid_size - 1) : (y0 + 1);
u = crn_x - x0;