Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <campbell@blender.org>2022-09-30 07:16:14 +0300
committerCampbell Barton <campbell@blender.org>2022-09-30 07:51:49 +0300
commit8bdd4b468554446cb1351785f0db751e2f84341f (patch)
treed81bda8a17f036de212b2982d7b13093f5b35a9e
parent1c1dc5f8440d918aca480904c53e31a528aef42f (diff)
Cleanup: use function style casts for C++
-rw-r--r--intern/ghost/intern/GHOST_XrControllerModel.cpp10
-rw-r--r--intern/ghost/intern/GHOST_XrSession.cpp6
-rw-r--r--source/blender/blenkernel/intern/brush.cc2
-rw-r--r--source/blender/blenkernel/intern/curve.cc2
-rw-r--r--source/blender/blenkernel/intern/customdata.cc2
-rw-r--r--source/blender/blenkernel/intern/gpencil_geom.cc2
-rw-r--r--source/blender/blenkernel/intern/mesh_normals.cc4
-rw-r--r--source/blender/blenkernel/intern/modifier.cc2
-rw-r--r--source/blender/blenkernel/intern/scene.cc6
-rw-r--r--source/blender/blenlib/intern/math_boolean.cc24
-rw-r--r--source/blender/blenloader/intern/readfile.cc4
-rw-r--r--source/blender/blenloader/intern/versioning_300.cc6
-rw-r--r--source/blender/draw/intern/draw_manager_text.cc8
-rw-r--r--source/blender/draw/intern/draw_pbvh.cc16
-rw-r--r--source/blender/editors/interface/interface.cc2
-rw-r--r--source/blender/editors/interface/view2d_ops.cc26
-rw-r--r--source/blender/editors/sculpt_paint/sculpt_automasking.cc14
-rw-r--r--source/blender/editors/space_outliner/outliner_draw.cc4
-rw-r--r--source/blender/editors/space_view3d/view3d_draw.cc50
-rw-r--r--source/blender/gpu/intern/gpu_index_buffer.cc4
-rw-r--r--source/blender/modifiers/intern/MOD_wave.cc8
21 files changed, 101 insertions, 101 deletions
diff --git a/intern/ghost/intern/GHOST_XrControllerModel.cpp b/intern/ghost/intern/GHOST_XrControllerModel.cpp
index c841fc0cf46..0a8b0dcb003 100644
--- a/intern/ghost/intern/GHOST_XrControllerModel.cpp
+++ b/intern/ghost/intern/GHOST_XrControllerModel.cpp
@@ -296,7 +296,7 @@ static void load_node(const tinygltf::Model &gltf_model,
float world_transform[4][4];
GHOST_XrControllerModelNode &node = nodes.emplace_back();
- const int32_t node_idx = (int32_t)(nodes.size() - 1);
+ const int32_t node_idx = int32_t(nodes.size() - 1);
node.parent_idx = parent_idx;
calc_node_transforms(gltf_node, parent_transform, node.local_transform, world_transform);
@@ -496,7 +496,7 @@ void GHOST_XrControllerModel::loadControllerModel(XrSession session)
std::vector<XrControllerModelNodePropertiesMSFT> node_properties(
model_properties.nodeCountOutput, {XR_TYPE_CONTROLLER_MODEL_NODE_PROPERTIES_MSFT});
- model_properties.nodeCapacityInput = (uint32_t)node_properties.size();
+ model_properties.nodeCapacityInput = uint32_t(node_properties.size());
model_properties.nodeProperties = node_properties.data();
CHECK_XR(g_xrGetControllerModelPropertiesMSFT(session, m_model_key, &model_properties),
"Failed to get controller model node properties.");
@@ -583,11 +583,11 @@ void GHOST_XrControllerModel::updateComponents(XrSession session)
void GHOST_XrControllerModel::getData(GHOST_XrControllerModelData &r_data)
{
if (m_data_loaded) {
- r_data.count_vertices = (uint32_t)m_vertices.size();
+ r_data.count_vertices = uint32_t(m_vertices.size());
r_data.vertices = m_vertices.data();
- r_data.count_indices = (uint32_t)m_indices.size();
+ r_data.count_indices = uint32_t(m_indices.size());
r_data.indices = m_indices.data();
- r_data.count_components = (uint32_t)m_components.size();
+ r_data.count_components = uint32_t(m_components.size());
r_data.components = m_components.data();
}
else {
diff --git a/intern/ghost/intern/GHOST_XrSession.cpp b/intern/ghost/intern/GHOST_XrSession.cpp
index 0031c1f1278..e8f9b96b15c 100644
--- a/intern/ghost/intern/GHOST_XrSession.cpp
+++ b/intern/ghost/intern/GHOST_XrSession.cpp
@@ -745,7 +745,7 @@ bool GHOST_XrSession::attachActionSets()
for (auto &[profile, bindings] : profile_bindings) {
bindings_info.interactionProfile = profile;
- bindings_info.countSuggestedBindings = (uint32_t)bindings.size();
+ bindings_info.countSuggestedBindings = uint32_t(bindings.size());
bindings_info.suggestedBindings = bindings.data();
CHECK_XR(xrSuggestInteractionProfileBindings(instance, &bindings_info),
@@ -754,7 +754,7 @@ bool GHOST_XrSession::attachActionSets()
/* Attach action sets. */
XrSessionActionSetsAttachInfo attach_info{XR_TYPE_SESSION_ACTION_SETS_ATTACH_INFO};
- attach_info.countActionSets = (uint32_t)m_oxr->action_sets.size();
+ attach_info.countActionSets = uint32_t(m_oxr->action_sets.size());
/* Create an aligned copy of the action sets to pass to xrAttachSessionActionSets(). */
std::vector<XrActionSet> action_sets(attach_info.countActionSets);
@@ -776,7 +776,7 @@ bool GHOST_XrSession::syncActions(const char *action_set_name)
XrActionsSyncInfo sync_info{XR_TYPE_ACTIONS_SYNC_INFO};
sync_info.countActiveActionSets = (action_set_name != nullptr) ? 1 :
- (uint32_t)action_sets.size();
+ uint32_t(action_sets.size());
if (sync_info.countActiveActionSets < 1) {
return false;
}
diff --git a/source/blender/blenkernel/intern/brush.cc b/source/blender/blenkernel/intern/brush.cc
index fb8a6785f64..7261e0a5869 100644
--- a/source/blender/blenkernel/intern/brush.cc
+++ b/source/blender/blenkernel/intern/brush.cc
@@ -2387,7 +2387,7 @@ void BKE_brush_scale_size(int *r_brush_size,
if (old_unprojected_radius != 0) {
scale /= new_unprojected_radius;
}
- (*r_brush_size) = (int)((float)(*r_brush_size) * scale);
+ (*r_brush_size) = int(float(*r_brush_size) * scale);
}
void BKE_brush_jitter_pos(const Scene *scene, Brush *brush, const float pos[2], float jitterpos[2])
diff --git a/source/blender/blenkernel/intern/curve.cc b/source/blender/blenkernel/intern/curve.cc
index ddd1f000644..95ef94a6cd5 100644
--- a/source/blender/blenkernel/intern/curve.cc
+++ b/source/blender/blenkernel/intern/curve.cc
@@ -3085,7 +3085,7 @@ void BKE_curve_bevelList_make(Object *ob, const ListBase *nurbs, const bool for_
make_bevel_list_segment_3D(bl);
}
else {
- make_bevel_list_3D(bl, (int)(resolu * cu->twist_smooth), cu->twist_mode);
+ make_bevel_list_3D(bl, int(resolu * cu->twist_smooth), cu->twist_mode);
}
}
}
diff --git a/source/blender/blenkernel/intern/customdata.cc b/source/blender/blenkernel/intern/customdata.cc
index 4bbb9b62549..32a6bc6ecb9 100644
--- a/source/blender/blenkernel/intern/customdata.cc
+++ b/source/blender/blenkernel/intern/customdata.cc
@@ -5263,7 +5263,7 @@ static void blend_read_mdisps(BlendDataReader *reader,
* overwritten with the correct value in
* bm_corners_to_loops() */
float gridsize = sqrtf(mdisps[i].totdisp);
- mdisps[i].level = (int)(logf(gridsize - 1.0f) / (float)M_LN2) + 1;
+ mdisps[i].level = int(logf(gridsize - 1.0f) / float(M_LN2)) + 1;
}
if (BLO_read_requires_endian_switch(reader) && (mdisps[i].disps)) {
diff --git a/source/blender/blenkernel/intern/gpencil_geom.cc b/source/blender/blenkernel/intern/gpencil_geom.cc
index fe5e656d55d..92b11ecaa61 100644
--- a/source/blender/blenkernel/intern/gpencil_geom.cc
+++ b/source/blender/blenkernel/intern/gpencil_geom.cc
@@ -3861,7 +3861,7 @@ static int generate_arc_from_point_to_point(ListBase *list,
/* Number of points is 2^(n+1) + 1 on half a circle (n=subdivisions)
* so we multiply by (angle / pi) to get the right amount of
* points to insert. */
- int num_points = (int)(((1 << (subdivisions + 1)) - 1) * (angle / M_PI));
+ int num_points = int(((1 << (subdivisions + 1)) - 1) * (angle / M_PI));
if (num_points > 0) {
float angle_incr = angle / float(num_points);
diff --git a/source/blender/blenkernel/intern/mesh_normals.cc b/source/blender/blenkernel/intern/mesh_normals.cc
index 154840e2ef7..55d83b64e39 100644
--- a/source/blender/blenkernel/intern/mesh_normals.cc
+++ b/source/blender/blenkernel/intern/mesh_normals.cc
@@ -1678,7 +1678,7 @@ void BKE_mesh_normals_loop_split(const MVert *mverts,
size_t(numLoops), sizeof(*loop_to_poly), __func__);
/* When using custom loop normals, disable the angle feature! */
- const bool check_angle = (split_angle < (float)M_PI) && (clnors_data == nullptr);
+ const bool check_angle = (split_angle < float(M_PI)) && (clnors_data == nullptr);
MLoopNorSpaceArray _lnors_spacearr = {nullptr};
@@ -1784,7 +1784,7 @@ static void mesh_normals_loop_custom_set(const MVert *mverts,
/* In this case we always consider split nors as ON,
* and do not want to use angle to define smooth fans! */
const bool use_split_normals = true;
- const float split_angle = (float)M_PI;
+ const float split_angle = float(M_PI);
BLI_SMALLSTACK_DECLARE(clnors_data, short *);
diff --git a/source/blender/blenkernel/intern/modifier.cc b/source/blender/blenkernel/intern/modifier.cc
index 7270f19a882..b3a61655635 100644
--- a/source/blender/blenkernel/intern/modifier.cc
+++ b/source/blender/blenkernel/intern/modifier.cc
@@ -350,7 +350,7 @@ void BKE_modifier_copydata_generic(const ModifierData *md_src,
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);
- memcpy(md_dst_data, md_src_data, (size_t)mti->structSize - data_size);
+ memcpy(md_dst_data, md_src_data, size_t(mti->structSize) - data_size);
/* Runtime fields are never to be preserved. */
md_dst->runtime = nullptr;
diff --git a/source/blender/blenkernel/intern/scene.cc b/source/blender/blenkernel/intern/scene.cc
index 4af6409347d..2489c64ba0a 100644
--- a/source/blender/blenkernel/intern/scene.cc
+++ b/source/blender/blenkernel/intern/scene.cc
@@ -2331,7 +2331,7 @@ Object *BKE_scene_camera_switch_find(Scene *scene)
return nullptr;
}
- const int ctime = (int)BKE_scene_ctime_get(scene);
+ const int ctime = int(BKE_scene_ctime_get(scene));
int frame = -(MAXFRAME + 1);
int min_frame = MAXFRAME + 1;
Object *camera = nullptr;
@@ -2872,10 +2872,10 @@ int get_render_child_particle_number(const RenderData *r, int child_num, bool fo
{
if (r->mode & R_SIMPLIFY) {
if (for_render) {
- return (int)(r->simplify_particles_render * child_num);
+ return int(r->simplify_particles_render * child_num);
}
- return (int)(r->simplify_particles * child_num);
+ return int(r->simplify_particles * child_num);
}
return child_num;
diff --git a/source/blender/blenlib/intern/math_boolean.cc b/source/blender/blenlib/intern/math_boolean.cc
index 871ea815e90..e5352540dd6 100644
--- a/source/blender/blenlib/intern/math_boolean.cc
+++ b/source/blender/blenlib/intern/math_boolean.cc
@@ -2191,18 +2191,18 @@ static double insphereadapt(const double *pa,
INEXACT double _i, _j;
double _0;
- aex = (double)(pa[0] - pe[0]);
- bex = (double)(pb[0] - pe[0]);
- cex = (double)(pc[0] - pe[0]);
- dex = (double)(pd[0] - pe[0]);
- aey = (double)(pa[1] - pe[1]);
- bey = (double)(pb[1] - pe[1]);
- cey = (double)(pc[1] - pe[1]);
- dey = (double)(pd[1] - pe[1]);
- aez = (double)(pa[2] - pe[2]);
- bez = (double)(pb[2] - pe[2]);
- cez = (double)(pc[2] - pe[2]);
- dez = (double)(pd[2] - pe[2]);
+ aex = double(pa[0] - pe[0]);
+ bex = double(pb[0] - pe[0]);
+ cex = double(pc[0] - pe[0]);
+ dex = double(pd[0] - pe[0]);
+ aey = double(pa[1] - pe[1]);
+ bey = double(pb[1] - pe[1]);
+ cey = double(pc[1] - pe[1]);
+ dey = double(pd[1] - pe[1]);
+ aez = double(pa[2] - pe[2]);
+ bez = double(pb[2] - pe[2]);
+ cez = double(pc[2] - pe[2]);
+ dez = double(pd[2] - pe[2]);
Two_Product(aex, bey, aexbey1, aexbey0);
Two_Product(bex, aey, bexaey1, bexaey0);
diff --git a/source/blender/blenloader/intern/readfile.cc b/source/blender/blenloader/intern/readfile.cc
index d627a93526e..fa9368db0d8 100644
--- a/source/blender/blenloader/intern/readfile.cc
+++ b/source/blender/blenloader/intern/readfile.cc
@@ -5111,12 +5111,12 @@ static void convert_pointer_array_64_to_32(BlendDataReader *reader,
for (int i = 0; i < array_size; i++) {
uint64_t ptr = src[i];
BLI_endian_switch_uint64(&ptr);
- dst[i] = (uint32_t)(ptr >> 3);
+ dst[i] = uint32_t(ptr >> 3);
}
}
else {
for (int i = 0; i < array_size; i++) {
- dst[i] = (uint32_t)(src[i] >> 3);
+ dst[i] = uint32_t(src[i] >> 3);
}
}
}
diff --git a/source/blender/blenloader/intern/versioning_300.cc b/source/blender/blenloader/intern/versioning_300.cc
index 878a4078295..2203cf0bc9b 100644
--- a/source/blender/blenloader/intern/versioning_300.cc
+++ b/source/blender/blenloader/intern/versioning_300.cc
@@ -3034,9 +3034,9 @@ void blo_do_versions_300(FileData *fd, Library *UNUSED(lib), Main *bmain)
gpmd->factor *= 2.0f;
}
else {
- gpmd->step = 1 + (int)(gpmd->factor * max_ff(0.0f,
- min_ff(5.1f * sqrtf(gpmd->step) - 3.0f,
- gpmd->step + 2.0f)));
+ gpmd->step = 1 + int(gpmd->factor * max_ff(0.0f,
+ min_ff(5.1f * sqrtf(gpmd->step) - 3.0f,
+ gpmd->step + 2.0f)));
gpmd->factor = 1.0f;
}
}
diff --git a/source/blender/draw/intern/draw_manager_text.cc b/source/blender/draw/intern/draw_manager_text.cc
index e09050877c9..d41127c3641 100644
--- a/source/blender/draw/intern/draw_manager_text.cc
+++ b/source/blender/draw/intern/draw_manager_text.cc
@@ -137,7 +137,7 @@ static void drw_text_cache_draw_ex(DRWTextStore *dt, ARegion *region)
}
BLF_position(
- font_id, (float)(vos->sco[0] + vos->xoffs), (float)(vos->sco[1] + vos->yoffs), 2.0f);
+ font_id, float(vos->sco[0] + vos->xoffs), float(vos->sco[1] + vos->yoffs), 2.0f);
BLF_draw(font_id,
(vos->flag & DRW_TEXT_CACHE_STRING_PTR) ? *((const char **)vos->str) : vos->str,
vos->str_len);
@@ -248,7 +248,7 @@ void DRW_text_edit_mesh_measure_stats(ARegion *region,
if ((v3d->overlay.edit_flag & V3D_OVERLAY_EDIT_INDICES) && (em->selectmode & SCE_SELECT_EDGE)) {
edge_tex_count += 1;
}
- const short edge_tex_sep = (short)((edge_tex_count - 1) * 5.0f * U.dpi_fac);
+ const short edge_tex_sep = short((edge_tex_count - 1) * 5.0f * U.dpi_fac);
/* Make the precision of the display value proportionate to the grid-size. */
@@ -450,14 +450,14 @@ void DRW_text_edit_mesh_measure_stats(ARegion *region,
area += area_tri_v3(v1, v2, v3);
}
- mul_v3_fl(vmid, 1.0f / (float)n);
+ mul_v3_fl(vmid, 1.0f / float(n));
mul_m4_v3(ob->obmat, vmid);
if (unit->system) {
numstr_len = BKE_unit_value_as_string(
numstr,
sizeof(numstr),
- (double)(area * unit->scale_length * unit->scale_length),
+ double(area * unit->scale_length * unit->scale_length),
3,
B_UNIT_AREA,
unit,
diff --git a/source/blender/draw/intern/draw_pbvh.cc b/source/blender/draw/intern/draw_pbvh.cc
index 895abdfc2ac..b5ad47b09ef 100644
--- a/source/blender/draw/intern/draw_pbvh.cc
+++ b/source/blender/draw/intern/draw_pbvh.cc
@@ -89,7 +89,7 @@ struct PBVHVbo {
{
char buf[512];
- sprintf(buf, "%d:%d:%s", (int)type, (int)domain, name.c_str());
+ sprintf(buf, "%d:%d:%s", int(type), int(domain), name.c_str());
key = string(buf);
return key;
@@ -382,7 +382,7 @@ struct PBVHBatches {
foreach_grids([&](int /*x*/, int /*y*/, int /*grid_index*/, CCGElem *elems[4], int i) {
float *mask = CCG_elem_mask(&args->ccg_key, elems[i]);
- *static_cast<uchar *>(GPU_vertbuf_raw_step(&access)) = mask ? (uchar)(*mask * 255.0f) :
+ *static_cast<uchar *>(GPU_vertbuf_raw_step(&access)) = mask ? uchar(*mask * 255.0f) :
255;
});
break;
@@ -536,8 +536,8 @@ struct PBVHBatches {
if (mask) {
foreach_faces(
[&](int /*buffer_i*/, int /*tri_i*/, int vertex_i, const MLoopTri * /*tri*/) {
- *static_cast<uchar *>(GPU_vertbuf_raw_step(&access)) = (uchar)(mask[vertex_i] *
- 255.0f);
+ *static_cast<uchar *>(GPU_vertbuf_raw_step(&access)) = uchar(mask[vertex_i] *
+ 255.0f);
});
}
else {
@@ -757,7 +757,7 @@ struct PBVHBatches {
foreach_bmesh([&](BMLoop *l) {
float mask = BM_ELEM_CD_GET_FLOAT(l->v, cd_mask);
- *static_cast<uchar *>(GPU_vertbuf_raw_step(&access)) = (uchar)(mask * 255.0f);
+ *static_cast<uchar *>(GPU_vertbuf_raw_step(&access)) = uchar(mask * 255.0f);
});
}
break;
@@ -1154,11 +1154,11 @@ struct PBVHBatches {
for (int i : IndexRange(attrs_num)) {
PBVHAttrReq *attr = attrs + i;
- if (!has_vbo(attr->domain, (int)attr->type, attr->name)) {
- create_vbo(attr->domain, (uint32_t)attr->type, attr->name, args);
+ if (!has_vbo(attr->domain, int(attr->type), attr->name)) {
+ create_vbo(attr->domain, uint32_t(attr->type), attr->name, args);
}
- PBVHVbo *vbo = get_vbo(attr->domain, (uint32_t)attr->type, attr->name);
+ PBVHVbo *vbo = get_vbo(attr->domain, uint32_t(attr->type), attr->name);
int vbo_i = get_vbo_index(vbo);
batch.vbos.append(vbo_i);
diff --git a/source/blender/editors/interface/interface.cc b/source/blender/editors/interface/interface.cc
index 403cb0116d2..42b3198a9c0 100644
--- a/source/blender/editors/interface/interface.cc
+++ b/source/blender/editors/interface/interface.cc
@@ -5933,7 +5933,7 @@ bContextStore *UI_but_context_get(const uiBut *but)
void UI_but_unit_type_set(uiBut *but, const int unit_type)
{
- but->unit_type = (uchar)(RNA_SUBTYPE_UNIT_VALUE(unit_type));
+ but->unit_type = uchar(RNA_SUBTYPE_UNIT_VALUE(unit_type));
}
int UI_but_unit_type_get(const uiBut *but)
diff --git a/source/blender/editors/interface/view2d_ops.cc b/source/blender/editors/interface/view2d_ops.cc
index 0282c1b1813..c72a0c75ee4 100644
--- a/source/blender/editors/interface/view2d_ops.cc
+++ b/source/blender/editors/interface/view2d_ops.cc
@@ -1628,7 +1628,7 @@ static int view2d_smoothview_invoke(bContext *C, wmOperator *UNUSED(op), const w
float step;
if (sms->time_allowed != 0.0) {
- step = (float)((v2d->smooth_timer->duration) / sms->time_allowed);
+ step = float((v2d->smooth_timer->duration) / sms->time_allowed);
}
else {
step = 1.0f;
@@ -1859,11 +1859,11 @@ static void scroller_activate_init(bContext *C,
if (in_scroller == 'h') {
/* horizontal scroller - calculate adjustment factor first */
- const float mask_size = (float)BLI_rcti_size_x(&v2d->hor);
+ const float mask_size = float(BLI_rcti_size_x(&v2d->hor));
vsm->fac = BLI_rctf_size_x(&tot_cur_union) / mask_size;
/* pixel rounding */
- vsm->fac_round = (BLI_rctf_size_x(&v2d->cur)) / (float)(BLI_rcti_size_x(&region->winrct) + 1);
+ vsm->fac_round = (BLI_rctf_size_x(&v2d->cur)) / float(BLI_rcti_size_x(&region->winrct) + 1);
/* get 'zone' (i.e. which part of scroller is activated) */
vsm->zone = mouse_in_scroller_handle(
@@ -1879,11 +1879,11 @@ static void scroller_activate_init(bContext *C,
}
else {
/* vertical scroller - calculate adjustment factor first */
- const float mask_size = (float)BLI_rcti_size_y(&v2d->vert);
+ const float mask_size = float(BLI_rcti_size_y(&v2d->vert));
vsm->fac = BLI_rctf_size_y(&tot_cur_union) / mask_size;
/* pixel rounding */
- vsm->fac_round = (BLI_rctf_size_y(&v2d->cur)) / (float)(BLI_rcti_size_y(&region->winrct) + 1);
+ vsm->fac_round = (BLI_rctf_size_y(&v2d->cur)) / float(BLI_rcti_size_y(&region->winrct) + 1);
/* get 'zone' (i.e. which part of scroller is activated) */
vsm->zone = mouse_in_scroller_handle(
@@ -2000,11 +2000,11 @@ static int scroller_activate_modal(bContext *C, wmOperator *op, const wmEvent *e
switch (vsm->scroller) {
case 'h': /* horizontal scroller - so only horizontal movement
* ('cur' moves opposite to mouse) */
- vsm->delta = (float)(event->xy[0] - vsm->lastx);
+ vsm->delta = float(event->xy[0] - vsm->lastx);
break;
case 'v': /* vertical scroller - so only vertical movement
* ('cur' moves opposite to mouse) */
- vsm->delta = (float)(event->xy[1] - vsm->lasty);
+ vsm->delta = float(event->xy[1] - vsm->lasty);
break;
}
}
@@ -2013,11 +2013,11 @@ static int scroller_activate_modal(bContext *C, wmOperator *op, const wmEvent *e
switch (vsm->scroller) {
case 'h': /* horizontal scroller - so only horizontal movement
* ('cur' moves with mouse) */
- vsm->delta = (float)(vsm->lastx - event->xy[0]);
+ vsm->delta = float(vsm->lastx - event->xy[0]);
break;
case 'v': /* vertical scroller - so only vertical movement
* ('cur' moves with to mouse) */
- vsm->delta = (float)(vsm->lasty - event->xy[1]);
+ vsm->delta = float(vsm->lasty - event->xy[1]);
break;
}
}
@@ -2080,11 +2080,11 @@ static int scroller_activate_invoke(bContext *C, wmOperator *op, const wmEvent *
switch (vsm->scroller) {
case 'h': /* horizontal scroller - so only horizontal movement
* ('cur' moves opposite to mouse) */
- vsm->delta = (float)(event->xy[0] - vsm->scrollbar_orig);
+ vsm->delta = float(event->xy[0] - vsm->scrollbar_orig);
break;
case 'v': /* vertical scroller - so only vertical movement
* ('cur' moves opposite to mouse) */
- vsm->delta = (float)(event->xy[1] - vsm->scrollbar_orig);
+ vsm->delta = float(event->xy[1] - vsm->scrollbar_orig);
break;
}
scroller_activate_apply(C, op);
@@ -2177,8 +2177,8 @@ static int reset_exec(bContext *C, wmOperator *UNUSED(op))
const int snap_test = ED_region_snap_size_test(region);
/* zoom 1.0 */
- const int winx = (float)(BLI_rcti_size_x(&v2d->mask) + 1);
- const int winy = (float)(BLI_rcti_size_y(&v2d->mask) + 1);
+ const int winx = float(BLI_rcti_size_x(&v2d->mask) + 1);
+ const int winy = float(BLI_rcti_size_y(&v2d->mask) + 1);
v2d->cur.xmax = v2d->cur.xmin + winx;
v2d->cur.ymax = v2d->cur.ymin + winy;
diff --git a/source/blender/editors/sculpt_paint/sculpt_automasking.cc b/source/blender/editors/sculpt_paint/sculpt_automasking.cc
index f22a05ef897..f0ce901e059 100644
--- a/source/blender/editors/sculpt_paint/sculpt_automasking.cc
+++ b/source/blender/editors/sculpt_paint/sculpt_automasking.cc
@@ -399,7 +399,7 @@ static void sculpt_calc_blurred_cavity(SculptSession *ss,
sco1 = SCULPT_vertex_co_get(ss, vertex);
}
else {
- sco1 /= (float)sco1_len;
+ sco1 /= float(sco1_len);
len1_sum /= sco1_len;
}
@@ -407,7 +407,7 @@ static void sculpt_calc_blurred_cavity(SculptSession *ss,
sco2 = SCULPT_vertex_co_get(ss, vertex);
}
else {
- sco2 /= (float)sco2_len;
+ sco2 /= float(sco2_len);
}
normalize_v3(sno1);
@@ -448,8 +448,8 @@ int SCULPT_automasking_settings_hash(Object *ob, AutomaskingCache *automasking)
for (int i = 0; i < cm->totpoint; i++) {
hash = BLI_hash_int_2d(hash, *reinterpret_cast<uint *>(&cm->curve[i].x));
hash = BLI_hash_int_2d(hash, *reinterpret_cast<uint *>(&cm->curve[i].y));
- hash = BLI_hash_int_2d(hash, (uint)cm->curve[i].flag);
- hash = BLI_hash_int_2d(hash, (uint)cm->curve[i].shorty);
+ hash = BLI_hash_int_2d(hash, uint(cm->curve[i].flag));
+ hash = BLI_hash_int_2d(hash, uint(cm->curve[i].shorty));
}
}
}
@@ -778,11 +778,11 @@ static void sculpt_normal_occlusion_automasking_fill(AutomaskingCache *automaski
float f = *(float *)SCULPT_vertex_attr_get(vertex, ss->attrs.automasking_factor);
- if ((int)mode & BRUSH_AUTOMASKING_BRUSH_NORMAL) {
+ if (int(mode) & BRUSH_AUTOMASKING_BRUSH_NORMAL) {
f *= automasking_brush_normal_factor(automasking, ss, vertex, &nodedata);
}
- if ((int)mode & BRUSH_AUTOMASKING_VIEW_NORMAL) {
- if ((int)mode & BRUSH_AUTOMASKING_VIEW_OCCLUSION) {
+ if (int(mode) & BRUSH_AUTOMASKING_VIEW_NORMAL) {
+ if (int(mode) & BRUSH_AUTOMASKING_VIEW_OCCLUSION) {
f *= automasking_view_occlusion_factor(automasking, ss, vertex, -1, &nodedata);
}
diff --git a/source/blender/editors/space_outliner/outliner_draw.cc b/source/blender/editors/space_outliner/outliner_draw.cc
index dd0f02a63c1..64aaf00344b 100644
--- a/source/blender/editors/space_outliner/outliner_draw.cc
+++ b/source/blender/editors/space_outliner/outliner_draw.cc
@@ -3605,8 +3605,8 @@ static void outliner_draw_struct_marks(ARegion *region,
immThemeColorShadeAlpha(TH_BACK, -15, -200);
immBegin(GPU_PRIM_LINES, 2);
- immVertex2f(pos, 0, (float)*starty + UI_UNIT_Y);
- immVertex2f(pos, region->v2d.cur.xmax, (float)*starty + UI_UNIT_Y);
+ immVertex2f(pos, 0, float(*starty) + UI_UNIT_Y);
+ immVertex2f(pos, region->v2d.cur.xmax, float(*starty) + UI_UNIT_Y);
immEnd();
immUnbindProgram();
diff --git a/source/blender/editors/space_view3d/view3d_draw.cc b/source/blender/editors/space_view3d/view3d_draw.cc
index 6ae44594db9..57c104455cd 100644
--- a/source/blender/editors/space_view3d/view3d_draw.cc
+++ b/source/blender/editors/space_view3d/view3d_draw.cc
@@ -122,8 +122,8 @@ void ED_view3d_update_viewmat(Depsgraph *depsgraph,
else {
float rect_scale[2];
if (rect) {
- rect_scale[0] = (float)BLI_rcti_size_x(rect) / (float)region->winx;
- rect_scale[1] = (float)BLI_rcti_size_y(rect) / (float)region->winy;
+ rect_scale[0] = float(BLI_rcti_size_x(rect)) / float(region->winx);
+ rect_scale[1] = float(BLI_rcti_size_y(rect)) / float(region->winy);
}
/* NOTE: calls BKE_object_where_is_calc for camera... */
view3d_viewmatrix_set(depsgraph, scene, v3d, rv3d, rect ? rect_scale : nullptr);
@@ -139,11 +139,11 @@ void ED_view3d_update_viewmat(Depsgraph *depsgraph,
if (!offscreen && rv3d->persp == RV3D_CAMOB && v3d->camera) {
rctf cameraborder;
ED_view3d_calc_camera_border(scene, depsgraph, region, v3d, rv3d, &cameraborder, false);
- rv3d->viewcamtexcofac[0] = (float)region->winx / BLI_rctf_size_x(&cameraborder);
- rv3d->viewcamtexcofac[1] = (float)region->winy / BLI_rctf_size_y(&cameraborder);
+ rv3d->viewcamtexcofac[0] = float(region->winx) / BLI_rctf_size_x(&cameraborder);
+ rv3d->viewcamtexcofac[1] = float(region->winy) / BLI_rctf_size_y(&cameraborder);
- rv3d->viewcamtexcofac[2] = -rv3d->viewcamtexcofac[0] * cameraborder.xmin / (float)region->winx;
- rv3d->viewcamtexcofac[3] = -rv3d->viewcamtexcofac[1] * cameraborder.ymin / (float)region->winy;
+ rv3d->viewcamtexcofac[2] = -rv3d->viewcamtexcofac[0] * cameraborder.xmin / float(region->winx);
+ rv3d->viewcamtexcofac[3] = -rv3d->viewcamtexcofac[1] * cameraborder.ymin / float(region->winy);
}
else {
rv3d->viewcamtexcofac[0] = rv3d->viewcamtexcofac[1] = 1.0f;
@@ -168,10 +168,10 @@ void ED_view3d_update_viewmat(Depsgraph *depsgraph,
len_px = 2.0f / sqrtf(min_ff(len_squared_v3(v1), len_squared_v3(v2)));
if (rect) {
- len_sc = (float)max_ii(BLI_rcti_size_x(rect), BLI_rcti_size_y(rect));
+ len_sc = float(max_ii(BLI_rcti_size_x(rect), BLI_rcti_size_y(rect)));
}
else {
- len_sc = (float)MAX2(region->winx, region->winy);
+ len_sc = float(MAX2(region->winx, region->winy));
}
rv3d->pixsize = len_px / len_sc;
@@ -561,10 +561,10 @@ static void drawviewborder(Scene *scene, Depsgraph *depsgraph, ARegion *region,
* obscures the 3D camera border */
/* NOTE: with VIEW3D_CAMERA_BORDER_HACK defined this error isn't noticeable
* but keep it here in case we need to remove the workaround */
- x1i = (int)(x1 - 1.0001f);
- y1i = (int)(y1 - 1.0001f);
- x2i = (int)(x2 + (1.0f - 0.0001f));
- y2i = (int)(y2 + (1.0f - 0.0001f));
+ x1i = int(x1 - 1.0001f);
+ y1i = int(y1 - 1.0001f);
+ x2i = int(x2 + (1.0f - 0.0001f));
+ y2i = int(y2 + (1.0f - 0.0001f));
uint shdr_pos = GPU_vertformat_attr_add(
immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
@@ -843,7 +843,7 @@ float ED_scene_grid_scale(const Scene *scene, const char **r_grid_unit)
if (r_grid_unit) {
*r_grid_unit = BKE_unit_display_name_get(usys, i);
}
- return (float)BKE_unit_scalar_get(usys, i) / scene->unit.scale_length;
+ return float(BKE_unit_scalar_get(usys, i)) / scene->unit.scale_length;
}
}
@@ -877,7 +877,7 @@ void ED_view3d_grid_steps(const Scene *scene,
int i;
for (i = 0; i < len; i++) {
- r_grid_steps[i] = (float)BKE_unit_scalar_get(usys, len - 1 - i) * grid_scale;
+ r_grid_steps[i] = float(BKE_unit_scalar_get(usys, len - 1 - i)) * grid_scale;
}
for (; i < STEPS_LEN; i++) {
/* Fill last slots */
@@ -1063,7 +1063,7 @@ static void draw_rotation_guide(const RegionView3D *rv3d)
# define ROT_AXIS_DETAIL 13
const float s = 0.05f * scale;
- const float step = 2.0f * (float)(M_PI / ROT_AXIS_DETAIL);
+ const float step = 2.0f * float(M_PI / ROT_AXIS_DETAIL);
float q[4]; /* rotate ring so it's perpendicular to axis */
const int upright = fabsf(rv3d->rot_axis[2]) >= 0.95f;
@@ -1386,7 +1386,7 @@ static void draw_selected_name(
/* color depends on whether there is a keyframe */
if (id_frame_has_keyframe(
- (ID *)ob, /* BKE_scene_ctime_get(scene) */ (float)cfra, ANIMFILTER_KEYS_LOCAL)) {
+ (ID *)ob, /* BKE_scene_ctime_get(scene) */ float(cfra), ANIMFILTER_KEYS_LOCAL)) {
UI_FontThemeColor(font_id, TH_TIME_KEYFRAME);
}
else if (ED_gpencil_has_keyframe_v3d(scene, ob, cfra)) {
@@ -2216,7 +2216,7 @@ void ED_view3d_select_id_validate(ViewContext *vc)
int ED_view3d_backbuf_sample_size_clamp(ARegion *region, const float dist)
{
- return (int)min_ff(ceilf(dist), (float)max_ii(region->winx, region->winx));
+ return int(min_ff(ceilf(dist), float(max_ii(region->winx, region->winx))));
}
/** \} */
@@ -2281,7 +2281,7 @@ static ViewDepths *view3d_depths_create(ARegion *region)
/* Convert in-place. */
int pixel_count = d->w * d->h;
for (int i = 0; i < pixel_count; i++) {
- d->depths[i] = (int_depths[i] >> 8u) / (float)0xFFFFFF;
+ d->depths[i] = (int_depths[i] >> 8u) / float(0xFFFFFF);
}
/* Assumed to be this as they are never changed. */
d->depth_range[0] = 0.0;
@@ -2293,13 +2293,13 @@ static ViewDepths *view3d_depths_create(ARegion *region)
float view3d_depth_near(ViewDepths *d)
{
/* Convert to float for comparisons. */
- const float near = (float)d->depth_range[0];
- const float far_real = (float)d->depth_range[1];
+ const float near = float(d->depth_range[0]);
+ const float far_real = float(d->depth_range[1]);
float far = far_real;
const float *depths = d->depths;
float depth = FLT_MAX;
- int i = (int)d->w * (int)d->h; /* Cast to avoid short overflow. */
+ int i = int(d->w) * int(d->h); /* Cast to avoid short overflow. */
/* Far is both the starting 'far' value
* and the closest value found. */
@@ -2515,8 +2515,8 @@ void ED_scene_draw_fps(const Scene *scene, int xoffset, int *yoffset)
printable[0] = '\0';
/* Doing an average for a more robust calculation. */
- fpsi->redrawtimes_fps[fpsi->redrawtime_index] = (float)(1.0 /
- (fpsi->lredrawtime - fpsi->redrawtime));
+ fpsi->redrawtimes_fps[fpsi->redrawtime_index] = float(1.0 /
+ (fpsi->lredrawtime - fpsi->redrawtime));
float fps = 0.0f;
int tot = 0;
@@ -2534,13 +2534,13 @@ void ED_scene_draw_fps(const Scene *scene, int xoffset, int *yoffset)
const int font_id = BLF_default();
/* Is this more than half a frame behind? */
- if (fps + 0.5f < (float)(FPS)) {
+ if (fps + 0.5f < float(FPS)) {
UI_FontThemeColor(font_id, TH_REDALERT);
BLI_snprintf(printable, sizeof(printable), IFACE_("fps: %.2f"), fps);
}
else {
UI_FontThemeColor(font_id, TH_TEXT_HI);
- BLI_snprintf(printable, sizeof(printable), IFACE_("fps: %i"), (int)(fps + 0.5f));
+ BLI_snprintf(printable, sizeof(printable), IFACE_("fps: %i"), int(fps + 0.5f));
}
BLF_enable(font_id, BLF_SHADOW);
diff --git a/source/blender/gpu/intern/gpu_index_buffer.cc b/source/blender/gpu/intern/gpu_index_buffer.cc
index 42f4e048131..99e47f5452a 100644
--- a/source/blender/gpu/intern/gpu_index_buffer.cc
+++ b/source/blender/gpu/intern/gpu_index_buffer.cc
@@ -388,13 +388,13 @@ void IndexBuf::squeeze_indices_short(uint min_idx,
0xFFFFu :
(max_idx - min_idx);
for (uint i = 0; i < index_len_; i++) {
- ushort_idx[i] = (uint16_t)MIN2(clamp_max_idx, uint_idx[i] - min_idx);
+ ushort_idx[i] = uint16_t(MIN2(clamp_max_idx, uint_idx[i] - min_idx));
}
}
else {
index_base_ = 0;
for (uint i = 0; i < index_len_; i++) {
- ushort_idx[i] = (uint16_t)(uint_idx[i]);
+ ushort_idx[i] = uint16_t(uint_idx[i]);
}
}
}
diff --git a/source/blender/modifiers/intern/MOD_wave.cc b/source/blender/modifiers/intern/MOD_wave.cc
index 44002b2d719..0fc2d76f87e 100644
--- a/source/blender/modifiers/intern/MOD_wave.cc
+++ b/source/blender/modifiers/intern/MOD_wave.cc
@@ -135,7 +135,7 @@ static void waveModifier_do(WaveModifierData *md,
const MDeformVert *dvert;
int defgrp_index;
float ctime = DEG_get_ctime(ctx->depsgraph);
- float minfac = (float)(1.0 / exp(wmd->width * wmd->narrow * wmd->width * wmd->narrow));
+ float minfac = float(1.0 / exp(wmd->width * wmd->narrow * wmd->width * wmd->narrow));
float lifefac = wmd->height;
float(*tex_co)[3] = nullptr;
const int wmd_axis = wmd->flag & (MOD_WAVE_X | MOD_WAVE_Y);
@@ -175,7 +175,7 @@ static void waveModifier_do(WaveModifierData *md,
lifefac = 0.0;
}
else {
- lifefac = (float)(wmd->height * (1.0f - sqrtf(lifefac / wmd->damp)));
+ lifefac = float(wmd->height * (1.0f - sqrtf(lifefac / wmd->damp)));
}
}
}
@@ -227,7 +227,7 @@ static void waveModifier_do(WaveModifierData *md,
amplit -= (ctime - wmd->timeoffs) * wmd->speed;
if (wmd->flag & MOD_WAVE_CYCL) {
- amplit = (float)fmodf(amplit - wmd->width, 2.0f * wmd->width) + wmd->width;
+ amplit = float(fmodf(amplit - wmd->width, 2.0f * wmd->width)) + wmd->width;
}
if (falloff != 0.0f) {
@@ -252,7 +252,7 @@ static void waveModifier_do(WaveModifierData *md,
/* GAUSSIAN */
if ((falloff_fac != 0.0f) && (amplit > -wmd->width) && (amplit < wmd->width)) {
amplit = amplit * wmd->narrow;
- amplit = (float)(1.0f / expf(amplit * amplit) - minfac);
+ amplit = float(1.0f / expf(amplit * amplit) - minfac);
/* Apply texture. */
if (tex_co) {