[Bf-blender-cvs] [8bdd4b46855] master: Cleanup: use function style casts for C++
Campbell Barton
noreply at git.blender.org
Fri Sep 30 06:55:17 CEST 2022
Commit: 8bdd4b468554446cb1351785f0db751e2f84341f
Author: Campbell Barton
Date: Fri Sep 30 14:16:14 2022 +1000
Branches: master
https://developer.blender.org/rB8bdd4b468554446cb1351785f0db751e2f84341f
Cleanup: use function style casts for C++
===================================================================
M intern/ghost/intern/GHOST_XrControllerModel.cpp
M intern/ghost/intern/GHOST_XrSession.cpp
M source/blender/blenkernel/intern/brush.cc
M source/blender/blenkernel/intern/curve.cc
M source/blender/blenkernel/intern/customdata.cc
M source/blender/blenkernel/intern/gpencil_geom.cc
M source/blender/blenkernel/intern/mesh_normals.cc
M source/blender/blenkernel/intern/modifier.cc
M source/blender/blenkernel/intern/scene.cc
M source/blender/blenlib/intern/math_boolean.cc
M source/blender/blenloader/intern/readfile.cc
M source/blender/blenloader/intern/versioning_300.cc
M source/blender/draw/intern/draw_manager_text.cc
M source/blender/draw/intern/draw_pbvh.cc
M source/blender/editors/interface/interface.cc
M source/blender/editors/interface/view2d_ops.cc
M source/blender/editors/sculpt_paint/sculpt_automasking.cc
M source/blender/editors/space_outliner/outliner_draw.cc
M source/blender/editors/space_view3d/view3d_draw.cc
M source/blender/gpu/intern/gpu_index_buffer.cc
M source/blender/modifiers/intern/MOD_wave.cc
===================================================================
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_
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list