Cleanup: function style casts for C++
This commit is contained in:
parent
494c3ba063
commit
8367f2bffc
|
@ -5249,7 +5249,7 @@ void CustomData_debug_info_from_layers(const CustomData *data, const char *inden
|
|||
const char *name = CustomData_layertype_name(type);
|
||||
const int size = CustomData_sizeof(type);
|
||||
const void *pt = CustomData_get_layer(data, type);
|
||||
const int pt_size = pt ? (int)(MEM_allocN_len(pt) / size) : 0;
|
||||
const int pt_size = pt ? int(MEM_allocN_len(pt) / size) : 0;
|
||||
const char *structname;
|
||||
int structnum;
|
||||
CustomData_file_write_info(type, &structname, &structnum);
|
||||
|
|
|
@ -349,7 +349,7 @@ void BKE_modifier_copydata_generic(const ModifierData *md_src,
|
|||
const size_t data_size = sizeof(ModifierData);
|
||||
const char *md_src_data = ((const char *)md_src) + data_size;
|
||||
char *md_dst_data = ((char *)md_dst) + data_size;
|
||||
BLI_assert(data_size <= (size_t)mti->structSize);
|
||||
BLI_assert(data_size <= size_t(mti->structSize));
|
||||
memcpy(md_dst_data, md_src_data, size_t(mti->structSize) - data_size);
|
||||
|
||||
/* Runtime fields are never to be preserved. */
|
||||
|
|
|
@ -521,8 +521,8 @@ void BKE_particle_init_rng(void)
|
|||
RNG *rng = BLI_rng_new_srandom(5831); /* arbitrary */
|
||||
for (int i = 0; i < PSYS_FRAND_COUNT; i++) {
|
||||
PSYS_FRAND_BASE[i] = BLI_rng_get_float(rng);
|
||||
PSYS_FRAND_SEED_OFFSET[i] = (uint)BLI_rng_get_int(rng);
|
||||
PSYS_FRAND_SEED_MULTIPLIER[i] = (uint)BLI_rng_get_int(rng);
|
||||
PSYS_FRAND_SEED_OFFSET[i] = uint(BLI_rng_get_int(rng));
|
||||
PSYS_FRAND_SEED_MULTIPLIER[i] = uint(BLI_rng_get_int(rng));
|
||||
}
|
||||
BLI_rng_free(rng);
|
||||
}
|
||||
|
|
|
@ -201,7 +201,7 @@ static RobustInitCaller init_caller;
|
|||
y = bvirt - b
|
||||
|
||||
#define Fast_Two_Diff(a, b, x, y) \
|
||||
x = (double)(a - b); \
|
||||
x = double(a - b); \
|
||||
Fast_Two_Diff_Tail(a, b, x, y)
|
||||
|
||||
#define Two_Sum_Tail(a, b, x, y) \
|
||||
|
@ -253,7 +253,7 @@ static RobustInitCaller init_caller;
|
|||
y = (alo * blo) - err3
|
||||
|
||||
#define Two_Product_2Presplit(a, ahi, alo, b, bhi, blo, x, y) \
|
||||
x = (double)(a * b); \
|
||||
x = double(a * b); \
|
||||
err1 = x - (ahi * bhi); \
|
||||
err2 = err1 - (alo * bhi); \
|
||||
err3 = err2 - (ahi * blo); \
|
||||
|
|
|
@ -70,7 +70,7 @@ static void edituv_get_edituv_stretch_angle(float auv[2][2],
|
|||
#if 0 /* here for reference, this is done in shader now. */
|
||||
float uvang = angle_normalized_v2v2(auv0, auv1);
|
||||
float ang = angle_normalized_v3v3(av0, av1);
|
||||
float stretch = fabsf(uvang - ang) / (float)M_PI;
|
||||
float stretch = fabsf(uvang - ang) / float(M_PI);
|
||||
return 1.0f - pow2f(1.0f - stretch);
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -266,8 +266,8 @@ BMVert *EDBM_vert_find_nearest_ex(ViewContext *vc,
|
|||
uint base_index = 0;
|
||||
|
||||
if (!XRAY_FLAG_ENABLED(vc->v3d)) {
|
||||
uint dist_px_manhattan_test = (uint)ED_view3d_backbuf_sample_size_clamp(vc->region,
|
||||
*dist_px_manhattan_p);
|
||||
uint dist_px_manhattan_test = uint(
|
||||
ED_view3d_backbuf_sample_size_clamp(vc->region, *dist_px_manhattan_p));
|
||||
uint index;
|
||||
BMVert *eve;
|
||||
|
||||
|
@ -492,8 +492,8 @@ BMEdge *EDBM_edge_find_nearest_ex(ViewContext *vc,
|
|||
uint base_index = 0;
|
||||
|
||||
if (!XRAY_FLAG_ENABLED(vc->v3d)) {
|
||||
uint dist_px_manhattan_test = (uint)ED_view3d_backbuf_sample_size_clamp(vc->region,
|
||||
*dist_px_manhattan_p);
|
||||
uint dist_px_manhattan_test = uint(
|
||||
ED_view3d_backbuf_sample_size_clamp(vc->region, *dist_px_manhattan_p));
|
||||
uint index;
|
||||
BMEdge *eed;
|
||||
|
||||
|
@ -713,8 +713,8 @@ BMFace *EDBM_face_find_nearest_ex(ViewContext *vc,
|
|||
{
|
||||
uint dist_px_manhattan_test = 0;
|
||||
if (*dist_px_manhattan_p != 0.0f && (use_zbuf_single_px == false)) {
|
||||
dist_px_manhattan_test = (uint)ED_view3d_backbuf_sample_size_clamp(vc->region,
|
||||
*dist_px_manhattan_p);
|
||||
dist_px_manhattan_test = uint(
|
||||
ED_view3d_backbuf_sample_size_clamp(vc->region, *dist_px_manhattan_p));
|
||||
}
|
||||
|
||||
DRW_select_buffer_context_create(bases, bases_len, SCE_SELECT_FACE);
|
||||
|
|
|
@ -398,13 +398,13 @@ static void um_arraystore_compact_with_info(UndoMesh *um, const UndoMesh *um_ref
|
|||
&um_arraystore.bs_stride, &size_expanded, &size_compacted);
|
||||
|
||||
const double percent_total = size_expanded ?
|
||||
(((double)size_compacted / (double)size_expanded) * 100.0) :
|
||||
((double(size_compacted) / double(size_expanded)) * 100.0) :
|
||||
-1.0;
|
||||
|
||||
size_t size_expanded_step = size_expanded - size_expanded_prev;
|
||||
size_t size_compacted_step = size_compacted - size_compacted_prev;
|
||||
const double percent_step = size_expanded_step ?
|
||||
(((double)size_compacted_step / (double)size_expanded_step) *
|
||||
((double(size_compacted_step) / double(size_expanded_step)) *
|
||||
100.0) :
|
||||
-1.0;
|
||||
|
||||
|
|
|
@ -2603,10 +2603,10 @@ static void copy_mtex_copybuf(ID *id)
|
|||
|
||||
switch (GS(id->name)) {
|
||||
case ID_PA:
|
||||
mtex = &(((ParticleSettings *)id)->mtex[(int)((ParticleSettings *)id)->texact]);
|
||||
mtex = &(((ParticleSettings *)id)->mtex[int(((ParticleSettings *)id)->texact)]);
|
||||
break;
|
||||
case ID_LS:
|
||||
mtex = &(((FreestyleLineStyle *)id)->mtex[(int)((FreestyleLineStyle *)id)->texact]);
|
||||
mtex = &(((FreestyleLineStyle *)id)->mtex[int(((FreestyleLineStyle *)id)->texact)]);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
@ -2631,10 +2631,10 @@ static void paste_mtex_copybuf(ID *id)
|
|||
|
||||
switch (GS(id->name)) {
|
||||
case ID_PA:
|
||||
mtex = &(((ParticleSettings *)id)->mtex[(int)((ParticleSettings *)id)->texact]);
|
||||
mtex = &(((ParticleSettings *)id)->mtex[int(((ParticleSettings *)id)->texact)]);
|
||||
break;
|
||||
case ID_LS:
|
||||
mtex = &(((FreestyleLineStyle *)id)->mtex[(int)((FreestyleLineStyle *)id)->texact]);
|
||||
mtex = &(((FreestyleLineStyle *)id)->mtex[int(((FreestyleLineStyle *)id)->texact)]);
|
||||
break;
|
||||
default:
|
||||
BLI_assert_msg(0, "invalid id type");
|
||||
|
|
|
@ -701,16 +701,16 @@ int ED_fileselect_layout_numfiles(FileLayout *layout, ARegion *region)
|
|||
*/
|
||||
if (layout->flag & FILE_LAYOUT_HOR) {
|
||||
const int x_item = layout->tile_w + (2 * layout->tile_border_x);
|
||||
const int x_view = (int)BLI_rctf_size_x(®ion->v2d.cur);
|
||||
const int x_view = int(BLI_rctf_size_x(®ion->v2d.cur));
|
||||
const int x_over = x_item - (x_view % x_item);
|
||||
numfiles = (int)((float)(x_view + x_over) / (float)(x_item));
|
||||
numfiles = int(float(x_view + x_over) / float(x_item));
|
||||
return numfiles * layout->rows;
|
||||
}
|
||||
|
||||
const int y_item = layout->tile_h + (2 * layout->tile_border_y);
|
||||
const int y_view = (int)BLI_rctf_size_y(®ion->v2d.cur) - layout->offset_top;
|
||||
const int y_view = int(BLI_rctf_size_y(®ion->v2d.cur)) - layout->offset_top;
|
||||
const int y_over = y_item - (y_view % y_item);
|
||||
numfiles = (int)((float)(y_view + y_over) / (float)(y_item));
|
||||
numfiles = int(float(y_view + y_over) / float(y_item));
|
||||
return numfiles * layout->flow_columns;
|
||||
}
|
||||
|
||||
|
@ -871,7 +871,7 @@ FileAttributeColumnType file_attribute_column_type_find_isect(const View2D *v2d,
|
|||
|
||||
UI_view2d_region_to_view(v2d, x, v2d->mask.ymax - layout->offset_top - 1, &mx, &my);
|
||||
offset_tile = ED_fileselect_layout_offset(
|
||||
layout, (int)(v2d->tot.xmin + mx), (int)(v2d->tot.ymax - my));
|
||||
layout, int(v2d->tot.xmin + mx), int(v2d->tot.ymax - my));
|
||||
if (offset_tile > -1) {
|
||||
int tile_x, tile_y;
|
||||
int pos_x = 0;
|
||||
|
@ -939,7 +939,7 @@ static void file_attribute_columns_widths(const FileSelectParams *params, FileLa
|
|||
pad;
|
||||
columns[COLUMN_SIZE].width = file_string_width(small_size ? "98.7 M" : "098.7 MiB") + pad;
|
||||
if (params->display == FILE_IMGDISPLAY) {
|
||||
columns[COLUMN_NAME].width = ((float)params->thumbnail_size / 8.0f) * UI_UNIT_X;
|
||||
columns[COLUMN_NAME].width = (float(params->thumbnail_size) / 8.0f) * UI_UNIT_X;
|
||||
}
|
||||
/* Name column uses remaining width */
|
||||
else {
|
||||
|
@ -993,22 +993,22 @@ void ED_fileselect_init_layout(struct SpaceFile *sfile, ARegion *region)
|
|||
}
|
||||
|
||||
numfiles = filelist_files_ensure(sfile->files);
|
||||
textheight = (int)file_font_pointsize();
|
||||
textheight = int(file_font_pointsize());
|
||||
layout = sfile->layout;
|
||||
layout->textheight = textheight;
|
||||
|
||||
if (params->display == FILE_IMGDISPLAY) {
|
||||
const float pad_fac = compact ? 0.15f : 0.3f;
|
||||
/* Matches UI_preview_tile_size_x()/_y() by default. */
|
||||
layout->prv_w = ((float)params->thumbnail_size / 20.0f) * UI_UNIT_X;
|
||||
layout->prv_h = ((float)params->thumbnail_size / 20.0f) * UI_UNIT_Y;
|
||||
layout->prv_w = (float(params->thumbnail_size) / 20.0f) * UI_UNIT_X;
|
||||
layout->prv_h = (float(params->thumbnail_size) / 20.0f) * UI_UNIT_Y;
|
||||
layout->tile_border_x = pad_fac * UI_UNIT_X;
|
||||
layout->tile_border_y = pad_fac * UI_UNIT_X;
|
||||
layout->prv_border_x = pad_fac * UI_UNIT_X;
|
||||
layout->prv_border_y = pad_fac * UI_UNIT_Y;
|
||||
layout->tile_w = layout->prv_w + 2 * layout->prv_border_x;
|
||||
layout->tile_h = layout->prv_h + 2 * layout->prv_border_y + textheight;
|
||||
layout->width = (int)(BLI_rctf_size_x(&v2d->cur) - 2 * layout->tile_border_x);
|
||||
layout->width = int(BLI_rctf_size_x(&v2d->cur) - 2 * layout->tile_border_x);
|
||||
layout->flow_columns = layout->width / (layout->tile_w + 2 * layout->tile_border_x);
|
||||
layout->attribute_column_header_h = 0;
|
||||
layout->offset_top = 0;
|
||||
|
@ -1027,17 +1027,17 @@ void ED_fileselect_init_layout(struct SpaceFile *sfile, ARegion *region)
|
|||
int rowcount;
|
||||
|
||||
/* Matches UI_preview_tile_size_x()/_y() by default. */
|
||||
layout->prv_w = ((float)params->thumbnail_size / 20.0f) * UI_UNIT_X;
|
||||
layout->prv_h = ((float)params->thumbnail_size / 20.0f) * UI_UNIT_Y;
|
||||
layout->prv_w = (float(params->thumbnail_size) / 20.0f) * UI_UNIT_X;
|
||||
layout->prv_h = (float(params->thumbnail_size) / 20.0f) * UI_UNIT_Y;
|
||||
layout->tile_border_x = 0.4f * UI_UNIT_X;
|
||||
layout->tile_border_y = 0.1f * UI_UNIT_Y;
|
||||
layout->tile_h = textheight * 3 / 2;
|
||||
layout->width = (int)(BLI_rctf_size_x(&v2d->cur) - 2 * layout->tile_border_x);
|
||||
layout->width = int(BLI_rctf_size_x(&v2d->cur) - 2 * layout->tile_border_x);
|
||||
layout->tile_w = layout->width;
|
||||
layout->flow_columns = 1;
|
||||
layout->attribute_column_header_h = layout->tile_h * 1.2f + 2 * layout->tile_border_y;
|
||||
layout->offset_top = layout->attribute_column_header_h;
|
||||
rowcount = (int)(BLI_rctf_size_y(&v2d->cur) - layout->offset_top - 2 * layout->tile_border_y) /
|
||||
rowcount = int(BLI_rctf_size_y(&v2d->cur) - layout->offset_top - 2 * layout->tile_border_y) /
|
||||
(layout->tile_h + 2 * layout->tile_border_y);
|
||||
file_attribute_columns_init(params, layout);
|
||||
|
||||
|
@ -1049,14 +1049,14 @@ void ED_fileselect_init_layout(struct SpaceFile *sfile, ARegion *region)
|
|||
}
|
||||
else if (params->display == FILE_HORIZONTALDISPLAY) {
|
||||
/* Matches UI_preview_tile_size_x()/_y() by default. */
|
||||
layout->prv_w = ((float)params->thumbnail_size / 20.0f) * UI_UNIT_X;
|
||||
layout->prv_h = ((float)params->thumbnail_size / 20.0f) * UI_UNIT_Y;
|
||||
layout->prv_w = (float(params->thumbnail_size) / 20.0f) * UI_UNIT_X;
|
||||
layout->prv_h = (float(params->thumbnail_size) / 20.0f) * UI_UNIT_Y;
|
||||
layout->tile_border_x = 0.4f * UI_UNIT_X;
|
||||
layout->tile_border_y = 0.1f * UI_UNIT_Y;
|
||||
layout->tile_h = textheight * 3 / 2;
|
||||
layout->attribute_column_header_h = 0;
|
||||
layout->offset_top = layout->attribute_column_header_h;
|
||||
layout->height = (int)(BLI_rctf_size_y(&v2d->cur) - 2 * layout->tile_border_y);
|
||||
layout->height = int(BLI_rctf_size_y(&v2d->cur) - 2 * layout->tile_border_y);
|
||||
/* Padding by full scroll-bar H is too much, can overlap tile border Y. */
|
||||
layout->rows = (layout->height - V2D_SCROLL_HEIGHT + layout->tile_border_y) /
|
||||
(layout->tile_h + 2 * layout->tile_border_y);
|
||||
|
|
|
@ -1275,11 +1275,11 @@ static void apply_ao_callback(DerivedMesh *lores_dm,
|
|||
const ushort J = ao_data->permutation_table_2[i];
|
||||
|
||||
const float JitPh = (get_ao_random2(I + perm_ofs) & (MAX_NUMBER_OF_AO_RAYS - 1)) /
|
||||
((float)MAX_NUMBER_OF_AO_RAYS);
|
||||
float(MAX_NUMBER_OF_AO_RAYS);
|
||||
const float JitTh = (get_ao_random1(J + perm_ofs) & (MAX_NUMBER_OF_AO_RAYS - 1)) /
|
||||
((float)MAX_NUMBER_OF_AO_RAYS);
|
||||
float(MAX_NUMBER_OF_AO_RAYS);
|
||||
const float SiSqPhi = (I + JitPh) / ao_data->number_of_rays;
|
||||
const float Theta = (float)(2 * M_PI) * ((J + JitTh) / ao_data->number_of_rays);
|
||||
const float Theta = float(2 * M_PI) * ((J + JitTh) / ao_data->number_of_rays);
|
||||
|
||||
/* this gives results identical to the so-called cosine
|
||||
* weighted distribution relative to the north pole.
|
||||
|
|
Loading…
Reference in New Issue