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

Also remove redundant parenthesis.
This commit is contained in:
Campbell Barton 2023-01-03 11:04:16 +11:00
parent 75cd1fdc0a
commit e39ca9d1e3
32 changed files with 180 additions and 182 deletions

View File

@ -1460,9 +1460,9 @@ static bool cloth_build_springs(ClothModifierData *clmd, Mesh *mesh)
Cloth *cloth = clmd->clothObject;
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 mvert_num = uint(mesh->totvert);
uint numedges = uint(mesh->totedge);
uint numpolys = (uint)mesh->totpoly;
uint numpolys = uint(mesh->totpoly);
float shrink_factor;
const MEdge *medge = BKE_mesh_edges(mesh);
const MPoly *mpoly = BKE_mesh_polys(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

@ -732,7 +732,7 @@ static void cp_key(const int start,
if (flagflo) {
ktot += start * kd;
a = (int)floor(ktot);
a = int(floor(ktot));
if (a) {
ktot -= a;
k1 += a * key->elemsize;
@ -1078,7 +1078,7 @@ static void do_key(const int start,
if (flagdo & 1) {
if (flagflo & 1) {
k1tot += start * k1d;
a = (int)floor(k1tot);
a = int(floor(k1tot));
if (a) {
k1tot -= a;
k1 += a * key->elemsize;
@ -1091,7 +1091,7 @@ static void do_key(const int start,
if (flagdo & 2) {
if (flagflo & 2) {
k2tot += start * k2d;
a = (int)floor(k2tot);
a = int(floor(k2tot));
if (a) {
k2tot -= a;
k2 += a * key->elemsize;
@ -1104,7 +1104,7 @@ static void do_key(const int start,
if (flagdo & 4) {
if (flagflo & 4) {
k3tot += start * k3d;
a = (int)floor(k3tot);
a = int(floor(k3tot));
if (a) {
k3tot -= a;
k3 += a * key->elemsize;
@ -1117,7 +1117,7 @@ static void do_key(const int start,
if (flagdo & 8) {
if (flagflo & 8) {
k4tot += start * k4d;
a = (int)floor(k4tot);
a = int(floor(k4tot));
if (a) {
k4tot -= a;
k4 += a * key->elemsize;
@ -1661,7 +1661,7 @@ int BKE_keyblock_element_count(const Key *key)
size_t BKE_keyblock_element_calc_size_from_shape(const Key *key, const int shape_index)
{
return (size_t)BKE_keyblock_element_count_from_shape(key, shape_index) * key->elemsize;
return size_t(BKE_keyblock_element_count_from_shape(key, shape_index)) * key->elemsize;
}
size_t BKE_keyblock_element_calc_size(const Key *key)

View File

@ -1057,7 +1057,7 @@ static void layer_collection_objects_sync(ViewLayer *view_layer,
}
/* Holdout and indirect only */
if ((layer->flag & LAYER_COLLECTION_HOLDOUT)) {
if (layer->flag & LAYER_COLLECTION_HOLDOUT) {
base->flag_from_collection |= BASE_HOLDOUT;
}
if (layer->flag & LAYER_COLLECTION_INDIRECT_ONLY) {

View File

@ -1592,7 +1592,7 @@ void BKE_mesh_remap_calc_loops_from_mesh(const int mode,
}
}
if ((size_t)mp_dst->totloop > islands_res_buff_size) {
if (size_t(mp_dst->totloop) > islands_res_buff_size) {
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 *>(
@ -2257,7 +2257,7 @@ void BKE_mesh_remap_calc_polys_from_mesh(const int mode,
*/
RNG *rng = BLI_rng_new(0);
const size_t numpolys_src = (size_t)me_src->totpoly;
const size_t numpolys_src = size_t(me_src->totpoly);
/* Here it's simpler to just allocate for all polys :/ */
int *indices = static_cast<int *>(MEM_mallocN(sizeof(*indices) * numpolys_src, __func__));

View File

@ -3789,7 +3789,7 @@ 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_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] -
@ -3828,8 +3828,8 @@ void blo_do_versions_300(FileData *fd, Library * /*lib*/, Main *bmain)
LISTBASE_FOREACH (SpaceLink *, sl, &area->spacedata) {
if (sl->spacetype == SPACE_VIEW3D) {
View3D *v3d = (View3D *)sl;
v3d->overlay.flag |= (int)(V3D_OVERLAY_SCULPT_SHOW_MASK |
V3D_OVERLAY_SCULPT_SHOW_FACE_SETS);
v3d->overlay.flag |= int(V3D_OVERLAY_SCULPT_SHOW_MASK |
V3D_OVERLAY_SCULPT_SHOW_FACE_SETS);
}
}
}

View File

@ -919,7 +919,7 @@ static void bm_mesh_loops_calc_normals_for_vert_with_clnors(BMesh *bm,
BLI_linklist_prepend_alloca(&loops_of_vert, l_curr);
loops_of_vert_count += 1;
const uint index_test = (uint)BM_elem_index_get(l_curr);
const uint index_test = uint(BM_elem_index_get(l_curr));
if (index_best > index_test) {
index_best = index_test;
link_best = loops_of_vert;

View File

@ -92,10 +92,10 @@ static void OVERLAY_engine_init(void *vedata)
}
if (ts->sculpt) {
if (!(v3d->overlay.flag & (int)V3D_OVERLAY_SCULPT_SHOW_FACE_SETS)) {
if (!(v3d->overlay.flag & int(V3D_OVERLAY_SCULPT_SHOW_FACE_SETS))) {
pd->overlay.sculpt_mode_face_sets_opacity = 0.0f;
}
if (!(v3d->overlay.flag & (int)V3D_OVERLAY_SCULPT_SHOW_MASK)) {
if (!(v3d->overlay.flag & int(V3D_OVERLAY_SCULPT_SHOW_MASK))) {
pd->overlay.sculpt_mode_mask_opacity = 0.0f;
}
}

View File

@ -276,7 +276,7 @@ BLI_INLINE int32_t pack_rotation_aspect_hardness(float rot, float asp, float har
int32_t packed = 0;
/* Aspect uses 9 bits */
float asp_normalized = (asp > 1.0f) ? (1.0f / asp) : asp;
packed |= (int32_t)unit_float_to_uchar_clamp(asp_normalized);
packed |= int32_t(unit_float_to_uchar_clamp(asp_normalized));
/* Store if inversed in the 9th bit. */
if (asp > 1.0f) {
packed |= 1 << 8;
@ -284,13 +284,13 @@ BLI_INLINE int32_t pack_rotation_aspect_hardness(float rot, float asp, float har
/* Rotation uses 9 bits */
/* Rotation are in [-90°..90°] range, so we can encode the sign of the angle + the cosine
* because the cosine will always be positive. */
packed |= (int32_t)unit_float_to_uchar_clamp(cosf(rot)) << 9;
packed |= int32_t(unit_float_to_uchar_clamp(cosf(rot))) << 9;
/* Store sine sign in 9th bit. */
if (rot < 0.0f) {
packed |= 1 << 17;
}
/* Hardness uses 8 bits */
packed |= (int32_t)unit_float_to_uchar_clamp(hard) << 18;
packed |= int32_t(unit_float_to_uchar_clamp(hard)) << 18;
return packed;
}
@ -315,7 +315,7 @@ static void gpencil_buffer_add_point(GPUIndexBufBuilder *ibo,
/* Encode fill opacity defined by opacity modifier in vertex color alpha. If
* no opacity modifier, the value will be always 1.0f. The opacity factor can be any
* value between 0.0f and 2.0f */
col->fcol[3] = ((int)(col->fcol[3] * 10000.0f) * 10.0f) + gps->fill_opacity_fac;
col->fcol[3] = (int(col->fcol[3] * 10000.0f) * 10.0f) + gps->fill_opacity_fac;
vert->strength = (round_cap0) ? pt->strength : -pt->strength;
vert->u_stroke = pt->uv_fac;
@ -579,7 +579,7 @@ bGPDstroke *DRW_cache_gpencil_sbuffer_stroke_data_get(Object *ob)
gps->runtime.stroke_start = 0;
copy_v4_v4(gps->vert_color_fill, gpd->runtime.vert_color_fill);
/* Caps. */
gps->caps[0] = gps->caps[1] = (short)brush->gpencil_settings->caps_type;
gps->caps[0] = gps->caps[1] = short(brush->gpencil_settings->caps_type);
gpd->runtime.sbuffer_gps = gps;
}

View File

@ -175,8 +175,8 @@ static bool eyedropper_cryptomatte_sample_renderlayer_fl(RenderLayer *render_lay
if (STRPREFIX(render_pass->name, render_pass_name_prefix) &&
!STREQLEN(render_pass->name, render_pass_name_prefix, sizeof(render_pass->name))) {
BLI_assert(render_pass->channels == 4);
const int x = (int)(fpos[0] * render_pass->rectx);
const int y = (int)(fpos[1] * render_pass->recty);
const int x = int(fpos[0] * render_pass->rectx);
const int y = int(fpos[1] * render_pass->recty);
const int offset = 4 * (y * render_pass->rectx + x);
zero_v3(r_col);
r_col[0] = render_pass->rect[offset];

View File

@ -115,10 +115,10 @@ void UI_draw_roundbox_3ub_alpha(
const rctf *rect, bool filled, float rad, const uchar col[3], uchar alpha)
{
const float colv[4] = {
(float(col[0])) / 255.0f,
(float(col[1])) / 255.0f,
(float(col[2])) / 255.0f,
(float(alpha)) / 255.0f,
float(col[0]) / 255.0f,
float(col[1]) / 255.0f,
float(col[2]) / 255.0f,
float(alpha) / 255.0f,
};
UI_draw_roundbox_4fv_ex(rect, (filled) ? colv : nullptr, nullptr, 1.0f, colv, U.pixelsize, rad);
}
@ -1791,7 +1791,7 @@ void ui_draw_but_CURVEPROFILE(ARegion *region,
/* Create array of the positions of the table's points. */
float(*table_coords)[2] = static_cast<float(*)[2]>(
MEM_mallocN(sizeof(*table_coords) * tot_points, __func__));
for (uint i = 0; i < (uint)BKE_curveprofile_table_size(profile); i++) {
for (uint i = 0; i < uint(BKE_curveprofile_table_size(profile)); i++) {
/* Only add the points from the table here. */
table_coords[i][0] = pts[i].x;
table_coords[i][1] = pts[i].y;

View File

@ -837,7 +837,7 @@ static ImBuf *create_mono_icon_with_border(ImBuf *buf,
blend_color_interpolate_float(dest_rgba, orig_rgba, border_rgba, 1.0 - orig_rgba[3]);
linearrgb_to_srgb_v4(dest_srgb, dest_rgba);
const uint alpha_mask = (uint)(dest_srgb[3] * 255) << 24;
const uint alpha_mask = uint(dest_srgb[3] * 255) << 24;
const uint cpack = rgb_to_cpack(dest_srgb[0], dest_srgb[1], dest_srgb[2]) | alpha_mask;
result->rect[offset_write] = cpack;
}
@ -1549,11 +1549,11 @@ 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;
}
@ -1772,7 +1772,7 @@ static void icon_draw_texture(float x,
sizeof(text_overlay->text),
text_color,
&params);
text_width = (float)UI_fontstyle_string_width(&fstyle_small, text_overlay->text) / UI_UNIT_X /
text_width = float(UI_fontstyle_string_width(&fstyle_small, text_overlay->text)) / UI_UNIT_X /
zoom_factor;
}
@ -1868,7 +1868,7 @@ static void icon_draw_size(float x,
}
/* scale width and height according to aspect */
int w = (int)(fdraw_size / aspect + 0.5f);
int w = int(fdraw_size / aspect + 0.5f);
int h = int(fdraw_size / aspect + 0.5f);
DrawInfo *di = icon_ensure_drawinfo(icon);

View File

@ -335,7 +335,7 @@ static int ui_text_icon_width_ex(uiLayout *layout,
const float aspect = layout->root->block->aspect;
const uiFontStyle *fstyle = UI_FSTYLE_WIDGET;
return UI_fontstyle_string_width_with_block_aspect(fstyle, name, aspect) +
(int)ceilf(unit_x * margin);
int(ceilf(unit_x * margin));
}
return unit_x * 10;
}
@ -4315,7 +4315,7 @@ static void ui_litem_grid_flow_compute(ListBase *items,
int item_w, item_h;
ui_item_size(item, &item_w, &item_h);
global_avg_w += (float)(item_w * item_w);
global_avg_w += float(item_w * item_w);
global_totweight_w += float(item_w);
global_max_h = max_ii(global_max_h, item_h);
@ -4361,8 +4361,8 @@ static void ui_litem_grid_flow_compute(ListBase *items,
/* Compute positions and sizes of all cells. */
if (results->cos_x_array != nullptr && results->widths_array != nullptr) {
/* We enlarge/narrow columns evenly to match available width. */
const float wfac = (float)(parameters->litem_w -
(parameters->tot_columns - 1) * parameters->space_x) /
const float wfac = float(parameters->litem_w -
(parameters->tot_columns - 1) * parameters->space_x) /
tot_w;
for (int col = 0; col < parameters->tot_columns; col++) {
@ -4382,7 +4382,7 @@ static void ui_litem_grid_flow_compute(ListBase *items,
(results->cos_x_array[col] - parameters->litem_x);
}
else {
results->widths_array[col] = (int)(avg_w[col] * wfac);
results->widths_array[col] = int(avg_w[col] * wfac);
}
}
}
@ -4460,10 +4460,10 @@ static void ui_litem_estimate_grid_flow(uiLayout *litem)
gflow->tot_columns = 1;
}
else {
gflow->tot_columns = min_ii(max_ii((int)(litem->w / avg_w), 1), gflow->tot_items);
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 */
}
@ -4505,8 +4505,8 @@ static void ui_litem_estimate_grid_flow(uiLayout *litem)
/* Set evenly-spaced axes size
* (quick optimization in case we have even columns and rows). */
if (gflow->even_columns && gflow->even_rows) {
litem->w = (int)(gflow->tot_columns * avg_w) + space_x * (gflow->tot_columns - 1);
litem->h = (int)(gflow->tot_rows * max_h) + space_y * (gflow->tot_rows - 1);
litem->w = int(gflow->tot_columns * avg_w) + space_x * (gflow->tot_columns - 1);
litem->h = int(gflow->tot_rows * max_h) + space_y * (gflow->tot_rows - 1);
return;
}
}
@ -4714,7 +4714,7 @@ 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);
const float width = extra_pixel + (w - int(w * percentage)) / (float(tot) - 1);
extra_pixel = width - int(width);
colw = int(width);
colw = MAX2(colw, 0);
@ -6135,7 +6135,7 @@ uiLayout *uiItemsAlertBox(uiBlock *block, const int size, const eAlertIcon icon)
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) /
(float)(dialog_width - style->columnspace);
float(dialog_width - style->columnspace);
uiLayout *block_layout = UI_block_layout(
block, UI_LAYOUT_VERTICAL, UI_LAYOUT_PANEL, 0, 0, dialog_width, 0, 0, style);

View File

@ -3183,7 +3183,7 @@ void uiTemplatePreview(uiLayout *layout,
if (!ui_preview) {
ui_preview = MEM_cnew<uiPreview>(__func__);
BLI_strncpy(ui_preview->preview_id, preview_id, sizeof(ui_preview->preview_id));
ui_preview->height = (short)(UI_UNIT_Y * 7.6f);
ui_preview->height = short(UI_UNIT_Y * 7.6f);
BLI_addtail(&region->ui_previews, ui_preview);
}
@ -3225,7 +3225,7 @@ void uiTemplatePreview(uiLayout *layout,
0,
0,
UI_UNIT_X * 10,
(short)(UI_UNIT_Y * 0.3f),
short(UI_UNIT_Y * 0.3f),
&ui_preview->height,
UI_UNIT_Y,
UI_UNIT_Y * 50.0f,
@ -4028,7 +4028,7 @@ void uiTemplateHistogram(uiLayout *layout, PointerRNA *ptr, const char *propname
0,
0,
UI_UNIT_X * 10,
(short)(UI_UNIT_Y * 0.3f),
short(UI_UNIT_Y * 0.3f),
&hist->height,
UI_UNIT_Y,
UI_UNIT_Y * 20.0f,
@ -4090,7 +4090,7 @@ void uiTemplateWaveform(uiLayout *layout, PointerRNA *ptr, const char *propname)
0,
0,
UI_UNIT_X * 10,
(short)(UI_UNIT_Y * 0.3f),
short(UI_UNIT_Y * 0.3f),
&scopes->wavefrm_height,
UI_UNIT_Y,
UI_UNIT_Y * 20.0f,
@ -4152,7 +4152,7 @@ void uiTemplateVectorscope(uiLayout *layout, PointerRNA *ptr, const char *propna
0,
0,
UI_UNIT_X * 10,
(short)(UI_UNIT_Y * 0.3f),
short(UI_UNIT_Y * 0.3f),
&scopes->vecscope_height,
UI_UNIT_Y,
UI_UNIT_Y * 20.0f,

View File

@ -133,9 +133,9 @@ static const uiWidgetStateInfo STATE_INFO_NULL = {0};
static void color_blend_v3_v3(uchar cp[3], const uchar cpstate[3], const float fac)
{
if (fac != 0.0f) {
cp[0] = (int)((1.0f - fac) * cp[0] + fac * cpstate[0]);
cp[1] = (int)((1.0f - fac) * cp[1] + fac * cpstate[1]);
cp[2] = (int)((1.0f - fac) * cp[2] + fac * cpstate[2]);
cp[0] = int((1.0f - fac) * cp[0] + fac * cpstate[0]);
cp[1] = int((1.0f - fac) * cp[1] + fac * cpstate[1]);
cp[2] = int((1.0f - fac) * cp[2] + fac * cpstate[2]);
}
}
@ -880,7 +880,7 @@ static void shape_preset_init_trias_ex(uiWidgetTrias *tria,
const float minsize = ELEM(where, 'r', 'l') ? BLI_rcti_size_y(rect) : BLI_rcti_size_x(rect);
/* center position and size */
float centx = (float)rect->xmin + 0.4f * minsize;
float centx = float(rect->xmin) + 0.4f * minsize;
float centy = float(rect->ymin) + 0.5f * minsize;
tria->size = sizex = sizey = -0.5f * triasize * minsize;
@ -1448,8 +1448,8 @@ static void widget_draw_submenu_tria(const uiBut *but,
const uiWidgetColors *wcol)
{
const float aspect = but->block->aspect * U.inv_dpi_fac;
const int tria_height = (int)(ICON_DEFAULT_HEIGHT / aspect);
const int tria_width = (int)(ICON_DEFAULT_WIDTH / aspect) - 2 * U.pixelsize;
const int tria_height = int(ICON_DEFAULT_HEIGHT / aspect);
const int tria_width = int(ICON_DEFAULT_WIDTH / aspect) - 2 * U.pixelsize;
const int xs = rect->xmax - tria_width;
const int ys = (rect->ymin + rect->ymax - tria_height) / 2.0f;
@ -1507,7 +1507,7 @@ static void ui_text_clip_right_ex(const uiFontStyle *fstyle,
/* At least one character, so clip and add the ellipsis. */
memcpy(str + l_end, sep, sep_len + 1); /* +1 for trailing '\0'. */
if (r_final_len) {
*r_final_len = (size_t)(l_end) + sep_len;
*r_final_len = size_t(l_end) + sep_len;
}
}
else {
@ -1602,7 +1602,7 @@ float UI_text_clip_middle_ex(const uiFontStyle *fstyle,
memmove(str + l_end + sep_len, str + r_offset, r_len);
memcpy(str + l_end, sep, sep_len);
/* -1 to remove trailing '\0'! */
final_lpart_len = (size_t)(l_end + sep_len + r_len - 1);
final_lpart_len = size_t(l_end + sep_len + r_len - 1);
while (BLF_width(fstyle->uifont_id, str, max_len) > okwidth) {
/* This will happen because a lot of string width processing is done in integer pixels,
@ -1638,10 +1638,10 @@ static void ui_text_clip_middle(const uiFontStyle *fstyle, uiBut *but, const rct
/* No margin for labels! */
const int border = ELEM(but->type, UI_BTYPE_LABEL, UI_BTYPE_MENU, UI_BTYPE_POPOVER) ?
0 :
(int)(UI_TEXT_CLIP_MARGIN + 0.5f);
const float okwidth = (float)max_ii(BLI_rcti_size_x(rect) - border, 0);
int(UI_TEXT_CLIP_MARGIN + 0.5f);
const float okwidth = float(max_ii(BLI_rcti_size_x(rect) - border, 0));
const size_t max_len = sizeof(but->drawstr);
const float minwidth = (float)(UI_DPI_ICON_SIZE) / but->block->aspect * 2.0f;
const float minwidth = float(UI_DPI_ICON_SIZE) / but->block->aspect * 2.0f;
but->ofs = 0;
but->strwidth = UI_text_clip_middle_ex(fstyle, but->drawstr, okwidth, minwidth, max_len, '\0');
@ -1661,10 +1661,10 @@ static void ui_text_clip_middle_protect_right(const uiFontStyle *fstyle,
/* No margin for labels! */
const int border = ELEM(but->type, UI_BTYPE_LABEL, UI_BTYPE_MENU, UI_BTYPE_POPOVER) ?
0 :
(int)(UI_TEXT_CLIP_MARGIN + 0.5f);
const float okwidth = (float)max_ii(BLI_rcti_size_x(rect) - border, 0);
int(UI_TEXT_CLIP_MARGIN + 0.5f);
const float okwidth = float(max_ii(BLI_rcti_size_x(rect) - border, 0));
const size_t max_len = sizeof(but->drawstr);
const float minwidth = (float)(UI_DPI_ICON_SIZE) / but->block->aspect * 2.0f;
const float minwidth = float(UI_DPI_ICON_SIZE) / but->block->aspect * 2.0f;
but->ofs = 0;
but->strwidth = UI_text_clip_middle_ex(fstyle, but->drawstr, okwidth, minwidth, max_len, rsep);
@ -1675,7 +1675,7 @@ static void ui_text_clip_middle_protect_right(const uiFontStyle *fstyle,
*/
static void ui_text_clip_cursor(const uiFontStyle *fstyle, uiBut *but, const rcti *rect)
{
const int border = (int)(UI_TEXT_CLIP_MARGIN + 0.5f);
const int border = int(UI_TEXT_CLIP_MARGIN + 0.5f);
const int okwidth = max_ii(BLI_rcti_size_x(rect) - border, 0);
BLI_assert(but->editstr && but->pos >= 0);
@ -2119,7 +2119,7 @@ static void widget_draw_text(const uiFontStyle *fstyle,
for (int i = 0; i < ARRAY_SIZE(keys); i++) {
const char *drawstr_menu = strchr(drawstr_ofs, keys[i]);
if (drawstr_menu != nullptr && drawstr_menu < drawstr_end) {
ul_index = (int)(drawstr_menu - drawstr_ofs);
ul_index = int(drawstr_menu - drawstr_ofs);
break;
}
}
@ -2814,7 +2814,7 @@ void ui_hsvcircle_vals_from_pos(
/* duplication of code... well, simple is better now */
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;
const float radius = float(min_ii(BLI_rcti_size_x(rect), BLI_rcti_size_y(rect))) / 2.0f;
const float m_delta[2] = {mx - centx, my - centy};
const float dist_sq = len_squared_v2(m_delta);
@ -2828,7 +2828,7 @@ void ui_hsvcircle_pos_from_vals(
/* duplication of code... well, simple is better now */
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;
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);
@ -2853,7 +2853,7 @@ static void ui_draw_but_HSVCIRCLE(uiBut *but, const uiWidgetColors *wcol, const
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;
const float radius = float(min_ii(BLI_rcti_size_x(rect), BLI_rcti_size_y(rect))) / 2.0f;
ColorPicker *cpicker = static_cast<ColorPicker *>(but->custom_data);
float rgb[3], hsv[3], rgb_center[3];
@ -3086,7 +3086,7 @@ void ui_draw_gradient(const rcti *rect,
sx1 = rect->xmin + dx * BLI_rcti_size_x(rect);
sx2 = rect->xmin + dx_next * BLI_rcti_size_x(rect);
sy = rect->ymin;
dy = (float)BLI_rcti_size_y(rect) / 3.0f;
dy = float(BLI_rcti_size_y(rect)) / 3.0f;
for (a = 0; a < 3; a++, sy += dy) {
immAttr4f(col, col0[a][0], col0[a][1], col0[a][2], alpha);
@ -3551,7 +3551,7 @@ static void widget_scroll(uiBut *but,
const float /*zoom*/)
{
/* calculate slider part */
const float value = (float)ui_but_value_get(but);
const float value = float(ui_but_value_get(but));
const float size = max_ff((but->softmax + but->a1 - but->softmin), 2.0f);
@ -3726,7 +3726,7 @@ static void widget_numslider(uiBut *but,
rcti rect1 = *rect;
float factor, factor_ui;
float factor_discard = 1.0f; /* No discard. */
const float value = (float)ui_but_value_get(but);
const float value = float(ui_but_value_get(but));
const float softmin = but->softmin;
const float softmax = but->softmax;
const float softrange = softmax - softmin;
@ -3758,7 +3758,7 @@ static void widget_numslider(uiBut *but,
}
}
const float width = (float)BLI_rcti_size_x(rect);
const float width = float(BLI_rcti_size_x(rect));
factor_ui = factor * width;
/* The rectangle width needs to be at least twice the corner radius for the round corners
* to be drawn properly. */
@ -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) {
@ -5129,7 +5129,7 @@ static void draw_disk_shaded(float start,
immBegin(GPU_PRIM_TRI_STRIP, subd * 2);
for (int i = 0; i < subd; i++) {
const float a = start + ((i) / (float)(subd - 1)) * angle;
const float a = start + ((i) / float(subd - 1)) * angle;
const float s = sinf(a);
const float c = cosf(a);
const float y1 = s * radius_int;
@ -5380,9 +5380,9 @@ void ui_draw_menu_item(const uiFontStyle *fstyle,
{
char drawstr[UI_MAX_DRAW_STR];
const float okwidth = (float)BLI_rcti_size_x(rect);
const float okwidth = float(BLI_rcti_size_x(rect));
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));
if (drawstr[0]) {
@ -5431,7 +5431,7 @@ void ui_draw_menu_item(const uiFontStyle *fstyle,
char hint_drawstr[UI_MAX_DRAW_STR];
{
const size_t max_len = sizeof(hint_drawstr);
const float minwidth = (float)(UI_DPI_ICON_SIZE);
const float minwidth = float(UI_DPI_ICON_SIZE);
BLI_strncpy(hint_drawstr, cpoin + 1, sizeof(hint_drawstr));
if (hint_drawstr[0] && (max_hint_width < INT_MAX)) {
@ -5484,7 +5484,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 float okwidth = float(BLI_rcti_size_x(&trect));
const size_t max_len = sizeof(drawstr);
const float minwidth = float(UI_DPI_ICON_SIZE);

View File

@ -1141,51 +1141,51 @@ void UI_FontThemeColor(int fontid, int colorid)
float UI_GetThemeValuef(int colorid)
{
const uchar *cp = UI_ThemeGetColorPtr(g_theme_state.theme, g_theme_state.spacetype, colorid);
return (float(cp[0]));
return float(cp[0]);
}
int UI_GetThemeValue(int colorid)
{
const uchar *cp = UI_ThemeGetColorPtr(g_theme_state.theme, g_theme_state.spacetype, colorid);
return (int(cp[0]));
return int(cp[0]);
}
float UI_GetThemeValueTypef(int colorid, int spacetype)
{
const uchar *cp = UI_ThemeGetColorPtr(g_theme_state.theme, spacetype, colorid);
return (float(cp[0]));
return float(cp[0]);
}
int UI_GetThemeValueType(int colorid, int spacetype)
{
const uchar *cp = UI_ThemeGetColorPtr(g_theme_state.theme, spacetype, colorid);
return (int(cp[0]));
return int(cp[0]);
}
void UI_GetThemeColor3fv(int colorid, float col[3])
{
const uchar *cp = UI_ThemeGetColorPtr(g_theme_state.theme, g_theme_state.spacetype, colorid);
col[0] = (float(cp[0])) / 255.0f;
col[1] = (float(cp[1])) / 255.0f;
col[2] = (float(cp[2])) / 255.0f;
col[0] = float(cp[0]) / 255.0f;
col[1] = float(cp[1]) / 255.0f;
col[2] = float(cp[2]) / 255.0f;
}
void UI_GetThemeColor4fv(int colorid, float col[4])
{
const uchar *cp = UI_ThemeGetColorPtr(g_theme_state.theme, g_theme_state.spacetype, colorid);
col[0] = (float(cp[0])) / 255.0f;
col[1] = (float(cp[1])) / 255.0f;
col[2] = (float(cp[2])) / 255.0f;
col[3] = (float(cp[3])) / 255.0f;
col[0] = float(cp[0]) / 255.0f;
col[1] = float(cp[1]) / 255.0f;
col[2] = float(cp[2]) / 255.0f;
col[3] = float(cp[3]) / 255.0f;
}
void UI_GetThemeColorType4fv(int colorid, int spacetype, float col[4])
{
const uchar *cp = UI_ThemeGetColorPtr(g_theme_state.theme, spacetype, colorid);
col[0] = (float(cp[0])) / 255.0f;
col[1] = (float(cp[1])) / 255.0f;
col[2] = (float(cp[2])) / 255.0f;
col[3] = (float(cp[3])) / 255.0f;
col[0] = float(cp[0]) / 255.0f;
col[1] = float(cp[1]) / 255.0f;
col[2] = float(cp[2]) / 255.0f;
col[3] = float(cp[3]) / 255.0f;
}
void UI_GetThemeColorShade3fv(int colorid, int offset, float col[3])
@ -1361,9 +1361,9 @@ void UI_GetThemeColor4ubv(int colorid, uchar col[4])
void UI_GetThemeColorType3fv(int colorid, int spacetype, float col[3])
{
const uchar *cp = UI_ThemeGetColorPtr(g_theme_state.theme, spacetype, colorid);
col[0] = (float(cp[0])) / 255.0f;
col[1] = (float(cp[1])) / 255.0f;
col[2] = (float(cp[2])) / 255.0f;
col[0] = float(cp[0]) / 255.0f;
col[1] = float(cp[1]) / 255.0f;
col[2] = float(cp[2]) / 255.0f;
}
void UI_GetThemeColorType3ubv(int colorid, int spacetype, uchar col[3])

View File

@ -217,7 +217,7 @@ static void load_tex_task_cb_ex(void *__restrict userdata,
/* Clamp to avoid precision overflow. */
CLAMP(avg, 0.0f, 1.0f);
buffer[index] = 255 - (uchar)(255 * avg);
buffer[index] = 255 - uchar(255 * avg);
}
}
else {
@ -386,7 +386,7 @@ static void load_tex_cursor_task_cb(void *__restrict userdata,
/* Falloff curve. */
float avg = BKE_brush_curve_strength_clamped(br, len, 1.0f);
buffer[index] = (uchar)(255 * avg);
buffer[index] = uchar(255 * avg);
}
else {
buffer[index] = 0;

View File

@ -604,8 +604,8 @@ static int project_bucket_offset(const ProjPaintState *ps, const float projCoSS[
*
* Second multiplication does similar but for vertical offset
*/
return (int)(((projCoSS[0] - ps->screenMin[0]) / ps->screen_width) * ps->buckets_x) +
((int)(((projCoSS[1] - ps->screenMin[1]) / ps->screen_height) * ps->buckets_y) *
return int(((projCoSS[0] - ps->screenMin[0]) / ps->screen_width) * ps->buckets_x) +
(int(((projCoSS[1] - ps->screenMin[1]) / ps->screen_height) * ps->buckets_y) *
ps->buckets_x);
}
@ -787,8 +787,8 @@ static bool project_paint_PickColor(
}
}
else {
// xi = (int)((uv[0]*ibuf->x) + 0.5f);
// yi = (int)((uv[1]*ibuf->y) + 0.5f);
// xi = int((uv[0]*ibuf->x) + 0.5f);
// yi = int((uv[1]*ibuf->y) + 0.5f);
// if (xi < 0 || xi >= ibuf->x || yi < 0 || yi >= ibuf->y) return false;
/* wrap */
@ -1080,11 +1080,11 @@ static bool pixel_bounds_uv(const float uv_quad[4][2],
minmax_v2v2_v2(min_uv, max_uv, uv_quad[2]);
minmax_v2v2_v2(min_uv, max_uv, uv_quad[3]);
bounds_px->xmin = (int)(ibuf_x * min_uv[0]);
bounds_px->ymin = (int)(ibuf_y * min_uv[1]);
bounds_px->xmin = int(ibuf_x * min_uv[0]);
bounds_px->ymin = int(ibuf_y * min_uv[1]);
bounds_px->xmax = (int)(ibuf_x * max_uv[0]) + 1;
bounds_px->ymax = (int)(ibuf_y * max_uv[1]) + 1;
bounds_px->xmax = int(ibuf_x * max_uv[0]) + 1;
bounds_px->ymax = int(ibuf_y * max_uv[1]) + 1;
// printf("%d %d %d %d\n", min_px[0], min_px[1], max_px[0], max_px[1]);
@ -1110,11 +1110,11 @@ static bool pixel_bounds_array(
uv++;
}
bounds_px->xmin = (int)(ibuf_x * min_uv[0]);
bounds_px->ymin = (int)(ibuf_y * min_uv[1]);
bounds_px->xmin = int(ibuf_x * min_uv[0]);
bounds_px->ymin = int(ibuf_y * min_uv[1]);
bounds_px->xmax = (int)(ibuf_x * max_uv[0]) + 1;
bounds_px->ymax = (int)(ibuf_y * max_uv[1]) + 1;
bounds_px->xmax = int(ibuf_x * max_uv[0]) + 1;
bounds_px->ymax = int(ibuf_y * max_uv[1]) + 1;
// printf("%d %d %d %d\n", min_px[0], min_px[1], max_px[0], max_px[1]);
@ -1945,7 +1945,7 @@ static ProjPixel *project_paint_uvpixel_init(const ProjPaintState *ps,
projPixel->x_px = x_px;
projPixel->y_px = y_px;
projPixel->mask = (ushort)(mask * 65535);
projPixel->mask = ushort(mask * 65535);
if (ps->do_masking) {
projPixel->mask_accum = projima->maskRect[tile_index] + tile_offset;
}
@ -1954,8 +1954,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 */
@ -3112,13 +3112,13 @@ static void project_paint_face_init(const ProjPaintState *ps,
has_isect = 0;
for (y = bounds_px.ymin; y < bounds_px.ymax; y++) {
// uv[1] = (((float)y) + 0.5f) / (float)ibuf->y;
// uv[1] = (float(y) + 0.5f) / float(ibuf->y);
/* use pixel offset UV coords instead */
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;
// uv[0] = (float(x) + 0.5f) / float(ibuf->x);
/* use pixel offset UV coords instead */
uv[0] = float(x) / ibuf_xf;
@ -3322,7 +3322,7 @@ static void project_paint_face_init(const ProjPaintState *ps,
has_isect = 0;
for (y = bounds_px.ymin; y < bounds_px.ymax; y++) {
// uv[1] = (((float)y) + 0.5f) / (float)ibuf->y;
// uv[1] = (float(y) + 0.5f) / float(ibuf->y);
/* use offset uvs instead */
uv[1] = float(y) / ibuf_yf;
@ -3330,7 +3330,7 @@ static void project_paint_face_init(const ProjPaintState *ps,
for (x = bounds_px.xmin; x < bounds_px.xmax; x++) {
const float puv[2] = {float(x), float(y)};
bool in_bounds;
// uv[0] = (((float)x) + 0.5f) / (float)ibuf->x;
// uv[0] = (float(x) + 0.5f) / float(ibuf->x);
/* use offset uvs instead */
uv[0] = float(x) / ibuf_xf;
@ -3379,7 +3379,7 @@ static void project_paint_face_init(const ProjPaintState *ps,
pixel_on_edge[3] = 1.0f;
/* cast because of const */
mul_m4_v4((float(*)[4])ps->projectMat, pixel_on_edge);
pixel_on_edge[0] = (float)(ps->winx * 0.5f) +
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) +
(ps->winy * 0.5f) * pixel_on_edge[1] / pixel_on_edge[3];
@ -3455,17 +3455,15 @@ static void project_paint_bucket_bounds(const ProjPaintState *ps,
* is always truncated to 1, is this really correct? */
/* these offsets of 0.5 and 1.5 seem odd but they are correct */
bucketMin[0] =
(int)((int)(((float)(min[0] - ps->screenMin[0]) / ps->screen_width) * ps->buckets_x) + 0.5f);
bucketMin[1] = (int)((int)(((float)(min[1] - ps->screenMin[1]) / ps->screen_height) *
ps->buckets_y) +
0.5f);
bucketMin[0] = int(int((float(min[0] - ps->screenMin[0]) / ps->screen_width) * ps->buckets_x) +
0.5f);
bucketMin[1] = int(int((float(min[1] - ps->screenMin[1]) / ps->screen_height) * ps->buckets_y) +
0.5f);
bucketMax[0] =
(int)((int)(((float)(max[0] - ps->screenMin[0]) / ps->screen_width) * ps->buckets_x) + 1.5f);
bucketMax[1] = (int)((int)(((float)(max[1] - ps->screenMin[1]) / ps->screen_height) *
ps->buckets_y) +
1.5f);
bucketMax[0] = int(int((float(max[0] - ps->screenMin[0]) / ps->screen_width) * ps->buckets_x) +
1.5f);
bucketMax[1] = int(int((float(max[1] - ps->screenMin[1]) / ps->screen_height) * ps->buckets_y) +
1.5f);
/* in case the rect is outside the mesh 2d bounds */
CLAMP(bucketMin[0], 0, ps->buckets_x);
@ -3821,8 +3819,8 @@ static void proj_paint_state_screen_coords_init(ProjPaintState *ps, const int di
mul_v3_m4v3(projScreenCo, ps->projectMat, mv->co);
/* screen space, not clamped */
projScreenCo[0] = (float)(ps->winx * 0.5f) + (ps->winx * 0.5f) * projScreenCo[0];
projScreenCo[1] = (float)(ps->winy * 0.5f) + (ps->winy * 0.5f) * projScreenCo[1];
projScreenCo[0] = float(ps->winx * 0.5f) + (ps->winx * 0.5f) * projScreenCo[0];
projScreenCo[1] = float(ps->winy * 0.5f) + (ps->winy * 0.5f) * projScreenCo[1];
minmax_v2v2_v2(ps->screenMin, ps->screenMax, projScreenCo);
}
}
@ -3835,9 +3833,9 @@ static void proj_paint_state_screen_coords_init(ProjPaintState *ps, const int di
if (projScreenCo[3] > ps->clip_start) {
/* screen space, not clamped */
projScreenCo[0] = (float)(ps->winx * 0.5f) +
projScreenCo[0] = float(ps->winx * 0.5f) +
(ps->winx * 0.5f) * projScreenCo[0] / projScreenCo[3];
projScreenCo[1] = (float)(ps->winy * 0.5f) +
projScreenCo[1] = float(ps->winy * 0.5f) +
(ps->winy * 0.5f) * projScreenCo[1] / projScreenCo[3];
/* Use the depth for bucket point occlusion */
projScreenCo[2] = projScreenCo[2] / projScreenCo[3];
@ -4546,7 +4544,7 @@ 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_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);
@ -4590,9 +4588,9 @@ static void paint_proj_begin_clone(ProjPaintState *ps, const float mouse[2])
projCo[3] = 1.0f;
mul_m4_v4(ps->projectMat, projCo);
ps->cloneOffset[0] = mouse[0] -
((float)(ps->winx * 0.5f) + (ps->winx * 0.5f) * projCo[0] / projCo[3]);
(float(ps->winx * 0.5f) + (ps->winx * 0.5f) * projCo[0] / projCo[3]);
ps->cloneOffset[1] = mouse[1] -
((float)(ps->winy * 0.5f) + (ps->winy * 0.5f) * projCo[1] / projCo[3]);
(float(ps->winy * 0.5f) + (ps->winy * 0.5f) * projCo[1] / projCo[3]);
}
}
@ -4798,7 +4796,7 @@ static bool project_bucket_iter_next(ProjPaintState *ps,
project_bucket_bounds(ps, bucket_x, bucket_y, bucket_bounds);
if ((ps->source != PROJ_SRC_VIEW) ||
project_bucket_isect_circle(mval, (float)(diameter * diameter), bucket_bounds)) {
project_bucket_isect_circle(mval, float(diameter * diameter), bucket_bounds)) {
*bucket_index = bidx;
return true;
@ -4838,7 +4836,7 @@ static void do_projectpaint_clone(ProjPaintState *ps, ProjPixel *projPixel, floa
clone_rgba[0] = clone_pt[0];
clone_rgba[1] = clone_pt[1];
clone_rgba[2] = clone_pt[2];
clone_rgba[3] = (uchar)(clone_pt[3] * mask);
clone_rgba[3] = uchar(clone_pt[3] * mask);
if (ps->do_masking) {
IMB_blend_color_byte(projPixel->pixel.ch_pt,
@ -5292,7 +5290,7 @@ static void do_projectpaint_thread(TaskPool *__restrict /*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. */
@ -5322,7 +5320,7 @@ static void do_projectpaint_thread(TaskPool *__restrict /*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,
@ -5359,7 +5357,7 @@ static void do_projectpaint_thread(TaskPool *__restrict /*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);
@ -5376,7 +5374,7 @@ static void do_projectpaint_thread(TaskPool *__restrict /*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(
@ -5406,7 +5404,7 @@ static void do_projectpaint_thread(TaskPool *__restrict /*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) {
@ -5805,7 +5803,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);

View File

@ -178,7 +178,7 @@ static void gather_add_node_operations(const bContext &C,
if (!(node_type->poll && node_type->poll(node_type, &node_tree, &disabled_hint))) {
continue;
}
if ((StringRefNull(node_tree.typeinfo->group_idname) == node_type->idname)) {
if (StringRefNull(node_tree.typeinfo->group_idname) == node_type->idname) {
/* Skip the empty group type. */
continue;
}

View File

@ -42,11 +42,11 @@ 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]) + double(b[0]);
const double y = static_cast<double>(a[1]) + double(b[1]);
const double x = double(a[0]) + double(b[0]);
const double y = 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);
r[0] = float(mat[0][0] * x + mat[1][0] * y);
r[1] = float(mat[0][1] * x + mat[1][1] * y);
}
static void island_uv_transform(FaceIsland *island,

View File

@ -4609,7 +4609,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

@ -827,7 +827,7 @@ void GLPixelBuffer::unmap()
int64_t GLPixelBuffer::get_native_handle()
{
return (int64_t)gl_id_;
return int64_t(gl_id_);
}
uint GLPixelBuffer::get_size()

View File

@ -596,7 +596,7 @@ AbcUvScope get_uv_scope(const Alembic::AbcGeom::GeometryScope scope,
/* kVaryingScope is sometimes used for vertex scopes as the values vary across the vertices. To
* be sure, one has to check the size of the data against the number of vertices, as it could
* also be a varying attribute across the faces (i.e. one value per face). */
if ((ELEM(scope, kVaryingScope, kVertexScope)) && indices->size() == config.totvert) {
if (ELEM(scope, kVaryingScope, kVertexScope) && indices->size() == config.totvert) {
return ABC_UV_SCOPE_VERTEX;
}

View File

@ -178,7 +178,7 @@ void GpencilExporterPDF::export_gpencil_layers()
gps_duplicate->thickness += gpl->line_change;
/* Apply object scale to thickness. */
const float scalef = mat4_to_scale(ob->object_to_world);
gps_duplicate->thickness = ceilf((float)gps_duplicate->thickness * scalef);
gps_duplicate->thickness = ceilf(float(gps_duplicate->thickness) * scalef);
CLAMP_MIN(gps_duplicate->thickness, 1.0f);
/* Fill. */
if ((is_fill) && (params_.flag & GP_EXPORT_FILL)) {

View File

@ -199,7 +199,7 @@ void GpencilExporterSVG::export_gpencil_layers()
gps_duplicate->thickness += gpl->line_change;
/* Apply object scale to thickness. */
const float scalef = mat4_to_scale(ob->object_to_world);
gps_duplicate->thickness = ceilf((float)gps_duplicate->thickness * scalef);
gps_duplicate->thickness = ceilf(float(gps_duplicate->thickness) * scalef);
CLAMP_MIN(gps_duplicate->thickness, 1.0f);
const bool is_normalized = ((params_.flag & GP_EXPORT_NORM_THICKNESS) != 0) ||

View File

@ -498,8 +498,8 @@ static Mesh *arrayModifier_doArray(ArrayModifierData *amd,
/* Ensure we keep things to a reasonable level, in terms of rough total amount of generated
* vertices.
*/
if (((size_t)count * (size_t)chunk_nverts + (size_t)start_cap_nverts +
(size_t)end_cap_nverts) > max_verts_num) {
if ((size_t(count) * size_t(chunk_nverts) + size_t(start_cap_nverts) +
size_t(end_cap_nverts)) > max_verts_num) {
count = 1;
offset_is_too_small = true;
}
@ -520,8 +520,8 @@ static Mesh *arrayModifier_doArray(ArrayModifierData *amd,
/* Ensure we keep things to a reasonable level, in terms of rough total amount of generated
* vertices.
*/
else if (((size_t)count * (size_t)chunk_nverts + (size_t)start_cap_nverts +
(size_t)end_cap_nverts) > max_verts_num) {
else if ((size_t(count) * size_t(chunk_nverts) + size_t(start_cap_nverts) +
size_t(end_cap_nverts)) > max_verts_num) {
count = 1;
BKE_modifier_set_error(ctx->object,
&amd->modifier,

View File

@ -195,7 +195,7 @@ class BokehBlurOperation : public NodeOperation {
int get_max_size()
{
return static_cast<int>(bnode().custom4);
return int(bnode().custom4);
}
};

View File

@ -64,14 +64,14 @@ static void colorfn(float *out, TexParams *p, bNode *node, bNodeStack **in, shor
tex_input_rgba(bricks2, in[1], p, thread);
tex_input_rgba(mortar, in[2], p, thread);
rownum = (int)floor(y / row_height);
rownum = int(floor(y / row_height));
if (node->custom1 && node->custom2) {
brick_width *= ((int)(rownum) % node->custom2) ? 1.0f : node->custom4; /* squash */
offset = ((int)(rownum) % node->custom1) ? 0 : (brick_width * node->custom3); /* offset */
brick_width *= (int(rownum) % node->custom2) ? 1.0f : node->custom4; /* squash */
offset = (int(rownum) % node->custom1) ? 0 : (brick_width * node->custom3); /* offset */
}
bricknum = (int)floor((x + offset) / brick_width);
bricknum = int(floor((x + offset) / brick_width));
ins_x = (x + offset) - brick_width * bricknum;
ins_y = y - row_height * rownum;

View File

@ -28,9 +28,9 @@ static void colorfn(float *out, TexParams *p, bNode * /*node*/, bNodeStack **in,
float sz = tex_input_value(in[2], p, thread);
/* 0.00001 because of unit sized stuff */
int xi = (int)fabs(floor(0.00001f + x / sz));
int yi = (int)fabs(floor(0.00001f + y / sz));
int zi = (int)fabs(floor(0.00001f + z / sz));
int xi = int(fabs(floor(0.00001f + x / sz)));
int yi = int(fabs(floor(0.00001f + y / sz)));
int zi = int(fabs(floor(0.00001f + z / sz)));
if ((xi % 2 == yi % 2) == (zi % 2)) {
tex_input_rgba(out, in[0], p, thread);

View File

@ -20,7 +20,7 @@ static void time_colorfn(
float fac = 0.0f;
if (node->custom1 < node->custom2) {
fac = (p->cfra - node->custom1) / (float)(node->custom2 - node->custom1);
fac = (p->cfra - node->custom1) / float(node->custom2 - node->custom1);
}
CurveMapping *mapping = static_cast<CurveMapping *>(node->storage);

View File

@ -33,8 +33,8 @@ static void colorfn(float *out, TexParams *p, bNode *node, bNodeStack ** /*in*/,
ysize = ibuf->y / 2;
xoff = yoff = -1;
px = (int)((x - xoff) * xsize);
py = (int)((y - yoff) * ysize);
px = int((x - xoff) * xsize);
py = int((y - yoff) * ysize);
if ((!xsize) || (!ysize)) {
return;

View File

@ -140,7 +140,7 @@ static void valuefn(float *out, TexParams *p, bNode *node, bNodeStack **in, shor
break;
}
case NODE_MATH_ROUND: {
*out = (in0 < 0) ? (int)(in0 - 0.5f) : (int)(in0 + 0.5f);
*out = (in0 < 0) ? int(in0 - 0.5f) : int(in0 + 0.5f);
break;
}

View File

@ -262,8 +262,8 @@ static void rasterize_half(const MBakeRast *bake_rast,
SWAP(float, x_l, x_r);
}
iXl = (int)ceilf(x_l);
iXr = (int)ceilf(x_r);
iXl = int(ceilf(x_l));
iXr = int(ceilf(x_r));
if (iXr > 0 && iXl < w) {
iXl = iXl < 0 ? 0 : iXl;
@ -313,9 +313,9 @@ static void bake_rasterize(const MBakeRast *bake_rast,
/* check if mid point is to the left or to the right of the lo-hi edge */
is_mid_right = (-(shi - slo) * (tmi - thi) + (thi - tlo) * (smi - shi)) > 0 ? 1 : 0;
ylo = (int)ceilf(tlo);
yhi_beg = (int)ceilf(tmi);
yhi = (int)ceilf(thi);
ylo = int(ceilf(tlo));
yhi_beg = int(ceilf(tmi));
yhi = int(ceilf(thi));
// if (fTmi>ceilf(fTlo))
rasterize_half(bake_rast, slo, tlo, smi, tmi, slo, tlo, shi, thi, ylo, yhi_beg, is_mid_right);