From f68cfd6bb078482c4a779a6e26a56e2734edb5b8 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 25 Sep 2022 18:33:28 +1000 Subject: Cleanup: replace C-style casts with functional casts for numeric types --- .../blender/blendthumb/src/blender_thumbnailer.cc | 2 +- .../blender/blendthumb/src/blendthumb_extract.cc | 2 +- source/blender/blenkernel/intern/attribute.cc | 6 +- source/blender/blenkernel/intern/brush.cc | 2 +- source/blender/blenkernel/intern/curve.cc | 22 ++-- source/blender/blenkernel/intern/curveprofile.cc | 10 +- source/blender/blenkernel/intern/customdata.cc | 42 +++---- source/blender/blenkernel/intern/displist.cc | 20 ++-- .../blender/blenkernel/intern/editmesh_tangent.cc | 12 +- source/blender/blenkernel/intern/gpencil_geom.cc | 64 +++++------ source/blender/blenkernel/intern/icons.cc | 2 +- source/blender/blenkernel/intern/image.cc | 16 +-- source/blender/blenkernel/intern/image_gpu.cc | 10 +- source/blender/blenkernel/intern/main_namemap.cc | 2 +- source/blender/blenkernel/intern/mball.cc | 2 +- source/blender/blenkernel/intern/mesh.cc | 4 +- source/blender/blenkernel/intern/mesh_convert.cc | 16 +-- source/blender/blenkernel/intern/mesh_evaluate.cc | 22 ++-- source/blender/blenkernel/intern/mesh_fair.cc | 2 +- .../blenkernel/intern/mesh_legacy_convert.cc | 30 ++--- source/blender/blenkernel/intern/mesh_mapping.cc | 48 ++++---- .../blenkernel/intern/mesh_merge_customdata.cc | 2 +- source/blender/blenkernel/intern/mesh_normals.cc | 40 +++---- .../blender/blenkernel/intern/mesh_remesh_voxel.cc | 10 +- source/blender/blenkernel/intern/mesh_tangent.cc | 42 +++---- .../blender/blenkernel/intern/mesh_tessellate.cc | 22 ++-- source/blender/blenkernel/intern/mesh_validate.cc | 2 +- source/blender/blenkernel/intern/node.cc | 2 +- .../blender/blenkernel/intern/node_tree_update.cc | 4 +- source/blender/blenkernel/intern/object_dupli.cc | 14 +-- source/blender/blenkernel/intern/paint.cc | 2 +- source/blender/blenkernel/intern/pbvh.cc | 2 +- source/blender/blenkernel/intern/scene.cc | 24 ++-- source/blender/blenkernel/intern/subdiv_mesh.cc | 4 +- .../blender/blenkernel/intern/type_conversions.cc | 28 ++--- source/blender/blenkernel/intern/volume.cc | 4 +- source/blender/blenlib/intern/dot_export.cc | 4 +- source/blender/blenlib/intern/math_boolean.cc | 58 +++++----- source/blender/blenlib/intern/noise.cc | 42 +++---- source/blender/blenlib/intern/rand.cc | 20 ++-- source/blender/blenlib/intern/string_search.cc | 4 +- source/blender/blenlib/intern/threads.cc | 4 +- source/blender/blenlib/tests/BLI_edgehash_test.cc | 2 +- .../blenlib/tests/BLI_generic_array_test.cc | 8 +- .../blender/blenlib/tests/BLI_heap_simple_test.cc | 8 +- source/blender/blenlib/tests/BLI_heap_test.cc | 20 ++-- source/blender/blenlib/tests/BLI_kdopbvh_test.cc | 4 +- .../blenlib/tests/BLI_linear_allocator_test.cc | 14 +-- .../blender/blenlib/tests/BLI_math_color_test.cc | 2 +- .../blenlib/tests/BLI_math_rotation_test.cc | 2 +- source/blender/blenlib/tests/BLI_path_util_test.cc | 2 +- .../blender/blenlib/tests/BLI_polyfill_2d_test.cc | 4 +- .../blender/blenlib/tests/BLI_string_utf8_test.cc | 10 +- .../blenlib/tests/BLI_virtual_array_test.cc | 6 +- .../performance/BLI_ghash_performance_test.cc | 6 +- .../tests/performance/BLI_task_performance_test.cc | 4 +- source/blender/blenloader/intern/readfile.cc | 16 +-- source/blender/blenloader/intern/undofile.cc | 2 +- source/blender/blenloader/intern/versioning_300.cc | 10 +- source/blender/blenloader/intern/writefile.cc | 6 +- source/blender/bmesh/intern/bmesh_query_uv.cc | 4 +- .../compositor/intern/COM_ChunkOrderHotspot.cc | 4 +- .../compositor/intern/COM_ExecutionGroup.cc | 20 ++-- .../blender/compositor/intern/COM_MemoryBuffer.cc | 8 +- .../blender/compositor/intern/COM_OpenCLDevice.cc | 4 +- source/blender/compositor/intern/COM_compositor.cc | 6 +- source/blender/compositor/nodes/COM_CropNode.cc | 4 +- source/blender/compositor/nodes/COM_MapUVNode.cc | 2 +- source/blender/compositor/nodes/COM_MaskNode.cc | 2 +- .../blender/compositor/nodes/COM_SceneTimeNode.cc | 2 +- source/blender/compositor/nodes/COM_TimeNode.cc | 2 +- .../compositor/operations/COM_BlurBaseOperation.cc | 4 +- .../operations/COM_BokehImageOperation.cc | 12 +- .../compositor/operations/COM_BoxMaskOperation.cc | 4 +- .../COM_CalculateStandardDeviationOperation.cc | 4 +- .../COM_ConvertDepthToRadiusOperation.cc | 4 +- .../operations/COM_CryptomatteOperation.cc | 8 +- .../compositor/operations/COM_DenoiseOperation.cc | 2 +- .../operations/COM_DespeckleOperation.cc | 4 +- .../operations/COM_DilateErodeOperation.cc | 8 +- .../operations/COM_DirectionalBlurOperation.cc | 2 +- .../compositor/operations/COM_DisplaceOperation.cc | 6 +- .../operations/COM_EllipseMaskOperation.cc | 4 +- .../compositor/operations/COM_FlipOperation.cc | 16 +-- .../COM_GaussianAlphaBlurBaseOperation.cc | 2 +- .../operations/COM_GaussianBlurBaseOperation.cc | 2 +- .../operations/COM_GaussianBokehBlurOperation.cc | 40 +++---- .../operations/COM_GlareFogGlowOperation.cc | 16 +-- .../operations/COM_GlareGhostOperation.cc | 12 +- .../operations/COM_GlareStreaksOperation.cc | 12 +- .../operations/COM_KeyingBlurOperation.cc | 2 +- .../operations/COM_KeyingClipOperation.cc | 4 +- .../operations/COM_KeyingScreenOperation.cc | 18 +-- .../compositor/operations/COM_MapUVOperation.cc | 6 +- .../compositor/operations/COM_MaskOperation.cc | 2 +- .../operations/COM_MovieDistortionOperation.cc | 16 +-- .../operations/COM_MultilayerImageOperation.cc | 6 +- .../operations/COM_PlaneDistortCommonOperation.cc | 12 +- .../operations/COM_PlaneTrackOperation.cc | 2 +- .../compositor/operations/COM_PreviewOperation.cc | 6 +- .../compositor/operations/COM_RenderLayersProg.cc | 4 +- .../compositor/operations/COM_RotateOperation.cc | 2 +- .../compositor/operations/COM_SMAAOperation.cc | 10 +- .../compositor/operations/COM_ScaleOperation.cc | 6 +- .../COM_ScreenLensDistortionOperation.cc | 28 ++--- .../compositor/operations/COM_SunBeamsOperation.cc | 34 +++--- .../compositor/operations/COM_TonemapOperation.cc | 12 +- .../operations/COM_TransformOperation.cc | 2 +- .../COM_VariableSizeBokehBlurOperation.cc | 24 ++-- .../operations/COM_VectorBlurOperation.cc | 26 ++--- .../compositor/operations/COM_ViewerOperation.cc | 2 +- .../depsgraph/intern/builder/deg_builder_cache.cc | 4 +- .../depsgraph/intern/builder/deg_builder_cycle.cc | 2 +- source/blender/depsgraph/intern/depsgraph_debug.cc | 2 +- .../depsgraph/intern/eval/deg_eval_flush.cc | 2 +- .../engines/eevee_next/eevee_depth_of_field.cc | 4 +- .../blender/draw/engines/eevee_next/eevee_film.cc | 2 +- .../draw/engines/eevee_next/eevee_renderbuffers.cc | 4 +- .../draw/engines/eevee_next/eevee_sampling.cc | 10 +- .../draw/engines/eevee_next/eevee_velocity.cc | 10 +- .../blender/draw/engines/eevee_next/eevee_view.cc | 2 +- .../draw/engines/overlay/overlay_armature.cc | 8 +- .../draw/engines/overlay/overlay_edit_uv.cc | 10 +- .../blender/draw/engines/overlay/overlay_engine.cc | 2 +- .../blender/draw/engines/overlay/overlay_grid.cc | 16 +-- .../blender/draw/engines/overlay/overlay_image.cc | 2 +- .../draw/engines/overlay/overlay_metaball.cc | 2 +- .../draw/engines/overlay/overlay_motion_path.cc | 2 +- .../draw/engines/overlay/overlay_outline.cc | 2 +- .../blender/draw/intern/draw_cache_extract_mesh.cc | 2 +- .../intern/draw_cache_extract_mesh_render_data.cc | 2 +- .../draw/intern/draw_cache_impl_subdivision.cc | 16 +-- source/blender/draw/intern/draw_command.cc | 12 +- .../extract_mesh_ibo_lines_adjacency.cc | 6 +- .../extract_mesh_ibo_lines_paint_mask.cc | 4 +- .../mesh_extractors/extract_mesh_vbo_edit_data.cc | 6 +- .../extract_mesh_vbo_edituv_stretch_angle.cc | 4 +- .../mesh_extractors/extract_mesh_vbo_fdots_pos.cc | 4 +- .../mesh_extractors/extract_mesh_vbo_fdots_uv.cc | 4 +- .../extract_mesh_vbo_mesh_analysis.cc | 8 +- .../intern/mesh_extractors/extract_mesh_vbo_tan.cc | 4 +- .../intern/mesh_extractors/extract_mesh_vbo_uv.cc | 2 +- source/blender/editors/asset/intern/asset_ops.cc | 4 +- source/blender/editors/curves/intern/curves_add.cc | 2 +- source/blender/editors/curves/intern/curves_ops.cc | 2 +- .../editors/gpencil/gpencil_bake_animation.cc | 4 +- source/blender/editors/gpencil/gpencil_mesh.cc | 4 +- source/blender/editors/interface/interface.cc | 126 ++++++++++----------- .../editors/interface/interface_dropboxes.cc | 2 +- .../blender/editors/interface/interface_panel.cc | 26 ++--- .../blender/editors/interface/interface_query.cc | 2 +- .../interface/interface_region_color_picker.cc | 2 +- .../editors/interface/interface_region_popover.cc | 6 +- .../editors/interface/interface_region_search.cc | 2 +- .../editors/interface/interface_region_tooltip.cc | 2 +- .../blender/editors/interface/interface_style.cc | 32 +++--- .../editors/interface/interface_template_list.cc | 8 +- .../interface/interface_template_search_menu.cc | 8 +- .../blender/editors/interface/interface_utils.cc | 4 +- source/blender/editors/interface/view2d.cc | 108 +++++++++--------- source/blender/editors/interface/view2d_draw.cc | 10 +- .../blender/editors/interface/view2d_edge_pan.cc | 16 +-- source/blender/editors/interface/view2d_ops.cc | 10 +- .../blender/editors/interface/views/grid_view.cc | 4 +- source/blender/editors/mesh/editface.cc | 6 +- source/blender/editors/mesh/mesh_data.cc | 4 +- source/blender/editors/mesh/meshtools.cc | 8 +- source/blender/editors/object/object_add.cc | 2 +- source/blender/editors/object/object_modifier.cc | 2 +- source/blender/editors/object/object_remesh.cc | 10 +- source/blender/editors/object/object_transform.cc | 4 +- source/blender/editors/render/render_preview.cc | 18 +-- source/blender/editors/render/render_shading.cc | 2 +- .../editors/sculpt_paint/curves_sculpt_brush.cc | 2 +- .../editors/sculpt_paint/curves_sculpt_density.cc | 4 +- .../editors/sculpt_paint/curves_sculpt_ops.cc | 2 +- .../sculpt_paint/paint_image_2d_curve_mask.cc | 10 +- .../blender/editors/sculpt_paint/paint_vertex.cc | 10 +- .../editors/sculpt_paint/sculpt_automasking.cc | 2 +- .../editors/sculpt_paint/sculpt_face_set.cc | 4 +- source/blender/editors/space_file/filelist.cc | 14 +-- source/blender/editors/space_node/drawnode.cc | 2 +- source/blender/editors/space_node/node_draw.cc | 46 ++++---- source/blender/editors/space_node/node_edit.cc | 4 +- source/blender/editors/space_node/node_gizmo.cc | 4 +- .../editors/space_node/node_relationships.cc | 2 +- source/blender/editors/space_node/node_select.cc | 5 +- source/blender/editors/space_node/node_view.cc | 24 ++-- source/blender/editors/space_node/space_node.cc | 6 +- .../editors/space_outliner/outliner_draw.cc | 118 +++++++++---------- .../editors/space_outliner/outliner_edit.cc | 8 +- .../editors/space_outliner/outliner_tools.cc | 2 +- .../space_spreadsheet/spreadsheet_layout.cc | 4 +- .../space_spreadsheet/spreadsheet_row_filter.cc | 4 +- .../space_spreadsheet/spreadsheet_row_filter_ui.cc | 2 +- .../blender/editors/space_view3d/space_view3d.cc | 4 +- .../blender/editors/space_view3d/view3d_select.cc | 20 ++-- .../editors/transform/transform_snap_object.cc | 2 +- source/blender/editors/uvedit/uvedit_islands.cc | 2 +- .../freestyle/intern/application/AppCanvas.cpp | 16 +-- .../intern/blender_interface/BlenderFileLoader.cpp | 2 +- .../blender/freestyle/intern/geometry/Bezier.cpp | 2 +- .../freestyle/intern/geometry/GeomCleaner.cpp | 6 +- source/blender/freestyle/intern/geometry/Grid.cpp | 2 +- source/blender/freestyle/intern/geometry/Noise.cpp | 8 +- .../freestyle/intern/image/GaussianFilter.cpp | 2 +- .../freestyle/intern/image/ImagePyramid.cpp | 2 +- .../freestyle/intern/python/BPy_Interface1D.cpp | 2 +- .../Interface0D/CurvePoint/BPy_StrokeVertex.cpp | 8 +- .../intern/stroke/AdvancedFunctions0D.cpp | 24 ++-- .../intern/stroke/AdvancedFunctions1D.cpp | 2 +- .../freestyle/intern/stroke/BasicStrokeShaders.cpp | 28 ++--- source/blender/freestyle/intern/stroke/Stroke.cpp | 12 +- .../blender/freestyle/intern/stroke/StrokeRep.cpp | 2 +- .../freestyle/intern/system/PseudoNoise.cpp | 2 +- source/blender/freestyle/intern/system/RandGen.cpp | 4 +- .../blender/freestyle/intern/view_map/BoxGrid.cpp | 4 +- .../freestyle/intern/view_map/SphericalGrid.cpp | 4 +- .../freestyle/intern/view_map/SteerableViewMap.cpp | 10 +- .../freestyle/intern/view_map/ViewMapBuilder.cpp | 10 +- .../freestyle/intern/winged_edge/WXEdge.cpp | 4 +- .../functions/intern/multi_function_builder.cc | 2 +- .../intern/multi_function_procedure_executor.cc | 4 +- .../functions/tests/FN_multi_function_test.cc | 2 +- .../blender/geometry/intern/add_curves_on_mesh.cc | 2 +- .../geometry/intern/mesh_merge_by_distance.cc | 16 +-- .../blender/geometry/intern/realize_instances.cc | 4 +- source/blender/geometry/intern/set_curve_type.cc | 4 +- source/blender/geometry/intern/trim_curves.cc | 26 ++--- source/blender/geometry/intern/uv_parametrizer.cc | 6 +- source/blender/gpu/intern/gpu_codegen.cc | 2 +- source/blender/gpu/intern/gpu_index_buffer.cc | 2 +- source/blender/gpu/intern/gpu_matrix.cc | 6 +- source/blender/gpu/intern/gpu_shader_log.cc | 6 +- source/blender/gpu/intern/gpu_state.cc | 30 ++--- source/blender/gpu/opengl/gl_context.cc | 8 +- source/blender/gpu/opengl/gl_framebuffer.cc | 4 +- source/blender/gpu/opengl/gl_shader.cc | 2 +- source/blender/gpu/opengl/gl_shader_interface.cc | 4 +- source/blender/gpu/opengl/gl_vertex_array.cc | 4 +- source/blender/ikplugin/intern/itasc_plugin.cpp | 6 +- .../blender/imbuf/intern/oiio/openimageio_api.cpp | 2 +- .../blender/imbuf/intern/openexr/openexr_api.cpp | 62 +++++----- source/blender/imbuf/intern/transform.cc | 12 +- source/blender/io/collada/AnimationImporter.cpp | 22 ++-- source/blender/io/collada/BCAnimationCurve.cpp | 10 +- source/blender/io/collada/BCMath.cpp | 4 +- source/blender/io/collada/CameraExporter.cpp | 4 +- source/blender/io/collada/DocumentImporter.cpp | 10 +- source/blender/io/collada/ExtraTags.cpp | 6 +- source/blender/io/collada/GeometryExporter.cpp | 10 +- source/blender/io/collada/MeshImporter.cpp | 2 +- source/blender/io/collada/TransformReader.cpp | 12 +- source/blender/io/collada/collada_internal.cpp | 6 +- source/blender/io/collada/collada_utils.cpp | 12 +- .../blender/io/gpencil/intern/gpencil_io_base.cc | 14 +-- .../io/gpencil/intern/gpencil_io_import_base.cc | 2 +- .../io/gpencil/intern/gpencil_io_import_svg.cc | 18 +-- source/blender/io/usd/intern/usd_reader_curve.cc | 6 +- source/blender/io/usd/intern/usd_reader_light.cc | 4 +- source/blender/io/usd/intern/usd_reader_nurbs.cc | 8 +- source/blender/io/usd/intern/usd_writer_volume.cc | 2 +- .../exporter/obj_export_file_writer.cc | 6 +- .../io/wavefront_obj/exporter/obj_export_mtl.cc | 8 +- .../importer/obj_import_file_reader.cc | 10 +- .../io/wavefront_obj/importer/obj_import_mesh.cc | 2 +- .../io/wavefront_obj/importer/obj_import_mtl.cc | 6 +- .../io/wavefront_obj/tests/obj_mtl_parser_tests.cc | 2 +- .../modifiers/intern/MOD_meshsequencecache.cc | 2 +- source/blender/modifiers/intern/MOD_nodes.cc | 10 +- .../nodes/function/nodes/node_fn_float_to_int.cc | 8 +- .../nodes/geometry/nodes/node_geo_convex_hull.cc | 4 +- .../nodes/geometry/nodes/node_geo_curve_fill.cc | 2 +- .../nodes/node_geo_curve_handle_type_selection.cc | 2 +- .../nodes/node_geo_curve_primitive_circle.cc | 2 +- .../nodes/node_geo_curve_primitive_spiral.cc | 6 +- .../nodes/node_geo_distribute_points_in_volume.cc | 16 +-- .../nodes/geometry/nodes/node_geo_image_texture.cc | 16 +-- .../geometry/nodes/node_geo_input_scene_time.cc | 2 +- .../geometry/nodes/node_geo_mesh_primitive_line.cc | 2 +- .../geometry/nodes/node_geo_points_to_volume.cc | 2 +- source/blender/nodes/intern/geometry_nodes_log.cc | 4 +- source/blender/nodes/intern/node_socket.cc | 8 +- source/blender/nodes/shader/node_shader_tree.cc | 2 +- .../nodes/node_shader_bsdf_hair_principled.cc | 2 +- .../nodes/shader/nodes/node_shader_tex_brick.cc | 6 +- .../nodes/shader/nodes/node_shader_tex_checker.cc | 6 +- .../nodes/shader/nodes/node_shader_tex_sky.cc | 8 +- .../shader/nodes/node_shader_tex_white_noise.cc | 2 +- .../python/gpu/gpu_py_shader_create_info.cc | 102 ++++++++--------- source/blender/render/intern/engine.cc | 2 +- source/blender/render/intern/initrender.cc | 2 +- source/blender/render/intern/pipeline.cc | 2 +- source/blender/render/intern/render_result.cc | 4 +- source/blender/render/intern/texture_margin.cc | 8 +- source/blender/simulation/intern/hair_volume.cpp | 36 +++--- .../windowmanager/intern/wm_event_system.cc | 24 ++-- 297 files changed, 1498 insertions(+), 1499 deletions(-) (limited to 'source/blender') diff --git a/source/blender/blendthumb/src/blender_thumbnailer.cc b/source/blender/blendthumb/src/blender_thumbnailer.cc index da0aef3d0e1..93a3d1530fc 100644 --- a/source/blender/blendthumb/src/blender_thumbnailer.cc +++ b/source/blender/blendthumb/src/blender_thumbnailer.cc @@ -95,5 +95,5 @@ int main(int argc, char *argv[]) eThumbStatus ret = extract_png_from_blend_file(argv[1], argv[2]); - return (int)ret; + return int(ret); } diff --git a/source/blender/blendthumb/src/blendthumb_extract.cc b/source/blender/blendthumb/src/blendthumb_extract.cc index 1429f26f82c..9a3e1cb73cc 100644 --- a/source/blender/blendthumb/src/blendthumb_extract.cc +++ b/source/blender/blendthumb/src/blendthumb_extract.cc @@ -103,7 +103,7 @@ static bool file_seek(FileReader *file, size_t len) blender::Array dummy_data(dummy_data_size); while (len > 0) { const size_t len_chunk = std::min(len, dummy_data_size); - if ((size_t)file->read(file, dummy_data.data(), len_chunk) != len_chunk) { + if (size_t(file->read(file, dummy_data.data(), len_chunk)) != len_chunk) { return false; } len -= len_chunk; diff --git a/source/blender/blenkernel/intern/attribute.cc b/source/blender/blenkernel/intern/attribute.cc index c69a7b4b2c7..1a54454bf9a 100644 --- a/source/blender/blenkernel/intern/attribute.cc +++ b/source/blender/blenkernel/intern/attribute.cc @@ -354,7 +354,7 @@ CustomDataLayer *BKE_id_attribute_search(ID *id, get_domains(id, info); for (eAttrDomain domain = ATTR_DOMAIN_POINT; domain < ATTR_DOMAIN_NUM; - domain = static_cast((int(domain)) + 1)) { + domain = static_cast(int(domain) + 1)) { if (!(domain_mask & ATTR_DOMAIN_AS_MASK(domain))) { continue; } @@ -388,7 +388,7 @@ int BKE_id_attributes_length(const ID *id, eAttrDomainMask domain_mask, eCustomD continue; } - if ((1 << (int)domain) & domain_mask) { + if ((1 << int(domain)) & domain_mask) { length += CustomData_number_of_layers_typemask(customdata, mask); } } @@ -574,7 +574,7 @@ CustomDataLayer *BKE_id_attribute_from_index(ID *id, for (const int domain : IndexRange(ATTR_DOMAIN_NUM)) { CustomData *customdata = info[domain].customdata; - if (!customdata || !((1 << (int)domain) & domain_mask)) { + if (!customdata || !((1 << int(domain)) & domain_mask)) { continue; } diff --git a/source/blender/blenkernel/intern/brush.cc b/source/blender/blenkernel/intern/brush.cc index a998fc0a75f..3708090f8ed 100644 --- a/source/blender/blenkernel/intern/brush.cc +++ b/source/blender/blenkernel/intern/brush.cc @@ -2358,7 +2358,7 @@ void BKE_brush_scale_unprojected_radius(float *unprojected_radius, float scale = new_brush_size; /* avoid division by zero */ if (old_brush_size != 0) { - scale /= (float)old_brush_size; + scale /= float(old_brush_size); } (*unprojected_radius) *= scale; } diff --git a/source/blender/blenkernel/intern/curve.cc b/source/blender/blenkernel/intern/curve.cc index 652315e74f9..ddd1f000644 100644 --- a/source/blender/blenkernel/intern/curve.cc +++ b/source/blender/blenkernel/intern/curve.cc @@ -1682,7 +1682,7 @@ void BKE_curve_calc_coords_axis(const BezTriple *bezt_array, bezt_next->vec[0][axis], bezt_next->vec[1][axis], r_points_offset, - (int)resolu, + int(resolu), stride); r_points_offset = (float *)POINTER_OFFSET(r_points_offset, resolu_stride); } @@ -1695,7 +1695,7 @@ void BKE_curve_calc_coords_axis(const BezTriple *bezt_array, bezt_next->vec[0][axis], bezt_next->vec[1][axis], r_points_offset, - (int)resolu, + int(resolu), stride); r_points_offset = (float *)POINTER_OFFSET(r_points_offset, resolu_stride); if (use_cyclic_duplicate_endpoint) { @@ -1719,7 +1719,7 @@ void BKE_curve_forward_diff_bezier( float rt0, rt1, rt2, rt3, f; int a; - f = (float)it; + f = float(it); rt0 = q0; rt1 = 3.0f * (q1 - q0) / f; f *= f; @@ -1747,7 +1747,7 @@ void BKE_curve_forward_diff_tangent_bezier( float rt0, rt1, rt2, f; int a; - f = 1.0f / (float)it; + f = 1.0f / float(it); rt0 = 3.0f * (q1 - q0); rt1 = f * (3.0f * (q3 - q0) + 9.0f * (q1 - q2)); @@ -1778,7 +1778,7 @@ static void forward_diff_bezier_cotangent(const float p0[3], * * This could also be optimized like BKE_curve_forward_diff_bezier */ for (int a = 0; a <= it; a++) { - float t = (float)a / (float)it; + float t = float(a) / float(it); for (int i = 0; i < 3; i++) { p[i] = (-6.0f * t + 6.0f) * p0[i] + (18.0f * t - 12.0f) * p1[i] + @@ -2005,7 +2005,7 @@ static void tilt_bezpart(const BezTriple *prevbezt, } fac = 0.0; - dfac = 1.0f / (float)resolu; + dfac = 1.0f / float(resolu); for (a = 0; a < resolu; a++, fac += dfac) { if (tilt_array) { @@ -2328,7 +2328,7 @@ static void make_bevel_list_3D_minimum_twist(BevList *bl) nr = bl->nr; while (nr--) { - ang_fac = angle * (1.0f - ((float)nr / bl->nr)); /* also works */ + ang_fac = angle * (1.0f - (float(nr) / bl->nr)); /* also works */ axis_angle_to_quat(q, bevp1->dir, ang_fac); mul_qt_qtqt(bevp1->quat, q, bevp1->quat); @@ -2515,7 +2515,7 @@ static void make_bevel_list_2D(BevList *bl) /* first */ bevp = bl->bevpoints; - angle = atan2f(bevp->dir[0], bevp->dir[1]) - (float)M_PI_2; + angle = atan2f(bevp->dir[0], bevp->dir[1]) - float(M_PI_2); bevp->sina = sinf(angle); bevp->cosa = cosf(angle); vec_to_quat(bevp->quat, bevp->dir, 5, 1); @@ -2523,7 +2523,7 @@ static void make_bevel_list_2D(BevList *bl) /* last */ bevp = bl->bevpoints; bevp += (bl->nr - 1); - angle = atan2f(bevp->dir[0], bevp->dir[1]) - (float)M_PI_2; + angle = atan2f(bevp->dir[0], bevp->dir[1]) - float(M_PI_2); bevp->sina = sinf(angle); bevp->cosa = cosf(angle); vec_to_quat(bevp->quat, bevp->dir, 5, 1); @@ -5153,7 +5153,7 @@ bool BKE_curve_center_median(Curve *cu, float cent[3]) } if (total) { - mul_v3_fl(cent, 1.0f / (float)total); + mul_v3_fl(cent, 1.0f / float(total)); } return (total != 0); @@ -5392,7 +5392,7 @@ bool BKE_curve_material_index_validate(Curve *cu) void BKE_curve_material_remap(Curve *cu, const uint *remap, uint remap_len) { const int curvetype = BKE_curve_type_get(cu); - const short remap_len_short = (short)remap_len; + const short remap_len_short = short(remap_len); #define MAT_NR_REMAP(n) \ if (n < remap_len_short) { \ diff --git a/source/blender/blenkernel/intern/curveprofile.cc b/source/blender/blenkernel/intern/curveprofile.cc index 0e34e4a55dd..5cff804cb18 100644 --- a/source/blender/blenkernel/intern/curveprofile.cc +++ b/source/blender/blenkernel/intern/curveprofile.cc @@ -207,7 +207,7 @@ bool BKE_curveprofile_remove_point(CurveProfile *profile, CurveProfilePoint *poi CurveProfilePoint *new_path = (CurveProfilePoint *)MEM_mallocN( sizeof(CurveProfilePoint) * profile->path_len, __func__); - int i_delete = (int)(point - profile->path); + int i_delete = int(point - profile->path); BLI_assert(i_delete > 0); /* Copy the before and after the deleted point. */ @@ -379,8 +379,8 @@ static void curveprofile_build_supports(CurveProfile *profile) point_init(&profile->path[0], 1.0f, 0.0f, 0, HD_VECT, HD_VECT); point_init(&profile->path[1], 1.0f, 0.5f, 0, HD_VECT, HD_VECT); for (int i = 1; i < n - 2; i++) { - const float x = 1.0f - (0.5f * (1.0f - cosf((float)(i / (float)(n - 3)) * M_PI_2))); - const float y = 0.5f + 0.5f * sinf((float)((i / (float)(n - 3)) * M_PI_2)); + const float x = 1.0f - (0.5f * (1.0f - cosf(float(i / float(n - 3)) * M_PI_2))); + const float y = 0.5f + 0.5f * sinf(float((i / float(n - 3)) * M_PI_2)); point_init(&profile->path[i], x, y, 0, HD_AUTO, HD_AUTO); } point_init(&profile->path[n - 2], 0.5f, 1.0f, 0, HD_VECT, HD_VECT); @@ -408,8 +408,8 @@ static void curveprofile_build_steps(CurveProfile *profile) for (int i = 0; i < n; i++) { int step_x = (i + 1) / 2; int step_y = i / 2; - const float x = 1.0f - ((float)(2 * step_x) / n_steps_x); - const float y = (float)(2 * step_y) / n_steps_y; + const float x = 1.0f - (float(2 * step_x) / n_steps_x); + const float y = float(2 * step_y) / n_steps_y; point_init(&profile->path[i], x, y, 0, HD_VECT, HD_VECT); } } diff --git a/source/blender/blenkernel/intern/customdata.cc b/source/blender/blenkernel/intern/customdata.cc index c07b4c7964e..0968f9a8a01 100644 --- a/source/blender/blenkernel/intern/customdata.cc +++ b/source/blender/blenkernel/intern/customdata.cc @@ -841,7 +841,7 @@ static void layerCopyValue_mloopcol(const void *source, /* Modes that do a full copy or nothing. */ if (ELEM(mixmode, CDT_MIX_REPLACE_ABOVE_THRESHOLD, CDT_MIX_REPLACE_BELOW_THRESHOLD)) { /* TODO: Check for a real valid way to get 'factor' value of our dest color? */ - const float f = ((float)m2->r + (float)m2->g + (float)m2->b) / 3.0f; + const float f = (float(m2->r) + float(m2->g) + float(m2->b)) / 3.0f; if (mixmode == CDT_MIX_REPLACE_ABOVE_THRESHOLD && f < mixfactor) { return; /* Do Nothing! */ } @@ -876,10 +876,10 @@ static void layerCopyValue_mloopcol(const void *source, blend_color_interpolate_byte(dst, dst, tmp_col, mixfactor); - m2->r = (char)dst[0]; - m2->g = (char)dst[1]; - m2->b = (char)dst[2]; - m2->a = (char)dst[3]; + m2->r = char(dst[0]); + m2->g = char(dst[1]); + m2->b = char(dst[2]); + m2->a = char(dst[3]); } } @@ -901,10 +901,10 @@ static void layerMultiply_mloopcol(void *data, const float fac) { MLoopCol *m = static_cast(data); - m->r = (float)m->r * fac; - m->g = (float)m->g * fac; - m->b = (float)m->b * fac; - m->a = (float)m->a * fac; + m->r = float(m->r) * fac; + m->g = float(m->g) * fac; + m->b = float(m->b) * fac; + m->a = float(m->a) * fac; } static void layerAdd_mloopcol(void *data1, const void *data2) @@ -3119,7 +3119,7 @@ static void *customData_duplicate_referenced_layer_index(CustomData *data, if (typeInfo->copy) { void *dst_data = MEM_malloc_arrayN( - (size_t)totelem, typeInfo->size, "CD duplicate ref layer"); + size_t(totelem), typeInfo->size, "CD duplicate ref layer"); typeInfo->copy(layer->data, dst_data, totelem); layer->data = dst_data; } @@ -3250,7 +3250,7 @@ void CustomData_copy_elements(const int type, typeInfo->copy(src_data_ofs, dst_data_ofs, count); } else { - memcpy(dst_data_ofs, src_data_ofs, (size_t)count * typeInfo->size); + memcpy(dst_data_ofs, src_data_ofs, size_t(count) * typeInfo->size); } } @@ -3269,8 +3269,8 @@ void CustomData_copy_data_layer(const CustomData *source, typeInfo = layerType_getInfo(source->layers[src_layer_index].type); - const size_t src_offset = (size_t)src_index * typeInfo->size; - const size_t dst_offset = (size_t)dst_index * typeInfo->size; + const size_t src_offset = size_t(src_index) * typeInfo->size; + const size_t dst_offset = size_t(dst_index) * typeInfo->size; if (!count || !src_data || !dst_data) { if (count && !(src_data == nullptr && dst_data == nullptr)) { @@ -3290,7 +3290,7 @@ void CustomData_copy_data_layer(const CustomData *source, else { memcpy(POINTER_OFFSET(dst_data, dst_offset), POINTER_OFFSET(src_data, src_offset), - (size_t)count * typeInfo->size); + size_t(count) * typeInfo->size); } } @@ -3379,7 +3379,7 @@ void CustomData_free_elem(CustomData *data, const int index, const int count) const LayerTypeInfo *typeInfo = layerType_getInfo(data->layers[i].type); if (typeInfo->free) { - size_t offset = (size_t)index * typeInfo->size; + size_t offset = size_t(index) * typeInfo->size; typeInfo->free(POINTER_OFFSET(data->layers[i].data, offset), count, typeInfo->size); } @@ -3415,7 +3415,7 @@ void CustomData_interp(const CustomData *source, if (weights == nullptr) { default_weights = (count > SOURCE_BUF_SIZE) ? static_cast( - MEM_mallocN(sizeof(*weights) * (size_t)count, __func__)) : + MEM_mallocN(sizeof(*weights) * size_t(count), __func__)) : default_weights_buf; copy_vn_fl(default_weights, count, 1.0f / count); weights = default_weights; @@ -3446,7 +3446,7 @@ void CustomData_interp(const CustomData *source, void *src_data = source->layers[src_i].data; for (int j = 0; j < count; j++) { - sources[j] = POINTER_OFFSET(src_data, (size_t)src_indices[j] * typeInfo->size); + sources[j] = POINTER_OFFSET(src_data, size_t(src_indices[j]) * typeInfo->size); } typeInfo->interp( @@ -3454,7 +3454,7 @@ void CustomData_interp(const CustomData *source, weights, sub_weights, count, - POINTER_OFFSET(dest->layers[dest_i].data, (size_t)dest_index * typeInfo->size)); + POINTER_OFFSET(dest->layers[dest_i].data, size_t(dest_index) * typeInfo->size)); /* if there are multiple source & dest layers of the same type, * we don't want to copy all source layers to the same dest, so @@ -3478,7 +3478,7 @@ void CustomData_swap_corners(CustomData *data, const int index, const int *corne const LayerTypeInfo *typeInfo = layerType_getInfo(data->layers[i].type); if (typeInfo->swap) { - const size_t offset = (size_t)index * typeInfo->size; + const size_t offset = size_t(index) * typeInfo->size; typeInfo->swap(POINTER_OFFSET(data->layers[i].data, offset), corner_indices); } @@ -3523,7 +3523,7 @@ void *CustomData_get(const CustomData *data, const int index, const int type) } /* get the offset of the desired element */ - const size_t offset = (size_t)index * layerType_getInfo(type)->size; + const size_t offset = size_t(index) * layerType_getInfo(type)->size; return POINTER_OFFSET(data->layers[layer_index].data, offset); } @@ -3538,7 +3538,7 @@ void *CustomData_get_n(const CustomData *data, const int type, const int index, return nullptr; } - const size_t offset = (size_t)index * layerType_getInfo(type)->size; + const size_t offset = size_t(index) * layerType_getInfo(type)->size; return POINTER_OFFSET(data->layers[layer_index + n].data, offset); } diff --git a/source/blender/blenkernel/intern/displist.cc b/source/blender/blenkernel/intern/displist.cc index 279166297ec..2b4bd3eb8f6 100644 --- a/source/blender/blenkernel/intern/displist.cc +++ b/source/blender/blenkernel/intern/displist.cc @@ -503,7 +503,7 @@ static float displist_calc_taper(Depsgraph *depsgraph, float BKE_displist_calc_taper( Depsgraph *depsgraph, const Scene *scene, Object *taperobj, int cur, int tot) { - const float fac = ((float)cur) / (float)(tot - 1); + const float fac = float(cur) / float(tot - 1); return displist_calc_taper(depsgraph, scene, taperobj, fac); } @@ -518,7 +518,7 @@ static ModifierData *curve_get_tessellate_point(const Scene *scene, ModifierMode required_mode = for_render ? eModifierMode_Render : eModifierMode_Realtime; if (editmode) { - required_mode = (ModifierMode)((int)required_mode | eModifierMode_Editmode); + required_mode = (ModifierMode)(int(required_mode) | eModifierMode_Editmode); } ModifierData *pretessellatePoint = nullptr; @@ -562,7 +562,7 @@ void BKE_curve_calc_modifiers_pre(Depsgraph *depsgraph, const bool editmode = (!for_render && (cu->editnurb || cu->editfont)); ModifierMode required_mode = for_render ? eModifierMode_Render : eModifierMode_Realtime; if (editmode) { - required_mode = (ModifierMode)((int)required_mode | eModifierMode_Editmode); + required_mode = (ModifierMode)(int(required_mode) | eModifierMode_Editmode); } ModifierApplyFlag apply_flag = (ModifierApplyFlag)0; @@ -689,7 +689,7 @@ static GeometrySet curve_calc_modifiers_post(Depsgraph *depsgraph, ModifierApplyFlag apply_flag = for_render ? MOD_APPLY_RENDER : (ModifierApplyFlag)0; ModifierMode required_mode = for_render ? eModifierMode_Render : eModifierMode_Realtime; if (editmode) { - required_mode = (ModifierMode)((int)required_mode | eModifierMode_Editmode); + required_mode = (ModifierMode)(int(required_mode) | eModifierMode_Editmode); } const ModifierEvalContext mectx_deform = { @@ -970,13 +970,13 @@ static void calc_bevfac_segment_mapping( int bevcount = 0, nr = bl->nr; float bev_fl = bevfac * (bl->nr - 1); - *r_bev = (int)bev_fl; + *r_bev = int(bev_fl); while (bevcount < nr - 1) { float normlen = *seglen / spline_length; if (normsum + normlen > bevfac) { bev_fl = bevcount + (bevfac - normsum) / normlen * *segbevcount; - *r_bev = (int)bev_fl; + *r_bev = int(bev_fl); *r_blend = bev_fl - *r_bev; break; } @@ -1046,7 +1046,7 @@ static void calc_bevfac_mapping(const Curve *cu, switch (cu->bevfac1_mapping) { case CU_BEVFAC_MAP_RESOLU: { const float start_fl = cu->bevfac1 * (bl->nr - 1); - *r_start = (int)start_fl; + *r_start = int(start_fl); *r_firstblend = 1.0f - (start_fl - (*r_start)); break; } @@ -1065,7 +1065,7 @@ static void calc_bevfac_mapping(const Curve *cu, switch (cu->bevfac2_mapping) { case CU_BEVFAC_MAP_RESOLU: { const float end_fl = cu->bevfac2 * (bl->nr - 1); - end = (int)end_fl; + end = int(end_fl); *r_steps = 2 + end - *r_start; *r_lastblend = end_fl - end; @@ -1238,12 +1238,12 @@ static GeometrySet evaluate_curve_type_object(Depsgraph *depsgraph, taper_factor = 1.0f; } else { - taper_factor = ((float)a - (1.0f - first_blend)) / len; + taper_factor = (float(a) - (1.0f - first_blend)) / len; } } else { float len = bl->nr - 1; - taper_factor = (float)i / len; + taper_factor = float(i) / len; if (a == 0) { taper_factor += (1.0f - first_blend) / len; diff --git a/source/blender/blenkernel/intern/editmesh_tangent.cc b/source/blender/blenkernel/intern/editmesh_tangent.cc index a65532d083d..6ce9d3c7bb5 100644 --- a/source/blender/blenkernel/intern/editmesh_tangent.cc +++ b/source/blender/blenkernel/intern/editmesh_tangent.cc @@ -33,9 +33,9 @@ struct SGLSLEditMeshToTangent { uint GetNumFaces() { #ifdef USE_LOOPTRI_DETECT_QUADS - return (uint)num_face_as_quad_map; + return uint(num_face_as_quad_map); #else - return (uint)numTessFaces; + return uint(numTessFaces); #endif } @@ -194,21 +194,21 @@ void BKE_editmesh_loop_tangent_calc(BMEditMesh *em, for (int i = 0; i < tangent_names_len; i++) { if (tangent_names[i][0]) { BKE_mesh_add_loop_tangent_named_layer_for_uv( - &bm->ldata, loopdata_out, (int)loopdata_out_len, tangent_names[i]); + &bm->ldata, loopdata_out, int(loopdata_out_len), tangent_names[i]); } } if ((tangent_mask & DM_TANGENT_MASK_ORCO) && CustomData_get_named_layer_index(loopdata_out, CD_TANGENT, "") == -1) { CustomData_add_layer_named( - loopdata_out, CD_TANGENT, CD_SET_DEFAULT, nullptr, (int)loopdata_out_len, ""); + loopdata_out, CD_TANGENT, CD_SET_DEFAULT, nullptr, int(loopdata_out_len), ""); } if (calc_act && act_uv_name[0]) { BKE_mesh_add_loop_tangent_named_layer_for_uv( - &bm->ldata, loopdata_out, (int)loopdata_out_len, act_uv_name); + &bm->ldata, loopdata_out, int(loopdata_out_len), act_uv_name); } if (calc_ren && ren_uv_name[0]) { BKE_mesh_add_loop_tangent_named_layer_for_uv( - &bm->ldata, loopdata_out, (int)loopdata_out_len, ren_uv_name); + &bm->ldata, loopdata_out, int(loopdata_out_len), ren_uv_name); } int totface = em->tottri; #ifdef USE_LOOPTRI_DETECT_QUADS diff --git a/source/blender/blenkernel/intern/gpencil_geom.cc b/source/blender/blenkernel/intern/gpencil_geom.cc index 4d0db4d5386..563f05691ae 100644 --- a/source/blender/blenkernel/intern/gpencil_geom.cc +++ b/source/blender/blenkernel/intern/gpencil_geom.cc @@ -746,7 +746,7 @@ bool BKE_gpencil_stroke_stretch(bGPDstroke *gps, * `curvature = delta angle/delta arclength = len_v3(total_angle) / overshoot_length` */ float curvature = normalize_v3(total_angle) / overshoot_length; /* Compensate for the weights powf(added_len, segment_influence). */ - curvature /= powf(overshoot_length / fminf(overshoot_parameter, (float)j), segment_influence); + curvature /= powf(overshoot_length / fminf(overshoot_parameter, float(j)), segment_influence); if (invert_curvature) { curvature = -curvature; } @@ -1044,14 +1044,14 @@ bool BKE_gpencil_stroke_smooth_point(bGPDstroke *gps, (iterations * iterations) / 4 + 2 * iterations + 12; double w = keep_shape ? 2.0 : 1.0; double w2 = keep_shape ? - (1.0 / M_SQRT3) * exp((2 * iterations * iterations) / (double)(n_half * 3)) : + (1.0 / M_SQRT3) * exp((2 * iterations * iterations) / double(n_half * 3)) : 0.0; double total_w = 0.0; for (int step = iterations; step > 0; step--) { int before = point_index - step; int after = point_index + step; - float w_before = (float)(w - w2); - float w_after = (float)(w - w2); + float w_before = float(w - w2); + float w_after = float(w - w2); if (is_cyclic) { before = (before % gps->totpoints + gps->totpoints) % gps->totpoints; @@ -1060,13 +1060,13 @@ bool BKE_gpencil_stroke_smooth_point(bGPDstroke *gps, else { if (before < 0) { if (!smooth_caps) { - w_before *= -before / (float)point_index; + w_before *= -before / float(point_index); } before = 0; } if (after > gps->totpoints - 1) { if (!smooth_caps) { - w_after *= (after - (gps->totpoints - 1)) / (float)(gps->totpoints - 1 - point_index); + w_after *= (after - (gps->totpoints - 1)) / float(gps->totpoints - 1 - point_index); } after = gps->totpoints - 1; } @@ -1081,14 +1081,14 @@ bool BKE_gpencil_stroke_smooth_point(bGPDstroke *gps, total_w += w_before; total_w += w_after; - w *= (n_half + step) / (double)(n_half + 1 - step); - w2 *= (n_half * 3 + step) / (double)(n_half * 3 + 1 - step); + w *= (n_half + step) / double(n_half + 1 - step); + w2 *= (n_half * 3 + step) / double(n_half * 3 + 1 - step); } total_w += w - w2; /* The accumulated weight total_w should be * ~sqrt(M_PI * n_half) * exp((iterations * iterations) / n_half) < 100 * here, but sometimes not quite. */ - mul_v3_fl(sco, (float)(1.0 / total_w)); + mul_v3_fl(sco, float(1.0 / total_w)); /* Shift back to global coordinates. */ add_v3_v3(sco, &pt->x); @@ -1123,8 +1123,8 @@ bool BKE_gpencil_stroke_smooth_strength( for (int step = iterations; step > 0; step--) { int before = point_index - step; int after = point_index + step; - float w_before = (float)w; - float w_after = (float)w; + float w_before = float(w); + float w_after = float(w); if (is_cyclic) { before = (before % gps->totpoints + gps->totpoints) % gps->totpoints; @@ -1142,7 +1142,7 @@ bool BKE_gpencil_stroke_smooth_strength( total_w += w_before; total_w += w_after; - w *= (n_half + step) / (double)(n_half + 1 - step); + w *= (n_half + step) / double(n_half + 1 - step); } total_w += w; /* The accumulated weight total_w should be @@ -1181,8 +1181,8 @@ bool BKE_gpencil_stroke_smooth_thickness( for (int step = iterations; step > 0; step--) { int before = point_index - step; int after = point_index + step; - float w_before = (float)w; - float w_after = (float)w; + float w_before = float(w); + float w_after = float(w); if (is_cyclic) { before = (before % gps->totpoints + gps->totpoints) % gps->totpoints; @@ -1200,7 +1200,7 @@ bool BKE_gpencil_stroke_smooth_thickness( total_w += w_before; total_w += w_after; - w *= (n_half + step) / (double)(n_half + 1 - step); + w *= (n_half + step) / double(n_half + 1 - step); } total_w += w; /* The accumulated weight total_w should be @@ -1251,8 +1251,8 @@ bool BKE_gpencil_stroke_smooth_uv(struct bGPDstroke *gps, for (int step = iterations; step > 0; step--) { int before = point_index - step; int after = point_index + step; - float w_before = (float)w; - float w_after = (float)w; + float w_before = float(w); + float w_after = float(w); if (is_cyclic) { before = (before % gps->totpoints + gps->totpoints) % gps->totpoints; @@ -1260,11 +1260,11 @@ bool BKE_gpencil_stroke_smooth_uv(struct bGPDstroke *gps, } else { if (before < 0) { - w_before *= -before / (float)point_index; + w_before *= -before / float(point_index); before = 0; } if (after > gps->totpoints - 1) { - w_after *= (after - (gps->totpoints - 1)) / (float)(gps->totpoints - 1 - point_index); + w_after *= (after - (gps->totpoints - 1)) / float(gps->totpoints - 1 - point_index); after = gps->totpoints - 1; } } @@ -1278,7 +1278,7 @@ bool BKE_gpencil_stroke_smooth_uv(struct bGPDstroke *gps, total_w += w_before; total_w += w_after; - w *= (n_half + step) / (double)(n_half + 1 - step); + w *= (n_half + step) / double(n_half + 1 - step); } total_w += w; /* The accumulated weight total_w should be @@ -1353,7 +1353,7 @@ void BKE_gpencil_stroke_2d_flat(const bGPDspoint *points, const bGPDspoint *pt0 = &points[0]; const bGPDspoint *pt1 = &points[1]; - const bGPDspoint *pt3 = &points[(int)(totpoints * 0.75)]; + const bGPDspoint *pt3 = &points[int(totpoints * 0.75)]; float locx[3]; float locy[3]; @@ -1430,7 +1430,7 @@ void BKE_gpencil_stroke_2d_flat_ref(const bGPDspoint *ref_points, const bGPDspoint *pt0 = &ref_points[0]; const bGPDspoint *pt1 = &ref_points[1]; - const bGPDspoint *pt3 = &ref_points[(int)(ref_totpoints * 0.75)]; + const bGPDspoint *pt3 = &ref_points[int(ref_totpoints * 0.75)]; float locx[3]; float locy[3]; @@ -1499,7 +1499,7 @@ void BKE_gpencil_stroke_2d_flat_ref(const bGPDspoint *ref_points, } /* Concave (-1), Convex (1), or Auto-detect (0)? */ - *r_direction = (int)locy[2]; + *r_direction = int(locy[2]); } /* Calc texture coordinates using flat projected points. */ @@ -1564,7 +1564,7 @@ void BKE_gpencil_stroke_fill_triangulate(bGPDstroke *gps) /* convert to 2d and triangulate */ BKE_gpencil_stroke_2d_flat(gps->points, gps->totpoints, points2d, &direction); - BLI_polyfill_calc(points2d, (uint)gps->totpoints, direction, tmp_triangles); + BLI_polyfill_calc(points2d, uint(gps->totpoints), direction, tmp_triangles); /* calc texture coordinates automatically */ float minv[2]; @@ -1844,7 +1844,7 @@ bool BKE_gpencil_stroke_close(bGPDstroke *gps) pt2 = &gps->points[0]; bGPDspoint *pt = &gps->points[old_tot]; for (int i = 1; i < tot_newpoints + 1; i++, pt++) { - float step = (tot_newpoints > 1) ? ((float)i / (float)tot_newpoints) : 0.99f; + float step = (tot_newpoints > 1) ? (float(i) / float(tot_newpoints)) : 0.99f; /* Clamp last point to be near, but not on top of first point. */ if ((tot_newpoints > 1) && (i == tot_newpoints)) { step *= 0.99f; @@ -1988,7 +1988,7 @@ void BKE_gpencil_stroke_normal(const bGPDstroke *gps, float r_normal[3]) const bGPDspoint *pt0 = &points[0]; const bGPDspoint *pt1 = &points[1]; - const bGPDspoint *pt3 = &points[(int)(totpoints * 0.75)]; + const bGPDspoint *pt3 = &points[int(totpoints * 0.75)]; float vec1[3]; float vec2[3]; @@ -3117,7 +3117,7 @@ bGPDstroke *BKE_gpencil_stroke_delete_tagged_points(bGPdata *gpd, bGPDstroke *new_stroke = nullptr; bGPDstroke *gps_first = nullptr; - const bool is_cyclic = (bool)(gps->flag & GP_STROKE_CYCLIC); + const bool is_cyclic = bool(gps->flag & GP_STROKE_CYCLIC); /* First Pass: Identify start/end of islands */ bGPDspoint *pt = gps->points; @@ -3210,7 +3210,7 @@ bGPDstroke *BKE_gpencil_stroke_delete_tagged_points(bGPdata *gpd, float delta = gps->points[island->start_idx].time; int j; - new_stroke->inittime += (double)delta; + new_stroke->inittime += double(delta); pts = new_stroke->points; for (j = 0; j < new_stroke->totpoints; j++, pts++) { @@ -3502,7 +3502,7 @@ void BKE_gpencil_stroke_join(bGPDstroke *gps_a, /* Ratio to apply in the points to keep the same thickness in the joined stroke using the * destination stroke thickness. */ const float ratio = (fit_thickness && gps_a->thickness > 0.0f) ? - (float)gps_b->thickness / (float)gps_a->thickness : + float(gps_b->thickness) / float(gps_a->thickness) : 1.0f; /* 3rd: add all points */ @@ -3863,7 +3863,7 @@ static int generate_arc_from_point_to_point(ListBase *list, * points to insert. */ int num_points = (int)(((1 << (subdivisions + 1)) - 1) * (angle / M_PI)); if (num_points > 0) { - float angle_incr = angle / (float)num_points; + float angle_incr = angle / float(num_points); float vec_p[3]; float vec_t[3]; @@ -3918,7 +3918,7 @@ static int generate_semi_circle_from_point_to_point(ListBase *list, } float vec_p[3]; - float angle_incr = M_PI / ((float)num_points - 1); + float angle_incr = M_PI / (float(num_points) - 1); tPerimeterPoint *last_point = from; for (int i = 1; i < num_points; i++) { @@ -4324,7 +4324,7 @@ float BKE_gpencil_stroke_average_pressure_get(bGPDstroke *gps) tot += pt->pressure; } - return tot / (float)gps->totpoints; + return tot / float(gps->totpoints); } bool BKE_gpencil_stroke_is_pressure_constant(bGPDstroke *gps) diff --git a/source/blender/blenkernel/intern/icons.cc b/source/blender/blenkernel/intern/icons.cc index 76a02316e9f..82023c23ca5 100644 --- a/source/blender/blenkernel/intern/icons.cc +++ b/source/blender/blenkernel/intern/icons.cc @@ -479,7 +479,7 @@ PreviewImage *BKE_previewimg_cached_thumbnail_read(const char *name, if (prv && force_update) { const char *prv_deferred_data = (char *)PRV_DEFERRED_DATA(prv); - if (((int)prv_deferred_data[0] == source) && STREQ(&prv_deferred_data[1], filepath)) { + if ((int(prv_deferred_data[0]) == source) && STREQ(&prv_deferred_data[1], filepath)) { /* If same filepath, no need to re-allocate preview, just clear it up. */ BKE_previewimg_clear(prv); } diff --git a/source/blender/blenkernel/intern/image.cc b/source/blender/blenkernel/intern/image.cc index b06317fa511..567b99216e5 100644 --- a/source/blender/blenkernel/intern/image.cc +++ b/source/blender/blenkernel/intern/image.cc @@ -256,7 +256,7 @@ static void image_foreach_cache(ID *id, function_callback(id, &key, (void **)&image->rr, 0, user_data); LISTBASE_FOREACH (RenderSlot *, slot, &image->renderslots) { - key.offset_in_ID = (size_t)BLI_ghashutil_strhash_p(slot->name); + key.offset_in_ID = size_t(BLI_ghashutil_strhash_p(slot->name)); function_callback(id, &key, (void **)&slot->render, 0, user_data); } } @@ -846,8 +846,8 @@ int BKE_image_get_tile_from_pos(Image *ima, const float uv[2], float r_uv[2], fl return 0; } - int ix = (int)uv[0]; - int iy = (int)uv[1]; + int ix = int(uv[0]); + int iy = int(uv[1]); int tile_number = 1001 + 10 * iy + ix; if (BKE_image_get_tile(ima, tile_number) == nullptr) { @@ -1534,14 +1534,14 @@ void BKE_image_print_memlist(Main *bmain) totsize += image_mem_size(ima); } - printf("\ntotal image memory len: %.3f MB\n", (double)totsize / (double)(1024 * 1024)); + printf("\ntotal image memory len: %.3f MB\n", double(totsize) / double(1024 * 1024)); for (ima = static_cast(bmain->images.first); ima; ima = static_cast(ima->id.next)) { size = image_mem_size(ima); if (size) { - printf("%s len: %.3f MB\n", ima->id.name + 2, (double)size / (double)(1024 * 1024)); + printf("%s len: %.3f MB\n", ima->id.name + 2, double(size) / double(1024 * 1024)); } } } @@ -1967,7 +1967,7 @@ void BKE_image_stamp_buf(Scene *scene, * for now though this is only used for renders which use scene settings */ #define TEXT_SIZE_CHECK(str, w, h) \ - ((str[0]) && ((void)(h = h_fixed), (w = (int)BLF_width(mono, str, sizeof(str))))) + ((str[0]) && ((void)(h = h_fixed), (w = int(BLF_width(mono, str, sizeof(str)))))) /* must enable BLF_WORD_WRAP before using */ #define TEXT_SIZE_CHECK_WORD_WRAP(str, w, h) \ @@ -5187,8 +5187,8 @@ void BKE_image_get_size_fl(Image *image, ImageUser *iuser, float r_size[2]) int width, height; BKE_image_get_size(image, iuser, &width, &height); - r_size[0] = (float)width; - r_size[1] = (float)height; + r_size[0] = float(width); + r_size[1] = float(height); } void BKE_image_get_aspect(Image *image, float *r_aspx, float *r_aspy) diff --git a/source/blender/blenkernel/intern/image_gpu.cc b/source/blender/blenkernel/intern/image_gpu.cc index 08fdd715512..6893a50638a 100644 --- a/source/blender/blenkernel/intern/image_gpu.cc +++ b/source/blender/blenkernel/intern/image_gpu.cc @@ -551,7 +551,7 @@ void BKE_image_free_anim_gputextures(Main *bmain) void BKE_image_free_old_gputextures(Main *bmain) { static int lasttime = 0; - int ctime = (int)PIL_check_seconds_timer(); + int ctime = int(PIL_check_seconds_timer()); /* * Run garbage collector once for every collecting period of time @@ -602,8 +602,8 @@ static ImBuf *update_do_scale(uchar *rect, int full_h) { /* Partial update with scaling. */ - float xratio = limit_w / (float)full_w; - float yratio = limit_h / (float)full_h; + float xratio = limit_w / float(full_w); + float yratio = limit_h / float(full_h); int part_w = *w, part_h = *h; @@ -611,8 +611,8 @@ static ImBuf *update_do_scale(uchar *rect, * losing 1 pixel due to rounding errors in x,y. */ *x *= xratio; *y *= yratio; - *w = (int)ceil(xratio * (*w)); - *h = (int)ceil(yratio * (*h)); + *w = int(ceil(xratio * (*w))); + *h = int(ceil(yratio * (*h))); /* ...but take back if we are over the limit! */ if (*x + *w > limit_w) { diff --git a/source/blender/blenkernel/intern/main_namemap.cc b/source/blender/blenkernel/intern/main_namemap.cc index 82133204e19..5a8f90ea10a 100644 --- a/source/blender/blenkernel/intern/main_namemap.cc +++ b/source/blender/blenkernel/intern/main_namemap.cc @@ -62,7 +62,7 @@ static bool id_name_final_build(char *name, char *base_name, size_t base_name_le /* Code above may have generated invalid utf-8 string, due to raw truncation. * Ensure we get a valid one now. */ - base_name_len -= (size_t)BLI_str_utf8_invalid_strip(base_name, base_name_len); + base_name_len -= size_t(BLI_str_utf8_invalid_strip(base_name, base_name_len)); /* Also truncate orig name, and start the whole check again. */ name[base_name_len] = '\0'; diff --git a/source/blender/blenkernel/intern/mball.cc b/source/blender/blenkernel/intern/mball.cc index 91797f8ed2f..7c83bed85b0 100644 --- a/source/blender/blenkernel/intern/mball.cc +++ b/source/blender/blenkernel/intern/mball.cc @@ -529,7 +529,7 @@ bool BKE_mball_center_median(const MetaBall *mb, float r_cent[3]) } if (total) { - mul_v3_fl(r_cent, 1.0f / (float)total); + mul_v3_fl(r_cent, 1.0f / float(total)); } return (total != 0); diff --git a/source/blender/blenkernel/intern/mesh.cc b/source/blender/blenkernel/intern/mesh.cc index 6df6cd31cf4..7079a3e1ae8 100644 --- a/source/blender/blenkernel/intern/mesh.cc +++ b/source/blender/blenkernel/intern/mesh.cc @@ -1396,7 +1396,7 @@ void BKE_mesh_material_remap(Mesh *me, const uint *remap, uint remap_len) { using namespace blender; using namespace blender::bke; - const short remap_len_short = (short)remap_len; + const short remap_len_short = short(remap_len); #define MAT_NR_REMAP(n) \ if (n < remap_len_short) { \ @@ -1832,7 +1832,7 @@ void BKE_mesh_calc_normals_split_ex(Mesh *mesh, * only in case auto-smooth is enabled. */ const bool use_split_normals = (r_lnors_spacearr != nullptr) || ((mesh->flag & ME_AUTOSMOOTH) != 0); - const float split_angle = (mesh->flag & ME_AUTOSMOOTH) != 0 ? mesh->smoothresh : (float)M_PI; + const float split_angle = (mesh->flag & ME_AUTOSMOOTH) != 0 ? mesh->smoothresh : float(M_PI); /* may be nullptr */ clnors = (short(*)[2])CustomData_get_layer(&mesh->ldata, CD_CUSTOMLOOPNORMAL); diff --git a/source/blender/blenkernel/intern/mesh_convert.cc b/source/blender/blenkernel/intern/mesh_convert.cc index 1ad74ef693a..05ef6dc0b54 100644 --- a/source/blender/blenkernel/intern/mesh_convert.cc +++ b/source/blender/blenkernel/intern/mesh_convert.cc @@ -274,13 +274,13 @@ static Mesh *mesh_nurbs_displist_to_mesh(const Curve *cu, const ListBase *dispba mloop[0].v = startvert + index[0]; mloop[1].v = startvert + index[2]; mloop[2].v = startvert + index[1]; - mpoly->loopstart = (int)(mloop - loops.data()); + mpoly->loopstart = int(mloop - loops.data()); mpoly->totloop = 3; material_indices.span[mpoly - polys.data()] = dl->col; if (mloopuv) { for (int i = 0; i < 3; i++, mloopuv++) { - mloopuv->uv[0] = (mloop[i].v - startvert) / (float)(dl->nr - 1); + mloopuv->uv[0] = (mloop[i].v - startvert) / float(dl->nr - 1); mloopuv->uv[1] = 0.0f; } } @@ -334,7 +334,7 @@ static Mesh *mesh_nurbs_displist_to_mesh(const Curve *cu, const ListBase *dispba mloop[1].v = p3; mloop[2].v = p4; mloop[3].v = p2; - mpoly->loopstart = (int)(mloop - loops.data()); + mpoly->loopstart = int(mloop - loops.data()); mpoly->totloop = 4; material_indices.span[mpoly - polys.data()] = dl->col; @@ -357,8 +357,8 @@ static Mesh *mesh_nurbs_displist_to_mesh(const Curve *cu, const ListBase *dispba /* find uv based on vertex index into grid array */ int v = mloop[i].v - startvert; - mloopuv->uv[0] = (v / dl->nr) / (float)orco_sizev; - mloopuv->uv[1] = (v % dl->nr) / (float)orco_sizeu; + mloopuv->uv[0] = (v / dl->nr) / float(orco_sizev); + mloopuv->uv[1] = (v % dl->nr) / float(orco_sizeu); /* cyclic correction */ if ((ELEM(i, 1, 2)) && mloopuv->uv[0] == 0.0f) { @@ -1133,11 +1133,11 @@ static void add_shapekey_layers(Mesh *mesh_dest, Mesh *mesh_src) mesh_src->totvert, kb->name, kb->totelem); - array = (float *)MEM_calloc_arrayN((size_t)mesh_src->totvert, sizeof(float[3]), __func__); + array = (float *)MEM_calloc_arrayN(size_t(mesh_src->totvert), sizeof(float[3]), __func__); } else { - array = (float *)MEM_malloc_arrayN((size_t)mesh_src->totvert, sizeof(float[3]), __func__); - memcpy(array, kb->data, sizeof(float[3]) * (size_t)mesh_src->totvert); + array = (float *)MEM_malloc_arrayN(size_t(mesh_src->totvert), sizeof(float[3]), __func__); + memcpy(array, kb->data, sizeof(float[3]) * size_t(mesh_src->totvert)); } CustomData_add_layer_named( diff --git a/source/blender/blenkernel/intern/mesh_evaluate.cc b/source/blender/blenkernel/intern/mesh_evaluate.cc index 4f8391263a1..ae0d5efa112 100644 --- a/source/blender/blenkernel/intern/mesh_evaluate.cc +++ b/source/blender/blenkernel/intern/mesh_evaluate.cc @@ -150,7 +150,7 @@ static void mesh_calc_ngon_center(const MPoly *mpoly, const MVert *mvert, float cent[3]) { - const float w = 1.0f / (float)mpoly->totloop; + const float w = 1.0f / float(mpoly->totloop); zero_v3(cent); @@ -190,7 +190,7 @@ float BKE_mesh_calc_poly_area(const MPoly *mpoly, const MLoop *loopstart, const } const MLoop *l_iter = loopstart; - float(*vertexcos)[3] = (float(*)[3])BLI_array_alloca(vertexcos, (size_t)mpoly->totloop); + float(*vertexcos)[3] = (float(*)[3])BLI_array_alloca(vertexcos, size_t(mpoly->totloop)); /* pack vertex cos into an array for area_poly_v3 */ for (int i = 0; i < mpoly->totloop; i++, l_iter++) { @@ -198,7 +198,7 @@ float BKE_mesh_calc_poly_area(const MPoly *mpoly, const MLoop *loopstart, const } /* finally calculate the area */ - float area = area_poly_v3((const float(*)[3])vertexcos, (uint)mpoly->totloop); + float area = area_poly_v3((const float(*)[3])vertexcos, uint(mpoly->totloop)); return area; } @@ -221,7 +221,7 @@ float BKE_mesh_calc_poly_uv_area(const MPoly *mpoly, const MLoopUV *uv_array) int i, l_iter = mpoly->loopstart; float area; - float(*vertexcos)[2] = (float(*)[2])BLI_array_alloca(vertexcos, (size_t)mpoly->totloop); + float(*vertexcos)[2] = (float(*)[2])BLI_array_alloca(vertexcos, size_t(mpoly->totloop)); /* pack vertex cos into an array for area_poly_v2 */ for (i = 0; i < mpoly->totloop; i++, l_iter++) { @@ -229,7 +229,7 @@ float BKE_mesh_calc_poly_uv_area(const MPoly *mpoly, const MLoopUV *uv_array) } /* finally calculate the area */ - area = area_poly_v2(vertexcos, (uint)mpoly->totloop); + area = area_poly_v2(vertexcos, uint(mpoly->totloop)); return area; } @@ -407,7 +407,7 @@ bool BKE_mesh_center_median(const Mesh *me, float r_cent[3]) } /* otherwise we get NAN for 0 verts */ if (me->totvert) { - mul_v3_fl(r_cent, 1.0f / (float)me->totvert); + mul_v3_fl(r_cent, 1.0f / float(me->totvert)); } return (me->totvert != 0); } @@ -428,7 +428,7 @@ bool BKE_mesh_center_median_from_polys(const Mesh *me, float r_cent[3]) } /* otherwise we get NAN for 0 verts */ if (me->totpoly) { - mul_v3_fl(r_cent, 1.0f / (float)tot); + mul_v3_fl(r_cent, 1.0f / float(tot)); } return (me->totpoly != 0); } @@ -638,7 +638,7 @@ void BKE_mesh_mdisp_flip(MDisps *md, const bool use_loop_mdisp_flip) return; } - const int sides = (int)sqrt(md->totdisp); + const int sides = int(sqrt(md->totdisp)); float(*co)[3] = md->disps; for (int x = 0; x < sides; x++) { @@ -922,9 +922,9 @@ void BKE_mesh_calc_relative_deform(const MPoly *mpoly, const MPoly *mp; int i; - int *vert_accum = (int *)MEM_calloc_arrayN((size_t)totvert, sizeof(*vert_accum), __func__); + int *vert_accum = (int *)MEM_calloc_arrayN(size_t(totvert), sizeof(*vert_accum), __func__); - memset(vert_cos_new, '\0', sizeof(*vert_cos_new) * (size_t)totvert); + memset(vert_cos_new, '\0', sizeof(*vert_cos_new) * size_t(totvert)); for (i = 0, mp = mpoly; i < totpoly; i++, mp++) { const MLoop *loopstart = mloop + mp->loopstart; @@ -952,7 +952,7 @@ void BKE_mesh_calc_relative_deform(const MPoly *mpoly, for (i = 0; i < totvert; i++) { if (vert_accum[i]) { - mul_v3_fl(vert_cos_new[i], 1.0f / (float)vert_accum[i]); + mul_v3_fl(vert_cos_new[i], 1.0f / float(vert_accum[i])); } else { copy_v3_v3(vert_cos_new[i], vert_cos_org[i]); diff --git a/source/blender/blenkernel/intern/mesh_fair.cc b/source/blender/blenkernel/intern/mesh_fair.cc index 41dcb3501cc..bb0a5610cf4 100644 --- a/source/blender/blenkernel/intern/mesh_fair.cc +++ b/source/blender/blenkernel/intern/mesh_fair.cc @@ -82,7 +82,7 @@ class FairingContext { LoopWeight *loop_weight) { - fair_verts_ex(affected, (int)depth, vertex_weight, loop_weight); + fair_verts_ex(affected, int(depth), vertex_weight, loop_weight); } protected: diff --git a/source/blender/blenkernel/intern/mesh_legacy_convert.cc b/source/blender/blenkernel/intern/mesh_legacy_convert.cc index 2c75c477b9a..b68117b7eb2 100644 --- a/source/blender/blenkernel/intern/mesh_legacy_convert.cc +++ b/source/blender/blenkernel/intern/mesh_legacy_convert.cc @@ -110,24 +110,24 @@ static void bm_corners_to_loops_ex(ID *id, BLI_assert(fd->totdisp == 0); } else { - const int side = (int)sqrtf((float)(fd->totdisp / corners)); + const int side = int(sqrtf(float(fd->totdisp / corners))); const int side_sq = side * side; for (int i = 0; i < tot; i++, disps += side_sq, ld++) { ld->totdisp = side_sq; - ld->level = (int)(logf((float)side - 1.0f) / (float)M_LN2) + 1; + ld->level = int(logf(float(side) - 1.0f) / float(M_LN2)) + 1; if (ld->disps) { MEM_freeN(ld->disps); } ld->disps = (float(*)[3])MEM_malloc_arrayN( - (size_t)side_sq, sizeof(float[3]), "converted loop mdisps"); + size_t(side_sq), sizeof(float[3]), "converted loop mdisps"); if (fd->disps) { - memcpy(ld->disps, disps, (size_t)side_sq * sizeof(float[3])); + memcpy(ld->disps, disps, size_t(side_sq) * sizeof(float[3])); } else { - memset(ld->disps, 0, (size_t)side_sq * sizeof(float[3])); + memset(ld->disps, 0, size_t(side_sq) * sizeof(float[3])); } } } @@ -212,7 +212,7 @@ static void convert_mfaces_to_mpolys(ID *id, CustomData_external_read(fdata, id, CD_MASK_MDISPS, totface_i); } - eh = BLI_edgehash_new_ex(__func__, (uint)totedge_i); + eh = BLI_edgehash_new_ex(__func__, uint(totedge_i)); /* build edge hash */ me = medge; @@ -609,15 +609,15 @@ static int mesh_tessface_calc(CustomData *fdata, * if all faces are triangles it will be correct, `quads == 2x` allocations. */ /* Take care since memory is _not_ zeroed so be sure to initialize each field. */ mface_to_poly_map = (int *)MEM_malloc_arrayN( - (size_t)looptri_num, sizeof(*mface_to_poly_map), __func__); - mface = (MFace *)MEM_malloc_arrayN((size_t)looptri_num, sizeof(*mface), __func__); - lindices = (uint(*)[4])MEM_malloc_arrayN((size_t)looptri_num, sizeof(*lindices), __func__); + size_t(looptri_num), sizeof(*mface_to_poly_map), __func__); + mface = (MFace *)MEM_malloc_arrayN(size_t(looptri_num), sizeof(*mface), __func__); + lindices = (uint(*)[4])MEM_malloc_arrayN(size_t(looptri_num), sizeof(*lindices), __func__); mface_index = 0; mp = mpoly; for (poly_index = 0; poly_index < totpoly; poly_index++, mp++) { - const uint mp_loopstart = (uint)mp->loopstart; - const uint mp_totloop = (uint)mp->totloop; + const uint mp_loopstart = uint(mp->loopstart); + const uint mp_totloop = uint(mp->totloop); uint l1, l2, l3, l4; uint *lidx; if (mp_totloop < 3) { @@ -701,8 +701,8 @@ static int mesh_tessface_calc(CustomData *fdata, arena = BLI_memarena_new(BLI_MEMARENA_STD_BUFSIZE, __func__); } - tris = (uint(*)[3])BLI_memarena_alloc(arena, sizeof(*tris) * (size_t)totfilltri); - projverts = (float(*)[2])BLI_memarena_alloc(arena, sizeof(*projverts) * (size_t)mp_totloop); + tris = (uint(*)[3])BLI_memarena_alloc(arena, sizeof(*tris) * size_t(totfilltri)); + projverts = (float(*)[2])BLI_memarena_alloc(arena, sizeof(*projverts) * size_t(mp_totloop)); zero_v3(normal); @@ -774,9 +774,9 @@ static int mesh_tessface_calc(CustomData *fdata, /* Not essential but without this we store over-allocated memory in the #CustomData layers. */ if (LIKELY(looptri_num != totface)) { - mface = (MFace *)MEM_reallocN(mface, sizeof(*mface) * (size_t)totface); + mface = (MFace *)MEM_reallocN(mface, sizeof(*mface) * size_t(totface)); mface_to_poly_map = (int *)MEM_reallocN(mface_to_poly_map, - sizeof(*mface_to_poly_map) * (size_t)totface); + sizeof(*mface_to_poly_map) * size_t(totface)); } CustomData_add_layer(fdata, CD_MFACE, CD_ASSIGN, mface, totface); diff --git a/source/blender/blenkernel/intern/mesh_mapping.cc b/source/blender/blenkernel/intern/mesh_mapping.cc index e7f5ce03c40..bd3902298b2 100644 --- a/source/blender/blenkernel/intern/mesh_mapping.cc +++ b/source/blender/blenkernel/intern/mesh_mapping.cc @@ -64,7 +64,7 @@ UvVertMap *BKE_mesh_uv_vert_map_create(const MPoly *mpoly, } vmap = (UvVertMap *)MEM_callocN(sizeof(*vmap), "UvVertMap"); - buf = vmap->buf = (UvMapVert *)MEM_callocN(sizeof(*vmap->buf) * (size_t)totuv, "UvMapVert"); + buf = vmap->buf = (UvMapVert *)MEM_callocN(sizeof(*vmap->buf) * size_t(totuv), "UvMapVert"); vmap->vert = (UvMapVert **)MEM_callocN(sizeof(*vmap->vert) * totvert, "UvMapVert*"); if (use_winding) { winding = static_cast(MEM_callocN(sizeof(*winding) * totpoly, "winding")); @@ -81,13 +81,13 @@ UvVertMap *BKE_mesh_uv_vert_map_create(const MPoly *mpoly, float(*tf_uv)[2] = NULL; if (use_winding) { - tf_uv = (float(*)[2])BLI_buffer_reinit_data(&tf_uv_buf, vec2f, (size_t)mp->totloop); + tf_uv = (float(*)[2])BLI_buffer_reinit_data(&tf_uv_buf, vec2f, size_t(mp->totloop)); } nverts = mp->totloop; for (i = 0; i < nverts; i++) { - buf->loop_of_poly_index = (ushort)i; + buf->loop_of_poly_index = ushort(i); buf->poly_index = a; buf->separate = 0; buf->next = vmap->vert[mloop[mp->loopstart + i].v]; @@ -101,7 +101,7 @@ UvVertMap *BKE_mesh_uv_vert_map_create(const MPoly *mpoly, } if (use_winding) { - winding[a] = cross_poly_v2(tf_uv, (uint)nverts) > 0; + winding[a] = cross_poly_v2(tf_uv, uint(nverts)) > 0; } } } @@ -196,11 +196,11 @@ static void mesh_vert_poly_or_loop_map_create(MeshElemMap **r_map, int totloop, const bool do_loops) { - MeshElemMap *map = MEM_cnew_array((size_t)totvert, __func__); + MeshElemMap *map = MEM_cnew_array(size_t(totvert), __func__); int *indices, *index_iter; int i, j; - indices = static_cast(MEM_mallocN(sizeof(int) * (size_t)totloop, __func__)); + indices = static_cast(MEM_mallocN(sizeof(int) * size_t(totloop), __func__)); index_iter = indices; /* Count number of polys for each vertex */ @@ -268,8 +268,8 @@ void BKE_mesh_vert_looptri_map_create(MeshElemMap **r_map, const MLoop *mloop, const int UNUSED(totloop)) { - MeshElemMap *map = MEM_cnew_array((size_t)totvert, __func__); - int *indices = static_cast(MEM_mallocN(sizeof(int) * (size_t)totlooptri * 3, __func__)); + MeshElemMap *map = MEM_cnew_array(size_t(totvert), __func__); + int *indices = static_cast(MEM_mallocN(sizeof(int) * size_t(totlooptri) * 3, __func__)); int *index_step; const MLoopTri *mlt; int i; @@ -306,8 +306,8 @@ void BKE_mesh_vert_looptri_map_create(MeshElemMap **r_map, void BKE_mesh_vert_edge_map_create( MeshElemMap **r_map, int **r_mem, const MEdge *medge, int totvert, int totedge) { - MeshElemMap *map = MEM_cnew_array((size_t)totvert, __func__); - int *indices = static_cast(MEM_mallocN(sizeof(int[2]) * (size_t)totedge, __func__)); + MeshElemMap *map = MEM_cnew_array(size_t(totvert), __func__); + int *indices = static_cast(MEM_mallocN(sizeof(int[2]) * size_t(totedge), __func__)); int *i_pt = indices; int i; @@ -345,8 +345,8 @@ void BKE_mesh_vert_edge_map_create( void BKE_mesh_vert_edge_vert_map_create( MeshElemMap **r_map, int **r_mem, const MEdge *medge, int totvert, int totedge) { - MeshElemMap *map = MEM_cnew_array((size_t)totvert, __func__); - int *indices = static_cast(MEM_mallocN(sizeof(int[2]) * (size_t)totedge, __func__)); + MeshElemMap *map = MEM_cnew_array(size_t(totvert), __func__); + int *indices = static_cast(MEM_mallocN(sizeof(int[2]) * size_t(totedge), __func__)); int *i_pt = indices; int i; @@ -370,8 +370,8 @@ void BKE_mesh_vert_edge_vert_map_create( for (i = 0; i < totedge; i++) { const uint v[2] = {medge[i].v1, medge[i].v2}; - map[v[0]].indices[map[v[0]].count] = (int)v[1]; - map[v[1]].indices[map[v[1]].count] = (int)v[0]; + map[v[0]].indices[map[v[0]].count] = int(v[1]); + map[v[1]].indices[map[v[1]].count] = int(v[0]); map[v[0]].count++; map[v[1]].count++; @@ -390,8 +390,8 @@ void BKE_mesh_edge_loop_map_create(MeshElemMap **r_map, const MLoop *mloop, const int totloop) { - MeshElemMap *map = MEM_cnew_array((size_t)totedge, __func__); - int *indices = static_cast(MEM_mallocN(sizeof(int) * (size_t)totloop * 2, __func__)); + MeshElemMap *map = MEM_cnew_array(size_t(totedge), __func__); + int *indices = static_cast(MEM_mallocN(sizeof(int) * size_t(totloop) * 2, __func__)); int *index_step; const MPoly *mp; int i; @@ -443,8 +443,8 @@ void BKE_mesh_edge_poly_map_create(MeshElemMap **r_map, const MLoop *mloop, const int totloop) { - MeshElemMap *map = MEM_cnew_array((size_t)totedge, __func__); - int *indices = static_cast(MEM_mallocN(sizeof(int) * (size_t)totloop, __func__)); + MeshElemMap *map = MEM_cnew_array(size_t(totedge), __func__); + int *indices = static_cast(MEM_mallocN(sizeof(int) * size_t(totloop), __func__)); int *index_step; const MPoly *mp; int i; @@ -488,8 +488,8 @@ void BKE_mesh_origindex_map_create(MeshElemMap **r_map, const int *final_origindex, const int totfinal) { - MeshElemMap *map = MEM_cnew_array((size_t)totsource, __func__); - int *indices = static_cast(MEM_mallocN(sizeof(int) * (size_t)totfinal, __func__)); + MeshElemMap *map = MEM_cnew_array(size_t(totsource), __func__); + int *indices = static_cast(MEM_mallocN(sizeof(int) * size_t(totfinal), __func__)); int *index_step; int i; @@ -530,8 +530,8 @@ void BKE_mesh_origindex_map_create_looptri(MeshElemMap **r_map, const MLoopTri *looptri, const int looptri_num) { - MeshElemMap *map = MEM_cnew_array((size_t)mpoly_num, __func__); - int *indices = static_cast(MEM_mallocN(sizeof(int) * (size_t)looptri_num, __func__)); + MeshElemMap *map = MEM_cnew_array(size_t(mpoly_num), __func__); + int *indices = static_cast(MEM_mallocN(sizeof(int) * size_t(looptri_num), __func__)); int *index_step; int i; @@ -662,7 +662,7 @@ static void poly_edge_loop_islands_calc(const MEdge *medge, mp = &mpoly[poly]; for (ml = &mloop[mp->loopstart], j = mp->totloop; j--; ml++) { /* loop over poly users */ - const int me_idx = (int)ml->e; + const int me_idx = int(ml->e); const MEdge *me = &medge[me_idx]; const MeshElemMap *map_ele = &edge_poly_map[me_idx]; const int *p = map_ele->indices; @@ -1097,7 +1097,7 @@ static bool mesh_calc_islands_loop_poly_uv(const MVert *UNUSED(verts), (edge_border_count[ml->e] < 2)) { edge_border_count[ml->e]++; if (edge_border_count[ml->e] == 2) { - edge_innercut_indices[num_einnercuts++] = (int)ml->e; + edge_innercut_indices[num_einnercuts++] = int(ml->e); } } } diff --git a/source/blender/blenkernel/intern/mesh_merge_customdata.cc b/source/blender/blenkernel/intern/mesh_merge_customdata.cc index f7936d8a4da..2c500f4d972 100644 --- a/source/blender/blenkernel/intern/mesh_merge_customdata.cc +++ b/source/blender/blenkernel/intern/mesh_merge_customdata.cc @@ -69,7 +69,7 @@ static void merge_uvs_for_vertex(const Span loops_for_vert, Span BLI_assert(loops_merge.is_empty()); loops_merge.extend_unchecked(loops_for_vert); while (loops_merge.size() > 1) { - uint i_last = (uint)loops_merge.size() - 1; + uint i_last = uint(loops_merge.size()) - 1; const float *uv_src = mloopuv[loops_merge[0]].uv; for (uint i = 1; i <= i_last;) { float *uv_dst = mloopuv[loops_merge[i]].uv; diff --git a/source/blender/blenkernel/intern/mesh_normals.cc b/source/blender/blenkernel/intern/mesh_normals.cc index 21dd39586ec..3eeebc8485a 100644 --- a/source/blender/blenkernel/intern/mesh_normals.cc +++ b/source/blender/blenkernel/intern/mesh_normals.cc @@ -320,7 +320,7 @@ void BKE_mesh_calc_normals_poly_and_vertex(const MVert *mvert, BLI_parallel_range_settings_defaults(&settings); settings.min_iter_per_thread = 1024; - memset(r_vert_normals, 0, sizeof(*r_vert_normals) * (size_t)mvert_len); + memset(r_vert_normals, 0, sizeof(*r_vert_normals) * size_t(mvert_len)); MeshCalcNormalsData_PolyAndVertex data = {}; data.mpoly = mpoly; @@ -476,10 +476,10 @@ void BKE_mesh_calc_normals_looptri(MVert *mverts, int looptri_num, float (*r_tri_nors)[3]) { - float(*tnorms)[3] = (float(*)[3])MEM_calloc_arrayN((size_t)numVerts, sizeof(*tnorms), "tnorms"); + float(*tnorms)[3] = (float(*)[3])MEM_calloc_arrayN(size_t(numVerts), sizeof(*tnorms), "tnorms"); float(*fnors)[3] = (r_tri_nors) ? r_tri_nors : (float(*)[3])MEM_calloc_arrayN( - (size_t)looptri_num, sizeof(*fnors), "meshnormals"); + size_t(looptri_num), sizeof(*fnors), "meshnormals"); if (!tnorms || !fnors) { goto cleanup; @@ -535,9 +535,9 @@ void BKE_lnor_spacearr_init(MLoopNorSpaceArray *lnors_spacearr, } mem = lnors_spacearr->mem; lnors_spacearr->lspacearr = (MLoopNorSpace **)BLI_memarena_calloc( - mem, sizeof(MLoopNorSpace *) * (size_t)numLoops); + mem, sizeof(MLoopNorSpace *) * size_t(numLoops)); lnors_spacearr->loops_pool = (LinkNode *)BLI_memarena_alloc( - mem, sizeof(LinkNode) * (size_t)numLoops); + mem, sizeof(LinkNode) * size_t(numLoops)); lnors_spacearr->spaces_num = 0; } @@ -598,7 +598,7 @@ void BKE_lnor_space_define(MLoopNorSpace *lnor_space, float vec_other[3], BLI_Stack *edge_vectors) { - const float pi2 = (float)M_PI * 2.0f; + const float pi2 = float(M_PI) * 2.0f; float tvec[3], dtp; const float dtp_ref = dot_v3v3(vec_ref, lnor); const float dtp_other = dot_v3v3(vec_other, lnor); @@ -632,7 +632,7 @@ void BKE_lnor_space_define(MLoopNorSpace *lnor_space, * a smooth vertex with only two edges and two faces (our Monkey's nose has that, e.g.). */ BLI_assert(count >= 2); /* This piece of code shall only be called for more than one loop. */ - lnor_space->ref_alpha = alpha / (float)count; + lnor_space->ref_alpha = alpha / float(count); } else { lnor_space->ref_alpha = (saacosf(dot_v3v3(vec_ref, lnor)) + @@ -690,13 +690,13 @@ void BKE_lnor_space_add_loop(MLoopNorSpaceArray *lnors_spacearr, MINLINE float unit_short_to_float(const short val) { - return (float)val / (float)SHRT_MAX; + return float(val) / float(SHRT_MAX); } MINLINE short unit_float_to_short(const float val) { /* Rounding. */ - return (short)floorf(val * (float)SHRT_MAX + 0.5f); + return short(floorf(val * float(SHRT_MAX) + 0.5f)); } void BKE_lnor_space_custom_data_to_normal(MLoopNorSpace *lnor_space, @@ -712,7 +712,7 @@ void BKE_lnor_space_custom_data_to_normal(MLoopNorSpace *lnor_space, { /* TODO: Check whether using #sincosf() gives any noticeable benefit * (could not even get it working under linux though)! */ - const float pi2 = (float)(M_PI * 2.0); + const float pi2 = float(M_PI * 2.0); const float alphafac = unit_short_to_float(clnor_data[0]); const float alpha = (alphafac > 0.0f ? lnor_space->ref_alpha : pi2 - lnor_space->ref_alpha) * alphafac; @@ -745,7 +745,7 @@ void BKE_lnor_space_custom_normal_to_data(MLoopNorSpace *lnor_space, } { - const float pi2 = (float)(M_PI * 2.0); + const float pi2 = float(M_PI * 2.0); const float cos_alpha = dot_v3v3(lnor_space->vec_lnor, custom_lnor); float vec[3], cos_beta; float alpha; @@ -955,17 +955,17 @@ void BKE_edges_sharp_from_angle_set(const struct MVert *mverts, const int numPolys, const float split_angle) { - if (split_angle >= (float)M_PI) { + if (split_angle >= float(M_PI)) { /* Nothing to do! */ return; } /* Mapping edge -> loops. See BKE_mesh_normals_loop_split() for details. */ int(*edge_to_loops)[2] = (int(*)[2])MEM_calloc_arrayN( - (size_t)numEdges, sizeof(*edge_to_loops), __func__); + size_t(numEdges), sizeof(*edge_to_loops), __func__); /* Simple mapping from a loop to its polygon index. */ - int *loop_to_poly = (int *)MEM_malloc_arrayN((size_t)numLoops, sizeof(*loop_to_poly), __func__); + int *loop_to_poly = (int *)MEM_malloc_arrayN(size_t(numLoops), sizeof(*loop_to_poly), __func__); LoopSplitTaskDataCommon common_data = {}; common_data.mverts = mverts; @@ -1278,8 +1278,8 @@ static void split_loop_nor_fan_do(LoopSplitTaskDataCommon *common_data, LoopSpli } while ((clnor = (short *)BLI_SMALLSTACK_POP(clnors))) { // print_v2("org clnor", clnor); - clnor[0] = (short)clnors_avg[0]; - clnor[1] = (short)clnors_avg[1]; + clnor[0] = short(clnors_avg[0]); + clnor[1] = short(clnors_avg[1]); } // print_v2("new clnors", clnors_avg); } @@ -1952,7 +1952,7 @@ static void mesh_normals_loop_custom_set(const MVert *mverts, LinkNode *loops = lnors_spacearr.lspacearr[i]->loops; if (lnors_spacearr.lspacearr[i]->flags & MLNOR_SPACE_IS_SINGLE) { BLI_assert(POINTER_AS_INT(loops) == i); - const int nidx = use_vertices ? (int)mloops[i].v : i; + const int nidx = use_vertices ? int(mloops[i].v) : i; float *nor = r_custom_loopnors[nidx]; BKE_lnor_space_custom_normal_to_data(lnors_spacearr.lspacearr[i], nor, r_clnors_data[i]); @@ -1966,7 +1966,7 @@ static void mesh_normals_loop_custom_set(const MVert *mverts, zero_v3(avg_nor); while (loops) { const int lidx = POINTER_AS_INT(loops->link); - const int nidx = use_vertices ? (int)mloops[lidx].v : lidx; + const int nidx = use_vertices ? int(mloops[lidx].v) : lidx; float *nor = r_custom_loopnors[nidx]; avg_nor_count++; @@ -1977,7 +1977,7 @@ static void mesh_normals_loop_custom_set(const MVert *mverts, done_loops[lidx].reset(); } - mul_v3_fl(avg_nor, 1.0f / (float)avg_nor_count); + mul_v3_fl(avg_nor, 1.0f / float(avg_nor_count)); BKE_lnor_space_custom_normal_to_data(lnors_spacearr.lspacearr[i], avg_nor, clnor_data_tmp); while ((clnor_data = (short *)BLI_SMALLSTACK_POP(clnors_data))) { @@ -2113,7 +2113,7 @@ void BKE_mesh_normals_loop_to_vertex(const int numVerts, } for (i = 0; i < numVerts; i++) { - mul_v3_fl(r_vert_clnors[i], 1.0f / (float)vert_loops_count[i]); + mul_v3_fl(r_vert_clnors[i], 1.0f / float(vert_loops_count[i])); } MEM_freeN(vert_loops_count); diff --git a/source/blender/blenkernel/intern/mesh_remesh_voxel.cc b/source/blender/blenkernel/intern/mesh_remesh_voxel.cc index 3c492e2e167..62354c83df1 100644 --- a/source/blender/blenkernel/intern/mesh_remesh_voxel.cc +++ b/source/blender/blenkernel/intern/mesh_remesh_voxel.cc @@ -407,8 +407,8 @@ void BKE_remesh_reproject_vertex_paint(Mesh *target, const Mesh *source) bvhtree.tree, target_verts[i].co, &nearest, bvhtree.nearest_callback, &bvhtree); if (nearest.index != -1) { - memcpy(POINTER_OFFSET(target_data, (size_t)i * data_size), - POINTER_OFFSET(source_data, (size_t)nearest.index * data_size), + memcpy(POINTER_OFFSET(target_data, size_t(i) * data_size), + POINTER_OFFSET(source_data, size_t(nearest.index) * data_size), data_size); } } @@ -469,11 +469,11 @@ void BKE_remesh_reproject_vertex_paint(Mesh *target, const Mesh *source) source_loops->count, target_loops->indices[0]); - void *elem = POINTER_OFFSET(target_data, (size_t)target_loops->indices[0] * data_size); + void *elem = POINTER_OFFSET(target_data, size_t(target_loops->indices[0]) * data_size); /* Copy to rest of target loops. */ for (int j = 1; j < target_loops->count; j++) { - memcpy(POINTER_OFFSET(target_data, (size_t)target_loops->indices[j] * data_size), + memcpy(POINTER_OFFSET(target_data, size_t(target_loops->indices[j]) * data_size), elem, data_size); } @@ -586,7 +586,7 @@ struct Mesh *BKE_mesh_remesh_voxel_fix_poles(const Mesh *mesh) BMVert *vert = BM_edge_other_vert(ed, v); add_v3_v3(co, vert->co); } - mul_v3_fl(co, 1.0f / (float)BM_vert_edge_count(v)); + mul_v3_fl(co, 1.0f / float(BM_vert_edge_count(v))); mid_v3_v3v3(v->co, v->co, co); } } diff --git a/source/blender/blenkernel/intern/mesh_tangent.cc b/source/blender/blenkernel/intern/mesh_tangent.cc index 8f9af5e9258..7c12e15ca7b 100644 --- a/source/blender/blenkernel/intern/mesh_tangent.cc +++ b/source/blender/blenkernel/intern/mesh_tangent.cc @@ -36,34 +36,34 @@ struct BKEMeshToTangent { uint GetNumFaces() { - return (uint)num_polys; + return uint(num_polys); } uint GetNumVerticesOfFace(const uint face_num) { - return (uint)mpolys[face_num].totloop; + return uint(mpolys[face_num].totloop); } mikk::float3 GetPosition(const uint face_num, const uint vert_num) { - const uint loop_idx = (uint)mpolys[face_num].loopstart + vert_num; + const uint loop_idx = uint(mpolys[face_num].loopstart) + vert_num; return mikk::float3(mverts[mloops[loop_idx].v].co); } mikk::float3 GetTexCoord(const uint face_num, const uint vert_num) { - const float *uv = luvs[(uint)mpolys[face_num].loopstart + vert_num].uv; + const float *uv = luvs[uint(mpolys[face_num].loopstart) + vert_num].uv; return mikk::float3(uv[0], uv[1], 1.0f); } mikk::float3 GetNormal(const uint face_num, const uint vert_num) { - return mikk::float3(lnors[(uint)mpolys[face_num].loopstart + vert_num]); + return mikk::float3(lnors[uint(mpolys[face_num].loopstart) + vert_num]); } void SetTangentSpace(const uint face_num, const uint vert_num, mikk::float3 T, bool orientation) { - float *p_res = tangents[(uint)mpolys[face_num].loopstart + vert_num]; + float *p_res = tangents[uint(mpolys[face_num].loopstart) + vert_num]; copy_v4_fl4(p_res, T.x, T.y, T.z, orientation ? 1.0f : -1.0f); } @@ -166,9 +166,9 @@ struct SGLSLMeshToTangent { uint GetNumFaces() { #ifdef USE_LOOPTRI_DETECT_QUADS - return (uint)num_face_as_quad_map; + return uint(num_face_as_quad_map); #else - return (uint)numTessFaces; + return uint(numTessFaces); #endif } @@ -196,7 +196,7 @@ struct SGLSLMeshToTangent { lt = &looptri[face_as_quad_map[face_num]]; const MPoly *mp = &mpoly[lt->poly]; if (mp->totloop == 4) { - return ((uint)mp->loopstart + vert_num); + return (uint(mp->loopstart) + vert_num); } /* fall through to regular triangle */ } @@ -382,7 +382,7 @@ void BKE_mesh_calc_loop_tangent_step_0(const CustomData *loopData, add = true; } if (add) { - *rtangent_mask |= (short)(1 << n); + *rtangent_mask |= short(1 << n); } } @@ -437,21 +437,21 @@ void BKE_mesh_calc_loop_tangent_ex(const MVert *mvert, for (int i = 0; i < tangent_names_len; i++) { if (tangent_names[i][0]) { BKE_mesh_add_loop_tangent_named_layer_for_uv( - loopdata, loopdata_out, (int)loopdata_out_len, tangent_names[i]); + loopdata, loopdata_out, int(loopdata_out_len), tangent_names[i]); } } if ((tangent_mask & DM_TANGENT_MASK_ORCO) && CustomData_get_named_layer_index(loopdata, CD_TANGENT, "") == -1) { CustomData_add_layer_named( - loopdata_out, CD_TANGENT, CD_SET_DEFAULT, nullptr, (int)loopdata_out_len, ""); + loopdata_out, CD_TANGENT, CD_SET_DEFAULT, nullptr, int(loopdata_out_len), ""); } if (calc_act && act_uv_name[0]) { BKE_mesh_add_loop_tangent_named_layer_for_uv( - loopdata, loopdata_out, (int)loopdata_out_len, act_uv_name); + loopdata, loopdata_out, int(loopdata_out_len), act_uv_name); } if (calc_ren && ren_uv_name[0]) { BKE_mesh_add_loop_tangent_named_layer_for_uv( - loopdata, loopdata_out, (int)loopdata_out_len, ren_uv_name); + loopdata, loopdata_out, int(loopdata_out_len), ren_uv_name); } #ifdef USE_LOOPTRI_DETECT_QUADS @@ -465,7 +465,7 @@ void BKE_mesh_calc_loop_tangent_ex(const MVert *mvert, /* map fake face index to looptri */ face_as_quad_map = static_cast(MEM_mallocN(sizeof(int) * looptri_len, __func__)); int k, j; - for (k = 0, j = 0; j < (int)looptri_len; k++, j++) { + for (k = 0, j = 0; j < int(looptri_len); k++, j++) { face_as_quad_map[k] = j; /* step over all quads */ if (mpoly[looptri[j].poly].totloop == 4) { @@ -475,7 +475,7 @@ void BKE_mesh_calc_loop_tangent_ex(const MVert *mvert, num_face_as_quad_map = k; } else { - num_face_as_quad_map = (int)looptri_len; + num_face_as_quad_map = int(looptri_len); } #endif @@ -491,7 +491,7 @@ void BKE_mesh_calc_loop_tangent_ex(const MVert *mvert, int index = CustomData_get_layer_index_n(loopdata_out, CD_TANGENT, n); BLI_assert(n < MAX_MTFACE); SGLSLMeshToTangent *mesh2tangent = &data_array[n]; - mesh2tangent->numTessFaces = (int)looptri_len; + mesh2tangent->numTessFaces = int(looptri_len); #ifdef USE_LOOPTRI_DETECT_QUADS mesh2tangent->face_as_quad_map = face_as_quad_map; mesh2tangent->num_face_as_quad_map = num_face_as_quad_map; @@ -525,7 +525,7 @@ void BKE_mesh_calc_loop_tangent_ex(const MVert *mvert, int uv_start = CustomData_get_layer_index(loopdata, CD_MLOOPUV); BLI_assert(uv_ind != -1 && uv_start != -1); BLI_assert(uv_ind - uv_start < MAX_MTFACE); - tangent_mask_curr |= (short)(1 << (uv_ind - uv_start)); + tangent_mask_curr |= short(1 << (uv_ind - uv_start)); } mesh2tangent->tangent = static_cast(loopdata_out->layers[index].data); @@ -583,10 +583,10 @@ void BKE_mesh_calc_loop_tangents(Mesh *me_eval, BKE_mesh_calc_loop_tangent_ex( BKE_mesh_verts(me_eval), BKE_mesh_polys(me_eval), - (uint)me_eval->totpoly, + uint(me_eval->totpoly), BKE_mesh_loops(me_eval), me_eval->runtime.looptris.array, - (uint)me_eval->runtime.looptris.len, + uint(me_eval->runtime.looptris.len), &me_eval->ldata, calc_active_tangent, tangent_names, @@ -598,7 +598,7 @@ void BKE_mesh_calc_loop_tangents(Mesh *me_eval, static_cast(CustomData_get_layer(&me_eval->vdata, CD_ORCO)), /* result */ &me_eval->ldata, - (uint)me_eval->totloop, + uint(me_eval->totloop), &tangent_mask); } diff --git a/source/blender/blenkernel/intern/mesh_tessellate.cc b/source/blender/blenkernel/intern/mesh_tessellate.cc index de4c60b28db..88f78197566 100644 --- a/source/blender/blenkernel/intern/mesh_tessellate.cc +++ b/source/blender/blenkernel/intern/mesh_tessellate.cc @@ -49,8 +49,8 @@ BLI_INLINE void mesh_calc_tessellation_for_face_impl(const MLoop *mloop, const bool face_normal, const float normal_precalc[3]) { - const uint mp_loopstart = (uint)mpoly[poly_index].loopstart; - const uint mp_totloop = (uint)mpoly[poly_index].totloop; + const uint mp_loopstart = uint(mpoly[poly_index].loopstart); + const uint mp_totloop = uint(mpoly[poly_index].totloop); #define ML_TO_MLT(i1, i2, i3) \ { \ @@ -125,9 +125,9 @@ BLI_INLINE void mesh_calc_tessellation_for_face_impl(const MLoop *mloop, } uint(*tris)[3] = static_cast( - BLI_memarena_alloc(pf_arena, sizeof(*tris) * (size_t)totfilltri)); + BLI_memarena_alloc(pf_arena, sizeof(*tris) * size_t(totfilltri))); float(*projverts)[2] = static_cast( - BLI_memarena_alloc(pf_arena, sizeof(*projverts) * (size_t)mp_totloop)); + BLI_memarena_alloc(pf_arena, sizeof(*projverts) * size_t(mp_totloop))); ml = mloop + mp_loopstart; for (uint j = 0; j < mp_totloop; j++, ml++) { @@ -186,7 +186,7 @@ static void mesh_recalc_looptri__single_threaded(const MLoop *mloop, uint tri_index = 0; if (poly_normals != nullptr) { - for (uint poly_index = 0; poly_index < (uint)totpoly; poly_index++, mp++) { + for (uint poly_index = 0; poly_index < uint(totpoly); poly_index++, mp++) { mesh_calc_tessellation_for_face_with_normal(mloop, mpoly, mvert, @@ -194,14 +194,14 @@ static void mesh_recalc_looptri__single_threaded(const MLoop *mloop, &mlooptri[tri_index], &pf_arena, poly_normals[poly_index]); - tri_index += (uint)(mp->totloop - 2); + tri_index += uint(mp->totloop - 2); } } else { - for (uint poly_index = 0; poly_index < (uint)totpoly; poly_index++, mp++) { + for (uint poly_index = 0; poly_index < uint(totpoly); poly_index++, mp++) { mesh_calc_tessellation_for_face( mloop, mpoly, mvert, poly_index, &mlooptri[tri_index], &pf_arena); - tri_index += (uint)(mp->totloop - 2); + tri_index += uint(mp->totloop - 2); } } @@ -209,7 +209,7 @@ static void mesh_recalc_looptri__single_threaded(const MLoop *mloop, BLI_memarena_free(pf_arena); pf_arena = nullptr; } - BLI_assert(tri_index == (uint)poly_to_tri_count(totpoly, totloop)); + BLI_assert(tri_index == uint(poly_to_tri_count(totpoly, totloop))); UNUSED_VARS_NDEBUG(totloop); } @@ -239,7 +239,7 @@ static void mesh_calc_tessellation_for_face_fn(void *__restrict userdata, mesh_calc_tessellation_for_face_impl(data->mloop, data->mpoly, data->mvert, - (uint)index, + uint(index), &data->mlooptri[tri_index], &tls_data->pf_arena, false, @@ -256,7 +256,7 @@ static void mesh_calc_tessellation_for_face_with_normal_fn(void *__restrict user mesh_calc_tessellation_for_face_impl(data->mloop, data->mpoly, data->mvert, - (uint)index, + uint(index), &data->mlooptri[tri_index], &tls_data->pf_arena, true, diff --git a/source/blender/blenkernel/intern/mesh_validate.cc b/source/blender/blenkernel/intern/mesh_validate.cc index 47de7245ccc..95f885c45dd 100644 --- a/source/blender/blenkernel/intern/mesh_validate.cc +++ b/source/blender/blenkernel/intern/mesh_validate.cc @@ -987,7 +987,7 @@ static bool mesh_validate_customdata(CustomData *data, } } - PRINT_MSG("%s: Finished (is_valid=%d)\n\n", __func__, (int)!has_fixes); + PRINT_MSG("%s: Finished (is_valid=%d)\n\n", __func__, int(!has_fixes)); *r_change = has_fixes; diff --git a/source/blender/blenkernel/intern/node.cc b/source/blender/blenkernel/intern/node.cc index 081f30c4329..bc4fb3191e3 100644 --- a/source/blender/blenkernel/intern/node.cc +++ b/source/blender/blenkernel/intern/node.cc @@ -374,7 +374,7 @@ static void node_foreach_cache(ID *id, if (nodetree->type == NTREE_COMPOSIT) { LISTBASE_FOREACH (bNode *, node, &nodetree->nodes) { if (node->type == CMP_NODE_MOVIEDISTORTION) { - key.offset_in_ID = (size_t)BLI_ghashutil_strhash_p(node->name); + key.offset_in_ID = size_t(BLI_ghashutil_strhash_p(node->name)); function_callback(id, &key, (void **)&node->storage, 0, user_data); } } diff --git a/source/blender/blenkernel/intern/node_tree_update.cc b/source/blender/blenkernel/intern/node_tree_update.cc index f9bab0959c9..44ca2752782 100644 --- a/source/blender/blenkernel/intern/node_tree_update.cc +++ b/source/blender/blenkernel/intern/node_tree_update.cc @@ -1432,7 +1432,7 @@ class NodeTreeMainUpdater { } /* When the hashes for the linked sockets are ready, combine them into a hash for the input * socket. */ - const uint64_t socket_ptr = (uintptr_t)&socket; + const uint64_t socket_ptr = uintptr_t(&socket); uint32_t socket_hash = noise::hash(socket_ptr, socket_ptr >> 32); for (const bNodeSocket *origin_socket : socket.logically_linked_sockets()) { const uint32_t origin_socket_hash = *hash_by_socket_id[origin_socket->index_in_tree()]; @@ -1457,7 +1457,7 @@ class NodeTreeMainUpdater { } /* When all input socket hashes have been computed, combine them into a hash for the output * socket. */ - const uint64_t socket_ptr = (uintptr_t)&socket; + const uint64_t socket_ptr = uintptr_t(&socket); uint32_t socket_hash = noise::hash(socket_ptr, socket_ptr >> 32); for (const bNodeSocket *input_socket : node.input_sockets()) { if (input_socket->is_available()) { diff --git a/source/blender/blenkernel/intern/object_dupli.cc b/source/blender/blenkernel/intern/object_dupli.cc index e7410b06deb..4d9b4baaffc 100644 --- a/source/blender/blenkernel/intern/object_dupli.cc +++ b/source/blender/blenkernel/intern/object_dupli.cc @@ -211,7 +211,7 @@ static DupliObject *make_dupli( if (dob->persistent_id[0] != INT_MAX) { for (i = 0; i < MAX_DUPLI_RECUR; i++) { - dob->random_id = BLI_hash_int_2d(dob->random_id, (uint)dob->persistent_id[i]); + dob->random_id = BLI_hash_int_2d(dob->random_id, uint(dob->persistent_id[i])); } } else { @@ -727,7 +727,7 @@ static void make_duplis_font(const DupliContext *ctx) /* XXX That G.main is *really* ugly, but not sure what to do here. * Definitively don't think it would be safe to put back `Main *bmain` pointer * in #DupliContext as done in 2.7x? */ - ob = find_family_object(G.main, cu->family, family_len, (uint)text[a], family_gh); + ob = find_family_object(G.main, cu->family, family_len, uint(text[a]), family_gh); if (is_eval_curve) { /* Workaround for the above hack. */ @@ -953,7 +953,7 @@ static void get_dupliface_transform_from_coords(Span coords, for (const float3 &coord : coords) { location += coord; } - location *= 1.0f / (float)coords.size(); + location *= 1.0f / float(coords.size()); /* Rotation. */ float quat[4]; @@ -964,7 +964,7 @@ static void get_dupliface_transform_from_coords(Span coords, /* Scale. */ float scale; if (use_scale) { - const float area = area_poly_v3((const float(*)[3])coords.data(), (uint)coords.size()); + const float area = area_poly_v3((const float(*)[3])coords.data(), uint(coords.size())); scale = sqrtf(area) * scale_fac; } else { @@ -1094,7 +1094,7 @@ static void make_child_duplis_faces_from_mesh(const DupliContext *ctx, DupliObject *dob = face_dupli_from_mesh( fdd->params.ctx, inst_ob, child_imat, a, use_scale, scale_fac, mp, loopstart, mvert); - const float w = 1.0f / (float)mp->totloop; + const float w = 1.0f / float(mp->totloop); if (orco) { for (int j = 0; j < mp->totloop; j++) { madd_v3_v3fl(dob->orco, orco[loopstart[j].v], w); @@ -1134,7 +1134,7 @@ static void make_child_duplis_faces_from_editmesh(const DupliContext *ctx, fdd->params.ctx, inst_ob, child_imat, a, use_scale, scale_fac, f, vert_coords); if (fdd->has_orco) { - const float w = 1.0f / (float)f->len; + const float w = 1.0f / float(f->len); BMLoop *l_first, *l_iter; l_iter = l_first = BM_FACE_FIRST_LOOP(f); do { @@ -1294,7 +1294,7 @@ static void make_duplis_particle_system(const DupliContext *ctx, ParticleSystem totpart = psys->totcached; } - RNG *rng = BLI_rng_new_srandom(31415926u + (uint)psys->seed); + RNG *rng = BLI_rng_new_srandom(31415926u + uint(psys->seed)); psys->lattice_deform_data = psys_create_lattice_deform_data(&sim); diff --git a/source/blender/blenkernel/intern/paint.cc b/source/blender/blenkernel/intern/paint.cc index 171a7b41373..a735250fd2a 100644 --- a/source/blender/blenkernel/intern/paint.cc +++ b/source/blender/blenkernel/intern/paint.cc @@ -2031,7 +2031,7 @@ int BKE_sculpt_mask_layers_ensure(Object *ob, MultiresModifierData *mmd) const MLoop *l = &loops[p->loopstart + j]; avg += paint_mask[l->v]; } - avg /= (float)p->totloop; + avg /= float(p->totloop); /* fill in multires mask corner */ for (j = 0; j < p->totloop; j++) { diff --git a/source/blender/blenkernel/intern/pbvh.cc b/source/blender/blenkernel/intern/pbvh.cc index 215d04fdc4d..b2f32a38f23 100644 --- a/source/blender/blenkernel/intern/pbvh.cc +++ b/source/blender/blenkernel/intern/pbvh.cc @@ -112,7 +112,7 @@ static void pbvh_vertex_color_get(const PBVH &pbvh, PBVHVertRef vertex, float r_ } if (count) { - mul_v4_fl(r_color, 1.0f / (float)count); + mul_v4_fl(r_color, 1.0f / float(count)); } } else { diff --git a/source/blender/blenkernel/intern/scene.cc b/source/blender/blenkernel/intern/scene.cc index fc36e3d00e7..bc2235f9205 100644 --- a/source/blender/blenkernel/intern/scene.cc +++ b/source/blender/blenkernel/intern/scene.cc @@ -137,7 +137,7 @@ static void scene_init_data(ID *id) scene->toolsettings = DNA_struct_default_alloc(ToolSettings); - scene->toolsettings->autokey_mode = (uchar)U.autokey_mode; + scene->toolsettings->autokey_mode = uchar(U.autokey_mode); /* Grease pencil multi-frame falloff curve. */ scene->toolsettings->gp_sculpt.cur_falloff = BKE_curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f); @@ -156,9 +156,9 @@ static void scene_init_data(ID *id) scene->unit.system = USER_UNIT_METRIC; scene->unit.scale_length = 1.0f; - scene->unit.length_unit = (uchar)BKE_unit_base_of_type_get(USER_UNIT_METRIC, B_UNIT_LENGTH); - scene->unit.mass_unit = (uchar)BKE_unit_base_of_type_get(USER_UNIT_METRIC, B_UNIT_MASS); - scene->unit.time_unit = (uchar)BKE_unit_base_of_type_get(USER_UNIT_METRIC, B_UNIT_TIME); + scene->unit.length_unit = uchar(BKE_unit_base_of_type_get(USER_UNIT_METRIC, B_UNIT_LENGTH)); + scene->unit.mass_unit = uchar(BKE_unit_base_of_type_get(USER_UNIT_METRIC, B_UNIT_MASS)); + scene->unit.time_unit = uchar(BKE_unit_base_of_type_get(USER_UNIT_METRIC, B_UNIT_TIME)); scene->unit.temperature_unit = (uchar)BKE_unit_base_of_type_get(USER_UNIT_METRIC, B_UNIT_TEMPERATURE); @@ -880,7 +880,7 @@ static bool seq_foreach_path_callback(Sequence *seq, void *user_data) } else if ((seq->type == SEQ_TYPE_IMAGE) && se) { /* NOTE: An option not to loop over all strips could be useful? */ - uint len = (uint)MEM_allocN_len(se) / (uint)sizeof(*se); + uint len = uint(MEM_allocN_len(se)) / uint(sizeof(*se)); uint i; if (bpath_data->flag & BKE_BPATH_FOREACH_PATH_SKIP_MULTIFILE) { @@ -1005,10 +1005,10 @@ static void scene_blend_write(BlendWriter *writer, ID *id, const void *id_addres if (sce->r.avicodecdata) { BLO_write_struct(writer, AviCodecData, sce->r.avicodecdata); if (sce->r.avicodecdata->lpFormat) { - BLO_write_raw(writer, (size_t)sce->r.avicodecdata->cbFormat, sce->r.avicodecdata->lpFormat); + BLO_write_raw(writer, size_t(sce->r.avicodecdata->cbFormat), sce->r.avicodecdata->lpFormat); } if (sce->r.avicodecdata->lpParms) { - BLO_write_raw(writer, (size_t)sce->r.avicodecdata->cbParms, sce->r.avicodecdata->lpParms); + BLO_write_raw(writer, size_t(sce->r.avicodecdata->cbParms), sce->r.avicodecdata->lpParms); } } @@ -1207,8 +1207,8 @@ static void scene_blend_read_data(BlendDataReader *reader, ID *id) intptr_t seqbase_offset; intptr_t channels_offset; - seqbase_offset = ((intptr_t) & (temp.seqbase)) - ((intptr_t)&temp); - channels_offset = ((intptr_t) & (temp.channels)) - ((intptr_t)&temp); + seqbase_offset = intptr_t(&(temp).seqbase) - intptr_t(&temp); + channels_offset = intptr_t(&(temp).channels) - intptr_t(&temp); /* seqbase root pointer */ if (ed->seqbasep == old_seqbasep) { @@ -1326,7 +1326,7 @@ static void scene_blend_read_data(BlendDataReader *reader, ID *id) /* make sure simulation starts from the beginning after loading file */ if (rbw->pointcache) { - rbw->ltime = (float)rbw->pointcache->startframe; + rbw->ltime = float(rbw->pointcache->startframe); } } else { @@ -1340,7 +1340,7 @@ static void scene_blend_read_data(BlendDataReader *reader, ID *id) /* make sure simulation starts from the beginning after loading file */ if (rbw->shared->pointcache) { - rbw->ltime = (float)rbw->shared->pointcache->startframe; + rbw->ltime = float(rbw->shared->pointcache->startframe); } } rbw->objects = nullptr; @@ -2426,7 +2426,7 @@ void BKE_scene_frame_set(Scene *scene, float frame) { double intpart; scene->r.subframe = modf((double)frame, &intpart); - scene->r.cfra = (int)intpart; + scene->r.cfra = int(intpart); } /* -------------------------------------------------------------------- */ diff --git a/source/blender/blenkernel/intern/subdiv_mesh.cc b/source/blender/blenkernel/intern/subdiv_mesh.cc index d716a7228c0..651e58d9ca4 100644 --- a/source/blender/blenkernel/intern/subdiv_mesh.cc +++ b/source/blender/blenkernel/intern/subdiv_mesh.cc @@ -222,7 +222,7 @@ static void vertex_interpolation_init(const SubdivMeshContext *ctx, vertex_interpolation->vertex_data_storage_allocated = true; /* Interpolate center of poly right away, it stays unchanged for all * ptex faces. */ - const float weight = 1.0f / (float)coarse_poly->totloop; + const float weight = 1.0f / float(coarse_poly->totloop); blender::Array weights(coarse_poly->totloop); blender::Array indices(coarse_poly->totloop); for (int i = 0; i < coarse_poly->totloop; i++) { @@ -355,7 +355,7 @@ static void loop_interpolation_init(const SubdivMeshContext *ctx, loop_interpolation->loop_data_storage_allocated = true; /* Interpolate center of poly right away, it stays unchanged for all * ptex faces. */ - const float weight = 1.0f / (float)coarse_poly->totloop; + const float weight = 1.0f / float(coarse_poly->totloop); blender::Array weights(coarse_poly->totloop); blender::Array indices(coarse_poly->totloop); for (int i = 0; i < coarse_poly->totloop; i++) { diff --git a/source/blender/blenkernel/intern/type_conversions.cc b/source/blender/blenkernel/intern/type_conversions.cc index 852fe38c92f..ffc5442af2d 100644 --- a/source/blender/blenkernel/intern/type_conversions.cc +++ b/source/blender/blenkernel/intern/type_conversions.cc @@ -49,7 +49,7 @@ static float3 float_to_float3(const float &a) } static int32_t float_to_int(const float &a) { - return (int32_t)a; + return int32_t(a); } static bool float_to_bool(const float &a) { @@ -79,7 +79,7 @@ static float float2_to_float(const float2 &a) } static int float2_to_int(const float2 &a) { - return (int32_t)((a.x + a.y) / 2.0f); + return int32_t((a.x + a.y) / 2.0f); } static bool float2_to_bool(const float2 &a) { @@ -112,7 +112,7 @@ static float float3_to_float(const float3 &a) } static int float3_to_int(const float3 &a) { - return (int)((a.x + a.y + a.z) / 3.0f); + return int((a.x + a.y + a.z) / 3.0f); } static float2 float3_to_float2(const float3 &a) { @@ -138,19 +138,19 @@ static int8_t int_to_int8(const int32_t &a) } static float int_to_float(const int32_t &a) { - return (float)a; + return float(a); } static float2 int_to_float2(const int32_t &a) { - return float2((float)a); + return float2(float(a)); } static float3 int_to_float3(const int32_t &a) { - return float3((float)a); + return float3(float(a)); } static ColorGeometry4f int_to_color(const int32_t &a) { - return ColorGeometry4f((float)a, (float)a, (float)a, 1.0f); + return ColorGeometry4f(float(a), float(a), float(a), 1.0f); } static ColorGeometry4b int_to_byte_color(const int32_t &a) { @@ -167,19 +167,19 @@ static int int8_to_int(const int8_t &a) } static float int8_to_float(const int8_t &a) { - return (float)a; + return float(a); } static float2 int8_to_float2(const int8_t &a) { - return float2((float)a); + return float2(float(a)); } static float3 int8_to_float3(const int8_t &a) { - return float3((float)a); + return float3(float(a)); } static ColorGeometry4f int8_to_color(const int8_t &a) { - return ColorGeometry4f((float)a, (float)a, (float)a, 1.0f); + return ColorGeometry4f(float(a), float(a), float(a), 1.0f); } static ColorGeometry4b int8_to_byte_color(const int8_t &a) { @@ -188,7 +188,7 @@ static ColorGeometry4b int8_to_byte_color(const int8_t &a) static float bool_to_float(const bool &a) { - return (bool)a; + return bool(a); } static int8_t bool_to_int8(const bool &a) { @@ -196,7 +196,7 @@ static int8_t bool_to_int8(const bool &a) } static int32_t bool_to_int(const bool &a) { - return (int32_t)a; + return int32_t(a); } static float2 bool_to_float2(const bool &a) { @@ -225,7 +225,7 @@ static float color_to_float(const ColorGeometry4f &a) } static int32_t color_to_int(const ColorGeometry4f &a) { - return (int)rgb_to_grayscale(a); + return int(rgb_to_grayscale(a)); } static int8_t color_to_int8(const ColorGeometry4f &a) { diff --git a/source/blender/blenkernel/intern/volume.cc b/source/blender/blenkernel/intern/volume.cc index 9c2e88f730a..6418523a614 100644 --- a/source/blender/blenkernel/intern/volume.cc +++ b/source/blender/blenkernel/intern/volume.cc @@ -1636,8 +1636,8 @@ bool BKE_volume_grid_bounds(openvdb::GridBase::ConstPtr grid, float3 &r_min, flo openvdb::BBoxd bbox = grid->transform().indexToWorld(coordbbox); - r_min = float3((float)bbox.min().x(), (float)bbox.min().y(), (float)bbox.min().z()); - r_max = float3((float)bbox.max().x(), (float)bbox.max().y(), (float)bbox.max().z()); + r_min = float3(float(bbox.min().x()), float(bbox.min().y()), float(bbox.min().z())); + r_max = float3(float(bbox.max().x()), float(bbox.max().y()), float(bbox.max().z())); return true; } diff --git a/source/blender/blenlib/intern/dot_export.cc b/source/blender/blenlib/intern/dot_export.cc index 796fd6a934a..d577de9bc34 100644 --- a/source/blender/blenlib/intern/dot_export.cc +++ b/source/blender/blenlib/intern/dot_export.cc @@ -93,7 +93,7 @@ void Graph::set_random_cluster_bgcolors() void Cluster::set_random_cluster_bgcolors() { - float hue = rand() / (float)RAND_MAX; + float hue = rand() / float(RAND_MAX); float staturation = 0.3f; float value = 0.8f; this->attributes.set("bgcolor", color_attr_from_hsv(hue, staturation, value)); @@ -227,7 +227,7 @@ void Attributes::export__as_bracket_list(std::stringstream &ss) const void Node::export__as_id(std::stringstream &ss) const { - ss << '"' << (uintptr_t)this << '"'; + ss << '"' << uintptr_t(this) << '"'; } void Node::export__as_declaration(std::stringstream &ss) const diff --git a/source/blender/blenlib/intern/math_boolean.cc b/source/blender/blenlib/intern/math_boolean.cc index 132d5dfda65..871ea815e90 100644 --- a/source/blender/blenlib/intern/math_boolean.cc +++ b/source/blender/blenlib/intern/math_boolean.cc @@ -193,7 +193,7 @@ static RobustInitCaller init_caller; y = b - bvirt #define Fast_Two_Sum(a, b, x, y) \ - x = (double)(a + b); \ + x = double(a + b); \ Fast_Two_Sum_Tail(a, b, x, y) #define Fast_Two_Diff_Tail(a, b, x, y) \ @@ -205,30 +205,30 @@ static RobustInitCaller init_caller; Fast_Two_Diff_Tail(a, b, x, y) #define Two_Sum_Tail(a, b, x, y) \ - bvirt = (double)(x - a); \ + bvirt = double(x - a); \ avirt = x - bvirt; \ bround = b - bvirt; \ around = a - avirt; \ y = around + bround #define Two_Sum(a, b, x, y) \ - x = (double)(a + b); \ + x = double(a + b); \ Two_Sum_Tail(a, b, x, y) #define Two_Diff_Tail(a, b, x, y) \ - bvirt = (double)(a - x); \ + bvirt = double(a - x); \ avirt = x + bvirt; \ bround = bvirt - b; \ around = a - avirt; \ y = around + bround #define Two_Diff(a, b, x, y) \ - x = (double)(a - b); \ + x = double(a - b); \ Two_Diff_Tail(a, b, x, y) #define Split(a, ahi, alo) \ - c = (double)(splitter * a); \ - abig = (double)(c - a); \ + c = double(splitter * a); \ + abig = double(c - a); \ ahi = c - abig; \ alo = a - ahi @@ -241,11 +241,11 @@ static RobustInitCaller init_caller; y = (alo * blo) - err3 #define Two_Product(a, b, x, y) \ - x = (double)(a * b); \ + x = double(a * b); \ Two_Product_Tail(a, b, x, y) #define Two_Product_Presplit(a, b, bhi, blo, x, y) \ - x = (double)(a * b); \ + x = double(a * b); \ Split(a, ahi, alo); \ err1 = x - (ahi * bhi); \ err2 = err1 - (alo * bhi); \ @@ -266,7 +266,7 @@ static RobustInitCaller init_caller; y = (alo * alo) - err3 #define Square(a, x, y) \ - x = (double)(a * a); \ + x = double(a * a); \ Square_Tail(a, x, y) #define Two_One_Sum(a1, a0, b, x2, x1, x0) \ @@ -647,10 +647,10 @@ static double orient2dadapt(const double *pa, const double *pb, const double *pc INEXACT double _i, _j; double _0; - acx = (double)(pa[0] - pc[0]); - bcx = (double)(pb[0] - pc[0]); - acy = (double)(pa[1] - pc[1]); - bcy = (double)(pb[1] - pc[1]); + acx = double(pa[0] - pc[0]); + bcx = double(pb[0] - pc[0]); + acy = double(pa[1] - pc[1]); + bcy = double(pb[1] - pc[1]); Two_Product(acx, bcy, detleft, detlefttail); Two_Product(acy, bcx, detright, detrighttail); @@ -834,15 +834,15 @@ static double orient3dadapt( INEXACT double _i, _j, _k; double _0; - adx = (double)(pa[0] - pd[0]); - bdx = (double)(pb[0] - pd[0]); - cdx = (double)(pc[0] - pd[0]); - ady = (double)(pa[1] - pd[1]); - bdy = (double)(pb[1] - pd[1]); - cdy = (double)(pc[1] - pd[1]); - adz = (double)(pa[2] - pd[2]); - bdz = (double)(pb[2] - pd[2]); - cdz = (double)(pc[2] - pd[2]); + adx = double(pa[0] - pd[0]); + bdx = double(pb[0] - pd[0]); + cdx = double(pc[0] - pd[0]); + ady = double(pa[1] - pd[1]); + bdy = double(pb[1] - pd[1]); + cdy = double(pc[1] - pd[1]); + adz = double(pa[2] - pd[2]); + bdz = double(pb[2] - pd[2]); + cdz = double(pc[2] - pd[2]); Two_Product(bdx, cdy, bdxcdy1, bdxcdy0); Two_Product(cdx, bdy, cdxbdy1, cdxbdy0); @@ -1358,12 +1358,12 @@ static double incircleadapt( INEXACT double _i, _j; double _0; - adx = (double)(pa[0] - pd[0]); - bdx = (double)(pb[0] - pd[0]); - cdx = (double)(pc[0] - pd[0]); - ady = (double)(pa[1] - pd[1]); - bdy = (double)(pb[1] - pd[1]); - cdy = (double)(pc[1] - pd[1]); + adx = double(pa[0] - pd[0]); + bdx = double(pb[0] - pd[0]); + cdx = double(pc[0] - pd[0]); + ady = double(pa[1] - pd[1]); + bdy = double(pb[1] - pd[1]); + cdy = double(pc[1] - pd[1]); Two_Product(bdx, cdy, bdxcdy1, bdxcdy0); Two_Product(cdx, bdy, cdxbdy1, cdxbdy0); diff --git a/source/blender/blenlib/intern/noise.cc b/source/blender/blenlib/intern/noise.cc index 19c4b92a315..65a6f102a7b 100644 --- a/source/blender/blenlib/intern/noise.cc +++ b/source/blender/blenlib/intern/noise.cc @@ -379,7 +379,7 @@ BLI_INLINE float noise_grad(uint32_t hash, float x, float y, float z, float w) BLI_INLINE float floor_fraction(float x, int &i) { - i = (int)x - ((x < 0) ? 1 : 0); + i = int(x) - ((x < 0) ? 1 : 0); return x - i; } @@ -729,7 +729,7 @@ float musgrave_fBm(const float co, const float pwHL = std::pow(lacunarity, -H); const float octaves = CLAMPIS(octaves_unclamped, 0.0f, 15.0f); - for (int i = 0; i < (int)octaves; i++) { + for (int i = 0; i < int(octaves); i++) { value += perlin_signed(p) * pwr; pwr *= pwHL; p *= lacunarity; @@ -754,7 +754,7 @@ float musgrave_multi_fractal(const float co, const float pwHL = std::pow(lacunarity, -H); const float octaves = CLAMPIS(octaves_unclamped, 0.0f, 15.0f); - for (int i = 0; i < (int)octaves; i++) { + for (int i = 0; i < int(octaves); i++) { value *= (pwr * perlin_signed(p) + 1.0f); pwr *= pwHL; p *= lacunarity; @@ -783,7 +783,7 @@ float musgrave_hetero_terrain(const float co, float value = offset + perlin_signed(p); p *= lacunarity; - for (int i = 1; i < (int)octaves; i++) { + for (int i = 1; i < int(octaves); i++) { float increment = (perlin_signed(p) + offset) * pwr * value; value += increment; pwr *= pwHL; @@ -815,7 +815,7 @@ float musgrave_hybrid_multi_fractal(const float co, const float octaves = CLAMPIS(octaves_unclamped, 0.0f, 15.0f); - for (int i = 0; (weight > 0.001f) && (i < (int)octaves); i++) { + for (int i = 0; (weight > 0.001f) && (i < int(octaves)); i++) { if (weight > 1.0f) { weight = 1.0f; } @@ -857,7 +857,7 @@ float musgrave_ridged_multi_fractal(const float co, const float octaves = CLAMPIS(octaves_unclamped, 0.0f, 15.0f); - for (int i = 1; i < (int)octaves; i++) { + for (int i = 1; i < int(octaves); i++) { p *= lacunarity; weight = CLAMPIS(signal * gain, 0.0f, 1.0f); signal = offset - std::abs(perlin_signed(p)); @@ -883,7 +883,7 @@ float musgrave_fBm(const float2 co, const float pwHL = std::pow(lacunarity, -H); const float octaves = CLAMPIS(octaves_unclamped, 0.0f, 15.0f); - for (int i = 0; i < (int)octaves; i++) { + for (int i = 0; i < int(octaves); i++) { value += perlin_signed(p) * pwr; pwr *= pwHL; p *= lacunarity; @@ -908,7 +908,7 @@ float musgrave_multi_fractal(const float2 co, const float pwHL = std::pow(lacunarity, -H); const float octaves = CLAMPIS(octaves_unclamped, 0.0f, 15.0f); - for (int i = 0; i < (int)octaves; i++) { + for (int i = 0; i < int(octaves); i++) { value *= (pwr * perlin_signed(p) + 1.0f); pwr *= pwHL; p *= lacunarity; @@ -938,7 +938,7 @@ float musgrave_hetero_terrain(const float2 co, const float octaves = CLAMPIS(octaves_unclamped, 0.0f, 15.0f); - for (int i = 1; i < (int)octaves; i++) { + for (int i = 1; i < int(octaves); i++) { float increment = (perlin_signed(p) + offset) * pwr * value; value += increment; pwr *= pwHL; @@ -970,7 +970,7 @@ float musgrave_hybrid_multi_fractal(const float2 co, const float octaves = CLAMPIS(octaves_unclamped, 0.0f, 15.0f); - for (int i = 0; (weight > 0.001f) && (i < (int)octaves); i++) { + for (int i = 0; (weight > 0.001f) && (i < int(octaves)); i++) { if (weight > 1.0f) { weight = 1.0f; } @@ -1012,7 +1012,7 @@ float musgrave_ridged_multi_fractal(const float2 co, const float octaves = CLAMPIS(octaves_unclamped, 0.0f, 15.0f); - for (int i = 1; i < (int)octaves; i++) { + for (int i = 1; i < int(octaves); i++) { p *= lacunarity; weight = CLAMPIS(signal * gain, 0.0f, 1.0f); signal = offset - std::abs(perlin_signed(p)); @@ -1039,7 +1039,7 @@ float musgrave_fBm(const float3 co, const float octaves = CLAMPIS(octaves_unclamped, 0.0f, 15.0f); - for (int i = 0; i < (int)octaves; i++) { + for (int i = 0; i < int(octaves); i++) { value += perlin_signed(p) * pwr; pwr *= pwHL; p *= lacunarity; @@ -1065,7 +1065,7 @@ float musgrave_multi_fractal(const float3 co, const float octaves = CLAMPIS(octaves_unclamped, 0.0f, 15.0f); - for (int i = 0; i < (int)octaves; i++) { + for (int i = 0; i < int(octaves); i++) { value *= (pwr * perlin_signed(p) + 1.0f); pwr *= pwHL; p *= lacunarity; @@ -1095,7 +1095,7 @@ float musgrave_hetero_terrain(const float3 co, const float octaves = CLAMPIS(octaves_unclamped, 0.0f, 15.0f); - for (int i = 1; i < (int)octaves; i++) { + for (int i = 1; i < int(octaves); i++) { float increment = (perlin_signed(p) + offset) * pwr * value; value += increment; pwr *= pwHL; @@ -1127,7 +1127,7 @@ float musgrave_hybrid_multi_fractal(const float3 co, const float octaves = CLAMPIS(octaves_unclamped, 0.0f, 15.0f); - for (int i = 0; (weight > 0.001f) && (i < (int)octaves); i++) { + for (int i = 0; (weight > 0.001f) && (i < int(octaves)); i++) { if (weight > 1.0f) { weight = 1.0f; } @@ -1169,7 +1169,7 @@ float musgrave_ridged_multi_fractal(const float3 co, const float octaves = CLAMPIS(octaves_unclamped, 0.0f, 15.0f); - for (int i = 1; i < (int)octaves; i++) { + for (int i = 1; i < int(octaves); i++) { p *= lacunarity; weight = CLAMPIS(signal * gain, 0.0f, 1.0f); signal = offset - std::abs(perlin_signed(p)); @@ -1196,7 +1196,7 @@ float musgrave_fBm(const float4 co, const float octaves = CLAMPIS(octaves_unclamped, 0.0f, 15.0f); - for (int i = 0; i < (int)octaves; i++) { + for (int i = 0; i < int(octaves); i++) { value += perlin_signed(p) * pwr; pwr *= pwHL; p *= lacunarity; @@ -1222,7 +1222,7 @@ float musgrave_multi_fractal(const float4 co, const float octaves = CLAMPIS(octaves_unclamped, 0.0f, 15.0f); - for (int i = 0; i < (int)octaves; i++) { + for (int i = 0; i < int(octaves); i++) { value *= (pwr * perlin_signed(p) + 1.0f); pwr *= pwHL; p *= lacunarity; @@ -1252,7 +1252,7 @@ float musgrave_hetero_terrain(const float4 co, const float octaves = CLAMPIS(octaves_unclamped, 0.0f, 15.0f); - for (int i = 1; i < (int)octaves; i++) { + for (int i = 1; i < int(octaves); i++) { float increment = (perlin_signed(p) + offset) * pwr * value; value += increment; pwr *= pwHL; @@ -1284,7 +1284,7 @@ float musgrave_hybrid_multi_fractal(const float4 co, const float octaves = CLAMPIS(octaves_unclamped, 0.0f, 15.0f); - for (int i = 0; (weight > 0.001f) && (i < (int)octaves); i++) { + for (int i = 0; (weight > 0.001f) && (i < int(octaves)); i++) { if (weight > 1.0f) { weight = 1.0f; } @@ -1326,7 +1326,7 @@ float musgrave_ridged_multi_fractal(const float4 co, const float octaves = CLAMPIS(octaves_unclamped, 0.0f, 15.0f); - for (int i = 1; i < (int)octaves; i++) { + for (int i = 1; i < int(octaves); i++) { p *= lacunarity; weight = CLAMPIS(signal * gain, 0.0f, 1.0f); signal = offset - std::abs(perlin_signed(p)); diff --git a/source/blender/blenlib/intern/rand.cc b/source/blender/blenlib/intern/rand.cc index b5db0d6b473..2e9b15c623e 100644 --- a/source/blender/blenlib/intern/rand.cc +++ b/source/blender/blenlib/intern/rand.cc @@ -161,7 +161,7 @@ void BLI_rng_shuffle_bitmap(struct RNG *rng, BLI_bitmap *bitmap, uint bits_num) void BLI_rng_skip(RNG *rng, int n) { - rng->rng.skip((uint)n); + rng->rng.skip(uint(n)); } /***/ @@ -239,7 +239,7 @@ RNG_THREAD_ARRAY *BLI_rng_threaded_new() "random_array"); for (i = 0; i < BLENDER_MAX_THREADS; i++) { - BLI_rng_srandom(&rngarr->rng_tab[i], (uint)clock()); + BLI_rng_srandom(&rngarr->rng_tab[i], uint(clock())); } return rngarr; @@ -283,7 +283,7 @@ BLI_INLINE double halton_ex(double invprimes, double *offset) void BLI_halton_1d(uint prime, double offset, int n, double *r) { - const double invprime = 1.0 / (double)prime; + const double invprime = 1.0 / double(prime); *r = 0.0; @@ -294,7 +294,7 @@ void BLI_halton_1d(uint prime, double offset, int n, double *r) void BLI_halton_2d(const uint prime[2], double offset[2], int n, double *r) { - const double invprimes[2] = {1.0 / (double)prime[0], 1.0 / (double)prime[1]}; + const double invprimes[2] = {1.0 / double(prime[0]), 1.0 / double(prime[1])}; r[0] = r[1] = 0.0; @@ -308,7 +308,7 @@ void BLI_halton_2d(const uint prime[2], double offset[2], int n, double *r) void BLI_halton_3d(const uint prime[3], double offset[3], int n, double *r) { const double invprimes[3] = { - 1.0 / (double)prime[0], 1.0 / (double)prime[1], 1.0 / (double)prime[2]}; + 1.0 / double(prime[0]), 1.0 / double(prime[1]), 1.0 / double(prime[2])}; r[0] = r[1] = r[2] = 0.0; @@ -321,7 +321,7 @@ void BLI_halton_3d(const uint prime[3], double offset[3], int n, double *r) void BLI_halton_2d_sequence(const uint prime[2], double offset[2], int n, double *r) { - const double invprimes[2] = {1.0 / (double)prime[0], 1.0 / (double)prime[1]}; + const double invprimes[2] = {1.0 / double(prime[0]), 1.0 / double(prime[1])}; for (int s = 0; s < n; s++) { for (int i = 0; i < 2; i++) { @@ -355,7 +355,7 @@ void BLI_hammersley_1d(uint n, double *r) void BLI_hammersley_2d_sequence(uint n, double *r) { for (uint s = 0; s < n; s++) { - r[s * 2 + 0] = (double)(s + 0.5) / (double)n; + r[s * 2 + 0] = double(s + 0.5) / double(n); r[s * 2 + 1] = radical_inverse(s); } } @@ -377,12 +377,12 @@ int RandomNumberGenerator::round_probabilistic(float x) BLI_assert(x >= 0.0f); const float round_up_probability = fractf(x); const bool round_up = round_up_probability > this->get_float(); - return (int)x + (int)round_up; + return int(x) + int(round_up); } float2 RandomNumberGenerator::get_unit_float2() { - float a = (float)(M_PI * 2.0) * this->get_float(); + float a = float(M_PI * 2.0) * this->get_float(); return {cosf(a), sinf(a)}; } @@ -391,7 +391,7 @@ float3 RandomNumberGenerator::get_unit_float3() float z = (2.0f * this->get_float()) - 1.0f; float r = 1.0f - z * z; if (r > 0.0f) { - float a = (float)(M_PI * 2.0) * this->get_float(); + float a = float(M_PI * 2.0) * this->get_float(); r = sqrtf(r); float x = r * cosf(a); float y = r * sinf(a); diff --git a/source/blender/blenlib/intern/string_search.cc b/source/blender/blenlib/intern/string_search.cc index 6eeae307fc1..f87304863c9 100644 --- a/source/blender/blenlib/intern/string_search.cc +++ b/source/blender/blenlib/intern/string_search.cc @@ -345,7 +345,7 @@ void extract_normalized_words(StringRef str, LinearAllocator<> &allocator, Vector &r_words) { - const uint32_t unicode_space = (uint32_t)' '; + const uint32_t unicode_space = uint32_t(' '); const uint32_t unicode_right_triangle = UI_MENU_ARROW_SEP_UNICODE; BLI_assert(unicode_space == BLI_str_utf8_as_unicode(" ")); @@ -418,7 +418,7 @@ void BLI_string_search_add(StringSearch *search, StringRef str_ref{str}; string_search::extract_normalized_words(str_ref, search->allocator, words); search->items.append({search->allocator.construct_array_copy(words.as_span()), - (int)str_ref.size(), + int(str_ref.size()), user_data, weight}); } diff --git a/source/blender/blenlib/intern/threads.cc b/source/blender/blenlib/intern/threads.cc index e7470ed86f8..156f2a7b338 100644 --- a/source/blender/blenlib/intern/threads.cc +++ b/source/blender/blenlib/intern/threads.cc @@ -293,7 +293,7 @@ int BLI_system_thread_count() #ifdef WIN32 SYSTEM_INFO info; GetSystemInfo(&info); - t = (int)info.dwNumberOfProcessors; + t = int(info.dwNumberOfProcessors); #else # ifdef __APPLE__ int mib[2]; @@ -304,7 +304,7 @@ int BLI_system_thread_count() len = sizeof(t); sysctl(mib, 2, &t, &len, nullptr, 0); # else - t = (int)sysconf(_SC_NPROCESSORS_ONLN); + t = int(sysconf(_SC_NPROCESSORS_ONLN)); # endif #endif } diff --git a/source/blender/blenlib/tests/BLI_edgehash_test.cc b/source/blender/blenlib/tests/BLI_edgehash_test.cc index 301fa226016..f6e987c7060 100644 --- a/source/blender/blenlib/tests/BLI_edgehash_test.cc +++ b/source/blender/blenlib/tests/BLI_edgehash_test.cc @@ -308,7 +308,7 @@ TEST(edgehash, StressTest) std::vector edges; for (int i = 0; i < amount; i++) { - edges.push_back({(uint)i, amount + (uint)std::rand() % 12345}); + edges.push_back({uint(i), amount + uint(std::rand()) % 12345}); } EdgeHash *eh = BLI_edgehash_new(__func__); diff --git a/source/blender/blenlib/tests/BLI_generic_array_test.cc b/source/blender/blenlib/tests/BLI_generic_array_test.cc index 52bc7728a6a..25e08f59f94 100644 --- a/source/blender/blenlib/tests/BLI_generic_array_test.cc +++ b/source/blender/blenlib/tests/BLI_generic_array_test.cc @@ -20,7 +20,7 @@ TEST(generic_array, TypeConstructor) TEST(generic_array, MoveConstructor) { - GArray array_a(CPPType::get(), (int64_t)10); + GArray array_a(CPPType::get(), int64_t(10)); GMutableSpan span_a = array_a.as_mutable_span(); MutableSpan typed_span_a = span_a.typed(); typed_span_a.fill(42); @@ -40,7 +40,7 @@ TEST(generic_array, MoveConstructor) TEST(generic_array, CopyConstructor) { - GArray array_a(CPPType::get(), (int64_t)10); + GArray array_a(CPPType::get(), int64_t(10)); GMutableSpan span_a = array_a.as_mutable_span(); MutableSpan typed_span_a = span_a.typed(); typed_span_a.fill(42); @@ -79,7 +79,7 @@ TEST(generic_array, BufferAndSizeConstructor) TEST(generic_array, Reinitialize) { - GArray array(CPPType::get(), (int64_t)5); + GArray array(CPPType::get(), int64_t(5)); EXPECT_FALSE(array.data() == nullptr); GMutableSpan span = array.as_mutable_span(); MutableSpan typed_span = span.typed(); @@ -106,7 +106,7 @@ TEST(generic_array, InContainer) { blender::Array> arrays; for (GArray<> &array : arrays) { - array = GArray(CPPType::get(), (int64_t)5); + array = GArray(CPPType::get(), int64_t(5)); array.as_mutable_span().typed().fill(55); } for (GArray<> &array : arrays) { diff --git a/source/blender/blenlib/tests/BLI_heap_simple_test.cc b/source/blender/blenlib/tests/BLI_heap_simple_test.cc index 818de67740b..96a5e42374e 100644 --- a/source/blender/blenlib/tests/BLI_heap_simple_test.cc +++ b/source/blender/blenlib/tests/BLI_heap_simple_test.cc @@ -18,7 +18,7 @@ static void range_fl(float *array_tar, const int size) float *array_pt = array_tar + (size - 1); int i = size; while (i--) { - *(array_pt--) = (float)i; + *(array_pt--) = float(i); } } @@ -53,7 +53,7 @@ TEST(heap, SimpleRange) const int items_total = SIZE; HeapSimple *heap = BLI_heapsimple_new(); for (int in = 0; in < items_total; in++) { - BLI_heapsimple_insert(heap, (float)in, POINTER_FROM_INT(in)); + BLI_heapsimple_insert(heap, float(in), POINTER_FROM_INT(in)); } for (int out_test = 0; out_test < items_total; out_test++) { EXPECT_EQ(out_test, POINTER_AS_INT(BLI_heapsimple_pop_min(heap))); @@ -67,7 +67,7 @@ TEST(heap, SimpleRangeReverse) const int items_total = SIZE; HeapSimple *heap = BLI_heapsimple_new(); for (int in = 0; in < items_total; in++) { - BLI_heapsimple_insert(heap, (float)-in, POINTER_FROM_INT(-in)); + BLI_heapsimple_insert(heap, float(-in), POINTER_FROM_INT(-in)); } for (int out_test = items_total - 1; out_test >= 0; out_test--) { EXPECT_EQ(-out_test, POINTER_AS_INT(BLI_heapsimple_pop_min(heap))); @@ -97,7 +97,7 @@ static void random_heapsimple_helper(const int items_total, const int random_see range_fl(values, items_total); BLI_array_randomize(values, sizeof(float), items_total, random_seed); for (int i = 0; i < items_total; i++) { - BLI_heapsimple_insert(heap, values[i], POINTER_FROM_INT((int)values[i])); + BLI_heapsimple_insert(heap, values[i], POINTER_FROM_INT(int(values[i]))); } for (int out_test = 0; out_test < items_total; out_test++) { EXPECT_EQ(out_test, POINTER_AS_INT(BLI_heapsimple_pop_min(heap))); diff --git a/source/blender/blenlib/tests/BLI_heap_test.cc b/source/blender/blenlib/tests/BLI_heap_test.cc index 333a1530b6d..f2368ce4abf 100644 --- a/source/blender/blenlib/tests/BLI_heap_test.cc +++ b/source/blender/blenlib/tests/BLI_heap_test.cc @@ -17,7 +17,7 @@ static void range_fl(float *array_tar, const int size) float *array_pt = array_tar + (size - 1); int i = size; while (i--) { - *(array_pt--) = (float)i; + *(array_pt--) = float(i); } } @@ -52,7 +52,7 @@ TEST(heap, Range) const int items_total = SIZE; Heap *heap = BLI_heap_new(); for (int in = 0; in < items_total; in++) { - BLI_heap_insert(heap, (float)in, POINTER_FROM_INT(in)); + BLI_heap_insert(heap, float(in), POINTER_FROM_INT(in)); } for (int out_test = 0; out_test < items_total; out_test++) { EXPECT_EQ(out_test, POINTER_AS_INT(BLI_heap_pop_min(heap))); @@ -66,7 +66,7 @@ TEST(heap, RangeReverse) const int items_total = SIZE; Heap *heap = BLI_heap_new(); for (int in = 0; in < items_total; in++) { - BLI_heap_insert(heap, (float)-in, POINTER_FROM_INT(-in)); + BLI_heap_insert(heap, float(-in), POINTER_FROM_INT(-in)); } for (int out_test = items_total - 1; out_test >= 0; out_test--) { EXPECT_EQ(-out_test, POINTER_AS_INT(BLI_heap_pop_min(heap))); @@ -81,7 +81,7 @@ TEST(heap, RangeRemove) Heap *heap = BLI_heap_new(); HeapNode **nodes = (HeapNode **)MEM_mallocN(sizeof(HeapNode *) * items_total, __func__); for (int in = 0; in < items_total; in++) { - nodes[in] = BLI_heap_insert(heap, (float)in, POINTER_FROM_INT(in)); + nodes[in] = BLI_heap_insert(heap, float(in), POINTER_FROM_INT(in)); } for (int i = 0; i < items_total; i += 2) { BLI_heap_remove(heap, nodes[i]); @@ -116,7 +116,7 @@ static void random_heap_helper(const int items_total, const int random_seed) range_fl(values, items_total); BLI_array_randomize(values, sizeof(float), items_total, random_seed); for (int i = 0; i < items_total; i++) { - BLI_heap_insert(heap, values[i], POINTER_FROM_INT((int)values[i])); + BLI_heap_insert(heap, values[i], POINTER_FROM_INT(int(values[i]))); } for (int out_test = 0; out_test < items_total; out_test++) { EXPECT_EQ(out_test, POINTER_AS_INT(BLI_heap_pop_min(heap))); @@ -145,10 +145,10 @@ TEST(heap, ReInsertSimple) Heap *heap = BLI_heap_new(); HeapNode **nodes = (HeapNode **)MEM_mallocN(sizeof(HeapNode *) * items_total, __func__); for (int in = 0; in < items_total; in++) { - nodes[in] = BLI_heap_insert(heap, (float)in, POINTER_FROM_INT(in)); + nodes[in] = BLI_heap_insert(heap, float(in), POINTER_FROM_INT(in)); } for (int i = 0; i < items_total; i++) { - BLI_heap_node_value_update(heap, nodes[i], (float)(items_total + i)); + BLI_heap_node_value_update(heap, nodes[i], float(items_total + i)); } for (int out_test = 0; out_test < items_total; out_test++) { @@ -165,11 +165,11 @@ static void random_heap_reinsert_helper(const int items_total, const int random_ Heap *heap = BLI_heap_new(); HeapNode **nodes = (HeapNode **)MEM_mallocN(sizeof(HeapNode *) * items_total, __func__); for (int in = 0; in < items_total; in++) { - nodes[in] = BLI_heap_insert(heap, (float)in, POINTER_FROM_INT(in)); + nodes[in] = BLI_heap_insert(heap, float(in), POINTER_FROM_INT(in)); } BLI_array_randomize(nodes, sizeof(HeapNode *), items_total, random_seed); for (int i = 0; i < items_total; i++) { - BLI_heap_node_value_update(heap, nodes[i], (float)i); + BLI_heap_node_value_update(heap, nodes[i], float(i)); } EXPECT_TRUE(BLI_heap_is_valid(heap)); @@ -177,7 +177,7 @@ static void random_heap_reinsert_helper(const int items_total, const int random_ HeapNode *node_top = BLI_heap_top(heap); float out = BLI_heap_node_value(node_top); EXPECT_EQ(out, BLI_heap_top_value(heap)); - EXPECT_EQ((float)out_test, out); + EXPECT_EQ(float(out_test), out); BLI_heap_pop_min(heap); } EXPECT_TRUE(BLI_heap_is_empty(heap)); diff --git a/source/blender/blenlib/tests/BLI_kdopbvh_test.cc b/source/blender/blenlib/tests/BLI_kdopbvh_test.cc index 756219cd733..83eeabaea40 100644 --- a/source/blender/blenlib/tests/BLI_kdopbvh_test.cc +++ b/source/blender/blenlib/tests/BLI_kdopbvh_test.cc @@ -18,7 +18,7 @@ static void rng_v3_round(float *coords, int coords_len, struct RNG *rng, int rou { for (int i = 0; i < coords_len; i++) { float f = BLI_rng_get_float(rng) * 2.0f - 1.0f; - coords[i] = ((float)((int)(f * round)) / (float)round) * scale; + coords[i] = (float(int(f * round)) / float(round)) * scale; } } @@ -90,7 +90,7 @@ static void find_nearest_points_test( if (j != i) { #if 0 const float dist = len_v3v3(points[i], points[j]); - if (dist > (1.0f / (float)round)) { + if (dist > (1.0f / float(round))) { printf("%.15f (%d %d)\n", dist, i, j); print_v3_id(points[i]); print_v3_id(points[j]); diff --git a/source/blender/blenlib/tests/BLI_linear_allocator_test.cc b/source/blender/blenlib/tests/BLI_linear_allocator_test.cc index b67683d0558..8f707789954 100644 --- a/source/blender/blenlib/tests/BLI_linear_allocator_test.cc +++ b/source/blender/blenlib/tests/BLI_linear_allocator_test.cc @@ -36,13 +36,13 @@ TEST(linear_allocator, PackedAllocation) blender::AlignedBuffer<256, 32> buffer; allocator.provide_buffer(buffer); - uintptr_t ptr1 = (uintptr_t)allocator.allocate(10, 4); /* 0 - 10 */ - uintptr_t ptr2 = (uintptr_t)allocator.allocate(10, 4); /* 12 - 22 */ - uintptr_t ptr3 = (uintptr_t)allocator.allocate(8, 32); /* 32 - 40 */ - uintptr_t ptr4 = (uintptr_t)allocator.allocate(16, 8); /* 40 - 56 */ - uintptr_t ptr5 = (uintptr_t)allocator.allocate(1, 8); /* 56 - 57 */ - uintptr_t ptr6 = (uintptr_t)allocator.allocate(1, 4); /* 60 - 61 */ - uintptr_t ptr7 = (uintptr_t)allocator.allocate(1, 1); /* 61 - 62 */ + uintptr_t ptr1 = uintptr_t(allocator.allocate(10, 4)); /* 0 - 10 */ + uintptr_t ptr2 = uintptr_t(allocator.allocate(10, 4)); /* 12 - 22 */ + uintptr_t ptr3 = uintptr_t(allocator.allocate(8, 32)); /* 32 - 40 */ + uintptr_t ptr4 = uintptr_t(allocator.allocate(16, 8)); /* 40 - 56 */ + uintptr_t ptr5 = uintptr_t(allocator.allocate(1, 8)); /* 56 - 57 */ + uintptr_t ptr6 = uintptr_t(allocator.allocate(1, 4)); /* 60 - 61 */ + uintptr_t ptr7 = uintptr_t(allocator.allocate(1, 1)); /* 61 - 62 */ EXPECT_EQ(ptr2 - ptr1, 12); /* 12 - 0 = 12 */ EXPECT_EQ(ptr3 - ptr2, 20); /* 32 - 12 = 20 */ diff --git a/source/blender/blenlib/tests/BLI_math_color_test.cc b/source/blender/blenlib/tests/BLI_math_color_test.cc index 4d928477870..0b6f9340379 100644 --- a/source/blender/blenlib/tests/BLI_math_color_test.cc +++ b/source/blender/blenlib/tests/BLI_math_color_test.cc @@ -68,7 +68,7 @@ TEST(math_color, LinearRGBTosRGBRoundtrip) const int N = 50; int i; for (i = 0; i < N; ++i) { - float orig_linear_color = (float)i / N; + float orig_linear_color = float(i) / N; float srgb_color = linearrgb_to_srgb(orig_linear_color); float linear_color = srgb_to_linearrgb(srgb_color); EXPECT_NEAR(orig_linear_color, linear_color, 1e-5); diff --git a/source/blender/blenlib/tests/BLI_math_rotation_test.cc b/source/blender/blenlib/tests/BLI_math_rotation_test.cc index 460cfd2d36c..e37b212e1df 100644 --- a/source/blender/blenlib/tests/BLI_math_rotation_test.cc +++ b/source/blender/blenlib/tests/BLI_math_rotation_test.cc @@ -161,7 +161,7 @@ static void test_sin_cos_from_fraction_accuracy(const int range, const float exp for (int i = 0; i < range; i++) { float sin_cos_fl[2]; sin_cos_from_fraction(i, range, &sin_cos_fl[0], &sin_cos_fl[1]); - const float phi = (float)(2.0 * M_PI) * ((float)i / (float)range); + const float phi = float(2.0 * M_PI) * (float(i) / float(range)); const float sin_cos_test_fl[2] = {sinf(phi), cosf(phi)}; EXPECT_V2_NEAR(sin_cos_fl, sin_cos_test_fl, expected_eps); } diff --git a/source/blender/blenlib/tests/BLI_path_util_test.cc b/source/blender/blenlib/tests/BLI_path_util_test.cc index 54afc3d975d..5ea6524f835 100644 --- a/source/blender/blenlib/tests/BLI_path_util_test.cc +++ b/source/blender/blenlib/tests/BLI_path_util_test.cc @@ -651,7 +651,7 @@ TEST(path_util, PathRelPath) abs_path_in[FILE_MAX - 1] = '\0'; abs_path_out[0] = '/'; abs_path_out[1] = '/'; - for (int i = 2; i < FILE_MAX - ((int)ref_path_in_len - 1); i++) { + for (int i = 2; i < FILE_MAX - (int(ref_path_in_len) - 1); i++) { abs_path_out[i] = 'A'; } abs_path_out[FILE_MAX - (ref_path_in_len - 1)] = '\0'; diff --git a/source/blender/blenlib/tests/BLI_polyfill_2d_test.cc b/source/blender/blenlib/tests/BLI_polyfill_2d_test.cc index 69c60c5bdb9..95fd664217f 100644 --- a/source/blender/blenlib/tests/BLI_polyfill_2d_test.cc +++ b/source/blender/blenlib/tests/BLI_polyfill_2d_test.cc @@ -94,10 +94,10 @@ static void test_polyfill_topology(const float /*poly*/[][2], const uint v2 = tris[i][(j + 1) % 3]; void **p = BLI_edgehash_lookup_p(edgehash, v1, v2); if (p) { - *p = (void *)((intptr_t)*p + (intptr_t)1); + *p = (void *)(intptr_t(*p) + intptr_t(1)); } else { - BLI_edgehash_insert(edgehash, v1, v2, (void *)(intptr_t)1); + BLI_edgehash_insert(edgehash, v1, v2, (void *)intptr_t(1)); } } } diff --git a/source/blender/blenlib/tests/BLI_string_utf8_test.cc b/source/blender/blenlib/tests/BLI_string_utf8_test.cc index 2da439dad18..7179eef5adb 100644 --- a/source/blender/blenlib/tests/BLI_string_utf8_test.cc +++ b/source/blender/blenlib/tests/BLI_string_utf8_test.cc @@ -274,7 +274,7 @@ TEST(string, Utf8InvalidBytes) for (int i = 0; utf8_invalid_tests[i][0] != nullptr; i++) { const char *tst = utf8_invalid_tests[i][0]; const char *tst_stripped = utf8_invalid_tests[i][1]; - const int errors_num = (int)utf8_invalid_tests[i][2][0]; + const int errors_num = int(utf8_invalid_tests[i][2][0]); char buff[80]; memcpy(buff, tst, sizeof(buff)); @@ -352,13 +352,13 @@ template void utf8_as_char32_test_at_buffer_size() /* Offset trailing bytes up and down in steps of 1, 2, 4 .. etc. */ if (Size > 1) { for (int mul = 1; mul < 256; mul *= 2) { - for (int ofs = 1; ofs < (int)Size; ofs++) { - utf8_src[ofs] = (char)(i + (ofs * mul)); + for (int ofs = 1; ofs < int(Size); ofs++) { + utf8_src[ofs] = char(i + (ofs * mul)); } utf8_as_char32_test_compare(utf8_src); - for (int ofs = 1; ofs < (int)Size; ofs++) { - utf8_src[ofs] = (char)(i - (ofs * mul)); + for (int ofs = 1; ofs < int(Size); ofs++) { + utf8_src[ofs] = char(i - (ofs * mul)); } utf8_as_char32_test_compare(utf8_src); } diff --git a/source/blender/blenlib/tests/BLI_virtual_array_test.cc b/source/blender/blenlib/tests/BLI_virtual_array_test.cc index 14f5480f751..6d6580c52d4 100644 --- a/source/blender/blenlib/tests/BLI_virtual_array_test.cc +++ b/source/blender/blenlib/tests/BLI_virtual_array_test.cc @@ -98,7 +98,7 @@ TEST(virtual_array, VectorSet) TEST(virtual_array, Func) { - auto func = [](int64_t index) { return (int)(index * index); }; + auto func = [](int64_t index) { return int(index * index); }; VArray varray = VArray::ForFunc(10, func); EXPECT_EQ(varray.size(), 10); EXPECT_EQ(varray[0], 0); @@ -108,7 +108,7 @@ TEST(virtual_array, Func) TEST(virtual_array, AsSpan) { - auto func = [](int64_t index) { return (int)(10 * index); }; + auto func = [](int64_t index) { return int(10 * index); }; VArray func_varray = VArray::ForFunc(10, func); VArraySpan span_varray{func_varray}; EXPECT_EQ(span_varray.size(), 10); @@ -210,7 +210,7 @@ TEST(virtual_array, MaterializeCompressed) EXPECT_EQ(compressed_array[2], 4); } { - VArray varray = VArray::ForFunc(10, [](const int64_t i) { return (int)(i * i); }); + VArray varray = VArray::ForFunc(10, [](const int64_t i) { return int(i * i); }); std::array compressed_array; varray.materialize_compressed({5, 7, 8}, compressed_array); EXPECT_EQ(compressed_array[0], 25); diff --git a/source/blender/blenlib/tests/performance/BLI_ghash_performance_test.cc b/source/blender/blenlib/tests/performance/BLI_ghash_performance_test.cc index e1d3adc6e78..efcf8dea922 100644 --- a/source/blender/blenlib/tests/performance/BLI_ghash_performance_test.cc +++ b/source/blender/blenlib/tests/performance/BLI_ghash_performance_test.cc @@ -270,7 +270,7 @@ static void randint_ghash_tests(GHash *ghash, const char *id, const uint count) { printf("\n========== STARTING %s ==========\n", id); - uint *data = (uint *)MEM_mallocN(sizeof(*data) * (size_t)count, __func__); + uint *data = (uint *)MEM_mallocN(sizeof(*data) * size_t(count), __func__); uint *dt; uint i; @@ -379,7 +379,7 @@ static void int4_ghash_tests(GHash *ghash, const char *id, const uint count) { printf("\n========== STARTING %s ==========\n", id); - void *data_v = MEM_mallocN(sizeof(uint[4]) * (size_t)count, __func__); + void *data_v = MEM_mallocN(sizeof(uint[4]) * size_t(count), __func__); uint(*data)[4] = (uint(*)[4])data_v; uint(*dt)[4]; uint i, j; @@ -485,7 +485,7 @@ TEST(ghash, Int2NoHash50000000) static void multi_small_ghash_tests_one(GHash *ghash, RNG *rng, const uint count) { - uint *data = (uint *)MEM_mallocN(sizeof(*data) * (size_t)count, __func__); + uint *data = (uint *)MEM_mallocN(sizeof(*data) * size_t(count), __func__); uint *dt; uint i; diff --git a/source/blender/blenlib/tests/performance/BLI_task_performance_test.cc b/source/blender/blenlib/tests/performance/BLI_task_performance_test.cc index a86e9b0b86d..adebb1edb8b 100644 --- a/source/blender/blenlib/tests/performance/BLI_task_performance_test.cc +++ b/source/blender/blenlib/tests/performance/BLI_task_performance_test.cc @@ -69,7 +69,7 @@ static void task_listbase_heavy_iter_func(void *UNUSED(userdata), LinkData *data = (LinkData *)item; /* 'Random' number of iterations. */ - const uint num = gen_pseudo_random_number((uint)index); + const uint num = gen_pseudo_random_number(uint(index)); for (uint i = 0; i < num; i++) { data->data = POINTER_FROM_INT(POINTER_AS_INT(data->data) + ((i % 2) ? -index : index)); @@ -86,7 +86,7 @@ static void task_listbase_heavy_membarrier_iter_func(void *userdata, int *count = (int *)userdata; /* 'Random' number of iterations. */ - const uint num = gen_pseudo_random_number((uint)index); + const uint num = gen_pseudo_random_number(uint(index)); for (uint i = 0; i < num; i++) { data->data = POINTER_FROM_INT(POINTER_AS_INT(data->data) + ((i % 2) ? -index : index)); diff --git a/source/blender/blenloader/intern/readfile.cc b/source/blender/blenloader/intern/readfile.cc index 71708c09c01..46ae207db48 100644 --- a/source/blender/blenloader/intern/readfile.cc +++ b/source/blender/blenloader/intern/readfile.cc @@ -193,7 +193,7 @@ typedef struct BHeadN { struct BHead bhead; } BHeadN; -#define BHEADN_FROM_BHEAD(bh) ((BHeadN *)POINTER_OFFSET(bh, -(int)offsetof(BHeadN, bhead))) +#define BHEADN_FROM_BHEAD(bh) ((BHeadN *)POINTER_OFFSET(bh, -int(offsetof(BHeadN, bhead)))) /** * We could change this in the future, for now it's simplest if only data is delayed @@ -475,7 +475,7 @@ static void split_libdata(ListBase *lb_src, Main **lib_main_array, const uint li idnext = static_cast(id->next); if (id->lib) { - if (((uint)id->lib->temp_index < lib_main_array_len) && + if ((uint(id->lib->temp_index) < lib_main_array_len) && /* this check should never fail, just in case 'id->lib' is a dangling pointer. */ (lib_main_array[id->lib->temp_index]->curlib == id->lib)) { Main *mainvar = lib_main_array[id->lib->temp_index]; @@ -591,7 +591,7 @@ static void read_file_bhead_idname_map_create(FileData *fd) if (code_prev != bhead->code) { code_prev = bhead->code; is_link = blo_bhead_is_id_valid_type(bhead) ? - BKE_idtype_idcode_is_linkable((short)code_prev) : + BKE_idtype_idcode_is_linkable(short(code_prev)) : false; } @@ -608,7 +608,7 @@ static void read_file_bhead_idname_map_create(FileData *fd) if (code_prev != bhead->code) { code_prev = bhead->code; is_link = blo_bhead_is_id_valid_type(bhead) ? - BKE_idtype_idcode_is_linkable((short)code_prev) : + BKE_idtype_idcode_is_linkable(short(code_prev)) : false; } @@ -738,7 +738,7 @@ static void bh4_from_bh8(BHead *bhead, BHead8 *bhead8, bool do_endian_swap) /* this patch is to avoid `intptr_t` being read from not-eight aligned positions * is necessary on any modern 64bit architecture) */ memcpy(&old, &bhead8->old, 8); - bhead4->old = (int)(old >> 3); + bhead4->old = int(old >> 3); bhead4->SDNAnr = bhead8->SDNAnr; bhead4->nr = bhead8->nr; @@ -862,7 +862,7 @@ static BHeadN *get_bhead(FileData *fd) #endif else { new_bhead = static_cast( - MEM_mallocN(sizeof(BHeadN) + (size_t)bhead.len, "new_bhead")); + MEM_mallocN(sizeof(BHeadN) + size_t(bhead.len), "new_bhead")); if (new_bhead) { new_bhead->next = new_bhead->prev = nullptr; #ifdef USE_BHEAD_READ_ON_DEMAND @@ -872,7 +872,7 @@ static BHeadN *get_bhead(FileData *fd) new_bhead->is_memchunk_identical = false; new_bhead->bhead = bhead; - readsize = fd->file->read(fd->file, new_bhead + 1, (size_t)bhead.len); + readsize = fd->file->read(fd->file, new_bhead + 1, size_t(bhead.len)); if (readsize != bhead.len) { fd->is_eof = true; @@ -966,7 +966,7 @@ static bool blo_bhead_read_data(FileData *fd, BHead *thisblock, void *buf) success = false; } else { - if (fd->file->read(fd->file, buf, (size_t)new_bhead->bhead.len) != new_bhead->bhead.len) { + if (fd->file->read(fd->file, buf, size_t(new_bhead->bhead.len)) != new_bhead->bhead.len) { success = false; } if (fd->flags & FD_FLAGS_IS_MEMFILE) { diff --git a/source/blender/blenloader/intern/undofile.cc b/source/blender/blenloader/intern/undofile.cc index 58c1020f4cb..4c417c41297 100644 --- a/source/blender/blenloader/intern/undofile.cc +++ b/source/blender/blenloader/intern/undofile.cc @@ -233,7 +233,7 @@ bool BLO_memfile_write_file(struct MemFile *memfile, const char *filepath) for (chunk = static_cast(memfile->chunks.first); chunk; chunk = static_cast(chunk->next)) { #ifdef _WIN32 - if ((size_t)write(file, chunk->buf, (uint)chunk->size) != chunk->size) + if ((size_t)write(file, chunk->buf, uint(chunk->size)) != chunk->size) #else if ((size_t)write(file, chunk->buf, chunk->size) != chunk->size) #endif diff --git a/source/blender/blenloader/intern/versioning_300.cc b/source/blender/blenloader/intern/versioning_300.cc index 02b83d73d1f..f2aa07b6678 100644 --- a/source/blender/blenloader/intern/versioning_300.cc +++ b/source/blender/blenloader/intern/versioning_300.cc @@ -169,7 +169,7 @@ static void version_idproperty_move_data_float(IDPropertyUIDataFloat *ui_data, MEM_malloc_arrayN(array_len, sizeof(double), __func__)); const float *old_default_array = static_cast(IDP_Array(default_value)); for (int i = 0; i < ui_data->default_array_len; i++) { - ui_data->default_array[i] = (double)old_default_array[i]; + ui_data->default_array[i] = double(old_default_array[i]); } } else if (default_value->subtype == IDP_DOUBLE) { @@ -412,9 +412,9 @@ static void do_versions_sequencer_speed_effect_recursive(Scene *scene, const Lis else { v->speed_control_type = SEQ_SPEED_MULTIPLY; v->speed_fader = globalSpeed * - ((float)seq->seq1->len / - max_ff((float)(SEQ_time_right_handle_frame_get(scene, seq->seq1) - - seq->seq1->start), + (float(seq->seq1->len) / + max_ff(float(SEQ_time_right_handle_frame_get(scene, seq->seq1) - + seq->seq1->start), 1.0f)); } } @@ -430,7 +430,7 @@ static void do_versions_sequencer_speed_effect_recursive(Scene *scene, const Lis } else { v->speed_control_type = SEQ_SPEED_FRAME_NUMBER; - v->speed_fader_frame_number = (int)(seq->speed_fader * globalSpeed); + v->speed_fader_frame_number = int(seq->speed_fader * globalSpeed); substr = "speed_frame_number"; } diff --git a/source/blender/blenloader/intern/writefile.cc b/source/blender/blenloader/intern/writefile.cc index 6b7c4489eee..757bce97bf1 100644 --- a/source/blender/blenloader/intern/writefile.cc +++ b/source/blender/blenloader/intern/writefile.cc @@ -685,7 +685,7 @@ static void writestruct_at_address_nr( } mywrite(wd, &bh, sizeof(BHead)); - mywrite(wd, data, (size_t)bh.len); + mywrite(wd, data, size_t(bh.len)); } static void writestruct_nr( @@ -709,14 +709,14 @@ static void writedata(WriteData *wd, int filecode, size_t len, const void *adr) } /* align to 4 (writes uninitialized bytes in some cases) */ - len = (len + 3) & ~((size_t)3); + len = (len + 3) & ~size_t(3); /* init BHead */ bh.code = filecode; bh.old = adr; bh.nr = 1; bh.SDNAnr = 0; - bh.len = (int)len; + bh.len = int(len); mywrite(wd, &bh, sizeof(BHead)); mywrite(wd, adr, len); diff --git a/source/blender/bmesh/intern/bmesh_query_uv.cc b/source/blender/bmesh/intern/bmesh_query_uv.cc index 5a725407c6b..33b2ca7a828 100644 --- a/source/blender/bmesh/intern/bmesh_query_uv.cc +++ b/source/blender/bmesh/intern/bmesh_query_uv.cc @@ -65,7 +65,7 @@ void BM_face_uv_calc_center_median_weighted(const BMFace *f, } while ((l_iter = l_iter->next) != l_first); if (totw != 0.0f) { - mul_v2_fl(r_cent, 1.0f / (float)totw); + mul_v2_fl(r_cent, 1.0f / float(totw)); } /* Reverse aspect. */ r_cent[0] /= aspect[0]; @@ -85,7 +85,7 @@ void BM_face_uv_calc_center_median(const BMFace *f, const int cd_loop_uv_offset, add_v2_v2(r_cent, luv->uv); } while ((l_iter = l_iter->next) != l_first); - mul_v2_fl(r_cent, 1.0f / (float)f->len); + mul_v2_fl(r_cent, 1.0f / float(f->len)); } float BM_face_uv_calc_cross(const BMFace *f, const int cd_loop_uv_offset) diff --git a/source/blender/compositor/intern/COM_ChunkOrderHotspot.cc b/source/blender/compositor/intern/COM_ChunkOrderHotspot.cc index b9179c0a910..5b9d2fa2797 100644 --- a/source/blender/compositor/intern/COM_ChunkOrderHotspot.cc +++ b/source/blender/compositor/intern/COM_ChunkOrderHotspot.cc @@ -10,8 +10,8 @@ double ChunkOrderHotspot::calc_distance(int x, int y) { int dx = this->x - x; int dy = this->y - y; - double result = sqrt((double)(dx * dx + dy * dy)); - result += (double)this->addition; + double result = sqrt(double(dx * dx + dy * dy)); + result += double(this->addition); return result; } diff --git a/source/blender/compositor/intern/COM_ExecutionGroup.cc b/source/blender/compositor/intern/COM_ExecutionGroup.cc index 9b4c46654f2..c9002b535ed 100644 --- a/source/blender/compositor/intern/COM_ExecutionGroup.cc +++ b/source/blender/compositor/intern/COM_ExecutionGroup.cc @@ -436,8 +436,8 @@ inline void ExecutionGroup::determine_chunk_rect(rcti *r_rect, else { const uint minx = x_chunk * chunk_size_ + viewer_border_.xmin; const uint miny = y_chunk * chunk_size_ + viewer_border_.ymin; - const uint width = MIN2((uint)viewer_border_.xmax, width_); - const uint height = MIN2((uint)viewer_border_.ymax, height_); + const uint width = MIN2(uint(viewer_border_.xmax), width_); + const uint height = MIN2(uint(viewer_border_.ymax), height_); BLI_rcti_init(r_rect, MIN2(minx, width_), MIN2(minx + chunk_size_, width), @@ -480,14 +480,14 @@ bool ExecutionGroup::schedule_area_when_possible(ExecutionSystem *graph, rcti *a int maxx = min_ii(area->xmax - viewer_border_.xmin, viewer_border_.xmax - viewer_border_.xmin); int miny = max_ii(area->ymin - viewer_border_.ymin, 0); int maxy = min_ii(area->ymax - viewer_border_.ymin, viewer_border_.ymax - viewer_border_.ymin); - int minxchunk = minx / (int)chunk_size_; - int maxxchunk = (maxx + (int)chunk_size_ - 1) / (int)chunk_size_; - int minychunk = miny / (int)chunk_size_; - int maxychunk = (maxy + (int)chunk_size_ - 1) / (int)chunk_size_; + int minxchunk = minx / int(chunk_size_); + int maxxchunk = (maxx + int(chunk_size_) - 1) / int(chunk_size_); + int minychunk = miny / int(chunk_size_); + int maxychunk = (maxy + int(chunk_size_) - 1) / int(chunk_size_); minxchunk = max_ii(minxchunk, 0); minychunk = max_ii(minychunk, 0); - maxxchunk = min_ii(maxxchunk, (int)x_chunks_len_); - maxychunk = min_ii(maxychunk, (int)y_chunks_len_); + maxxchunk = min_ii(maxxchunk, int(x_chunks_len_)); + maxychunk = min_ii(maxychunk, int(y_chunks_len_)); bool result = true; for (indexx = minxchunk; indexx < maxxchunk; indexx++) { @@ -516,10 +516,10 @@ bool ExecutionGroup::schedule_chunk_when_possible(ExecutionSystem *graph, const int chunk_x, const int chunk_y) { - if (chunk_x < 0 || chunk_x >= (int)x_chunks_len_) { + if (chunk_x < 0 || chunk_x >= int(x_chunks_len_)) { return true; } - if (chunk_y < 0 || chunk_y >= (int)y_chunks_len_) { + if (chunk_y < 0 || chunk_y >= int(y_chunks_len_)) { return true; } diff --git a/source/blender/compositor/intern/COM_MemoryBuffer.cc b/source/blender/compositor/intern/COM_MemoryBuffer.cc index 95bb233ff6c..539e1179bc8 100644 --- a/source/blender/compositor/intern/COM_MemoryBuffer.cc +++ b/source/blender/compositor/intern/COM_MemoryBuffer.cc @@ -266,7 +266,7 @@ void MemoryBuffer::copy_from(const uchar *src, const float *row_end = to_elem + width * this->elem_stride; while (to_elem < row_end) { for (int i = 0; i < elem_size; i++) { - to_elem[i] = ((float)from_elem[i]) * (1.0f / 255.0f); + to_elem[i] = float(from_elem[i]) * (1.0f / 255.0f); } to_elem += this->elem_stride; from_elem += elem_stride; @@ -427,7 +427,7 @@ void MemoryBuffer::read_elem_filtered( const float deriv[2][2] = {{dx[0], dx[1]}, {dy[0], dy[1]}}; - float inv_width = 1.0f / (float)this->get_width(), inv_height = 1.0f / (float)this->get_height(); + float inv_width = 1.0f / float(this->get_width()), inv_height = 1.0f / float(this->get_height()); /* TODO(sergey): Render pipeline uses normalized coordinates and derivatives, * but compositor uses pixel space. For now let's just divide the values and * switch compositor to normalized space for EWA later. @@ -463,8 +463,8 @@ void MemoryBuffer::readEWA(float *result, const float uv[2], const float derivat } else { BLI_assert(datatype_ == DataType::Color); - float inv_width = 1.0f / (float)this->get_width(), - inv_height = 1.0f / (float)this->get_height(); + float inv_width = 1.0f / float(this->get_width()), + inv_height = 1.0f / float(this->get_height()); /* TODO(sergey): Render pipeline uses normalized coordinates and derivatives, * but compositor uses pixel space. For now let's just divide the values and * switch compositor to normalized space for EWA later. diff --git a/source/blender/compositor/intern/COM_OpenCLDevice.cc b/source/blender/compositor/intern/COM_OpenCLDevice.cc index 5d5751944b2..188389b88c9 100644 --- a/source/blender/compositor/intern/COM_OpenCLDevice.cc +++ b/source/blender/compositor/intern/COM_OpenCLDevice.cc @@ -187,8 +187,8 @@ void OpenCLDevice::COM_cl_enqueue_range(cl_kernel kernel, MemoryBuffer *output_m { cl_int error; const size_t size[] = { - (size_t)output_memory_buffer->get_width(), - (size_t)output_memory_buffer->get_height(), + size_t(output_memory_buffer->get_width()), + size_t(output_memory_buffer->get_height()), }; error = clEnqueueNDRangeKernel(queue_, kernel, 2, nullptr, size, nullptr, 0, nullptr, nullptr); diff --git a/source/blender/compositor/intern/COM_compositor.cc b/source/blender/compositor/intern/COM_compositor.cc index 519ad93bcaf..1ffc749ce64 100644 --- a/source/blender/compositor/intern/COM_compositor.cc +++ b/source/blender/compositor/intern/COM_compositor.cc @@ -25,15 +25,15 @@ static void compositor_init_node_previews(const RenderData *render_data, bNodeTr /* We fit the aspect into COM_PREVIEW_SIZE x COM_PREVIEW_SIZE image to avoid * insane preview resolution, which might even overflow preview dimensions. */ const float aspect = render_data->xsch > 0 ? - (float)render_data->ysch / (float)render_data->xsch : + float(render_data->ysch) / float(render_data->xsch) : 1.0f; int preview_width, preview_height; if (aspect < 1.0f) { preview_width = blender::compositor::COM_PREVIEW_SIZE; - preview_height = (int)(blender::compositor::COM_PREVIEW_SIZE * aspect); + preview_height = int(blender::compositor::COM_PREVIEW_SIZE * aspect); } else { - preview_width = (int)(blender::compositor::COM_PREVIEW_SIZE / aspect); + preview_width = int(blender::compositor::COM_PREVIEW_SIZE / aspect); preview_height = blender::compositor::COM_PREVIEW_SIZE; } BKE_node_preview_init_tree(node_tree, preview_width, preview_height); diff --git a/source/blender/compositor/nodes/COM_CropNode.cc b/source/blender/compositor/nodes/COM_CropNode.cc index 849fb80a8a8..80f345e8762 100644 --- a/source/blender/compositor/nodes/COM_CropNode.cc +++ b/source/blender/compositor/nodes/COM_CropNode.cc @@ -16,8 +16,8 @@ void CropNode::convert_to_operations(NodeConverter &converter, { const bNode *node = get_bnode(); NodeTwoXYs *crop_settings = (NodeTwoXYs *)node->storage; - bool relative = (bool)node->custom2; - bool crop_image = (bool)node->custom1; + bool relative = bool(node->custom2); + bool crop_image = bool(node->custom1); CropBaseOperation *operation; if (crop_image) { operation = new CropImageOperation(); diff --git a/source/blender/compositor/nodes/COM_MapUVNode.cc b/source/blender/compositor/nodes/COM_MapUVNode.cc index ed9bff657f3..0ff86cabd4d 100644 --- a/source/blender/compositor/nodes/COM_MapUVNode.cc +++ b/source/blender/compositor/nodes/COM_MapUVNode.cc @@ -17,7 +17,7 @@ void MapUVNode::convert_to_operations(NodeConverter &converter, const bNode *node = this->get_bnode(); MapUVOperation *operation = new MapUVOperation(); - operation->set_alpha((float)node->custom1); + operation->set_alpha(float(node->custom1)); operation->set_canvas_input_index(1); converter.add_operation(operation); diff --git a/source/blender/compositor/nodes/COM_MaskNode.cc b/source/blender/compositor/nodes/COM_MaskNode.cc index f92e307328d..3c6812d606f 100644 --- a/source/blender/compositor/nodes/COM_MaskNode.cc +++ b/source/blender/compositor/nodes/COM_MaskNode.cc @@ -41,7 +41,7 @@ void MaskNode::convert_to_operations(NodeConverter &converter, operation->set_mask(mask); operation->set_framenumber(context.get_framenumber()); - operation->set_feather((bool)(editor_node->custom1 & CMP_NODEFLAG_MASK_NO_FEATHER) == 0); + operation->set_feather(bool(editor_node->custom1 & CMP_NODEFLAG_MASK_NO_FEATHER) == 0); if ((editor_node->custom1 & CMP_NODEFLAG_MASK_MOTION_BLUR) && (editor_node->custom2 > 1) && (editor_node->custom3 > FLT_EPSILON)) { diff --git a/source/blender/compositor/nodes/COM_SceneTimeNode.cc b/source/blender/compositor/nodes/COM_SceneTimeNode.cc index edd6efdb67b..dd5784f03ee 100644 --- a/source/blender/compositor/nodes/COM_SceneTimeNode.cc +++ b/source/blender/compositor/nodes/COM_SceneTimeNode.cc @@ -20,7 +20,7 @@ void SceneTimeNode::convert_to_operations(NodeConverter &converter, const int frameNumber = context.get_framenumber(); const Scene *scene = context.get_scene(); - const double frameRate = (((double)scene->r.frs_sec) / (double)scene->r.frs_sec_base); + const double frameRate = (double(scene->r.frs_sec) / double(scene->r.frs_sec_base)); SecondOperation->set_value(float(frameNumber / frameRate)); converter.add_operation(SecondOperation); diff --git a/source/blender/compositor/nodes/COM_TimeNode.cc b/source/blender/compositor/nodes/COM_TimeNode.cc index 4f4f6f7bf8a..4004a5f718f 100644 --- a/source/blender/compositor/nodes/COM_TimeNode.cc +++ b/source/blender/compositor/nodes/COM_TimeNode.cc @@ -31,7 +31,7 @@ void TimeNode::convert_to_operations(NodeConverter &converter, fac = 1.0f; } else if (node->custom1 < node->custom2) { - fac = (context.get_framenumber() - node->custom1) / (float)(node->custom2 - node->custom1); + fac = (context.get_framenumber() - node->custom1) / float(node->custom2 - node->custom1); } BKE_curvemapping_init((CurveMapping *)node->storage); diff --git a/source/blender/compositor/operations/COM_BlurBaseOperation.cc b/source/blender/compositor/operations/COM_BlurBaseOperation.cc index b278997eced..53a5cebaf5d 100644 --- a/source/blender/compositor/operations/COM_BlurBaseOperation.cc +++ b/source/blender/compositor/operations/COM_BlurBaseOperation.cc @@ -71,7 +71,7 @@ float *BlurBaseOperation::make_gausstab(float rad, int size) sum = 0.0f; float fac = (rad > 0.0f ? 1.0f / rad : 0.0f); for (i = -size; i <= size; i++) { - val = RE_filter_value(data_.filtertype, (float)i * fac); + val = RE_filter_value(data_.filtertype, float(i) * fac); sum += val; gausstab[i + size] = val; } @@ -107,7 +107,7 @@ float *BlurBaseOperation::make_dist_fac_inverse(float rad, int size, int falloff float fac = (rad > 0.0f ? 1.0f / rad : 0.0f); for (i = -size; i <= size; i++) { - val = 1.0f - fabsf((float)i * fac); + val = 1.0f - fabsf(float(i) * fac); /* keep in sync with rna_enum_proportional_falloff_curve_only_items */ switch (falloff) { diff --git a/source/blender/compositor/operations/COM_BokehImageOperation.cc b/source/blender/compositor/operations/COM_BokehImageOperation.cc index 42caa7aa3c0..9828d38d83f 100644 --- a/source/blender/compositor/operations/COM_BokehImageOperation.cc +++ b/source/blender/compositor/operations/COM_BokehImageOperation.cc @@ -16,13 +16,13 @@ void BokehImageOperation::init_execution() center_[1] = get_height() / 2; inverse_rounding_ = 1.0f - data_->rounding; circular_distance_ = get_width() / 2; - flap_rad_ = (float)(M_PI * 2) / data_->flaps; + flap_rad_ = float(M_PI * 2) / data_->flaps; flap_rad_add_ = data_->angle; while (flap_rad_add_ < 0.0f) { - flap_rad_add_ += (float)(M_PI * 2.0); + flap_rad_add_ += float(M_PI * 2.0); } - while (flap_rad_add_ > (float)M_PI) { - flap_rad_add_ -= (float)(M_PI * 2.0); + while (flap_rad_add_ > float(M_PI)) { + flap_rad_add_ -= float(M_PI * 2.0); } } void BokehImageOperation::detemine_start_point_of_flap(float r[2], int flap_number, float distance) @@ -43,8 +43,8 @@ float BokehImageOperation::is_inside_bokeh(float distance, float x, float y) point[1] = y; const float distance_to_center = len_v2v2(point, center_); - const float bearing = (atan2f(deltaX, deltaY) + (float)(M_PI * 2.0)); - int flap_number = (int)((bearing - flap_rad_add_) / flap_rad_); + const float bearing = (atan2f(deltaX, deltaY) + float(M_PI * 2.0)); + int flap_number = int((bearing - flap_rad_add_) / flap_rad_); detemine_start_point_of_flap(line_p1, flap_number, distance); detemine_start_point_of_flap(line_p2, flap_number + 1, distance); diff --git a/source/blender/compositor/operations/COM_BoxMaskOperation.cc b/source/blender/compositor/operations/COM_BoxMaskOperation.cc index 5b3e00afe31..85ac9434647 100644 --- a/source/blender/compositor/operations/COM_BoxMaskOperation.cc +++ b/source/blender/compositor/operations/COM_BoxMaskOperation.cc @@ -19,10 +19,10 @@ void BoxMaskOperation::init_execution() { input_mask_ = this->get_input_socket_reader(0); input_value_ = this->get_input_socket_reader(1); - const double rad = (double)data_->rotation; + const double rad = double(data_->rotation); cosine_ = cos(rad); sine_ = sin(rad); - aspect_ratio_ = ((float)this->get_width()) / this->get_height(); + aspect_ratio_ = float(this->get_width()) / this->get_height(); } void BoxMaskOperation::execute_pixel_sampled(float output[4], diff --git a/source/blender/compositor/operations/COM_CalculateStandardDeviationOperation.cc b/source/blender/compositor/operations/COM_CalculateStandardDeviationOperation.cc index 881b894d66d..95acf51413c 100644 --- a/source/blender/compositor/operations/COM_CalculateStandardDeviationOperation.cc +++ b/source/blender/compositor/operations/COM_CalculateStandardDeviationOperation.cc @@ -74,7 +74,7 @@ void *CalculateStandardDeviationOperation::initialize_tile_data(rcti *rect) } } } - standard_deviation_ = sqrt(sum / (float)(pixels - 1)); + standard_deviation_ = sqrt(sum / float(pixels - 1)); iscalculated_ = true; } unlock_mutex(); @@ -98,7 +98,7 @@ void CalculateStandardDeviationOperation::update_memory_buffer_started( join.num_pixels += chunk.num_pixels; }); standard_deviation_ = total.num_pixels <= 1 ? 0.0f : - sqrt(total.sum / (float)(total.num_pixels - 1)); + sqrt(total.sum / float(total.num_pixels - 1)); iscalculated_ = true; } } diff --git a/source/blender/compositor/operations/COM_ConvertDepthToRadiusOperation.cc b/source/blender/compositor/operations/COM_ConvertDepthToRadiusOperation.cc index 89c1c7cb153..25d4b2d6a6c 100644 --- a/source/blender/compositor/operations/COM_ConvertDepthToRadiusOperation.cc +++ b/source/blender/compositor/operations/COM_ConvertDepthToRadiusOperation.cc @@ -46,8 +46,8 @@ void ConvertDepthToRadiusOperation::init_execution() } inverse_focal_distance_ = 1.0f / focal_distance; aspect_ = (this->get_width() > this->get_height()) ? - (this->get_height() / (float)this->get_width()) : - (this->get_width() / (float)this->get_height()); + (this->get_height() / float(this->get_width())) : + (this->get_width() / float(this->get_height())); aperture_ = 0.5f * (cam_lens_ / (aspect_ * cam_sensor)) / f_stop_; const float minsz = MIN2(get_width(), get_height()); dof_sp_ = minsz / ((cam_sensor / 2.0f) / diff --git a/source/blender/compositor/operations/COM_CryptomatteOperation.cc b/source/blender/compositor/operations/COM_CryptomatteOperation.cc index 69218576237..71e892cb7f1 100644 --- a/source/blender/compositor/operations/COM_CryptomatteOperation.cc +++ b/source/blender/compositor/operations/COM_CryptomatteOperation.cc @@ -42,8 +42,8 @@ void CryptomatteOperation::execute_pixel(float output[4], int x, int y, void *da ::memcpy(&m3hash, &input[0], sizeof(uint32_t)); /* Since the red channel is likely to be out of display range, * setting green and blue gives more meaningful images. */ - output[1] = ((float)(m3hash << 8) / (float)UINT32_MAX); - output[2] = ((float)(m3hash << 16) / (float)UINT32_MAX); + output[1] = (float(m3hash << 8) / float(UINT32_MAX)); + output[2] = (float(m3hash << 16) / float(UINT32_MAX)); } for (float hash : object_index_) { if (input[0] == hash) { @@ -71,8 +71,8 @@ void CryptomatteOperation::update_memory_buffer_partial(MemoryBuffer *output, ::memcpy(&m3hash, &input[0], sizeof(uint32_t)); /* Since the red channel is likely to be out of display range, * setting green and blue gives more meaningful images. */ - it.out[1] = ((float)(m3hash << 8) / (float)UINT32_MAX); - it.out[2] = ((float)(m3hash << 16) / (float)UINT32_MAX); + it.out[1] = (float(m3hash << 8) / float(UINT32_MAX)); + it.out[2] = (float(m3hash << 16) / float(UINT32_MAX)); } for (const float hash : object_index_) { if (input[0] == hash) { diff --git a/source/blender/compositor/operations/COM_DenoiseOperation.cc b/source/blender/compositor/operations/COM_DenoiseOperation.cc index 3f32eced0f8..123f33d3c9e 100644 --- a/source/blender/compositor/operations/COM_DenoiseOperation.cc +++ b/source/blender/compositor/operations/COM_DenoiseOperation.cc @@ -178,7 +178,7 @@ static bool are_guiding_passes_noise_free(const NodeDenoise *settings) void DenoiseOperation::hash_output_params() { if (settings_) { - hash_params((int)settings_->hdr, are_guiding_passes_noise_free(settings_)); + hash_params(int(settings_->hdr), are_guiding_passes_noise_free(settings_)); } } diff --git a/source/blender/compositor/operations/COM_DespeckleOperation.cc b/source/blender/compositor/operations/COM_DespeckleOperation.cc index cfc437a6324..a0c82ad531c 100644 --- a/source/blender/compositor/operations/COM_DespeckleOperation.cc +++ b/source/blender/compositor/operations/COM_DespeckleOperation.cc @@ -99,7 +99,7 @@ void DespeckleOperation::execute_pixel(float output[4], int x, int y, void * /*d input_operation_->read(in1, x3, y3, nullptr); COLOR_ADD(TOT_DIV_CNR) - mul_v4_fl(color_mid, 1.0f / (4.0f + (4.0f * (float)M_SQRT1_2))); + mul_v4_fl(color_mid, 1.0f / (4.0f + (4.0f * float(M_SQRT1_2)))); // mul_v4_fl(color_mid, 1.0f / w); if ((w != 0.0f) && ((w / WTOT) > (threshold_neighbor_)) && @@ -214,7 +214,7 @@ void DespeckleOperation::update_memory_buffer_partial(MemoryBuffer *output, in1 = image->get_elem(x3, y3); COLOR_ADD(TOT_DIV_CNR) - mul_v4_fl(color_mid, 1.0f / (4.0f + (4.0f * (float)M_SQRT1_2))); + mul_v4_fl(color_mid, 1.0f / (4.0f + (4.0f * float(M_SQRT1_2)))); // mul_v4_fl(color_mid, 1.0f / w); if ((w != 0.0f) && ((w / WTOT) > (threshold_neighbor_)) && diff --git a/source/blender/compositor/operations/COM_DilateErodeOperation.cc b/source/blender/compositor/operations/COM_DilateErodeOperation.cc index a93571ebee4..9a2d5e09b33 100644 --- a/source/blender/compositor/operations/COM_DilateErodeOperation.cc +++ b/source/blender/compositor/operations/COM_DilateErodeOperation.cc @@ -181,8 +181,8 @@ static float get_min_distance(DilateErodeThresholdOperation::PixelData &p) * true. */ const TCompare compare; float min_dist = p.distance; - const float *row = p.elem + ((intptr_t)p.ymin - p.y) * p.row_stride + - ((intptr_t)p.xmin - p.x) * p.elem_stride; + const float *row = p.elem + (intptr_t(p.ymin) - p.y) * p.row_stride + + (intptr_t(p.xmin) - p.x) * p.elem_stride; for (int yi = p.ymin; yi < p.ymax; yi++) { const float dy = yi - p.y; const float dist_y = dy * dy; @@ -410,8 +410,8 @@ static float get_distance_value(DilateDistanceOperation::PixelData &p, const flo const TCompare compare; const float min_dist = p.min_distance; float value = start_value; - const float *row = p.elem + ((intptr_t)p.ymin - p.y) * p.row_stride + - ((intptr_t)p.xmin - p.x) * p.elem_stride; + const float *row = p.elem + (intptr_t(p.ymin) - p.y) * p.row_stride + + (intptr_t(p.xmin) - p.x) * p.elem_stride; for (int yi = p.ymin; yi < p.ymax; yi++) { const float dy = yi - p.y; const float dist_y = dy * dy; diff --git a/source/blender/compositor/operations/COM_DirectionalBlurOperation.cc b/source/blender/compositor/operations/COM_DirectionalBlurOperation.cc index 37e05de33db..31ff3b5f4a2 100644 --- a/source/blender/compositor/operations/COM_DirectionalBlurOperation.cc +++ b/source/blender/compositor/operations/COM_DirectionalBlurOperation.cc @@ -30,7 +30,7 @@ void DirectionalBlurOperation::init_execution() const float height = get_height(); const float a = angle; - const float itsc = 1.0f / powf(2.0f, (float)iterations); + const float itsc = 1.0f / powf(2.0f, float(iterations)); float D; D = distance * sqrtf(width * width + height * height); diff --git a/source/blender/compositor/operations/COM_DisplaceOperation.cc b/source/blender/compositor/operations/COM_DisplaceOperation.cc index 198cca0482e..bbc8c09e866 100644 --- a/source/blender/compositor/operations/COM_DisplaceOperation.cc +++ b/source/blender/compositor/operations/COM_DisplaceOperation.cc @@ -113,7 +113,7 @@ void DisplaceOperation::pixel_transform(const float xy[2], float r_uv[2], float num++; } if (num > 0) { - float numinv = 1.0f / (float)num; + float numinv = 1.0f / float(num); r_deriv[0][0] *= numinv; r_deriv[1][0] *= numinv; } @@ -130,7 +130,7 @@ void DisplaceOperation::pixel_transform(const float xy[2], float r_uv[2], float num++; } if (num > 0) { - float numinv = 1.0f / (float)num; + float numinv = 1.0f / float(num); r_deriv[0][1] *= numinv; r_deriv[1][1] *= numinv; } @@ -227,7 +227,7 @@ void DisplaceOperation::update_memory_buffer_partial(MemoryBuffer *output, { const MemoryBuffer *input_color = inputs[0]; for (BuffersIterator it = output->iterate_with({}, area); !it.is_end(); ++it) { - const float xy[2] = {(float)it.x, (float)it.y}; + const float xy[2] = {float(it.x), float(it.y)}; float uv[2]; float deriv[2][2]; diff --git a/source/blender/compositor/operations/COM_EllipseMaskOperation.cc b/source/blender/compositor/operations/COM_EllipseMaskOperation.cc index 508e5ea5712..064163801ea 100644 --- a/source/blender/compositor/operations/COM_EllipseMaskOperation.cc +++ b/source/blender/compositor/operations/COM_EllipseMaskOperation.cc @@ -19,10 +19,10 @@ void EllipseMaskOperation::init_execution() { input_mask_ = this->get_input_socket_reader(0); input_value_ = this->get_input_socket_reader(1); - const double rad = (double)data_->rotation; + const double rad = double(data_->rotation); cosine_ = cos(rad); sine_ = sin(rad); - aspect_ratio_ = ((float)this->get_width()) / this->get_height(); + aspect_ratio_ = float(this->get_width()) / this->get_height(); } void EllipseMaskOperation::execute_pixel_sampled(float output[4], diff --git a/source/blender/compositor/operations/COM_FlipOperation.cc b/source/blender/compositor/operations/COM_FlipOperation.cc index 369f124622a..3d9d574b89d 100644 --- a/source/blender/compositor/operations/COM_FlipOperation.cc +++ b/source/blender/compositor/operations/COM_FlipOperation.cc @@ -26,8 +26,8 @@ void FlipOperation::deinit_execution() void FlipOperation::execute_pixel_sampled(float output[4], float x, float y, PixelSampler sampler) { - float nx = flip_x_ ? ((int)this->get_width() - 1) - x : x; - float ny = flip_y_ ? ((int)this->get_height() - 1) - y : y; + float nx = flip_x_ ? (int(this->get_width()) - 1) - x : x; + float ny = flip_y_ ? (int(this->get_height()) - 1) - y : y; input_operation_->read_sampled(output, nx, ny, sampler); } @@ -39,7 +39,7 @@ bool FlipOperation::determine_depending_area_of_interest(rcti *input, rcti new_input; if (flip_x_) { - const int w = (int)this->get_width() - 1; + const int w = int(this->get_width()) - 1; new_input.xmax = (w - input->xmin) + 1; new_input.xmin = (w - input->xmax) - 1; } @@ -48,7 +48,7 @@ bool FlipOperation::determine_depending_area_of_interest(rcti *input, new_input.xmax = input->xmax; } if (flip_y_) { - const int h = (int)this->get_height() - 1; + const int h = int(this->get_height()) - 1; new_input.ymax = (h - input->ymin) + 1; new_input.ymin = (h - input->ymax) - 1; } @@ -85,7 +85,7 @@ void FlipOperation::get_area_of_interest(const int input_idx, BLI_assert(input_idx == 0); UNUSED_VARS_NDEBUG(input_idx); if (flip_x_) { - const int w = (int)this->get_width() - 1; + const int w = int(this->get_width()) - 1; r_input_area.xmax = (w - output_area.xmin) + 1; r_input_area.xmin = (w - output_area.xmax) + 1; } @@ -94,7 +94,7 @@ void FlipOperation::get_area_of_interest(const int input_idx, r_input_area.xmax = output_area.xmax; } if (flip_y_) { - const int h = (int)this->get_height() - 1; + const int h = int(this->get_height()) - 1; r_input_area.ymax = (h - output_area.ymin) + 1; r_input_area.ymin = (h - output_area.ymax) + 1; } @@ -112,8 +112,8 @@ void FlipOperation::update_memory_buffer_partial(MemoryBuffer *output, const int input_offset_x = input_img->get_rect().xmin; const int input_offset_y = input_img->get_rect().ymin; for (BuffersIterator it = output->iterate_with({}, area); !it.is_end(); ++it) { - const int nx = flip_x_ ? ((int)this->get_width() - 1) - it.x : it.x; - const int ny = flip_y_ ? ((int)this->get_height() - 1) - it.y : it.y; + const int nx = flip_x_ ? (int(this->get_width()) - 1) - it.x : it.x; + const int ny = flip_y_ ? (int(this->get_height()) - 1) - it.y : it.y; input_img->read_elem(input_offset_x + nx, input_offset_y + ny, it.out); } } diff --git a/source/blender/compositor/operations/COM_GaussianAlphaBlurBaseOperation.cc b/source/blender/compositor/operations/COM_GaussianAlphaBlurBaseOperation.cc index f380abf42f0..75b2249b6a7 100644 --- a/source/blender/compositor/operations/COM_GaussianAlphaBlurBaseOperation.cc +++ b/source/blender/compositor/operations/COM_GaussianAlphaBlurBaseOperation.cc @@ -114,7 +114,7 @@ void GaussianAlphaBlurBaseOperation::update_memory_buffer_partial(MemoryBuffer * float distfacinv_max = 1.0f; /* 0 to 1 */ const int step = QualityStepHelper::get_step(); - const float *in = it.in(0) + ((intptr_t)coord_min - coord) * elem_stride; + const float *in = it.in(0) + (intptr_t(coord_min) - coord) * elem_stride; const int in_stride = elem_stride * step; int index = (coord_min - coord) + filtersize_; const int index_end = index + (coord_max - coord_min); diff --git a/source/blender/compositor/operations/COM_GaussianBlurBaseOperation.cc b/source/blender/compositor/operations/COM_GaussianBlurBaseOperation.cc index 3c66f74f284..b2b10e77012 100644 --- a/source/blender/compositor/operations/COM_GaussianBlurBaseOperation.cc +++ b/source/blender/compositor/operations/COM_GaussianBlurBaseOperation.cc @@ -112,7 +112,7 @@ void GaussianBlurBaseOperation::update_memory_buffer_partial(MemoryBuffer *outpu float multiplier_accum = 0.0f; const int step = QualityStepHelper::get_step(); - const float *in = it.in(0) + ((intptr_t)coord_min - coord) * elem_stride; + const float *in = it.in(0) + (intptr_t(coord_min) - coord) * elem_stride; const int in_stride = elem_stride * step; int gauss_idx = (coord_min - coord) + filtersize_; const int gauss_end = gauss_idx + (coord_max - coord_min); diff --git a/source/blender/compositor/operations/COM_GaussianBokehBlurOperation.cc b/source/blender/compositor/operations/COM_GaussianBokehBlurOperation.cc index fa45034b00c..039e6a9bcc0 100644 --- a/source/blender/compositor/operations/COM_GaussianBokehBlurOperation.cc +++ b/source/blender/compositor/operations/COM_GaussianBokehBlurOperation.cc @@ -35,11 +35,11 @@ void GaussianBokehBlurOperation::init_data() } } - radxf_ = size_ * (float)data_.sizex; + radxf_ = size_ * float(data_.sizex); CLAMP(radxf_, 0.0f, width / 2.0f); /* Vertical. */ - radyf_ = size_ * (float)data_.sizey; + radyf_ = size_ * float(data_.sizey); CLAMP(radyf_, 0.0f, height / 2.0f); radx_ = ceil(radxf_); @@ -71,8 +71,8 @@ void GaussianBokehBlurOperation::update_gauss() float facy = (radyf_ > 0.0f ? 1.0f / radyf_ : 0.0f); for (int j = -rady_; j <= rady_; j++) { for (int i = -radx_; i <= radx_; i++, dgauss++) { - float fj = (float)j * facy; - float fi = (float)i * facx; + float fj = float(j) * facy; + float fi = float(i) * facx; float dist = sqrt(fj * fj + fi * fi); *dgauss = RE_filter_value(data_.filtertype, dist); @@ -105,10 +105,10 @@ void GaussianBokehBlurOperation::execute_pixel(float output[4], int x, int y, vo const float width = this->get_width(); const float height = this->get_height(); - radxf_ = size_ * (float)data_.sizex; + radxf_ = size_ * float(data_.sizex); CLAMP(radxf_, 0.0f, width / 2.0f); - radyf_ = size_ * (float)data_.sizey; + radyf_ = size_ * float(data_.sizey); CLAMP(radyf_, 0.0f, height / 2.0f); radx_ = ceil(radxf_); @@ -265,22 +265,22 @@ void GaussianBlurReferenceOperation::init_data() if (data_.relative) { switch (data_.aspect) { case CMP_NODE_BLUR_ASPECT_NONE: - data_.sizex = (int)(data_.percentx * 0.01f * data_.image_in_width); - data_.sizey = (int)(data_.percenty * 0.01f * data_.image_in_height); + data_.sizex = int(data_.percentx * 0.01f * data_.image_in_width); + data_.sizey = int(data_.percenty * 0.01f * data_.image_in_height); break; case CMP_NODE_BLUR_ASPECT_Y: - data_.sizex = (int)(data_.percentx * 0.01f * data_.image_in_width); - data_.sizey = (int)(data_.percenty * 0.01f * data_.image_in_width); + data_.sizex = int(data_.percentx * 0.01f * data_.image_in_width); + data_.sizey = int(data_.percenty * 0.01f * data_.image_in_width); break; case CMP_NODE_BLUR_ASPECT_X: - data_.sizex = (int)(data_.percentx * 0.01f * data_.image_in_height); - data_.sizey = (int)(data_.percenty * 0.01f * data_.image_in_height); + data_.sizex = int(data_.percentx * 0.01f * data_.image_in_height); + data_.sizey = int(data_.percenty * 0.01f * data_.image_in_height); break; } } /* Horizontal. */ - filtersizex_ = (float)data_.sizex; + filtersizex_ = float(data_.sizex); int imgx = get_width() / 2; if (filtersizex_ > imgx) { filtersizex_ = imgx; @@ -288,10 +288,10 @@ void GaussianBlurReferenceOperation::init_data() else if (filtersizex_ < 1) { filtersizex_ = 1; } - radx_ = (float)filtersizex_; + radx_ = float(filtersizex_); /* Vertical. */ - filtersizey_ = (float)data_.sizey; + filtersizey_ = float(data_.sizey); int imgy = get_height() / 2; if (filtersizey_ > imgy) { filtersizey_ = imgy; @@ -299,7 +299,7 @@ void GaussianBlurReferenceOperation::init_data() else if (filtersizey_ < 1) { filtersizey_ = 1; } - rady_ = (float)filtersizey_; + rady_ = float(filtersizey_); } void *GaussianBlurReferenceOperation::initialize_tile_data(rcti * /*rect*/) @@ -340,8 +340,8 @@ void GaussianBlurReferenceOperation::execute_pixel(float output[4], int x, int y float temp_size[4]; input_size_->read(temp_size, x, y, data); float ref_size = temp_size[0]; - int refradx = (int)(ref_size * radx_); - int refrady = (int)(ref_size * rady_); + int refradx = int(ref_size * radx_); + int refrady = int(ref_size * rady_); if (refradx > filtersizex_) { refradx = filtersizex_; } @@ -447,8 +447,8 @@ void GaussianBlurReferenceOperation::update_memory_buffer_partial(MemoryBuffer * MemoryBuffer *size_input = inputs[SIZE_INPUT_INDEX]; for (BuffersIterator it = output->iterate_with({size_input}, area); !it.is_end(); ++it) { const float ref_size = *it.in(0); - int ref_radx = (int)(ref_size * radx_); - int ref_rady = (int)(ref_size * rady_); + int ref_radx = int(ref_size * radx_); + int ref_rady = int(ref_size * rady_); if (ref_radx > filtersizex_) { ref_radx = filtersizex_; } diff --git a/source/blender/compositor/operations/COM_GlareFogGlowOperation.cc b/source/blender/compositor/operations/COM_GlareFogGlowOperation.cc index 5c4d470bc35..4f7b1be9057 100644 --- a/source/blender/compositor/operations/COM_GlareFogGlowOperation.cc +++ b/source/blender/compositor/operations/COM_GlareFogGlowOperation.cc @@ -75,8 +75,8 @@ static void FHT(fREAL *data, uint M, uint inverse) fREAL *data_nbd = &data_n[bd]; fREAL *data_bd = &data[bd]; for (k = bl; k < len; k += istep) { - t1 = fc * (double)data_n[k] + fs * (double)data_nbd[k]; - t2 = fs * (double)data_n[k] - fc * (double)data_nbd[k]; + t1 = fc * double(data_n[k]) + fs * double(data_nbd[k]); + t2 = fs * double(data_n[k]) - fc * double(data_nbd[k]); data_n[k] = data[k] - t1; data_nbd[k] = data_bd[k] - t2; data[k] += t1; @@ -360,14 +360,14 @@ static void convolve(float *dst, MemoryBuffer *in1, MemoryBuffer *in2) /* Data again transposed, so in order again. */ /* Overlap-add result. */ - for (y = 0; y < (int)h2; y++) { + for (y = 0; y < int(h2); y++) { const int yy = ybl * ybsz + y - hh; if ((yy < 0) || (yy >= image_height)) { continue; } fp = &data2[y * w2]; colp = (fRGB *)&rdst->get_buffer()[yy * image_width * COM_DATA_TYPE_COLOR_CHANNELS]; - for (x = 0; x < (int)w2; x++) { + for (x = 0; x < int(w2); x++) { const int xx = xbl * xbsz + x - hw; if ((xx < 0) || (xx >= image_width)) { continue; @@ -405,12 +405,12 @@ void GlareFogGlowOperation::generate_glare(float *data, BLI_rcti_init(&kernel_rect, 0, sz, 0, sz); ckrn = new MemoryBuffer(DataType::Color, kernel_rect); - scale = 0.25f * sqrtf((float)(sz * sz)); + scale = 0.25f * sqrtf(float(sz * sz)); for (y = 0; y < sz; y++) { - v = 2.0f * (y / (float)sz) - 1.0f; + v = 2.0f * (y / float(sz)) - 1.0f; for (x = 0; x < sz; x++) { - u = 2.0f * (x / (float)sz) - 1.0f; + u = 2.0f * (x / float(sz)) - 1.0f; r = (u * u + v * v) * scale; d = -sqrtf(sqrtf(sqrtf(r))) * 9.0f; fcol[0] = expf(d * cs_r); @@ -419,7 +419,7 @@ void GlareFogGlowOperation::generate_glare(float *data, /* Linear window good enough here, visual result counts, not scientific analysis: * `w = (1.0f-fabs(u))*(1.0f-fabs(v));` * actually, Hanning window is ok, `cos^2` for some reason is slower. */ - w = (0.5f + 0.5f * cosf(u * (float)M_PI)) * (0.5f + 0.5f * cosf(v * (float)M_PI)); + w = (0.5f + 0.5f * cosf(u * float(M_PI))) * (0.5f + 0.5f * cosf(v * float(M_PI))); mul_v3_fl(fcol, w); ckrn->write_pixel(x, y, fcol); } diff --git a/source/blender/compositor/operations/COM_GlareGhostOperation.cc b/source/blender/compositor/operations/COM_GlareGhostOperation.cc index 13b7af2329e..5ba0901231d 100644 --- a/source/blender/compositor/operations/COM_GlareGhostOperation.cc +++ b/source/blender/compositor/operations/COM_GlareGhostOperation.cc @@ -23,7 +23,7 @@ void GlareGhostOperation::generate_glare(float *data, const NodeGlare *settings) { const int qt = 1 << settings->quality; - const float s1 = 4.0f / (float)qt, s2 = 2.0f * s1; + const float s1 = 4.0f / float(qt), s2 = 2.0f * s1; int x, y, n, p, np; fRGB c, tc, cm[64]; float sc, isc, u, v, sm, s, t, ofs, scalef[64]; @@ -79,7 +79,7 @@ void GlareGhostOperation::generate_glare(float *data, if (y == 3) { fRGB_rgbmult(cm[x], cmo, 1.0f, cmo); } - scalef[x] = 2.1f * (1.0f - (x + ofs) / (float)(settings->iter * 4)); + scalef[x] = 2.1f * (1.0f - (x + ofs) / float(settings->iter * 4)); if (x & 1) { scalef[x] = -0.99f / scalef[x]; } @@ -88,9 +88,9 @@ void GlareGhostOperation::generate_glare(float *data, sc = 2.13; isc = -0.97; for (y = 0; y < gbuf.get_height() && (!breaked); y++) { - v = ((float)y + 0.5f) / (float)gbuf.get_height(); + v = (float(y) + 0.5f) / float(gbuf.get_height()); for (x = 0; x < gbuf.get_width(); x++) { - u = ((float)x + 0.5f) / (float)gbuf.get_width(); + u = (float(x) + 0.5f) / float(gbuf.get_width()); s = (u - 0.5f) * sc + 0.5f; t = (v - 0.5f) * sc + 0.5f; tbuf1.read_bilinear(c, s * gbuf.get_width(), t * gbuf.get_height()); @@ -114,9 +114,9 @@ void GlareGhostOperation::generate_glare(float *data, tbuf1.get_width() * tbuf1.get_height() * COM_DATA_TYPE_COLOR_CHANNELS * sizeof(float)); for (n = 1; n < settings->iter && (!breaked); n++) { for (y = 0; y < gbuf.get_height() && (!breaked); y++) { - v = ((float)y + 0.5f) / (float)gbuf.get_height(); + v = (float(y) + 0.5f) / float(gbuf.get_height()); for (x = 0; x < gbuf.get_width(); x++) { - u = ((float)x + 0.5f) / (float)gbuf.get_width(); + u = (float(x) + 0.5f) / float(gbuf.get_width()); tc[0] = tc[1] = tc[2] = 0.0f; for (p = 0; p < 4; p++) { np = (n << 2) + p; diff --git a/source/blender/compositor/operations/COM_GlareStreaksOperation.cc b/source/blender/compositor/operations/COM_GlareStreaksOperation.cc index 8c303ab6332..c544e13cf34 100644 --- a/source/blender/compositor/operations/COM_GlareStreaksOperation.cc +++ b/source/blender/compositor/operations/COM_GlareStreaksOperation.cc @@ -12,7 +12,7 @@ void GlareStreaksOperation::generate_glare(float *data, int x, y, n; uint nump = 0; float c1[4], c2[4], c3[4], c4[4]; - float a, ang = DEG2RADF(360.0f) / (float)settings->streaks; + float a, ang = DEG2RADF(360.0f) / float(settings->streaks); int size = input_tile->get_width() * input_tile->get_height(); int size4 = size * 4; @@ -26,14 +26,14 @@ void GlareStreaksOperation::generate_glare(float *data, for (a = 0.0f; a < DEG2RADF(360.0f) && (!breaked); a += ang) { const float an = a + settings->angle_ofs; - const float vx = cos((double)an), vy = sin((double)an); + const float vx = cos(double(an)), vy = sin(double(an)); for (n = 0; n < settings->iter && (!breaked); n++) { - const float p4 = pow(4.0, (double)n); + const float p4 = pow(4.0, double(n)); const float vxp = vx * p4, vyp = vy * p4; - const float wt = pow((double)settings->fade, (double)p4); + const float wt = pow(double(settings->fade), double(p4)); /* Color-modulation amount relative to current pass. */ - const float cmo = 1.0f - (float)pow((double)settings->colmod, (double)n + 1); + const float cmo = 1.0f - float(pow(double(settings->colmod), double(n) + 1)); float *tdstcol = tdst.get_buffer(); for (y = 0; y < tsrc.get_height() && (!breaked); y++) { @@ -72,7 +72,7 @@ void GlareStreaksOperation::generate_glare(float *data, } float *sourcebuffer = tsrc.get_buffer(); - float factor = 1.0f / (float)(6 - settings->iter); + float factor = 1.0f / float(6 - settings->iter); for (int i = 0; i < size4; i += 4) { madd_v3_v3fl(&data[i], &sourcebuffer[i], factor); data[i + 3] = 1.0f; diff --git a/source/blender/compositor/operations/COM_KeyingBlurOperation.cc b/source/blender/compositor/operations/COM_KeyingBlurOperation.cc index 71699f23a4b..4ae11c04506 100644 --- a/source/blender/compositor/operations/COM_KeyingBlurOperation.cc +++ b/source/blender/compositor/operations/COM_KeyingBlurOperation.cc @@ -48,7 +48,7 @@ void KeyingBlurOperation::execute_pixel(float output[4], int x, int y, void *dat } } - average /= (float)count; + average /= float(count); output[0] = average; } diff --git a/source/blender/compositor/operations/COM_KeyingClipOperation.cc b/source/blender/compositor/operations/COM_KeyingClipOperation.cc index bb951aaa938..2cbdfaa6a01 100644 --- a/source/blender/compositor/operations/COM_KeyingClipOperation.cc +++ b/source/blender/compositor/operations/COM_KeyingClipOperation.cc @@ -47,7 +47,7 @@ void KeyingClipOperation::execute_pixel(float output[4], int x, int y, void *dat end_y = min_ff(y + delta - 1, buffer_height - 1); int count = 0, total_count = (end_x - start_x + 1) * (end_y - start_y + 1) - 1; - int threshold_count = ceil((float)total_count * 0.9f); + int threshold_count = ceil(float(total_count) * 0.9f); if (delta == 0) { ok = true; @@ -147,7 +147,7 @@ void KeyingClipOperation::update_memory_buffer_partial(MemoryBuffer *output, const int y_len = end_y - start_y; const int total_count = x_len * y_len - 1; - const int threshold_count = ceil((float)total_count * 0.9f); + const int threshold_count = ceil(float(total_count) * 0.9f); bool ok = false; if (delta == 0) { ok = true; diff --git a/source/blender/compositor/operations/COM_KeyingScreenOperation.cc b/source/blender/compositor/operations/COM_KeyingScreenOperation.cc index c037a1e0330..5c5bf5534a7 100644 --- a/source/blender/compositor/operations/COM_KeyingScreenOperation.cc +++ b/source/blender/compositor/operations/COM_KeyingScreenOperation.cc @@ -152,9 +152,9 @@ KeyingScreenOperation::TriangulationData *KeyingScreenOperation::build_voronoi_t else { uchar *rrgb = (uchar *)pattern_ibuf->rect; - site->color[0] += srgb_to_linearrgb((float)rrgb[4 * j + 0] / 255.0f); - site->color[1] += srgb_to_linearrgb((float)rrgb[4 * j + 1] / 255.0f); - site->color[2] += srgb_to_linearrgb((float)rrgb[4 * j + 2] / 255.0f); + site->color[0] += srgb_to_linearrgb(float(rrgb[4 * j + 0]) / 255.0f); + site->color[1] += srgb_to_linearrgb(float(rrgb[4 * j + 1]) / 255.0f); + site->color[2] += srgb_to_linearrgb(float(rrgb[4 * j + 2]) / 255.0f); } } @@ -204,11 +204,11 @@ KeyingScreenOperation::TriangulationData *KeyingScreenOperation::build_voronoi_t minmax_v2v2_v2(min, max, b->co); minmax_v2v2_v2(min, max, c->co); - rect->xmin = (int)min[0]; - rect->ymin = (int)min[1]; + rect->xmin = int(min[0]); + rect->ymin = int(min[1]); - rect->xmax = (int)max[0] + 1; - rect->ymax = (int)max[1] + 1; + rect->xmax = int(max[0]) + 1; + rect->ymax = int(max[1]) + 1; } } @@ -311,7 +311,7 @@ void KeyingScreenOperation::execute_pixel(float output[4], int x, int y, void *d TriangulationData *triangulation = cached_triangulation_; TileData *tile_data = (TileData *)data; int i; - float co[2] = {(float)x, (float)y}; + float co[2] = {float(x), float(y)}; for (i = 0; i < tile_data->triangles_total; i++) { int triangle_idx = tile_data->triangles[i]; @@ -356,7 +356,7 @@ void KeyingScreenOperation::update_memory_buffer_partial(MemoryBuffer *output, for (BuffersIterator it = output->iterate_with(inputs, area); !it.is_end(); ++it) { copy_v4_v4(it.out, COM_COLOR_BLACK); - const float co[2] = {(float)it.x, (float)it.y}; + const float co[2] = {float(it.x), float(it.y)}; for (int i = 0; i < num_triangles; i++) { const int triangle_idx = triangles[i]; const rcti *rect = &triangulation->triangles_AABB[triangle_idx]; diff --git a/source/blender/compositor/operations/COM_MapUVOperation.cc b/source/blender/compositor/operations/COM_MapUVOperation.cc index 40f91a04134..e6899949528 100644 --- a/source/blender/compositor/operations/COM_MapUVOperation.cc +++ b/source/blender/compositor/operations/COM_MapUVOperation.cc @@ -124,7 +124,7 @@ void MapUVOperation::pixel_transform(const float xy[2], num++; } if (num > 0) { - float numinv = 1.0f / (float)num; + float numinv = 1.0f / float(num); r_deriv[0][0] *= numinv; r_deriv[1][0] *= numinv; } @@ -141,7 +141,7 @@ void MapUVOperation::pixel_transform(const float xy[2], num++; } if (num > 0) { - float numinv = 1.0f / (float)num; + float numinv = 1.0f / float(num); r_deriv[0][1] *= numinv; r_deriv[1][1] *= numinv; } @@ -217,7 +217,7 @@ void MapUVOperation::update_memory_buffer_partial(MemoryBuffer *output, { const MemoryBuffer *input_image = inputs[IMAGE_INPUT_INDEX]; for (BuffersIterator it = output->iterate_with({}, area); !it.is_end(); ++it) { - float xy[2] = {(float)it.x, (float)it.y}; + float xy[2] = {float(it.x), float(it.y)}; float uv[2]; float deriv[2][2]; float alpha; diff --git a/source/blender/compositor/operations/COM_MaskOperation.cc b/source/blender/compositor/operations/COM_MaskOperation.cc index 5517306f1af..d8b7c52d9d7 100644 --- a/source/blender/compositor/operations/COM_MaskOperation.cc +++ b/source/blender/compositor/operations/COM_MaskOperation.cc @@ -33,7 +33,7 @@ void MaskOperation::init_execution() } else { /* make a throw away copy of the mask */ - const float frame = (float)frame_number_ - frame_shutter_; + const float frame = float(frame_number_) - frame_shutter_; const float frame_step = (frame_shutter_ * 2.0f) / raster_mask_handle_tot_; float frame_iter = frame; diff --git a/source/blender/compositor/operations/COM_MovieDistortionOperation.cc b/source/blender/compositor/operations/COM_MovieDistortionOperation.cc index ea3aad20792..b89a48f2a39 100644 --- a/source/blender/compositor/operations/COM_MovieDistortionOperation.cc +++ b/source/blender/compositor/operations/COM_MovieDistortionOperation.cc @@ -81,10 +81,10 @@ void MovieDistortionOperation::execute_pixel_sampled(float output[4], if (distortion_ != nullptr) { /* float overscan = 0.0f; */ const float pixel_aspect = pixel_aspect_; - const float w = (float)this->get_width() /* / (1 + overscan) */; - const float h = (float)this->get_height() /* / (1 + overscan) */; - const float aspx = w / (float)calibration_width_; - const float aspy = h / (float)calibration_height_; + const float w = float(this->get_width()) /* / (1 + overscan) */; + const float h = float(this->get_height()) /* / (1 + overscan) */; + const float aspx = w / float(calibration_width_); + const float aspy = h / float(calibration_height_); float in[2]; float out[2]; @@ -143,10 +143,10 @@ void MovieDistortionOperation::update_memory_buffer_partial(MemoryBuffer *output /* `float overscan = 0.0f;` */ const float pixel_aspect = pixel_aspect_; - const float w = (float)this->get_width() /* `/ (1 + overscan)` */; - const float h = (float)this->get_height() /* `/ (1 + overscan)` */; - const float aspx = w / (float)calibration_width_; - const float aspy = h / (float)calibration_height_; + const float w = float(this->get_width()) /* `/ (1 + overscan)` */; + const float h = float(this->get_height()) /* `/ (1 + overscan)` */; + const float aspx = w / float(calibration_width_); + const float aspy = h / float(calibration_height_); float xy[2]; float distorted_xy[2]; for (BuffersIterator it = output->iterate_with({}, area); !it.is_end(); ++it) { diff --git a/source/blender/compositor/operations/COM_MultilayerImageOperation.cc b/source/blender/compositor/operations/COM_MultilayerImageOperation.cc index fec7c1972f3..991a909ddb7 100644 --- a/source/blender/compositor/operations/COM_MultilayerImageOperation.cc +++ b/source/blender/compositor/operations/COM_MultilayerImageOperation.cc @@ -93,7 +93,7 @@ void MultilayerColorOperation::execute_pixel_sampled(float output[4], else { int yi = y; int xi = x; - if (xi < 0 || yi < 0 || (uint)xi >= this->get_width() || (uint)yi >= this->get_height()) { + if (xi < 0 || yi < 0 || uint(xi) >= this->get_width() || uint(yi) >= this->get_height()) { zero_v4(output); } else { @@ -115,7 +115,7 @@ void MultilayerValueOperation::execute_pixel_sampled(float output[4], else { int yi = y; int xi = x; - if (xi < 0 || yi < 0 || (uint)xi >= this->get_width() || (uint)yi >= this->get_height()) { + if (xi < 0 || yi < 0 || uint(xi) >= this->get_width() || uint(yi) >= this->get_height()) { output[0] = 0.0f; } else { @@ -136,7 +136,7 @@ void MultilayerVectorOperation::execute_pixel_sampled(float output[4], else { int yi = y; int xi = x; - if (xi < 0 || yi < 0 || (uint)xi >= this->get_width() || (uint)yi >= this->get_height()) { + if (xi < 0 || yi < 0 || uint(xi) >= this->get_width() || uint(yi) >= this->get_height()) { output[0] = 0.0f; } else { diff --git a/source/blender/compositor/operations/COM_PlaneDistortCommonOperation.cc b/source/blender/compositor/operations/COM_PlaneDistortCommonOperation.cc index 9c19f55e04f..18b43f73356 100644 --- a/source/blender/compositor/operations/COM_PlaneDistortCommonOperation.cc +++ b/source/blender/compositor/operations/COM_PlaneDistortCommonOperation.cc @@ -82,7 +82,7 @@ void PlaneDistortWarpImageOperation::calculate_corners(const float corners[4][2] } float frame_corners[4][2] = { - {0.0f, 0.0f}, {(float)width, 0.0f}, {(float)width, (float)height}, {0.0f, (float)height}}; + {0.0f, 0.0f}, {float(width), 0.0f}, {float(width), float(height)}, {0.0f, float(height)}}; BKE_tracking_homography_between_two_quads( sample_data->frame_space_corners, frame_corners, sample_data->perspective_matrix); } @@ -116,7 +116,7 @@ void PlaneDistortWarpImageOperation::execute_pixel_sampled(float output[4], pixel_reader_->read_filtered(color, uv[0], uv[1], deriv[0], deriv[1]); add_v4_v4(output, color); } - mul_v4_fl(output, 1.0f / (float)motion_blur_samples_); + mul_v4_fl(output, 1.0f / float(motion_blur_samples_)); } } @@ -143,7 +143,7 @@ void PlaneDistortWarpImageOperation::update_memory_buffer_partial(MemoryBuffer * input_img->read_elem_filtered(uv[0], uv[1], deriv[0], deriv[1], color); add_v4_v4(it.out, color); } - mul_v4_fl(it.out, 1.0f / (float)motion_blur_samples_); + mul_v4_fl(it.out, 1.0f / float(motion_blur_samples_)); } } } @@ -258,7 +258,7 @@ void PlaneDistortMaskOperation::execute_pixel_sampled(float output[4], inside_counter++; } } - output[0] = (float)inside_counter / osa_; + output[0] = float(inside_counter) / osa_; } else { for (int motion_sample = 0; motion_sample < motion_blur_samples_; motion_sample++) { @@ -278,7 +278,7 @@ void PlaneDistortMaskOperation::execute_pixel_sampled(float output[4], } } } - output[0] = (float)inside_counter / (osa_ * motion_blur_samples_); + output[0] = float(inside_counter) / (osa_ * motion_blur_samples_); } } @@ -292,7 +292,7 @@ void PlaneDistortMaskOperation::update_memory_buffer_partial(MemoryBuffer *outpu MotionSample &sample = samples_[motion_sample]; inside_count += get_jitter_samples_inside_count(it.x, it.y, sample); } - *it.out = (float)inside_count / (osa_ * motion_blur_samples_); + *it.out = float(inside_count) / (osa_ * motion_blur_samples_); } } diff --git a/source/blender/compositor/operations/COM_PlaneTrackOperation.cc b/source/blender/compositor/operations/COM_PlaneTrackOperation.cc index 7d515284737..f5922d54fc9 100644 --- a/source/blender/compositor/operations/COM_PlaneTrackOperation.cc +++ b/source/blender/compositor/operations/COM_PlaneTrackOperation.cc @@ -28,7 +28,7 @@ void PlaneTrackCommon::read_and_calculate_corners(PlaneDistortBaseOperation *dis distort_op->calculate_corners(corners, true, 0); } else { - const float frame = (float)framenumber_ - distort_op->motion_blur_shutter_; + const float frame = float(framenumber_) - distort_op->motion_blur_shutter_; const float frame_step = (distort_op->motion_blur_shutter_ * 2.0f) / distort_op->motion_blur_samples_; float frame_iter = frame; diff --git a/source/blender/compositor/operations/COM_PreviewOperation.cc b/source/blender/compositor/operations/COM_PreviewOperation.cc index 2a6d858f91c..cf48942c542 100644 --- a/source/blender/compositor/operations/COM_PreviewOperation.cc +++ b/source/blender/compositor/operations/COM_PreviewOperation.cc @@ -39,7 +39,7 @@ void PreviewOperation::init_execution() { input_ = get_input_socket_reader(0); - if (this->get_width() == (uint)preview_->xsize && this->get_height() == (uint)preview_->ysize) { + if (this->get_width() == uint(preview_->xsize) && this->get_height() == uint(preview_->ysize)) { output_buffer_ = preview_->rect; } @@ -124,10 +124,10 @@ void PreviewOperation::determine_canvas(const rcti &UNUSED(preferred_area), rcti divider_ = 0.0f; if (width > 0 && height > 0) { if (width > height) { - divider_ = (float)COM_PREVIEW_SIZE / (width); + divider_ = float(COM_PREVIEW_SIZE) / (width); } else { - divider_ = (float)COM_PREVIEW_SIZE / (height); + divider_ = float(COM_PREVIEW_SIZE) / (height); } } width = width * divider_; diff --git a/source/blender/compositor/operations/COM_RenderLayersProg.cc b/source/blender/compositor/operations/COM_RenderLayersProg.cc index fa9efbe15be..e390ab38c7f 100644 --- a/source/blender/compositor/operations/COM_RenderLayersProg.cc +++ b/source/blender/compositor/operations/COM_RenderLayersProg.cc @@ -323,8 +323,8 @@ void RenderLayersDepthProg::execute_pixel_sampled(float output[4], int iy = y; float *input_buffer = this->get_input_buffer(); - if (input_buffer == nullptr || ix < 0 || iy < 0 || ix >= (int)this->get_width() || - iy >= (int)this->get_height()) { + if (input_buffer == nullptr || ix < 0 || iy < 0 || ix >= int(this->get_width()) || + iy >= int(this->get_height())) { output[0] = 10e10f; } else { diff --git a/source/blender/compositor/operations/COM_RotateOperation.cc b/source/blender/compositor/operations/COM_RotateOperation.cc index 79f8cf5fc51..b0854cace52 100644 --- a/source/blender/compositor/operations/COM_RotateOperation.cc +++ b/source/blender/compositor/operations/COM_RotateOperation.cc @@ -143,7 +143,7 @@ inline void RotateOperation::ensure_degree() double rad; if (do_degree2_rad_conversion_) { - rad = DEG2RAD((double)degree[0]); + rad = DEG2RAD(double(degree[0])); } else { rad = degree[0]; diff --git a/source/blender/compositor/operations/COM_SMAAOperation.cc b/source/blender/compositor/operations/COM_SMAAOperation.cc index 55983572ede..7bbc600cda2 100644 --- a/source/blender/compositor/operations/COM_SMAAOperation.cc +++ b/source/blender/compositor/operations/COM_SMAAOperation.cc @@ -65,7 +65,7 @@ static void sample_bilinear_vertical(T *reader, int x, int y, float yoffset, flo { float iy = floorf(yoffset); float fy = yoffset - iy; - y += (int)iy; + y += int(iy); float color00[4], color01[4]; @@ -83,7 +83,7 @@ static void sample_bilinear_horizontal(T *reader, int x, int y, float xoffset, f { float ix = floorf(xoffset); float fx = xoffset - ix; - x += (int)ix; + x += int(ix); float color00[4], color10[4]; @@ -113,12 +113,12 @@ static inline const float *areatex_sample_internal(const float *areatex, int x, static void area(int d1, int d2, int e1, int e2, float weights[2]) { /* The areas texture is compressed quadratically: */ - float x = (float)(SMAA_AREATEX_MAX_DISTANCE * e1) + sqrtf((float)d1); - float y = (float)(SMAA_AREATEX_MAX_DISTANCE * e2) + sqrtf((float)d2); + float x = float(SMAA_AREATEX_MAX_DISTANCE * e1) + sqrtf(float(d1)); + float y = float(SMAA_AREATEX_MAX_DISTANCE * e2) + sqrtf(float(d2)); float ix = floorf(x), iy = floorf(y); float fx = x - ix, fy = y - iy; - int X = (int)ix, Y = (int)iy; + int X = int(ix), Y = int(iy); const float *weights00 = areatex_sample_internal(areatex, X + 0, Y + 0); const float *weights10 = areatex_sample_internal(areatex, X + 1, Y + 0); diff --git a/source/blender/compositor/operations/COM_ScaleOperation.cc b/source/blender/compositor/operations/COM_ScaleOperation.cc index 2a2aff31893..cc914239caf 100644 --- a/source/blender/compositor/operations/COM_ScaleOperation.cc +++ b/source/blender/compositor/operations/COM_ScaleOperation.cc @@ -16,7 +16,7 @@ namespace blender::compositor { BaseScaleOperation::BaseScaleOperation() { #ifdef USE_FORCE_BILINEAR - sampler_ = (int)PixelSampler::Bilinear; + sampler_ = int(PixelSampler::Bilinear); #else sampler_ = -1; #endif @@ -372,8 +372,8 @@ void ScaleFixedSizeOperation::init_data(const rcti &input_canvas) { const int input_width = BLI_rcti_size_x(&input_canvas); const int input_height = BLI_rcti_size_y(&input_canvas); - rel_x_ = input_width / (float)new_width_; - rel_y_ = input_height / (float)new_height_; + rel_x_ = input_width / float(new_width_); + rel_y_ = input_height / float(new_height_); /* *** all the options below are for a fairly special case - camera framing *** */ if (offset_x_ != 0.0f || offset_y_ != 0.0f) { diff --git a/source/blender/compositor/operations/COM_ScreenLensDistortionOperation.cc b/source/blender/compositor/operations/COM_ScreenLensDistortionOperation.cc index 0fc5589a3df..e27ffcb7c9b 100644 --- a/source/blender/compositor/operations/COM_ScreenLensDistortionOperation.cc +++ b/source/blender/compositor/operations/COM_ScreenLensDistortionOperation.cc @@ -40,8 +40,8 @@ void ScreenLensDistortionOperation::set_dispersion(float dispersion) void ScreenLensDistortionOperation::init_data() { - cx_ = 0.5f * (float)get_width(); - cy_ = 0.5f * (float)get_height(); + cx_ = 0.5f * float(get_width()); + cy_ = 0.5f * float(get_height()); switch (execution_model_) { case eExecutionModel::FullFrame: { @@ -72,8 +72,8 @@ void ScreenLensDistortionOperation::init_execution() input_program_ = this->get_input_socket_reader(0); this->init_mutex(); - uint rng_seed = (uint)(PIL_check_seconds_timer_i() & UINT_MAX); - rng_seed ^= (uint)POINTER_AS_INT(input_program_); + uint rng_seed = uint(PIL_check_seconds_timer_i() & UINT_MAX); + rng_seed ^= uint(POINTER_AS_INT(input_program_)); rng_ = BLI_rng_new(rng_seed); } @@ -147,8 +147,8 @@ void ScreenLensDistortionOperation::accumulate(const MemoryBuffer *buffer, float color[4]; float dsf = len_v2v2(delta[a], delta[b]) + 1.0f; - int ds = jitter_ ? (dsf < 4.0f ? 2 : (int)sqrtf(dsf)) : (int)dsf; - float sd = 1.0f / (float)ds; + int ds = jitter_ ? (dsf < 4.0f ? 2 : int(sqrtf(dsf))) : int(dsf); + float sd = 1.0f / float(ds); float k4 = k4_[a]; float dk4 = dk4_[a]; @@ -178,7 +178,7 @@ void ScreenLensDistortionOperation::accumulate(const MemoryBuffer *buffer, void ScreenLensDistortionOperation::execute_pixel(float output[4], int x, int y, void *data) { MemoryBuffer *buffer = (MemoryBuffer *)data; - float xy[2] = {(float)x, (float)y}; + float xy[2] = {float(x), float(y)}; float uv[2]; get_uv(xy, uv); float uv_dot = len_squared_v2(uv); @@ -196,13 +196,13 @@ void ScreenLensDistortionOperation::execute_pixel(float output[4], int x, int y, accumulate(buffer, 1, 2, uv_dot, uv, delta, sum, count); if (count[0]) { - output[0] = 2.0f * sum[0] / (float)count[0]; + output[0] = 2.0f * sum[0] / float(count[0]); } if (count[1]) { - output[1] = 2.0f * sum[1] / (float)count[1]; + output[1] = 2.0f * sum[1] / float(count[1]); } if (count[2]) { - output[2] = 2.0f * sum[2] / (float)count[2]; + output[2] = 2.0f * sum[2] / float(count[2]); } /* set alpha */ @@ -485,7 +485,7 @@ void ScreenLensDistortionOperation::update_memory_buffer_partial(MemoryBuffer *o { const MemoryBuffer *input_image = inputs[0]; for (BuffersIterator it = output->iterate_with({}, area); !it.is_end(); ++it) { - float xy[2] = {(float)it.x, (float)it.y}; + float xy[2] = {float(it.x), float(it.y)}; float uv[2]; get_uv(xy, uv); const float uv_dot = len_squared_v2(uv); @@ -505,13 +505,13 @@ void ScreenLensDistortionOperation::update_memory_buffer_partial(MemoryBuffer *o accumulate(input_image, 1, 2, uv_dot, uv, delta, sum, count); if (count[0]) { - it.out[0] = 2.0f * sum[0] / (float)count[0]; + it.out[0] = 2.0f * sum[0] / float(count[0]); } if (count[1]) { - it.out[1] = 2.0f * sum[1] / (float)count[1]; + it.out[1] = 2.0f * sum[1] / float(count[1]); } if (count[2]) { - it.out[2] = 2.0f * sum[2] / (float)count[2]; + it.out[2] = 2.0f * sum[2] / float(count[2]); } /* Set alpha. */ diff --git a/source/blender/compositor/operations/COM_SunBeamsOperation.cc b/source/blender/compositor/operations/COM_SunBeamsOperation.cc index 1628c0fa1f8..94674c8fd6c 100644 --- a/source/blender/compositor/operations/COM_SunBeamsOperation.cc +++ b/source/blender/compositor/operations/COM_SunBeamsOperation.cc @@ -52,18 +52,18 @@ template struct BufferLineAccumulator { static inline void buffer_to_sector(const float source[2], float x, float y, float &u, float &v) { - int x0 = (int)source[0]; - int y0 = (int)source[1]; - x -= (float)x0; - y -= (float)y0; + int x0 = int(source[0]); + int y0 = int(source[1]); + x -= float(x0); + y -= float(y0); u = x * fxu + y * fyu; v = x * fxv + y * fyv; } static inline void sector_to_buffer(const float source[2], int u, int v, int &x, int &y) { - int x0 = (int)source[0]; - int y0 = (int)source[1]; + int x0 = int(source[0]); + int y0 = int(source[1]); x = x0 + u * fxu + v * fxv; y = y0 + u * fyu + v * fyv; } @@ -95,7 +95,7 @@ template struct BufferLineAccumulator { buffer_to_sector(source, co[0], co[1], pu, pv); /* line angle */ - double tan_phi = pv / (double)pu; + double tan_phi = pv / double(pu); double dr = sqrt(tan_phi * tan_phi + 1.0); double cos_phi = 1.0 / dr; @@ -105,13 +105,13 @@ template struct BufferLineAccumulator { v = umin * tan_phi; dv = tan_phi; - int start = (int)floorf(umax); - int end = (int)ceilf(umin); + int start = int(floorf(umax)); + int end = int(ceilf(umin)); num = end - start; - sector_to_buffer(source, end, (int)ceilf(v), x, y); + sector_to_buffer(source, end, int(ceilf(v)), x, y); - falloff_factor = dist_max > dist_min ? dr / (double)(dist_max - dist_min) : 0.0f; + falloff_factor = dist_max > dist_min ? dr / double(dist_max - dist_min) : 0.0f; float *iter = input->get_buffer() + input->get_coords_offset(x, y); return iter; @@ -139,7 +139,7 @@ template struct BufferLineAccumulator { zero_v4(output); - if ((int)(co[0] - source[0]) == 0 && (int)(co[1] - source[1]) == 0) { + if (int(co[0] - source[0]) == 0 && int(co[1] - source[1]) == 0) { copy_v4_v4(output, input->get_elem(source[0], source[1])); return; } @@ -154,7 +154,7 @@ template struct BufferLineAccumulator { float v_local = v - floorf(v); for (int i = 0; i < num; i++) { - float weight = 1.0f - (float)i * falloff_factor; + float weight = 1.0f - float(i) * falloff_factor; weight *= weight; /* range check, use last valid color when running beyond the image border */ @@ -195,7 +195,7 @@ template struct BufferLineAccumulator { /* normalize */ if (num > 0) { - mul_v4_fl(output, 1.0f / (float)num); + mul_v4_fl(output, 1.0f / float(num)); } } }; @@ -288,14 +288,14 @@ void *SunBeamsOperation::initialize_tile_data(rcti * /*rect*/) void SunBeamsOperation::execute_pixel(float output[4], int x, int y, void *data) { - const float co[2] = {(float)x, (float)y}; + const float co[2] = {float(x), float(y)}; accumulate_line((MemoryBuffer *)data, output, co, source_px_, 0.0f, ray_length_px_); } static void calc_ray_shift(rcti *rect, float x, float y, const float source[2], float ray_length) { - float co[2] = {(float)x, (float)y}; + float co[2] = {float(x), float(y)}; float dir[2], dist; /* move (x,y) vector toward the source by ray_length distance */ @@ -304,7 +304,7 @@ static void calc_ray_shift(rcti *rect, float x, float y, const float source[2], mul_v2_fl(dir, min_ff(dist, ray_length)); sub_v2_v2(co, dir); - int ico[2] = {(int)co[0], (int)co[1]}; + int ico[2] = {int(co[0]), int(co[1])}; BLI_rcti_do_minmax_v(rect, ico); } diff --git a/source/blender/compositor/operations/COM_TonemapOperation.cc b/source/blender/compositor/operations/COM_TonemapOperation.cc index 714625e483d..ae5b60c4912 100644 --- a/source/blender/compositor/operations/COM_TonemapOperation.cc +++ b/source/blender/compositor/operations/COM_TonemapOperation.cc @@ -120,11 +120,11 @@ void *TonemapOperation::initialize_tile_data(rcti *rect) } data->lav = Lav * sc; mul_v3_v3fl(data->cav, cav, sc); - maxl = log((double)maxl + 1e-5); - minl = log((double)minl + 1e-5); + maxl = log(double(maxl) + 1e-5); + minl = log(double(minl) + 1e-5); avl = lsum * sc; data->auto_key = (maxl > minl) ? ((maxl - avl) / (maxl - minl)) : 1.0f; - float al = exp((double)avl); + float al = exp(double(avl)); data->al = (al == 0.0f) ? 0.0f : (data_->key / al); data->igm = (data_->gamma == 0.0f) ? 1 : (1.0f / data_->gamma); cached_instance_ = data; @@ -193,11 +193,11 @@ void TonemapOperation::update_memory_buffer_started(MemoryBuffer *UNUSED(output) AvgLogLum *avg = new AvgLogLum(); avg->lav = lum.sum / lum.num_pixels; mul_v3_v3fl(avg->cav, lum.color_sum, 1.0f / lum.num_pixels); - const float max_log = log((double)lum.max + 1e-5); - const float min_log = log((double)lum.min + 1e-5); + const float max_log = log(double(lum.max) + 1e-5); + const float min_log = log(double(lum.min) + 1e-5); const float avg_log = lum.log_sum / lum.num_pixels; avg->auto_key = (max_log > min_log) ? ((max_log - avg_log) / (max_log - min_log)) : 1.0f; - const float al = exp((double)avg_log); + const float al = exp(double(avg_log)); avg->al = (al == 0.0f) ? 0.0f : (data_->key / al); avg->igm = (data_->gamma == 0.0f) ? 1 : (1.0f / data_->gamma); cached_instance_ = avg; diff --git a/source/blender/compositor/operations/COM_TransformOperation.cc b/source/blender/compositor/operations/COM_TransformOperation.cc index 36a4899ef53..0db018a3dc0 100644 --- a/source/blender/compositor/operations/COM_TransformOperation.cc +++ b/source/blender/compositor/operations/COM_TransformOperation.cc @@ -38,7 +38,7 @@ void TransformOperation::init_data() translate_factor_y_; const float degree = get_input_operation(DEGREE_INPUT_INDEX)->get_constant_value_default(0.0f); - const double rad = convert_degree_to_rad_ ? DEG2RAD((double)degree) : degree; + const double rad = convert_degree_to_rad_ ? DEG2RAD(double(degree)) : degree; rotate_cosine_ = cos(rad); rotate_sine_ = sin(rad); diff --git a/source/blender/compositor/operations/COM_VariableSizeBokehBlurOperation.cc b/source/blender/compositor/operations/COM_VariableSizeBokehBlurOperation.cc index 9a02bd70586..bf6ee64c73f 100644 --- a/source/blender/compositor/operations/COM_VariableSizeBokehBlurOperation.cc +++ b/source/blender/compositor/operations/COM_VariableSizeBokehBlurOperation.cc @@ -61,7 +61,7 @@ void *VariableSizeBokehBlurOperation::initialize_tile_data(rcti *rect) const float max_dim = MAX2(this->get_width(), this->get_height()); const float scalar = do_size_scale_ ? (max_dim / 100.0f) : 1.0f; - data->max_blur_scalar = (int)(data->size->get_max_value(rect2) * scalar); + data->max_blur_scalar = int(data->size->get_max_value(rect2) * scalar); CLAMP(data->max_blur_scalar, 1.0f, max_blur_); return data; } @@ -106,8 +106,8 @@ void VariableSizeBokehBlurOperation::execute_pixel(float output[4], int x, int y #else int minx = MAX2(x - max_blur_scalar, 0); int miny = MAX2(y - max_blur_scalar, 0); - int maxx = MIN2(x + max_blur_scalar, (int)get_width()); - int maxy = MIN2(y + max_blur_scalar, (int)get_height()); + int maxx = MIN2(x + max_blur_scalar, int(get_width())); + int maxy = MIN2(y + max_blur_scalar, int(get_height())); #endif { input_size_buffer->read_no_check(temp_size, x, y); @@ -134,10 +134,10 @@ void VariableSizeBokehBlurOperation::execute_pixel(float output[4], int x, int y float dx = nx - x; if (size > fabsf(dx) && size > fabsf(dy)) { float uv[2] = { - (float)(COM_BLUR_BOKEH_PIXELS / 2) + - (dx / size) * (float)((COM_BLUR_BOKEH_PIXELS / 2) - 1), - (float)(COM_BLUR_BOKEH_PIXELS / 2) + - (dy / size) * (float)((COM_BLUR_BOKEH_PIXELS / 2) - 1), + float(COM_BLUR_BOKEH_PIXELS / 2) + + (dx / size) * float((COM_BLUR_BOKEH_PIXELS / 2) - 1), + float(COM_BLUR_BOKEH_PIXELS / 2) + + (dy / size) * float((COM_BLUR_BOKEH_PIXELS / 2) - 1), }; input_bokeh_buffer->read(bokeh, uv[0], uv[1]); madd_v4_v4v4(color_accum, bokeh, &input_program_float_buffer[offset_color_nx_ny]); @@ -185,7 +185,7 @@ void VariableSizeBokehBlurOperation::execute_opencl( const float max_dim = MAX2(get_width(), get_height()); cl_float scalar = do_size_scale_ ? (max_dim / 100.0f) : 1.0f; - max_blur = (cl_int)min_ff(size_memory_buffer->get_max_value() * scalar, (float)max_blur_); + max_blur = (cl_int)min_ff(size_memory_buffer->get_max_value() * scalar, float(max_blur_)); device->COM_cl_attach_memory_buffer_to_kernel_parameter( defocus_kernel, 0, -1, cl_mem_to_clean_up, input_memory_buffers, input_program_); @@ -358,10 +358,10 @@ static void blur_pixel(int x, int y, PixelData &p) /* XXX: There is no way to ensure bokeh input is an actual bokeh with #COM_BLUR_BOKEH_PIXELS * size, anything may be connected. Use the real input size and remove asserts? */ - const float u = (float)(COM_BLUR_BOKEH_PIXELS / 2) + - (dx / size) * (float)((COM_BLUR_BOKEH_PIXELS / 2) - 1); - const float v = (float)(COM_BLUR_BOKEH_PIXELS / 2) + - (dy / size) * (float)((COM_BLUR_BOKEH_PIXELS / 2) - 1); + const float u = float(COM_BLUR_BOKEH_PIXELS / 2) + + (dx / size) * float((COM_BLUR_BOKEH_PIXELS / 2) - 1); + const float v = float(COM_BLUR_BOKEH_PIXELS / 2) + + (dy / size) * float((COM_BLUR_BOKEH_PIXELS / 2) - 1); float bokeh[4]; p.bokeh_input->read_elem_checked(u, v, bokeh); madd_v4_v4v4(p.color_accum, bokeh, color); diff --git a/source/blender/compositor/operations/COM_VectorBlurOperation.cc b/source/blender/compositor/operations/COM_VectorBlurOperation.cc index 75d6bba713d..c71d88695a7 100644 --- a/source/blender/compositor/operations/COM_VectorBlurOperation.cc +++ b/source/blender/compositor/operations/COM_VectorBlurOperation.cc @@ -388,9 +388,9 @@ static void zbuf_fill_in_rgba( xx1 = (x0 * v1[0] + y0 * v1[1]) / z0 + v1[2]; - zxd = -(double)x0 / (double)z0; - zyd = -(double)y0 / (double)z0; - zy0 = ((double)my2) * zyd + (double)xx1; + zxd = -double(x0) / double(z0); + zyd = -double(y0) / double(z0); + zy0 = double(my2) * zyd + double(xx1); /* start-offset in rect */ rectx = zspan->rectx; @@ -422,13 +422,13 @@ static void zbuf_fill_in_rgba( } if (sn2 >= sn1) { - zverg = (double)sn1 * zxd + zy0; + zverg = double(sn1) * zxd + zy0; rz = rectzofs + sn1; rp = rectpofs + sn1; x = sn2 - sn1; while (x >= 0) { - if (zverg < (double)*rz) { + if (zverg < double(*rz)) { *rz = zverg; *rp = *col; } @@ -593,15 +593,15 @@ void zbuf_accumulate_vecblur(NodeBlurData *nbd, const float *dimg, *dz, *ro; float *rectvz, *dvz, *dvec1, *dvec2, *dz1, *dz2, *rectz; float *minvecbufrect = nullptr, *rectweight, *rw, *rectmax, *rm; - float maxspeedsq = (float)nbd->maxspeed * nbd->maxspeed; + float maxspeedsq = float(nbd->maxspeed) * nbd->maxspeed; int y, x, step, maxspeed = nbd->maxspeed, samples = nbd->samples; int tsktsk = 0; static int firsttime = 1; char *rectmove, *dm; zbuf_alloc_span(&zspan, xsize, ysize, 1.0f); - zspan.zmulx = ((float)xsize) / 2.0f; - zspan.zmuly = ((float)ysize) / 2.0f; + zspan.zmulx = float(xsize) / 2.0f; + zspan.zmuly = float(ysize) / 2.0f; zspan.zofsx = 0.0f; zspan.zofsy = 0.0f; @@ -630,7 +630,7 @@ void zbuf_accumulate_vecblur(NodeBlurData *nbd, /* Min speed? then copy speed-buffer to recalculate speed vectors. */ if (nbd->minspeed) { - float minspeed = (float)nbd->minspeed; + float minspeed = float(nbd->minspeed); float minspeedsq = minspeed * minspeed; minvecbufrect = (float *)MEM_callocN(sizeof(float[4]) * xsize * ysize, "minspeed buf"); @@ -729,7 +729,7 @@ void zbuf_accumulate_vecblur(NodeBlurData *nbd, if (maxspeed) { float speedsq = dvz[0] * dvz[0] + dvz[1] * dvz[1]; if (speedsq > maxspeedsq) { - speedsq = (float)maxspeed / sqrtf(speedsq); + speedsq = float(maxspeed) / sqrtf(speedsq); dvz[0] *= speedsq; dvz[1] *= speedsq; } @@ -779,7 +779,7 @@ void zbuf_accumulate_vecblur(NodeBlurData *nbd, /* accumulate */ samples /= 2; for (step = 1; step <= samples; step++) { - float speedfac = 0.5f * nbd->fac * (float)step / (float)(samples + 1); + float speedfac = 0.5f * nbd->fac * float(step) / float(samples + 1); int side; for (side = 0; side < 2; side++) { @@ -867,7 +867,7 @@ void zbuf_accumulate_vecblur(NodeBlurData *nbd, col.alpha = 0.0f; } else { - col.alpha = ((float)*dm) / 255.0f; + col.alpha = float(*dm) / 255.0f; } col.colpoin = dimg; @@ -885,7 +885,7 @@ void zbuf_accumulate_vecblur(NodeBlurData *nbd, * we don't know what is behind it so we don't do that. this hack * overestimates the contribution of foreground pixels but looks a * bit better without a sudden cutoff. */ - blendfac = ((samples - step) / (float)samples); + blendfac = ((samples - step) / float(samples)); /* Smooth-step to make it look a bit nicer as well. */ blendfac = 3.0f * pow(blendfac, 2.0f) - 2.0f * pow(blendfac, 3.0f); diff --git a/source/blender/compositor/operations/COM_ViewerOperation.cc b/source/blender/compositor/operations/COM_ViewerOperation.cc index c1874bb51db..1d0aead3a94 100644 --- a/source/blender/compositor/operations/COM_ViewerOperation.cc +++ b/source/blender/compositor/operations/COM_ViewerOperation.cc @@ -264,7 +264,7 @@ void ViewerOperation::clear_display_buffer() return; } - size_t buf_bytes = (size_t)ibuf_->y * ibuf_->x * COM_DATA_TYPE_COLOR_CHANNELS * sizeof(float); + size_t buf_bytes = size_t(ibuf_->y) * ibuf_->x * COM_DATA_TYPE_COLOR_CHANNELS * sizeof(float); if (buf_bytes > 0) { memset(output_buffer_, 0, buf_bytes); rcti display_area; diff --git a/source/blender/depsgraph/intern/builder/deg_builder_cache.cc b/source/blender/depsgraph/intern/builder/deg_builder_cache.cc index 0a86cd62576..a9f8d1f73d3 100644 --- a/source/blender/depsgraph/intern/builder/deg_builder_cache.cc +++ b/source/blender/depsgraph/intern/builder/deg_builder_cache.cc @@ -59,8 +59,8 @@ bool operator==(const AnimatedPropertyID &a, const AnimatedPropertyID &b) uint64_t AnimatedPropertyID::hash() const { - uintptr_t ptr1 = (uintptr_t)data; - uintptr_t ptr2 = (uintptr_t)property_rna; + uintptr_t ptr1 = uintptr_t(data); + uintptr_t ptr2 = uintptr_t(property_rna); return uint64_t(((ptr1 >> 4) * 33) ^ (ptr2 >> 4)); } diff --git a/source/blender/depsgraph/intern/builder/deg_builder_cycle.cc b/source/blender/depsgraph/intern/builder/deg_builder_cycle.cc index 8ba6c840a59..7f3c59f1522 100644 --- a/source/blender/depsgraph/intern/builder/deg_builder_cycle.cc +++ b/source/blender/depsgraph/intern/builder/deg_builder_cycle.cc @@ -60,7 +60,7 @@ struct CyclesSolverState { inline void set_node_visited_state(Node *node, eCyclicCheckVisitedState state) { - node->custom_flags = (node->custom_flags & ~0x3) | (int)state; + node->custom_flags = (node->custom_flags & ~0x3) | int(state); } inline eCyclicCheckVisitedState get_node_visited_state(Node *node) diff --git a/source/blender/depsgraph/intern/depsgraph_debug.cc b/source/blender/depsgraph/intern/depsgraph_debug.cc index ddad00bc0e8..2f528873f1d 100644 --- a/source/blender/depsgraph/intern/depsgraph_debug.cc +++ b/source/blender/depsgraph/intern/depsgraph_debug.cc @@ -171,7 +171,7 @@ bool DEG_debug_consistency_check(Depsgraph *graph) node->identifier().c_str(), node->num_links_pending, num_links_pending); - printf("Number of inlinks: %d\n", (int)node->inlinks.size()); + printf("Number of inlinks: %d\n", int(node->inlinks.size())); return false; } } diff --git a/source/blender/depsgraph/intern/eval/deg_eval_flush.cc b/source/blender/depsgraph/intern/eval/deg_eval_flush.cc index 08ce7bed83b..a5b29ae56a9 100644 --- a/source/blender/depsgraph/intern/eval/deg_eval_flush.cc +++ b/source/blender/depsgraph/intern/eval/deg_eval_flush.cc @@ -235,7 +235,7 @@ void flush_editors_id_update(Depsgraph *graph, const DEGEditorUpdateContext *upd EVAL, "Accumulated recalc bits for %s: %u\n", id_orig->name, - (uint)id_cow->recalc); + uint(id_cow->recalc)); /* Inform editors. Only if the data-block is being evaluated a second * time, to distinguish between user edits and initial evaluation when diff --git a/source/blender/draw/engines/eevee_next/eevee_depth_of_field.cc b/source/blender/draw/engines/eevee_next/eevee_depth_of_field.cc index bc0891ceb92..e4c4f6f3f6f 100644 --- a/source/blender/draw/engines/eevee_next/eevee_depth_of_field.cc +++ b/source/blender/draw/engines/eevee_next/eevee_depth_of_field.cc @@ -637,8 +637,8 @@ void DepthOfField::render(View &view, /* Do not step over any unvisited tile. */ int max_multiplier = dilation_radius + 1; - int ring_count = min_ii(DOF_DILATE_RING_COUNT, ceilf(remainder / (float)max_multiplier)); - int multiplier = min_ii(max_multiplier, floorf(remainder / (float)ring_count)); + int ring_count = min_ii(DOF_DILATE_RING_COUNT, ceilf(remainder / float(max_multiplier))); + int multiplier = min_ii(max_multiplier, floorf(remainder / float(ring_count))); dilation_radius += ring_count * multiplier; diff --git a/source/blender/draw/engines/eevee_next/eevee_film.cc b/source/blender/draw/engines/eevee_next/eevee_film.cc index 244eb1e54ef..82f948167dc 100644 --- a/source/blender/draw/engines/eevee_next/eevee_film.cc +++ b/source/blender/draw/engines/eevee_next/eevee_film.cc @@ -120,7 +120,7 @@ void Film::sync_mist() const ::World *world = inst_.scene->world; float mist_start = world ? world->miststa : cam.clip_near; float mist_distance = world ? world->mistdist : fabsf(cam.clip_far - cam.clip_near); - int mist_type = world ? world->mistype : (int)WO_MIST_LINEAR; + int mist_type = world ? world->mistype : int(WO_MIST_LINEAR); switch (mist_type) { case WO_MIST_QUADRATIC: diff --git a/source/blender/draw/engines/eevee_next/eevee_renderbuffers.cc b/source/blender/draw/engines/eevee_next/eevee_renderbuffers.cc index f5638cc5160..29a5484f438 100644 --- a/source/blender/draw/engines/eevee_next/eevee_renderbuffers.cc +++ b/source/blender/draw/engines/eevee_next/eevee_renderbuffers.cc @@ -43,10 +43,10 @@ void RenderBuffers::acquire(int2 extent) bool do_vector_render_pass = (enabled_passes & EEVEE_RENDER_PASS_VECTOR) || (inst_.motion_blur.postfx_enabled() && !inst_.is_viewport()); uint32_t max_light_color_layer = max_ii(enabled_passes & EEVEE_RENDER_PASS_DIFFUSE_LIGHT ? - (int)RENDER_PASS_LAYER_DIFFUSE_LIGHT : + int(RENDER_PASS_LAYER_DIFFUSE_LIGHT) : -1, enabled_passes & EEVEE_RENDER_PASS_SPECULAR_LIGHT ? - (int)RENDER_PASS_LAYER_SPECULAR_LIGHT : + int(RENDER_PASS_LAYER_SPECULAR_LIGHT) : -1) + 1; /* Only RG16F when only doing only reprojection or motion blur. */ diff --git a/source/blender/draw/engines/eevee_next/eevee_sampling.cc b/source/blender/draw/engines/eevee_next/eevee_sampling.cc index 76a0e98638b..521b6d603df 100644 --- a/source/blender/draw/engines/eevee_next/eevee_sampling.cc +++ b/source/blender/draw/engines/eevee_next/eevee_sampling.cc @@ -215,8 +215,8 @@ void Sampling::dof_disk_sample_get(float *r_radius, float *r_theta) const samples_passed += ring_sample_count; } - *r_radius = ring / (float)dof_ring_count_; - *r_theta = 2.0f * M_PI * ring_sample / (float)ring_sample_count; + *r_radius = ring / float(dof_ring_count_); + *r_theta = 2.0f * M_PI * ring_sample / float(ring_sample_count); } /** \} */ @@ -233,7 +233,7 @@ void Sampling::cdf_from_curvemapping(const CurveMapping &curve, Vector &c cdf[0] = 0.0f; /* Actual CDF evaluation. */ for (int u : IndexRange(cdf.size() - 1)) { - float x = (float)(u + 1) / (float)(cdf.size() - 1); + float x = float(u + 1) / float(cdf.size() - 1); cdf[u + 1] = cdf[u] + BKE_curvemapping_evaluateF(&curve, 0, x); } /* Normalize the CDF. */ @@ -249,14 +249,14 @@ void Sampling::cdf_from_curvemapping(const CurveMapping &curve, Vector &c void Sampling::cdf_invert(Vector &cdf, Vector &inverted_cdf) { for (int u : inverted_cdf.index_range()) { - float x = (float)u / (float)(inverted_cdf.size() - 1); + float x = float(u) / float(inverted_cdf.size() - 1); for (int i : cdf.index_range()) { if (i == cdf.size() - 1) { inverted_cdf[u] = 1.0f; } else if (cdf[i] >= x) { float t = (x - cdf[i]) / (cdf[i + 1] - cdf[i]); - inverted_cdf[u] = ((float)i + t) / (float)(cdf.size() - 1); + inverted_cdf[u] = (float(i) + t) / float(cdf.size() - 1); break; } } diff --git a/source/blender/draw/engines/eevee_next/eevee_velocity.cc b/source/blender/draw/engines/eevee_next/eevee_velocity.cc index 7af311a8ccc..e7e4984f7de 100644 --- a/source/blender/draw/engines/eevee_next/eevee_velocity.cc +++ b/source/blender/draw/engines/eevee_next/eevee_velocity.cc @@ -226,11 +226,11 @@ void VelocityModule::step_swap() for (VelocityObjectData &vel : velocity_map.values()) { vel.obj.ofs[step_a] = vel.obj.ofs[step_b]; - vel.obj.ofs[step_b] = (uint)-1; + vel.obj.ofs[step_b] = uint(-1); vel.geo.ofs[step_a] = vel.geo.ofs[step_b]; vel.geo.len[step_a] = vel.geo.len[step_b]; - vel.geo.ofs[step_b] = (uint)-1; - vel.geo.len[step_b] = (uint)-1; + vel.geo.ofs[step_b] = uint(-1); + vel.geo.len[step_b] = uint(-1); } }; @@ -262,7 +262,7 @@ void VelocityModule::end_sync() uint32_t max_resource_id_ = 0u; for (Map::Item item : velocity_map.items()) { - if (item.value.obj.resource_id == (uint32_t)-1) { + if (item.value.obj.resource_id == uint32_t(-1)) { deleted_obj.append(item.key); } else { @@ -302,7 +302,7 @@ void VelocityModule::end_sync() } indirection_buf[vel.obj.resource_id] = vel; /* Reset for next sync. */ - vel.obj.resource_id = (uint)-1; + vel.obj.resource_id = uint(-1); } object_steps[STEP_PREVIOUS]->push_update(); diff --git a/source/blender/draw/engines/eevee_next/eevee_view.cc b/source/blender/draw/engines/eevee_next/eevee_view.cc index 48951c2bae7..3a4fb9d4c20 100644 --- a/source/blender/draw/engines/eevee_next/eevee_view.cc +++ b/source/blender/draw/engines/eevee_next/eevee_view.cc @@ -39,7 +39,7 @@ void ShadingView::sync() int2 render_extent = inst_.film.render_extent_get(); if (false /* inst_.camera.is_panoramic() */) { - int64_t render_pixel_count = render_extent.x * (int64_t)render_extent.y; + int64_t render_pixel_count = render_extent.x * int64_t(render_extent.y); /* Divide pixel count between the 6 views. Rendering to a square target. */ extent_[0] = extent_[1] = ceilf(sqrtf(1 + (render_pixel_count / 6))); /* TODO(@fclem): Clip unused views here. */ diff --git a/source/blender/draw/engines/overlay/overlay_armature.cc b/source/blender/draw/engines/overlay/overlay_armature.cc index 494fd3739d7..903bcbb911e 100644 --- a/source/blender/draw/engines/overlay/overlay_armature.cc +++ b/source/blender/draw/engines/overlay/overlay_armature.cc @@ -416,7 +416,7 @@ static float encode_2f_to_float(float a, float b) { CLAMP(a, 0.0f, 1.0f); CLAMP(b, 0.0f, 2.0f); /* Can go up to 2. Needed for wire size. */ - return (float)((int)(a * 255) | ((int)(b * 255) << 8)); + return float(int(a * 255) | (int(b * 255) << 8)); } void OVERLAY_bone_instance_data_set_color_hint(BoneInstanceData *data, const float hint_color[4]) @@ -941,11 +941,11 @@ static void cp_shade_color3ub(uchar cp[3], const int offset) { int r, g, b; - r = offset + (int)cp[0]; + r = offset + int(cp[0]); CLAMP(r, 0, 255); - g = offset + (int)cp[1]; + g = offset + int(cp[1]); CLAMP(g, 0, 255); - b = offset + (int)cp[2]; + b = offset + int(cp[2]); CLAMP(b, 0, 255); cp[0] = r; diff --git a/source/blender/draw/engines/overlay/overlay_edit_uv.cc b/source/blender/draw/engines/overlay/overlay_edit_uv.cc index dd29a128255..2b1af67175e 100644 --- a/source/blender/draw/engines/overlay/overlay_edit_uv.cc +++ b/source/blender/draw/engines/overlay/overlay_edit_uv.cc @@ -68,7 +68,7 @@ static OVERLAY_UVLineStyle edit_uv_line_style_from_space_image(const SpaceImage static GPUTexture *edit_uv_mask_texture( Mask *mask, const int width, const int height_, const float aspx, const float aspy) { - const int height = (float)height_ * (aspy / aspx); + const int height = float(height_) * (aspy / aspx); MaskRasterHandle *handle; float *buffer = static_cast(MEM_mallocN(sizeof(float) * height * width, __func__)); @@ -308,8 +308,8 @@ void OVERLAY_edit_uv_cache_init(OVERLAY_Data *vedata) LISTBASE_FOREACH (ImageTile *, tile, &image->tiles) { const int tile_x = ((tile->tile_number - 1001) % 10); const int tile_y = ((tile->tile_number - 1001) / 10); - obmat[3][1] = (float)tile_y; - obmat[3][0] = (float)tile_x; + obmat[3][1] = float(tile_y); + obmat[3][0] = float(tile_x); DRW_shgroup_call_obmat(grp, geom, obmat); } /* Only mark active border when overlays are enabled. */ @@ -318,8 +318,8 @@ void OVERLAY_edit_uv_cache_init(OVERLAY_Data *vedata) ImageTile *active_tile = static_cast( BLI_findlink(&image->tiles, image->active_tile_index)); if (active_tile) { - obmat[3][0] = (float)((active_tile->tile_number - 1001) % 10); - obmat[3][1] = (float)((active_tile->tile_number - 1001) / 10); + obmat[3][0] = float((active_tile->tile_number - 1001) % 10); + obmat[3][1] = float((active_tile->tile_number - 1001) / 10); grp = DRW_shgroup_create(sh, psl->edit_uv_tiled_image_borders_ps); DRW_shgroup_uniform_vec4_copy(grp, "color", selected_color); DRW_shgroup_call_obmat(grp, geom, obmat); diff --git a/source/blender/draw/engines/overlay/overlay_engine.cc b/source/blender/draw/engines/overlay/overlay_engine.cc index bb9f2e3a8ce..bbcae92561d 100644 --- a/source/blender/draw/engines/overlay/overlay_engine.cc +++ b/source/blender/draw/engines/overlay/overlay_engine.cc @@ -50,7 +50,7 @@ static void OVERLAY_engine_init(void *vedata) } OVERLAY_PrivateData *pd = stl->pd; - pd->space_type = v3d != nullptr ? (int)SPACE_VIEW3D : draw_ctx->space_data->spacetype; + pd->space_type = v3d != nullptr ? int(SPACE_VIEW3D) : draw_ctx->space_data->spacetype; if (pd->space_type == SPACE_IMAGE) { const SpaceImage *sima = (SpaceImage *)draw_ctx->space_data; diff --git a/source/blender/draw/engines/overlay/overlay_grid.cc b/source/blender/draw/engines/overlay/overlay_grid.cc index d1958205a10..0cffa528219 100644 --- a/source/blender/draw/engines/overlay/overlay_grid.cc +++ b/source/blender/draw/engines/overlay/overlay_grid.cc @@ -67,8 +67,8 @@ void OVERLAY_grid_init(OVERLAY_Data *vedata) grid->distance = 1.0f; copy_v3_fl3(grid->size, 1.0f, 1.0f, 1.0f); if (is_uv_edit) { - grid->size[0] = (float)sima->tile_grid_shape[0]; - grid->size[1] = (float)sima->tile_grid_shape[1]; + grid->size[0] = float(sima->tile_grid_shape[0]); + grid->size[1] = float(sima->tile_grid_shape[1]); } grid->zoom_factor = ED_space_image_zoom_level(v2d, SI_GRID_STEPS_LEN); @@ -122,9 +122,9 @@ void OVERLAY_grid_init(OVERLAY_Data *vedata) } } - grid_axes[0] = (float)((grid_flag & (PLANE_XZ | PLANE_XY)) != 0); - grid_axes[1] = (float)((grid_flag & (PLANE_YZ | PLANE_XY)) != 0); - grid_axes[2] = (float)((grid_flag & (PLANE_YZ | PLANE_XZ)) != 0); + grid_axes[0] = float((grid_flag & (PLANE_XZ | PLANE_XY)) != 0); + grid_axes[1] = float((grid_flag & (PLANE_YZ | PLANE_XY)) != 0); + grid_axes[2] = float((grid_flag & (PLANE_YZ | PLANE_XZ)) != 0); /* Z axis if needed */ if (((rv3d->view == RV3D_VIEW_USER) || (rv3d->persp != RV3D_ORTHO)) && show_axis_z) { @@ -156,9 +156,9 @@ void OVERLAY_grid_init(OVERLAY_Data *vedata) zneg_flag |= CLIP_ZPOS; } - zplane_axes[0] = (float)((zpos_flag & (PLANE_XZ | PLANE_XY)) != 0); - zplane_axes[1] = (float)((zpos_flag & (PLANE_YZ | PLANE_XY)) != 0); - zplane_axes[2] = (float)((zpos_flag & (PLANE_YZ | PLANE_XZ)) != 0); + zplane_axes[0] = float((zpos_flag & (PLANE_XZ | PLANE_XY)) != 0); + zplane_axes[1] = float((zpos_flag & (PLANE_YZ | PLANE_XY)) != 0); + zplane_axes[2] = float((zpos_flag & (PLANE_YZ | PLANE_XZ)) != 0); } else { zneg_flag = zpos_flag = CLIP_ZNEG | CLIP_ZPOS; diff --git a/source/blender/draw/engines/overlay/overlay_image.cc b/source/blender/draw/engines/overlay/overlay_image.cc index 47587319098..f42867622e4 100644 --- a/source/blender/draw/engines/overlay/overlay_image.cc +++ b/source/blender/draw/engines/overlay/overlay_image.cc @@ -135,7 +135,7 @@ static struct GPUTexture *image_camera_background_texture_get(CameraBGImage *bgp Scene *scene = draw_ctx->scene; float aspect_x, aspect_y; int width, height; - int ctime = (int)DEG_get_ctime(draw_ctx->depsgraph); + int ctime = int(DEG_get_ctime(draw_ctx->depsgraph)); *r_use_alpha_premult = false; *r_use_view_transform = false; diff --git a/source/blender/draw/engines/overlay/overlay_metaball.cc b/source/blender/draw/engines/overlay/overlay_metaball.cc index 38de273028b..2fc6910fe44 100644 --- a/source/blender/draw/engines/overlay/overlay_metaball.cc +++ b/source/blender/draw/engines/overlay/overlay_metaball.cc @@ -74,7 +74,7 @@ void OVERLAY_edit_metaball_cache_populate(OVERLAY_Data *vedata, Object *ob) LISTBASE_FOREACH (MetaElem *, ml, mb->editelems) { const bool is_selected = (ml->flag & SELECT) != 0; const bool is_scale_radius = (ml->flag & MB_SCALE_RAD) != 0; - float stiffness_radius = ml->rad * atanf(ml->s) / (float)M_PI_2; + float stiffness_radius = ml->rad * atanf(ml->s) / float(M_PI_2); BoneInstanceData instdata; if (is_select) { diff --git a/source/blender/draw/engines/overlay/overlay_motion_path.cc b/source/blender/draw/engines/overlay/overlay_motion_path.cc index 00b2a8665fd..3f6954f821b 100644 --- a/source/blender/draw/engines/overlay/overlay_motion_path.cc +++ b/source/blender/draw/engines/overlay/overlay_motion_path.cc @@ -116,7 +116,7 @@ static void motion_path_cache(OVERLAY_Data *vedata, const DRWContextState *draw_ctx = DRW_context_state_get(); struct DRWTextStore *dt = DRW_text_cache_ensure(); int txt_flag = DRW_TEXT_CACHE_GLOBALSPACE; - int cfra = (int)DEG_get_ctime(draw_ctx->depsgraph); + int cfra = int(DEG_get_ctime(draw_ctx->depsgraph)); bool selected = (pchan) ? (pchan->bone->flag & BONE_SELECTED) : (ob->base_flag & BASE_SELECTED); bool show_keyframes = (avs->path_viewflag & MOTIONPATH_VIEW_KFRAS) != 0; bool show_keyframes_no = (avs->path_viewflag & MOTIONPATH_VIEW_KFNOS) != 0; diff --git a/source/blender/draw/engines/overlay/overlay_outline.cc b/source/blender/draw/engines/overlay/overlay_outline.cc index e308775dc6e..af348ae3c3e 100644 --- a/source/blender/draw/engines/overlay/overlay_outline.cc +++ b/source/blender/draw/engines/overlay/overlay_outline.cc @@ -192,7 +192,7 @@ static void gpencil_layer_cache_populate(bGPDlayer *gpl, DRWShadingGroup *grp = iter->stroke_grp = DRW_shgroup_create_sub(iter->stroke_grp); DRW_shgroup_uniform_bool_copy(grp, "gpStrokeOrder3d", is_stroke_order_3d); DRW_shgroup_uniform_float_copy(grp, "gpThicknessScale", object_scale); - DRW_shgroup_uniform_float_copy(grp, "gpThicknessOffset", (float)gpl->line_change); + DRW_shgroup_uniform_float_copy(grp, "gpThicknessOffset", float(gpl->line_change)); DRW_shgroup_uniform_float_copy(grp, "gpThicknessWorldScale", thickness_scale); DRW_shgroup_uniform_vec4_copy(grp, "gpDepthPlane", iter->plane); } diff --git a/source/blender/draw/intern/draw_cache_extract_mesh.cc b/source/blender/draw/intern/draw_cache_extract_mesh.cc index 79f2982ab65..fd00059bac6 100644 --- a/source/blender/draw/intern/draw_cache_extract_mesh.cc +++ b/source/blender/draw/intern/draw_cache_extract_mesh.cc @@ -204,7 +204,7 @@ BLI_INLINE void extract_init(const MeshRenderData *mr, run_data.buffer = mesh_extract_buffer_get(extractor, mbuflist); run_data.data_offset = data_offset; extractor->init(mr, cache, run_data.buffer, POINTER_OFFSET(data_stack, data_offset)); - data_offset += (uint32_t)extractor->data_size; + data_offset += uint32_t(extractor->data_size); } } diff --git a/source/blender/draw/intern/draw_cache_extract_mesh_render_data.cc b/source/blender/draw/intern/draw_cache_extract_mesh_render_data.cc index 392144246df..f554e9e67c3 100644 --- a/source/blender/draw/intern/draw_cache_extract_mesh_render_data.cc +++ b/source/blender/draw/intern/draw_cache_extract_mesh_render_data.cc @@ -349,7 +349,7 @@ void mesh_render_data_update_normals(MeshRenderData *mr, const eMRDataType data_ { Mesh *me = mr->me; const bool is_auto_smooth = (me->flag & ME_AUTOSMOOTH) != 0; - const float split_angle = is_auto_smooth ? me->smoothresh : (float)M_PI; + const float split_angle = is_auto_smooth ? me->smoothresh : float(M_PI); if (mr->extract_type != MR_EXTRACT_BMESH) { /* Mesh */ diff --git a/source/blender/draw/intern/draw_cache_impl_subdivision.cc b/source/blender/draw/intern/draw_cache_impl_subdivision.cc index c387a47f0a6..97cec585979 100644 --- a/source/blender/draw/intern/draw_cache_impl_subdivision.cc +++ b/source/blender/draw/intern/draw_cache_impl_subdivision.cc @@ -664,7 +664,7 @@ static void draw_subdiv_cache_extra_coarse_face_data_bm(BMesh *bm, flag |= SUBDIV_COARSE_FACE_FLAG_SMOOTH; } const int loopstart = BM_elem_index_get(f->l_first); - flags_data[index] = (uint)(loopstart) | (flag << SUBDIV_COARSE_FACE_FLAG_OFFSET); + flags_data[index] = uint(loopstart) | (flag << SUBDIV_COARSE_FACE_FLAG_OFFSET); } } @@ -684,7 +684,7 @@ static void draw_subdiv_cache_extra_coarse_face_data_mesh(const MeshRenderData * if (mr->hide_poly && mr->hide_poly[i]) { flag |= SUBDIV_COARSE_FACE_FLAG_HIDDEN; } - flags_data[i] = (uint)(polys[i].loopstart) | (flag << SUBDIV_COARSE_FACE_FLAG_OFFSET); + flags_data[i] = uint(polys[i].loopstart) | (flag << SUBDIV_COARSE_FACE_FLAG_OFFSET); } } @@ -707,7 +707,7 @@ static void draw_subdiv_cache_extra_coarse_face_data_mapped(Mesh *mesh, if ((polys[i].flag & ME_SMOOTH) != 0) { flag |= SUBDIV_COARSE_FACE_FLAG_SMOOTH; } - flags_data[i] = (uint)(polys[i].loopstart) | (flag << SUBDIV_COARSE_FACE_FLAG_OFFSET); + flags_data[i] = uint(polys[i].loopstart) | (flag << SUBDIV_COARSE_FACE_FLAG_OFFSET); } } @@ -828,10 +828,10 @@ static bool draw_subdiv_topology_info_cb(const SubdivForeachContext *foreach_con /* Set topology information only if we have loops. */ if (num_loops != 0) { - cache->num_subdiv_edges = (uint)num_edges; - cache->num_subdiv_loops = (uint)num_loops; - cache->num_subdiv_verts = (uint)num_verts; - cache->num_subdiv_quads = (uint)num_polys; + cache->num_subdiv_edges = uint(num_edges); + cache->num_subdiv_loops = uint(num_loops); + cache->num_subdiv_verts = uint(num_verts); + cache->num_subdiv_quads = uint(num_polys); cache->subdiv_polygon_offset = static_cast(MEM_dupallocN(subdiv_polygon_offset)); } @@ -2137,7 +2137,7 @@ void DRW_subdivide_loose_geom(DRWSubdivCache *subdiv_cache, MeshBufferCache *cac const bool is_simple = subdiv_cache->subdiv->settings.is_simple; const int resolution = subdiv_cache->resolution; const int resolution_1 = resolution - 1; - const float inv_resolution_1 = 1.0f / (float)resolution_1; + const float inv_resolution_1 = 1.0f / float(resolution_1); const int num_subdiv_vertices_per_coarse_edge = resolution - 2; const int num_subdivided_edge = coarse_loose_edge_len * diff --git a/source/blender/draw/intern/draw_command.cc b/source/blender/draw/intern/draw_command.cc index ff69885b3b6..882eda9b31d 100644 --- a/source/blender/draw/intern/draw_command.cc +++ b/source/blender/draw/intern/draw_command.cc @@ -90,7 +90,7 @@ void DrawMulti::execute(RecordingState &state) const DrawMultiBuf::DrawGroupBuf &groups = multi_draw_buf->group_buf_; uint group_index = this->group_first; - while (group_index != (uint)-1) { + while (group_index != uint(-1)) { const DrawGroup &group = groups[group_index]; if (group.vertex_len > 0) { @@ -345,9 +345,9 @@ std::string PushConstant::serialize() const std::string Draw::serialize() const { - std::string inst_len = (instance_len == (uint)-1) ? "from_batch" : std::to_string(instance_len); - std::string vert_len = (vertex_len == (uint)-1) ? "from_batch" : std::to_string(vertex_len); - std::string vert_first = (vertex_first == (uint)-1) ? "from_batch" : + std::string inst_len = (instance_len == uint(-1)) ? "from_batch" : std::to_string(instance_len); + std::string vert_len = (vertex_len == uint(-1)) ? "from_batch" : std::to_string(vertex_len); + std::string vert_first = (vertex_first == uint(-1)) ? "from_batch" : std::to_string(vertex_first); return std::string(".draw(inst_len=") + inst_len + ", vert_len=" + vert_len + ", vert_first=" + vert_first + ", res_id=" + std::to_string(handle.resource_index()) + @@ -379,7 +379,7 @@ std::string DrawMulti::serialize(std::string line_prefix) const uint group_len = 0; uint group_index = this->group_first; - while (group_index != (uint)-1) { + while (group_index != uint(-1)) { const DrawGroup &grp = groups[group_index]; ss << std::endl << line_prefix << " .group(id=" << group_index << ", len=" << grp.len << ")"; @@ -505,7 +505,7 @@ void DrawCommandBuf::bind(RecordingState &state, * instance to set the correct resource_id. Workaround is a storage_buf + gl_InstanceID. */ BLI_assert(batch_inst_len == 1); - if (cmd.vertex_len == (uint)-1) { + if (cmd.vertex_len == uint(-1)) { cmd.vertex_len = batch_vert_len; } diff --git a/source/blender/draw/intern/mesh_extractors/extract_mesh_ibo_lines_adjacency.cc b/source/blender/draw/intern/mesh_extractors/extract_mesh_ibo_lines_adjacency.cc index d6c246c51a9..32a262e4533 100644 --- a/source/blender/draw/intern/mesh_extractors/extract_mesh_ibo_lines_adjacency.cc +++ b/source/blender/draw/intern/mesh_extractors/extract_mesh_ibo_lines_adjacency.cc @@ -71,7 +71,7 @@ BLI_INLINE void lines_adjacency_triangle( if (!value_is_init || v_data == NO_EDGE) { /* Save the winding order inside the sign bit. Because the * Edge-hash sort the keys and we need to compare winding later. */ - int value = (int)l1 + 1; /* 0 cannot be signed so add one. */ + int value = int(l1) + 1; /* 0 cannot be signed so add one. */ *pval = POINTER_FROM_INT((inv_indices) ? -value : value); /* Store loop indices for remaining non-manifold edges. */ data->vert_to_loop[v2] = l2; @@ -81,7 +81,7 @@ BLI_INLINE void lines_adjacency_triangle( /* HACK Tag as not used. Prevent overhead of BLI_edgehash_remove. */ *pval = POINTER_FROM_INT(NO_EDGE); bool inv_opposite = (v_data < 0); - uint l_opposite = (uint)abs(v_data) - 1; + uint l_opposite = uint(abs(v_data)) - 1; /* TODO: Make this part thread-safe. */ if (inv_opposite == inv_indices) { /* Don't share edge if triangles have non matching winding. */ @@ -146,7 +146,7 @@ static void extract_lines_adjacency_finish(const MeshRenderData *UNUSED(mr), int v_data = POINTER_AS_INT(BLI_edgehashIterator_getValue(ehi)); if (v_data != NO_EDGE) { BLI_edgehashIterator_getKey(ehi, &v2, &v3); - l1 = (uint)abs(v_data) - 1; + l1 = uint(abs(v_data)) - 1; if (v_data < 0) { /* `inv_opposite`. */ SWAP(uint, v2, v3); } diff --git a/source/blender/draw/intern/mesh_extractors/extract_mesh_ibo_lines_paint_mask.cc b/source/blender/draw/intern/mesh_extractors/extract_mesh_ibo_lines_paint_mask.cc index 9fbbfc3d705..3977ba492ca 100644 --- a/source/blender/draw/intern/mesh_extractors/extract_mesh_ibo_lines_paint_mask.cc +++ b/source/blender/draw/intern/mesh_extractors/extract_mesh_ibo_lines_paint_mask.cc @@ -115,8 +115,8 @@ static void extract_lines_paint_mask_iter_subdiv_mesh(const DRWSubdivCache *subd uint start_loop_idx = subdiv_quad_index * 4; uint end_loop_idx = (subdiv_quad_index + 1) * 4; for (uint loop_idx = start_loop_idx; loop_idx < end_loop_idx; loop_idx++) { - const uint coarse_edge_index = (uint)subdiv_loop_edge_index[loop_idx]; - const uint subdiv_edge_index = (uint)subdiv_loop_subdiv_edge_index[loop_idx]; + const uint coarse_edge_index = uint(subdiv_loop_edge_index[loop_idx]); + const uint subdiv_edge_index = uint(subdiv_loop_subdiv_edge_index[loop_idx]); if (coarse_edge_index == -1u) { GPU_indexbuf_set_line_restart(&data->elb, subdiv_edge_index); diff --git a/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_edit_data.cc b/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_edit_data.cc index 27fd6546b8c..12e3d4afd5d 100644 --- a/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_edit_data.cc +++ b/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_edit_data.cc @@ -60,14 +60,14 @@ static void mesh_render_data_edge_flag(const MeshRenderData *mr, if (mr->edge_crease_ofs != -1) { float crease = BM_ELEM_CD_GET_FLOAT(eed, mr->edge_crease_ofs); if (crease > 0) { - eattr->crease = (uchar)ceil(crease * 15.0f); + eattr->crease = uchar(ceil(crease * 15.0f)); } } /* Use a byte for value range */ if (mr->bweight_ofs != -1) { float bweight = BM_ELEM_CD_GET_FLOAT(eed, mr->bweight_ofs); if (bweight > 0) { - eattr->bweight = (uchar)(bweight * 255.0f); + eattr->bweight = uchar(bweight * 255.0f); } } #ifdef WITH_FREESTYLE @@ -95,7 +95,7 @@ static void mesh_render_data_vert_flag(const MeshRenderData *mr, if (mr->vert_crease_ofs != -1) { float crease = BM_ELEM_CD_GET_FLOAT(eve, mr->vert_crease_ofs); if (crease > 0) { - eattr->crease |= (uchar)ceil(crease * 15.0f) << 4; + eattr->crease |= uchar(ceil(crease * 15.0f)) << 4; } } } diff --git a/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_edituv_stretch_angle.cc b/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_edituv_stretch_angle.cc index e4714aabf34..683abf24f03 100644 --- a/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_edituv_stretch_angle.cc +++ b/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_edituv_stretch_angle.cc @@ -52,7 +52,7 @@ static void compute_normalize_edge_vectors(float auv[2][2], static short v2_to_short_angle(const float v[2]) { - return atan2f(v[1], v[0]) * (float)M_1_PI * SHRT_MAX; + return atan2f(v[1], v[0]) * float(M_1_PI) * SHRT_MAX; } static void edituv_get_edituv_stretch_angle(float auv[2][2], @@ -63,7 +63,7 @@ static void edituv_get_edituv_stretch_angle(float auv[2][2], r_stretch->uv_angles[0] = v2_to_short_angle(auv[0]); r_stretch->uv_angles[1] = v2_to_short_angle(auv[1]); /* Compute 3D angle here. */ - r_stretch->angle = angle_normalized_v3v3(av[0], av[1]) * (float)M_1_PI * SHRT_MAX; + r_stretch->angle = angle_normalized_v3v3(av[0], av[1]) * float(M_1_PI) * SHRT_MAX; #if 0 /* here for reference, this is done in shader now. */ float uvang = angle_normalized_v2v2(auv0, auv1); diff --git a/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_fdots_pos.cc b/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_fdots_pos.cc index c391cb6ca5a..8bc4d7fe7c7 100644 --- a/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_fdots_pos.cc +++ b/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_fdots_pos.cc @@ -63,7 +63,7 @@ static void extract_fdots_pos_iter_poly_bm(const MeshRenderData *mr, do { add_v3_v3(co, bm_vert_co_get(mr, l_iter->v)); } while ((l_iter = l_iter->next) != l_first); - mul_v3_fl(co, 1.0f / (float)f->len); + mul_v3_fl(co, 1.0f / float(f->len)); } static void extract_fdots_pos_iter_poly_mesh(const MeshRenderData *mr, @@ -95,7 +95,7 @@ static void extract_fdots_pos_iter_poly_mesh(const MeshRenderData *mr, } if (!mr->use_subsurf_fdots) { - mul_v3_fl(co, 1.0f / (float)mp->totloop); + mul_v3_fl(co, 1.0f / float(mp->totloop)); } } diff --git a/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_fdots_uv.cc b/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_fdots_uv.cc index b0403cf7c4c..0c1b58a035f 100644 --- a/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_fdots_uv.cc +++ b/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_fdots_uv.cc @@ -62,7 +62,7 @@ static void extract_fdots_uv_iter_poly_bm(const MeshRenderData *UNUSED(mr), BMLoop *l_iter, *l_first; l_iter = l_first = BM_FACE_FIRST_LOOP(f); do { - float w = 1.0f / (float)f->len; + float w = 1.0f / float(f->len); const MLoopUV *luv = (const MLoopUV *)BM_ELEM_CD_GET_VOID_P(l_iter, data->cd_ofs); madd_v2_v2fl(data->vbo_data[BM_elem_index_get(f)], luv->uv, w); } while ((l_iter = l_iter->next) != l_first); @@ -86,7 +86,7 @@ static void extract_fdots_uv_iter_poly_mesh(const MeshRenderData *mr, } } else { - float w = 1.0f / (float)mp->totloop; + float w = 1.0f / float(mp->totloop); madd_v2_v2fl(data->vbo_data[mp_index], data->uv_data[ml_index].uv, w); } } diff --git a/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_mesh_analysis.cc b/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_mesh_analysis.cc index fe2a02b6b63..a803fcaac1c 100644 --- a/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_mesh_analysis.cc +++ b/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_mesh_analysis.cc @@ -67,8 +67,8 @@ BLI_INLINE float overhang_remap(float fac, float min, float max, float minmax_ir static void statvis_calc_overhang(const MeshRenderData *mr, float *r_overhang) { const MeshStatVis *statvis = &mr->toolsettings->statvis; - const float min = statvis->overhang_min / (float)M_PI; - const float max = statvis->overhang_max / (float)M_PI; + const float min = statvis->overhang_min / float(M_PI); + const float max = statvis->overhang_max / float(M_PI); const char axis = statvis->overhang_axis; BMEditMesh *em = mr->edit_bmesh; BMIter iter; @@ -88,7 +88,7 @@ static void statvis_calc_overhang(const MeshRenderData *mr, float *r_overhang) if (mr->extract_type == MR_EXTRACT_BMESH) { int l_index = 0; BM_ITER_MESH (f, &iter, bm, BM_FACES_OF_MESH) { - float fac = angle_normalized_v3v3(bm_face_no_get(mr, f), dir) / (float)M_PI; + float fac = angle_normalized_v3v3(bm_face_no_get(mr, f), dir) / float(M_PI); fac = overhang_remap(fac, min, max, minmax_irange); for (int i = 0; i < f->len; i++, l_index++) { r_overhang[l_index] = fac; @@ -98,7 +98,7 @@ static void statvis_calc_overhang(const MeshRenderData *mr, float *r_overhang) else { const MPoly *mp = mr->mpoly; for (int mp_index = 0, l_index = 0; mp_index < mr->poly_len; mp_index++, mp++) { - float fac = angle_normalized_v3v3(mr->poly_normals[mp_index], dir) / (float)M_PI; + float fac = angle_normalized_v3v3(mr->poly_normals[mp_index], dir) / float(M_PI); fac = overhang_remap(fac, min, max, minmax_irange); for (int i = 0; i < mp->totloop; i++, l_index++) { r_overhang[l_index] = fac; diff --git a/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_tan.cc b/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_tan.cc index 049fa416523..60ade9daadc 100644 --- a/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_tan.cc +++ b/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_tan.cc @@ -302,7 +302,7 @@ static void extract_tan_init_subdiv(const DRWSubdivCache *subdiv_cache, /* Ensure data is uploaded properly. */ GPU_vertbuf_tag_dirty(coarse_vbo); /* Include stride in offset. */ - const int dst_offset = (int)subdiv_cache->num_subdiv_loops * 4 * pack_layer_index++; + const int dst_offset = int(subdiv_cache->num_subdiv_loops) * 4 * pack_layer_index++; draw_subdiv_interp_custom_data(subdiv_cache, coarse_vbo, dst_buffer, 4, dst_offset, false); } if (use_orco_tan) { @@ -317,7 +317,7 @@ static void extract_tan_init_subdiv(const DRWSubdivCache *subdiv_cache, /* Ensure data is uploaded properly. */ GPU_vertbuf_tag_dirty(coarse_vbo); /* Include stride in offset. */ - const int dst_offset = (int)subdiv_cache->num_subdiv_loops * 4 * pack_layer_index++; + const int dst_offset = int(subdiv_cache->num_subdiv_loops) * 4 * pack_layer_index++; draw_subdiv_interp_custom_data(subdiv_cache, coarse_vbo, dst_buffer, 4, dst_offset, false); } diff --git a/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_uv.cc b/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_uv.cc index 6606912850d..cbade20dd03 100644 --- a/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_uv.cc +++ b/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_uv.cc @@ -146,7 +146,7 @@ static void extract_uv_init_subdiv(const DRWSubdivCache *subdiv_cache, int pack_layer_index = 0; for (int i = 0; i < MAX_MTFACE; i++) { if (uv_layers & (1 << i)) { - const int offset = (int)subdiv_cache->num_subdiv_loops * pack_layer_index++; + const int offset = int(subdiv_cache->num_subdiv_loops) * pack_layer_index++; draw_subdiv_extract_uvs(subdiv_cache, vbo, i, offset); } } diff --git a/source/blender/editors/asset/intern/asset_ops.cc b/source/blender/editors/asset/intern/asset_ops.cc index ba7b56db3ec..5aac4f02b03 100644 --- a/source/blender/editors/asset/intern/asset_ops.cc +++ b/source/blender/editors/asset/intern/asset_ops.cc @@ -925,9 +925,9 @@ static bool has_external_files(Main *bmain, struct ReportList *reports) callback_info.reports, RPT_ERROR, "Unable to copy bundle due to %zu external dependencies; more details on the console", - (size_t)callback_info.external_files.size()); + size_t(callback_info.external_files.size())); printf("Unable to copy bundle due to %zu external dependencies:\n", - (size_t)callback_info.external_files.size()); + size_t(callback_info.external_files.size())); for (const std::string &path : callback_info.external_files) { printf(" \"%s\"\n", path.c_str()); } diff --git a/source/blender/editors/curves/intern/curves_add.cc b/source/blender/editors/curves/intern/curves_add.cc index f234a58f439..edcd1e32cc1 100644 --- a/source/blender/editors/curves/intern/curves_add.cc +++ b/source/blender/editors/curves/intern/curves_add.cc @@ -125,7 +125,7 @@ bke::CurvesGeometry primitive_random_sphere(const int curves_size, const int poi float3 co = no; for (int key = 0; key < points_per_curve; key++) { - float t = key / (float)(points_per_curve - 1); + float t = key / float(points_per_curve - 1); curve_positions[key] = co; curve_radii[key] = 0.02f * (1.0f - t); diff --git a/source/blender/editors/curves/intern/curves_ops.cc b/source/blender/editors/curves/intern/curves_ops.cc index eb3e40f9f76..2c643225072 100644 --- a/source/blender/editors/curves/intern/curves_ops.cc +++ b/source/blender/editors/curves/intern/curves_ops.cc @@ -336,7 +336,7 @@ static void try_convert_single_object(Object &curves_ob, HairKey &key = hair_keys[key_i]; copy_v3_v3(key.co, key_pos_ha); - key.time = 100.0f * key_i / (float)(hair_keys.size() - 1); + key.time = 100.0f * key_i / float(hair_keys.size() - 1); } } diff --git a/source/blender/editors/gpencil/gpencil_bake_animation.cc b/source/blender/editors/gpencil/gpencil_bake_animation.cc index 28d4e1c6d42..927bb83ef51 100644 --- a/source/blender/editors/gpencil/gpencil_bake_animation.cc +++ b/source/blender/editors/gpencil/gpencil_bake_animation.cc @@ -119,7 +119,7 @@ static void animdata_keyframe_list_get(ListBase *ob_list, /* Keyframe number is x value of point. */ if ((bezt->f2 & SELECT) || (!only_selected)) { /* Insert only one key for each keyframe number. */ - int key = (int)bezt->vec[1][0]; + int key = int(bezt->vec[1][0]); if (!BLI_ghash_haskey(r_keyframes, POINTER_FROM_INT(key))) { BLI_ghash_insert(r_keyframes, POINTER_FROM_INT(key), POINTER_FROM_INT(key)); } @@ -243,7 +243,7 @@ static int gpencil_bake_grease_pencil_animation_exec(bContext *C, wmOperator *op } /* Loop all frame range. */ - int oldframe = (int)DEG_get_ctime(depsgraph); + int oldframe = int(DEG_get_ctime(depsgraph)); int key = -1; /* Get list of keyframes. */ diff --git a/source/blender/editors/gpencil/gpencil_mesh.cc b/source/blender/editors/gpencil/gpencil_mesh.cc index 739a1b319c3..11d865f814c 100644 --- a/source/blender/editors/gpencil/gpencil_mesh.cc +++ b/source/blender/editors/gpencil/gpencil_mesh.cc @@ -91,7 +91,7 @@ static void animdata_keyframe_list_get(ListBase *ob_list, /* Keyframe number is x value of point. */ if ((bezt->f2 & SELECT) || (!only_selected)) { /* Insert only one key for each keyframe number. */ - int key = (int)bezt->vec[1][0]; + int key = int(bezt->vec[1][0]); if (!BLI_ghash_haskey(r_keyframes, POINTER_FROM_INT(key))) { BLI_ghash_insert(r_keyframes, POINTER_FROM_INT(key), POINTER_FROM_INT(key)); } @@ -261,7 +261,7 @@ static int gpencil_bake_mesh_animation_exec(bContext *C, wmOperator *op) } /* Loop all frame range. */ - int oldframe = (int)DEG_get_ctime(depsgraph); + int oldframe = int(DEG_get_ctime(depsgraph)); int key = -1; /* Get list of keyframes. */ diff --git a/source/blender/editors/interface/interface.cc b/source/blender/editors/interface/interface.cc index 64f7e035d3f..b2d2fa64fde 100644 --- a/source/blender/editors/interface/interface.cc +++ b/source/blender/editors/interface/interface.cc @@ -133,10 +133,10 @@ void ui_block_to_region_fl(const ARegion *region, uiBlock *block, float *r_x, fl gy += block->panel->ofsy; } - *r_x = ((float)getsizex) * (0.5f + 0.5f * (gx * block->winmat[0][0] + gy * block->winmat[1][0] + - block->winmat[3][0])); - *r_y = ((float)getsizey) * (0.5f + 0.5f * (gx * block->winmat[0][1] + gy * block->winmat[1][1] + - block->winmat[3][1])); + *r_x = float(getsizex) * (0.5f + 0.5f * (gx * block->winmat[0][0] + gy * block->winmat[1][0] + + block->winmat[3][0])); + *r_y = float(getsizey) * (0.5f + 0.5f * (gx * block->winmat[0][1] + gy * block->winmat[1][1] + + block->winmat[3][1])); } void ui_block_to_window_fl(const ARegion *region, uiBlock *block, float *r_x, float *r_y) @@ -153,8 +153,8 @@ void ui_block_to_window(const ARegion *region, uiBlock *block, int *r_x, int *r_ ui_block_to_window_fl(region, block, &fx, &fy); - *r_x = (int)lround(fx); - *r_y = (int)lround(fy); + *r_x = int(lround(fx)); + *r_y = int(lround(fy)); } void ui_block_to_region_rctf(const ARegion *region, @@ -195,13 +195,13 @@ void ui_window_to_block_fl(const ARegion *region, uiBlock *block, float *r_x, fl const int sx = region->winrct.xmin; const int sy = region->winrct.ymin; - const float a = 0.5f * ((float)getsizex) * block->winmat[0][0]; - const float b = 0.5f * ((float)getsizex) * block->winmat[1][0]; - const float c = 0.5f * ((float)getsizex) * (1.0f + block->winmat[3][0]); + const float a = 0.5f * float(getsizex) * block->winmat[0][0]; + const float b = 0.5f * float(getsizex) * block->winmat[1][0]; + const float c = 0.5f * float(getsizex) * (1.0f + block->winmat[3][0]); - const float d = 0.5f * ((float)getsizey) * block->winmat[0][1]; - const float e = 0.5f * ((float)getsizey) * block->winmat[1][1]; - const float f = 0.5f * ((float)getsizey) * (1.0f + block->winmat[3][1]); + const float d = 0.5f * float(getsizey) * block->winmat[0][1]; + const float e = 0.5f * float(getsizey) * block->winmat[1][1]; + const float f = 0.5f * float(getsizey) * (1.0f + block->winmat[3][1]); const float px = *r_x - sx; const float py = *r_y - sy; @@ -232,8 +232,8 @@ void ui_window_to_block(const ARegion *region, uiBlock *block, int *r_x, int *r_ ui_window_to_block_fl(region, block, &fx, &fy); - *r_x = (int)lround(fx); - *r_y = (int)lround(fy); + *r_x = int(lround(fx)); + *r_y = int(lround(fy)); } void ui_window_to_region(const ARegion *region, int *r_x, int *r_y) @@ -279,8 +279,8 @@ static void ui_update_flexible_spacing(const ARegion *region, uiBlock *block) rcti rect; ui_but_to_pixelrect(&rect, region, block, static_cast(block->buttons.last)); - const float buttons_width = (float)rect.xmax + UI_HEADER_OFFSET; - const float region_width = (float)region->sizex * U.dpi_fac; + const float buttons_width = float(rect.xmax) + UI_HEADER_OFFSET; + const float region_width = float(region->sizex) * U.dpi_fac; if (region_width <= buttons_width) { return; @@ -296,7 +296,7 @@ static void ui_update_flexible_spacing(const ARegion *region, uiBlock *block) } const float view_scale_x = UI_view2d_scale_get_x(®ion->v2d); - const float segment_width = region_width / (float)sepr_flex_len; + const float segment_width = region_width / float(sepr_flex_len); float offset = 0, remaining_space = region_width - buttons_width; int i = 0; LISTBASE_FOREACH (uiBut *, but, &block->buttons) { @@ -502,8 +502,8 @@ static void ui_block_bounds_calc_centered(wmWindow *window, uiBlock *block) static void ui_block_bounds_calc_centered_pie(uiBlock *block) { const int xy[2] = { - (int)block->pie_data.pie_center_spawned[0], - (int)block->pie_data.pie_center_spawned[1], + int(block->pie_data.pie_center_spawned[0]), + int(block->pie_data.pie_center_spawned[1]), }; UI_block_translate(block, xy[0], xy[1]); @@ -682,7 +682,7 @@ static int ui_but_calc_float_precision(uiBut *but, double value) return 0; } - int prec = (int)ui_but_get_float_precision(but); + int prec = int(ui_but_get_float_precision(but)); /* first check for various special cases: * * If button is radians, we want additional precision (see T39861). @@ -1411,7 +1411,7 @@ static bool ui_but_event_property_operator_string(const bContext *C, ui_def_but_rna__menu, ui_def_but_rna__panel_type, ui_def_but_rna__menu_type)) { - prop_enum_value = (int)but->hardmin; + prop_enum_value = int(but->hardmin); ptr = &but_parent->rnapoin; prop = but_parent->rnaprop; prop_enum_value_ok = true; @@ -1804,7 +1804,7 @@ static void ui_but_predefined_extra_operator_icons_add(uiBut *but) return; } } - ui_but_extra_operator_icon_add_ptr(but, optype, WM_OP_INVOKE_DEFAULT, (int)icon); + ui_but_extra_operator_icon_add_ptr(but, optype, WM_OP_INVOKE_DEFAULT, int(icon)); } } @@ -1853,7 +1853,7 @@ static void ui_but_validate(const uiBut *but) uiButNumber *number_but = (uiButNumber *)but; if (ELEM(but->pointype, UI_BUT_POIN_CHAR, UI_BUT_POIN_SHORT, UI_BUT_POIN_INT)) { - BLI_assert((int)number_but->step_size > 0); + BLI_assert(int(number_but->step_size) > 0); } } } @@ -2165,7 +2165,7 @@ int ui_but_is_pushed_ex(uiBut *but, double *value) but->type, UI_BTYPE_TOGGLE_N, UI_BTYPE_ICON_TOGGLE_N, UI_BTYPE_CHECKBOX_N); int lvalue; UI_GET_BUT_VALUE_INIT(but, *value); - lvalue = (int)*value; + lvalue = int(*value); if (UI_BITBUT_TEST(lvalue, (but->bitnr))) { is_push = state; } @@ -2187,7 +2187,7 @@ int ui_but_is_pushed_ex(uiBut *but, double *value) case UI_BTYPE_ICON_TOGGLE: case UI_BTYPE_CHECKBOX: UI_GET_BUT_VALUE_INIT(but, *value); - if (*value != (double)but->hardmin) { + if (*value != double(but->hardmin)) { is_push = true; } break; @@ -2220,12 +2220,12 @@ int ui_but_is_pushed_ex(uiBut *but, double *value) UI_GET_BUT_VALUE_INIT(but, *value); /* support for rna enum buts */ if (but->rnaprop && (RNA_property_flag(but->rnaprop) & PROP_ENUM_FLAG)) { - if ((int)*value & (int)but->hardmax) { + if (int(*value) & int(but->hardmax)) { is_push = true; } } else { - if (*value == (double)but->hardmax) { + if (*value == double(but->hardmax)) { is_push = true; } } @@ -2246,7 +2246,7 @@ int ui_but_is_pushed_ex(uiBut *but, double *value) } if ((but->drawflag & UI_BUT_CHECKBOX_INVERT) && (is_push != -1)) { - is_push = !((bool)is_push); + is_push = !bool(is_push); } return is_push; } @@ -2315,9 +2315,9 @@ void ui_but_v3_get(uiBut *but, float vec[3]) } else if (but->pointype == UI_BUT_POIN_CHAR) { const char *cp = (char *)but->poin; - vec[0] = ((float)cp[0]) / 255.0f; - vec[1] = ((float)cp[1]) / 255.0f; - vec[2] = ((float)cp[2]) / 255.0f; + vec[0] = float(cp[0]) / 255.0f; + vec[1] = float(cp[1]) / 255.0f; + vec[2] = float(cp[2]) / 255.0f; } else if (but->pointype == UI_BUT_POIN_FLOAT) { const float *fp = (float *)but->poin; @@ -2363,9 +2363,9 @@ void ui_but_v3_set(uiBut *but, const float vec[3]) } else if (but->pointype == UI_BUT_POIN_CHAR) { char *cp = (char *)but->poin; - cp[0] = (char)lround(vec[0] * 255.0f); - cp[1] = (char)lround(vec[1] * 255.0f); - cp[2] = (char)lround(vec[2] * 255.0f); + cp[0] = char(lround(vec[0] * 255.0f)); + cp[1] = char(lround(vec[1] * 255.0f)); + cp[2] = char(lround(vec[2] * 255.0f)); } else if (but->pointype == UI_BUT_POIN_FLOAT) { float *fp = (float *)but->poin; @@ -2572,10 +2572,10 @@ void ui_but_value_set(uiBut *but, double value) break; case PROP_INT: if (RNA_property_array_check(prop)) { - RNA_property_int_set_index(&but->rnapoin, prop, but->rnaindex, (int)value); + RNA_property_int_set_index(&but->rnapoin, prop, but->rnaindex, int(value)); } else { - RNA_property_int_set(&but->rnapoin, prop, (int)value); + RNA_property_int_set(&but->rnapoin, prop, int(value)); } break; case PROP_FLOAT: @@ -2588,7 +2588,7 @@ void ui_but_value_set(uiBut *but, double value) break; case PROP_ENUM: if (RNA_property_flag(prop) & PROP_ENUM_FLAG) { - int ivalue = (int)value; + int ivalue = int(value); /* toggle for enum/flag buttons */ ivalue ^= RNA_property_enum_get(&but->rnapoin, prop); RNA_property_enum_set(&but->rnapoin, prop, ivalue); @@ -2621,7 +2621,7 @@ void ui_but_value_set(uiBut *but, double value) value = round_db_to_int_clamp(value); } else if (but->pointype == UI_BUT_POIN_FLOAT) { - float fval = (float)value; + float fval = float(value); if (fval >= -0.00001f && fval <= 0.00001f) { /* prevent negative zero */ fval = 0.0f; @@ -2634,16 +2634,16 @@ void ui_but_value_set(uiBut *but, double value) value = *but->editval = value; } else if (but->pointype == UI_BUT_POIN_CHAR) { - value = *((char *)but->poin) = (char)value; + value = *((char *)but->poin) = char(value); } else if (but->pointype == UI_BUT_POIN_SHORT) { - value = *((short *)but->poin) = (short)value; + value = *((short *)but->poin) = short(value); } else if (but->pointype == UI_BUT_POIN_INT) { - value = *((int *)but->poin) = (int)value; + value = *((int *)but->poin) = int(value); } else if (but->pointype == UI_BUT_POIN_FLOAT) { - value = *((float *)but->poin) = (float)value; + value = *((float *)but->poin) = float(value); } } @@ -2721,7 +2721,7 @@ static void ui_get_but_string_unit( /* Use precision override? */ if (float_precision == -1) { /* Sanity checks */ - precision = (int)ui_but_get_float_precision(but); + precision = int(ui_but_get_float_precision(but)); if (precision > UI_PRECISION_FLOAT_MAX) { precision = UI_PRECISION_FLOAT_MAX; } @@ -2763,7 +2763,7 @@ static float ui_get_but_step_unit(uiBut *but, float step_default) BLI_assert(step > 0.0); - step_final = (step / scale_unit) / (double)UI_PRECISION_FLOAT_SCALE; + step_final = (step / scale_unit) / double(UI_PRECISION_FLOAT_SCALE); if (step == step_unit) { /* Logic here is to scale by the original 'step_orig' @@ -2775,7 +2775,7 @@ static float ui_get_but_step_unit(uiBut *but, float step_default) step_final *= step_orig; } - return (float)step_final; + return float(step_final); } void ui_but_string_get_ex(uiBut *but, @@ -2904,7 +2904,7 @@ void ui_but_string_get_ex(uiBut *but, } } else { - BLI_snprintf(str, maxlen, "%d", (int)value); + BLI_snprintf(str, maxlen, "%d", int(value)); } } } @@ -3211,10 +3211,10 @@ bool ui_but_string_set(bContext *C, uiBut *but, const char *str) } /* not that we use hard limits here */ - if (value < (double)but->hardmin) { + if (value < double(but->hardmin)) { value = but->hardmin; } - if (value > (double)but->hardmax) { + if (value > double(but->hardmax)) { value = but->hardmax; } @@ -3307,8 +3307,8 @@ void ui_but_range_set_soft(uiBut *but) if (is_array) { int value_range[2]; RNA_property_int_get_array_range(&but->rnapoin, but->rnaprop, value_range); - value_min = (double)value_range[0]; - value_max = (double)value_range[1]; + value_min = double(value_range[0]); + value_max = double(value_range[1]); } else { value_min = value_max = ui_but_value_get(but); @@ -3319,8 +3319,8 @@ void ui_but_range_set_soft(uiBut *but) float fmin, fmax, fstep, fprecision; RNA_property_float_ui_range(&but->rnapoin, but->rnaprop, &fmin, &fmax, &fstep, &fprecision); - softmin = (fmin == -FLT_MAX) ? (float)-1e4 : fmin; - softmax = (fmax == FLT_MAX) ? (float)1e4 : fmax; + softmin = (fmin == -FLT_MAX) ? float(-1e4) : fmin; + softmax = (fmax == FLT_MAX) ? float(1e4) : fmax; // step = fstep; /* UNUSED */ // precision = fprecision; /* UNUSED */ @@ -3328,8 +3328,8 @@ void ui_but_range_set_soft(uiBut *but) if (is_array && !(subtype == PROP_COLOR && but->rnaindex == 3)) { float value_range[2]; RNA_property_float_get_array_range(&but->rnapoin, but->rnaprop, value_range); - value_min = (double)value_range[0]; - value_max = (double)value_range[1]; + value_min = double(value_range[0]); + value_max = double(value_range[1]); } else { value_min = value_max = ui_but_value_get(but); @@ -3348,8 +3348,8 @@ void ui_but_range_set_soft(uiBut *but) softmin = soft_range_round_down(value_min, softmin); } - if (softmin < (double)but->hardmin) { - softmin = (double)but->hardmin; + if (softmin < double(but->hardmin)) { + softmin = double(but->hardmin); } } if (value_max - 1e-10 > softmax) { @@ -3360,7 +3360,7 @@ void ui_but_range_set_soft(uiBut *but) softmax = soft_range_round_up(value_max, softmax); } - if (softmax > (double)but->hardmax) { + if (softmax > double(but->hardmax)) { softmax = but->hardmax; } } @@ -3810,7 +3810,7 @@ static void ui_but_update_ex(uiBut *but, const bool validate) ui_but_build_drawstr_float(but, value); } else { - ui_but_build_drawstr_int(but, (int)value); + ui_but_build_drawstr_int(but, int(value)); } break; @@ -3843,7 +3843,7 @@ static void ui_but_update_ex(uiBut *but, const bool validate) } else { UI_GET_BUT_VALUE_INIT(but, value); - str = WM_key_event_string((short)value, false); + str = WM_key_event_string(short(value), false); } BLI_snprintf(but->drawstr, UI_MAX_DRAW_STR, "%s%s", but->str, str); break; @@ -4573,7 +4573,7 @@ static uiBut *ui_def_but_rna(uiBlock *block, value = RNA_property_enum_get(ptr, prop); } else { - value = (int)max; + value = int(max); } const int i = RNA_enum_from_value(item, value); @@ -5938,7 +5938,7 @@ void UI_but_unit_type_set(uiBut *but, const int unit_type) int UI_but_unit_type_get(const uiBut *but) { - const int ownUnit = (int)but->unit_type; + const int ownUnit = int(but->unit_type); /* own unit define always takes precedence over RNA provided, allowing for overriding * default value provided in RNA in a few special cases (i.e. Active Keyframe in Graph Edit) @@ -6663,8 +6663,8 @@ void UI_but_string_info_get(bContext *C, uiBut *but, ...) /* enum property */ ptr = &but->rnapoin; prop = but->rnaprop; - value = (ELEM(but->type, UI_BTYPE_ROW, UI_BTYPE_TAB)) ? (int)but->hardmax : - (int)ui_but_value_get(but); + value = (ELEM(but->type, UI_BTYPE_ROW, UI_BTYPE_TAB)) ? int(but->hardmax) : + int(ui_but_value_get(but)); } else if (but->optype) { PointerRNA *opptr = UI_but_operator_ptr_get(but); diff --git a/source/blender/editors/interface/interface_dropboxes.cc b/source/blender/editors/interface/interface_dropboxes.cc index b72d8d2c238..378162a120e 100644 --- a/source/blender/editors/interface/interface_dropboxes.cc +++ b/source/blender/editors/interface/interface_dropboxes.cc @@ -87,7 +87,7 @@ static bool ui_drop_material_poll(bContext *C, wmDrag *drag, const wmEvent *UNUS static void ui_drop_material_copy(bContext *UNUSED(C), wmDrag *drag, wmDropBox *drop) { const ID *id = WM_drag_get_local_ID_or_import_from_asset(drag, ID_MA); - RNA_int_set(drop->ptr, "session_uuid", (int)id->session_uuid); + RNA_int_set(drop->ptr, "session_uuid", int(id->session_uuid)); } static char *ui_drop_material_tooltip(bContext *C, diff --git a/source/blender/editors/interface/interface_panel.cc b/source/blender/editors/interface/interface_panel.cc index 90572c45e8b..d25302616e5 100644 --- a/source/blender/editors/interface/interface_panel.cc +++ b/source/blender/editors/interface/interface_panel.cc @@ -142,7 +142,7 @@ static bool panel_active_animation_changed(ListBase *lb, } /* Detect changes in panel expansions. */ - if ((bool)(panel->runtime_flag & PANEL_WAS_CLOSED) != UI_panel_is_closed(panel)) { + if (bool(panel->runtime_flag & PANEL_WAS_CLOSED) != UI_panel_is_closed(panel)) { *r_panel_animation = panel; return false; } @@ -1232,7 +1232,7 @@ void ui_draw_aligned_panel(const uiStyle *style, rect->xmin, rect->xmax, rect->ymax, - rect->ymax + (int)floor(PNL_HEADER / block->aspect + 0.001f), + rect->ymax + int(floor(PNL_HEADER / block->aspect + 0.001f)), }; if (show_background) { @@ -1368,7 +1368,7 @@ void UI_panel_category_draw_all(ARegion *region, const char *category_id_active) } if (y_ofs > BLI_rcti_size_y(&v2d->mask)) { - scaletabs = (float)BLI_rcti_size_y(&v2d->mask) / (float)y_ofs; + scaletabs = float(BLI_rcti_size_y(&v2d->mask)) / float(y_ofs); LISTBASE_FOREACH (PanelCategoryDyn *, pc_dyn, ®ion->panels_category) { rcti *rct = &pc_dyn->rect; @@ -1705,12 +1705,12 @@ static bool uiAlignPanelStep(ARegion *region, const float factor, const bool dra } if (ps->new_offset_x != ps->panel->ofsx) { - const float x = interpf((float)ps->new_offset_x, (float)ps->panel->ofsx, factor); + const float x = interpf(float(ps->new_offset_x), float(ps->panel->ofsx), factor); ps->panel->ofsx = round_fl_to_int(x); changed = true; } if (ps->new_offset_y != ps->panel->ofsy) { - const float y = interpf((float)ps->new_offset_y, (float)ps->panel->ofsy, factor); + const float y = interpf(float(ps->new_offset_y), float(ps->panel->ofsy), factor); ps->panel->ofsy = round_fl_to_int(y); changed = true; } @@ -1875,13 +1875,13 @@ static void ui_do_drag(const bContext *C, const wmEvent *event, Panel *panel) /* Keep the drag position in the region with a small pad to keep the panel visible. */ const int y = clamp_i(event->xy[1], region->winrct.ymin, region->winrct.ymax + DRAG_REGION_PAD); - float dy = (float)(y - data->starty); + float dy = float(y - data->starty); /* Adjust for region zoom. */ - dy *= BLI_rctf_size_y(®ion->v2d.cur) / (float)BLI_rcti_size_y(®ion->winrct); + dy *= BLI_rctf_size_y(®ion->v2d.cur) / float(BLI_rcti_size_y(®ion->winrct)); /* Add the movement of the view due to edge scrolling while dragging. */ - dy += ((float)region->v2d.cur.ymin - data->start_cur_ymin); + dy += (float(region->v2d.cur.ymin) - data->start_cur_ymin); panel->ofsy = data->startofsy + round_fl_to_int(dy); @@ -1902,16 +1902,16 @@ static uiPanelMouseState ui_panel_mouse_state_get(const uiBlock *block, const int mx, const int my) { - if (!IN_RANGE((float)mx, block->rect.xmin, block->rect.xmax)) { + if (!IN_RANGE(float(mx), block->rect.xmin, block->rect.xmax)) { return PANEL_MOUSE_OUTSIDE; } - if (IN_RANGE((float)my, block->rect.ymax, block->rect.ymax + PNL_HEADER)) { + if (IN_RANGE(float(my), block->rect.ymax, block->rect.ymax + PNL_HEADER)) { return PANEL_MOUSE_INSIDE_HEADER; } if (!UI_panel_is_closed(panel)) { - if (IN_RANGE((float)my, block->rect.ymin, block->rect.ymax + PNL_HEADER)) { + if (IN_RANGE(float(my), block->rect.ymin, block->rect.ymax + PNL_HEADER)) { return PANEL_MOUSE_INSIDE_CONTENT; } } @@ -1937,8 +1937,8 @@ static void ui_panel_drag_collapse(const bContext *C, ARegion *region = CTX_wm_region(C); LISTBASE_FOREACH (uiBlock *, block, ®ion->uiblocks) { - float xy_a_block[2] = {(float)dragcol_data->xy_init[0], (float)dragcol_data->xy_init[1]}; - float xy_b_block[2] = {(float)xy_dst[0], (float)xy_dst[1]}; + float xy_a_block[2] = {float(dragcol_data->xy_init[0]), float(dragcol_data->xy_init[1])}; + float xy_b_block[2] = {float(xy_dst[0]), float(xy_dst[1])}; Panel *panel = block->panel; if (panel == nullptr || (panel->type && (panel->type->flag & PANEL_TYPE_NO_HEADER))) { diff --git a/source/blender/editors/interface/interface_query.cc b/source/blender/editors/interface/interface_query.cc index f084f3e06cb..63dc3017da0 100644 --- a/source/blender/editors/interface/interface_query.cc +++ b/source/blender/editors/interface/interface_query.cc @@ -182,7 +182,7 @@ void ui_but_pie_dir(RadialDirection dir, float vec[2]) BLI_assert(dir != UI_RADIAL_NONE); - angle = DEG2RADF((float)ui_radial_dir_to_angle[dir]); + angle = DEG2RADF(float(ui_radial_dir_to_angle[dir])); vec[0] = cosf(angle); vec[1] = sinf(angle); } diff --git a/source/blender/editors/interface/interface_region_color_picker.cc b/source/blender/editors/interface/interface_region_color_picker.cc index 72912b8c7f7..b49888005fa 100644 --- a/source/blender/editors/interface/interface_region_color_picker.cc +++ b/source/blender/editors/interface/interface_region_color_picker.cc @@ -542,7 +542,7 @@ static void ui_block_colorpicker(uiBlock *block, UI_UNIT_Y, &colormode, 0.0, - (float)PICKER_TYPE_RGB, + float(PICKER_TYPE_RGB), 0, 0, ""); diff --git a/source/blender/editors/interface/interface_region_popover.cc b/source/blender/editors/interface/interface_region_popover.cc index 17c8d890755..e3bb4056608 100644 --- a/source/blender/editors/interface/interface_region_popover.cc +++ b/source/blender/editors/interface/interface_region_popover.cc @@ -146,8 +146,8 @@ static uiBlock *ui_block_func_POPOVER(bContext *C, uiPopupBlockHandle *handle, v ui_block_to_window_fl(handle->ctx_region, pup->but->block, ¢er[0], ¢er[1]); /* These variables aren't used for popovers, * we could add new variables if there is a conflict. */ - block->bounds_offset[0] = (int)center[0]; - block->bounds_offset[1] = (int)center[1]; + block->bounds_offset[0] = int(center[0]); + block->bounds_offset[1] = int(center[1]); copy_v2_v2_int(handle->prev_bounds_offset, block->bounds_offset); } else { @@ -245,7 +245,7 @@ uiPopupBlockHandle *ui_popover_panel_create( /* Scale width by changes to Text Style point size. */ const int text_points_max = MAX2(style->widget.points, style->widgetlabel.points); pup->ui_size_x = ui_units_x * U.widget_unit * - (text_points_max / (float)UI_DEFAULT_TEXT_POINTS); + (text_points_max / float(UI_DEFAULT_TEXT_POINTS)); } pup->menu_func = menu_func; diff --git a/source/blender/editors/interface/interface_region_search.cc b/source/blender/editors/interface/interface_region_search.cc index fb7810792e9..fdef2c15d82 100644 --- a/source/blender/editors/interface/interface_region_search.cc +++ b/source/blender/editors/interface/interface_region_search.cc @@ -44,7 +44,7 @@ #include "interface_intern.h" #include "interface_regions_intern.hh" -#define MENU_BORDER (int)(0.3f * U.widget_unit) +#define MENU_BORDER int(0.3f * U.widget_unit) /* -------------------------------------------------------------------- */ /** \name Search Box Creation diff --git a/source/blender/editors/interface/interface_region_tooltip.cc b/source/blender/editors/interface/interface_region_tooltip.cc index b1621f1a040..74985c50cc1 100644 --- a/source/blender/editors/interface/interface_region_tooltip.cc +++ b/source/blender/editors/interface/interface_region_tooltip.cc @@ -56,7 +56,7 @@ #include "interface_regions_intern.hh" #define UI_TIP_PAD_FAC 1.3f -#define UI_TIP_PADDING (int)(UI_TIP_PAD_FAC * UI_UNIT_Y) +#define UI_TIP_PADDING int(UI_TIP_PAD_FAC * UI_UNIT_Y) #define UI_TIP_MAXWIDTH 600 #define UI_TIP_STR_MAX 1024 diff --git a/source/blender/editors/interface/interface_style.cc b/source/blender/editors/interface/interface_style.cc index 3895a687033..9493f40548d 100644 --- a/source/blender/editors/interface/interface_style.cc +++ b/source/blender/editors/interface/interface_style.cc @@ -319,20 +319,20 @@ const uiStyle *UI_style_get_dpi(void) _style = *style; - _style.paneltitle.shadx = (short)(UI_DPI_FAC * _style.paneltitle.shadx); - _style.paneltitle.shady = (short)(UI_DPI_FAC * _style.paneltitle.shady); - _style.grouplabel.shadx = (short)(UI_DPI_FAC * _style.grouplabel.shadx); - _style.grouplabel.shady = (short)(UI_DPI_FAC * _style.grouplabel.shady); - _style.widgetlabel.shadx = (short)(UI_DPI_FAC * _style.widgetlabel.shadx); - _style.widgetlabel.shady = (short)(UI_DPI_FAC * _style.widgetlabel.shady); - - _style.columnspace = (short)(UI_DPI_FAC * _style.columnspace); - _style.templatespace = (short)(UI_DPI_FAC * _style.templatespace); - _style.boxspace = (short)(UI_DPI_FAC * _style.boxspace); - _style.buttonspacex = (short)(UI_DPI_FAC * _style.buttonspacex); - _style.buttonspacey = (short)(UI_DPI_FAC * _style.buttonspacey); - _style.panelspace = (short)(UI_DPI_FAC * _style.panelspace); - _style.panelouter = (short)(UI_DPI_FAC * _style.panelouter); + _style.paneltitle.shadx = short(UI_DPI_FAC * _style.paneltitle.shadx); + _style.paneltitle.shady = short(UI_DPI_FAC * _style.paneltitle.shady); + _style.grouplabel.shadx = short(UI_DPI_FAC * _style.grouplabel.shadx); + _style.grouplabel.shady = short(UI_DPI_FAC * _style.grouplabel.shady); + _style.widgetlabel.shadx = short(UI_DPI_FAC * _style.widgetlabel.shadx); + _style.widgetlabel.shady = short(UI_DPI_FAC * _style.widgetlabel.shady); + + _style.columnspace = short(UI_DPI_FAC * _style.columnspace); + _style.templatespace = short(UI_DPI_FAC * _style.templatespace); + _style.boxspace = short(UI_DPI_FAC * _style.boxspace); + _style.buttonspacex = short(UI_DPI_FAC * _style.buttonspacex); + _style.buttonspacey = short(UI_DPI_FAC * _style.buttonspacey); + _style.panelspace = short(UI_DPI_FAC * _style.panelspace); + _style.panelouter = short(UI_DPI_FAC * _style.panelouter); return &_style; } @@ -340,7 +340,7 @@ const uiStyle *UI_style_get_dpi(void) int UI_fontstyle_string_width(const uiFontStyle *fs, const char *str) { UI_fontstyle_set(fs); - return (int)BLF_width(fs->uifont_id, str, BLF_DRAW_STR_DUMMY_MAX); + return int(BLF_width(fs->uifont_id, str, BLF_DRAW_STR_DUMMY_MAX)); } int UI_fontstyle_string_width_with_block_aspect(const uiFontStyle *fs, @@ -359,7 +359,7 @@ int UI_fontstyle_string_width_with_block_aspect(const uiFontStyle *fs, if (aspect != 1.0f) { /* While in most cases rounding up isn't important, it can make a difference * with small fonts (3px or less), zooming out in the node-editor for e.g. */ - width = (int)ceilf(width * aspect); + width = int(ceilf(width * aspect)); } return width; } diff --git a/source/blender/editors/interface/interface_template_list.cc b/source/blender/editors/interface/interface_template_list.cc index d8a9591a021..f09eb5f3eb0 100644 --- a/source/blender/editors/interface/interface_template_list.cc +++ b/source/blender/editors/interface/interface_template_list.cc @@ -519,8 +519,8 @@ static void uilist_prepare(uiList *ui_list, int activei_row; if (columns > 1) { - dyn_data->height = (int)ceil((double)items->tot_items / (double)columns); - activei_row = (int)floor((double)items->active_item_idx / (double)columns); + dyn_data->height = int(ceil(double(items->tot_items) / double(columns))); + activei_row = int(floor(double(items->active_item_idx) / double(columns))); } else { dyn_data->height = items->tot_items; @@ -567,8 +567,8 @@ static void uilist_resize_update_cb(bContext *C, void *arg1, void *UNUSED(arg2)) uiListDyn *dyn_data = ui_list->dyn_data; /* This way we get diff in number of additional items to show (positive) or hide (negative). */ - const int diff = round_fl_to_int((float)(dyn_data->resize - dyn_data->resize_prev) / - (float)UI_UNIT_Y); + const int diff = round_fl_to_int(float(dyn_data->resize - dyn_data->resize_prev) / + float(UI_UNIT_Y)); if (diff != 0) { ui_list->list_grip += diff; diff --git a/source/blender/editors/interface/interface_template_search_menu.cc b/source/blender/editors/interface/interface_template_search_menu.cc index c777b7834f2..f61baf65b58 100644 --- a/source/blender/editors/interface/interface_template_search_menu.cc +++ b/source/blender/editors/interface/interface_template_search_menu.cc @@ -191,7 +191,7 @@ static bool menu_items_from_ui_create_item_from_button(MenuSearch_Data *data, if (drawstr_is_empty) { if (prop_type == PROP_ENUM) { - const int value_enum = (int)but->hardmax; + const int value_enum = int(but->hardmax); EnumPropertyItem enum_item; if (RNA_property_enum_item_from_value_gettexted((bContext *)but->block->evil_C, &but->rnapoin, @@ -227,7 +227,7 @@ static bool menu_items_from_ui_create_item_from_button(MenuSearch_Data *data, item->rna.index = but->rnaindex; if (prop_type == PROP_ENUM) { - item->rna.enum_value = (int)but->hardmax; + item->rna.enum_value = int(but->hardmax); } } } @@ -544,8 +544,8 @@ static MenuSearch_Data *menu_items_from_ui_create( if (wm_contexts[space_type_ui_index].space_type_ui_index != -1) { ScrArea *area_best = wm_contexts[space_type_ui_index].area; - const uint value_best = (uint)area_best->winx * (uint)area_best->winy; - const uint value_test = (uint)area->winx * (uint)area->winy; + const uint value_best = uint(area_best->winx) * uint(area_best->winy); + const uint value_test = uint(area->winx) * uint(area->winy); if (value_best > value_test) { continue; } diff --git a/source/blender/editors/interface/interface_utils.cc b/source/blender/editors/interface/interface_utils.cc index 4b94834ce97..139d3c9353f 100644 --- a/source/blender/editors/interface/interface_utils.cc +++ b/source/blender/editors/interface/interface_utils.cc @@ -495,7 +495,7 @@ static bool add_collection_search_item(CollItemSearch *cis, cis->name, cis->data, cis->iconid, - cis->has_sep_char ? (int)UI_BUT_HAS_SEP_CHAR : 0, + cis->has_sep_char ? int(UI_BUT_HAS_SEP_CHAR) : 0, name_prefix_offset); } @@ -787,7 +787,7 @@ int UI_calc_float_precision(int prec, double value) */ value = fabs(value); if ((value < pow10_neg[prec]) && (value > (1.0 / max_pow))) { - int value_i = (int)lround(value * max_pow); + int value_i = int(lround(value * max_pow)); if (value_i != 0) { const int prec_span = 3; /* show: 0.01001, 5 would allow 0.0100001 for eg. */ int test_prec; diff --git a/source/blender/editors/interface/view2d.cc b/source/blender/editors/interface/view2d.cc index 95e5c0ad7d8..bb660d6bf7d 100644 --- a/source/blender/editors/interface/view2d.cc +++ b/source/blender/editors/interface/view2d.cc @@ -53,16 +53,16 @@ static void ui_view2d_curRect_validate_resize(View2D *v2d, bool resize); BLI_INLINE int clamp_float_to_int(const float f) { - const float min = (float)INT_MIN; - const float max = (float)INT_MAX; + const float min = float(INT_MIN); + const float max = float(INT_MAX); if (UNLIKELY(f < min)) { return min; } if (UNLIKELY(f > max)) { - return (int)max; + return int(max); } - return (int)f; + return int(f); } /** @@ -244,8 +244,8 @@ void UI_view2d_region_reinit(View2D *v2d, short type, int winx, int winy) v2d->keeptot = V2D_KEEPTOT_BOUNDS; if (do_init) { v2d->tot.xmin = v2d->tot.ymin = 0.0f; - v2d->tot.xmax = (float)(winx - 1); - v2d->tot.ymax = (float)(winy - 1); + v2d->tot.xmax = float(winx - 1); + v2d->tot.ymax = float(winy - 1); v2d->cur = v2d->tot; } @@ -297,8 +297,8 @@ void UI_view2d_region_reinit(View2D *v2d, short type, int winx, int winy) v2d->tot.ymax = winy; v2d->cur = v2d->tot; - v2d->min[0] = v2d->max[0] = (float)(winx - 1); - v2d->min[1] = v2d->max[1] = (float)(winy - 1); + v2d->min[0] = v2d->max[0] = float(winx - 1); + v2d->min[1] = v2d->max[1] = float(winy - 1); } /* tot rect has strictly regulated placement, and must only occur in +/+ quadrant */ v2d->align = (V2D_ALIGN_NO_NEG_X | V2D_ALIGN_NO_NEG_Y); @@ -388,8 +388,8 @@ static void ui_view2d_curRect_validate_resize(View2D *v2d, bool resize) /* use mask as size of region that View2D resides in, as it takes into account * scroll-bars already - keep in sync with zoomx/zoomy in #view_zoomstep_apply_ex! */ - winx = (float)(BLI_rcti_size_x(&v2d->mask) + 1); - winy = (float)(BLI_rcti_size_y(&v2d->mask) + 1); + winx = float(BLI_rcti_size_x(&v2d->mask) + 1); + winy = float(BLI_rcti_size_y(&v2d->mask) + 1); /* get pointers to rcts for less typing */ cur = &v2d->cur; @@ -584,8 +584,8 @@ static void ui_view2d_curRect_validate_resize(View2D *v2d, bool resize) } /* store region size for next time */ - v2d->oldwinx = (short)winx; - v2d->oldwiny = (short)winy; + v2d->oldwinx = short(winx); + v2d->oldwiny = short(winy); } /* Step 2: apply new sizes to cur rect, @@ -916,8 +916,8 @@ void UI_view2d_curRect_reset(View2D *v2d) float width, height; /* assume width and height of 'cur' rect by default, should be same size as mask */ - width = (float)(BLI_rcti_size_x(&v2d->mask) + 1); - height = (float)(BLI_rcti_size_y(&v2d->mask) + 1); + width = float(BLI_rcti_size_x(&v2d->mask) + 1); + height = float(BLI_rcti_size_y(&v2d->mask) + 1); /* handle width - posx and negx flags are mutually exclusive, so watch out */ if ((v2d->align & V2D_ALIGN_NO_POS_X) && !(v2d->align & V2D_ALIGN_NO_NEG_X)) { @@ -980,17 +980,17 @@ void UI_view2d_totRect_set_resize(View2D *v2d, int width, int height, bool resiz /* handle width - posx and negx flags are mutually exclusive, so watch out */ if ((v2d->align & V2D_ALIGN_NO_POS_X) && !(v2d->align & V2D_ALIGN_NO_NEG_X)) { /* width is in negative-x half */ - v2d->tot.xmin = (float)-width; + v2d->tot.xmin = float(-width); v2d->tot.xmax = 0.0f; } else if ((v2d->align & V2D_ALIGN_NO_NEG_X) && !(v2d->align & V2D_ALIGN_NO_POS_X)) { /* width is in positive-x half */ v2d->tot.xmin = 0.0f; - v2d->tot.xmax = (float)width; + v2d->tot.xmax = float(width); } else { /* width is centered around (x == 0) */ - const float dx = (float)width / 2.0f; + const float dx = float(width) / 2.0f; v2d->tot.xmin = -dx; v2d->tot.xmax = dx; @@ -999,17 +999,17 @@ void UI_view2d_totRect_set_resize(View2D *v2d, int width, int height, bool resiz /* handle height - posx and negx flags are mutually exclusive, so watch out */ if ((v2d->align & V2D_ALIGN_NO_POS_Y) && !(v2d->align & V2D_ALIGN_NO_NEG_Y)) { /* height is in negative-y half */ - v2d->tot.ymin = (float)-height; + v2d->tot.ymin = float(-height); v2d->tot.ymax = 0.0f; } else if ((v2d->align & V2D_ALIGN_NO_NEG_Y) && !(v2d->align & V2D_ALIGN_NO_POS_Y)) { /* height is in positive-y half */ v2d->tot.ymin = 0.0f; - v2d->tot.ymax = (float)height; + v2d->tot.ymax = float(height); } else { /* height is centered around (y == 0) */ - const float dy = (float)height / 2.0f; + const float dy = float(height) / 2.0f; v2d->tot.ymin = -dy; v2d->tot.ymax = dy; @@ -1062,17 +1062,17 @@ static void view2d_map_cur_using_mask(const View2D *v2d, rctf *r_curmasked) const float dy = BLI_rctf_size_y(&v2d->cur) / (sizey + 1); if (v2d->mask.xmin != 0) { - r_curmasked->xmin -= dx * (float)v2d->mask.xmin; + r_curmasked->xmin -= dx * float(v2d->mask.xmin); } if (v2d->mask.xmax + 1 != v2d->winx) { - r_curmasked->xmax += dx * (float)(v2d->winx - v2d->mask.xmax - 1); + r_curmasked->xmax += dx * float(v2d->winx - v2d->mask.xmax - 1); } if (v2d->mask.ymin != 0) { - r_curmasked->ymin -= dy * (float)v2d->mask.ymin; + r_curmasked->ymin -= dy * float(v2d->mask.ymin); } if (v2d->mask.ymax + 1 != v2d->winy) { - r_curmasked->ymax += dy * (float)(v2d->winy - v2d->mask.ymax - 1); + r_curmasked->ymax += dy * float(v2d->winy - v2d->mask.ymax - 1); } } } @@ -1151,7 +1151,7 @@ void UI_view2d_view_restore(const bContext *C) const int width = BLI_rcti_size_x(®ion->winrct) + 1; const int height = BLI_rcti_size_y(®ion->winrct) + 1; - wmOrtho2(0.0f, (float)width, 0.0f, (float)height); + wmOrtho2(0.0f, float(width), 0.0f, float(height)); GPU_matrix_identity_set(); // ED_region_pixelspace(CTX_wm_region(C)); @@ -1177,8 +1177,8 @@ void UI_view2d_multi_grid_draw( /* Make an estimate of at least how many vertices will be needed */ uint vertex_count = 4; - vertex_count += 2 * ((int)((v2d->cur.xmax - v2d->cur.xmin) / lstep) + 1); - vertex_count += 2 * ((int)((v2d->cur.ymax - v2d->cur.ymin) / lstep) + 1); + vertex_count += 2 * (int((v2d->cur.xmax - v2d->cur.xmin) / lstep) + 1); + vertex_count += 2 * (int((v2d->cur.ymax - v2d->cur.ymin) / lstep) + 1); GPUVertFormat *format = immVertexFormat(); const uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); @@ -1195,7 +1195,7 @@ void UI_view2d_multi_grid_draw( * or high contrast grid lines. This only has an effect if colorid != TH_GRID. */ UI_GetThemeColorBlendShade3ubv(colorid, TH_GRID, 0.25f, offset, grid_line_color); - int i = (int)(v2d->cur.xmin / lstep); + int i = int(v2d->cur.xmin / lstep); if (v2d->cur.xmin > 0.0f) { i++; } @@ -1212,7 +1212,7 @@ void UI_view2d_multi_grid_draw( immVertex2f(pos, start, v2d->cur.ymax); } - i = (int)(v2d->cur.ymin / lstep); + i = int(v2d->cur.ymin / lstep); if (v2d->cur.ymin > 0.0f) { i++; } @@ -1256,10 +1256,10 @@ static void grid_axis_start_and_count( { *r_start = min; if (*r_start < 0.0f) { - *r_start += -(float)fmod(min, step); + *r_start += -float(fmod(min, step)); } else { - *r_start += step - (float)fabs(fmod(min, step)); + *r_start += step - float(fabs(fmod(min, step))); } if (*r_start > max) { @@ -1280,7 +1280,7 @@ void UI_view2d_dot_grid_draw(const View2D *v2d, return; } - const float zoom_x = (float)(BLI_rcti_size_x(&v2d->mask) + 1) / BLI_rctf_size_x(&v2d->cur); + const float zoom_x = float(BLI_rcti_size_x(&v2d->mask) + 1) / BLI_rctf_size_x(&v2d->cur); GPUVertFormat *format = immVertexFormat(); const uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); @@ -1296,7 +1296,7 @@ void UI_view2d_dot_grid_draw(const View2D *v2d, const int subdivision_scale = 5; const float view_level = logf(min_step / zoom_x) / logf(subdivision_scale); - const int largest_visible_level = (int)view_level; + const int largest_visible_level = int(view_level); for (int level_offset = 0; level_offset <= grid_subdivisions; level_offset++) { const int level = largest_visible_level - level_offset; @@ -1408,7 +1408,7 @@ void UI_view2d_scrollers_calc(View2D *v2d, vert.ymax -= UI_HEADER_OFFSET; /* width of sliders */ - smaller = (int)(0.1f * U.widget_unit); + smaller = int(0.1f * U.widget_unit); if (scroll & V2D_SCROLL_BOTTOM) { hor.ymin += smaller; } @@ -1439,7 +1439,7 @@ void UI_view2d_scrollers_calc(View2D *v2d, if (scroll & V2D_SCROLL_HORIZONTAL) { /* scroller 'button' extents */ totsize = BLI_rctf_size_x(&v2d->tot); - scrollsize = (float)BLI_rcti_size_x(&hor); + scrollsize = float(BLI_rcti_size_x(&hor)); if (totsize == 0.0f) { totsize = 1.0f; /* avoid divide by zero */ } @@ -1449,7 +1449,7 @@ void UI_view2d_scrollers_calc(View2D *v2d, r_scrollers->hor_min = hor.xmin; } else { - r_scrollers->hor_min = (int)(hor.xmin + (fac1 * scrollsize)); + r_scrollers->hor_min = int(hor.xmin + (fac1 * scrollsize)); } fac2 = (v2d->cur.xmax - v2d->tot.xmin) / totsize; @@ -1457,7 +1457,7 @@ void UI_view2d_scrollers_calc(View2D *v2d, r_scrollers->hor_max = hor.xmax; } else { - r_scrollers->hor_max = (int)(hor.xmin + (fac2 * scrollsize)); + r_scrollers->hor_max = int(hor.xmin + (fac2 * scrollsize)); } /* prevent inverted sliders */ @@ -1477,7 +1477,7 @@ void UI_view2d_scrollers_calc(View2D *v2d, if (scroll & V2D_SCROLL_VERTICAL) { /* scroller 'button' extents */ totsize = BLI_rctf_size_y(&v2d->tot); - scrollsize = (float)BLI_rcti_size_y(&vert); + scrollsize = float(BLI_rcti_size_y(&vert)); if (totsize == 0.0f) { totsize = 1.0f; /* avoid divide by zero */ } @@ -1487,7 +1487,7 @@ void UI_view2d_scrollers_calc(View2D *v2d, r_scrollers->vert_min = vert.ymin; } else { - r_scrollers->vert_min = (int)(vert.ymin + (fac1 * scrollsize)); + r_scrollers->vert_min = int(vert.ymin + (fac1 * scrollsize)); } fac2 = (v2d->cur.ymax - v2d->tot.ymin) / totsize; @@ -1495,7 +1495,7 @@ void UI_view2d_scrollers_calc(View2D *v2d, r_scrollers->vert_max = vert.ymax; } else { - r_scrollers->vert_max = (int)(vert.ymin + (fac2 * scrollsize)); + r_scrollers->vert_max = int(vert.ymin + (fac2 * scrollsize)); } /* prevent inverted sliders */ @@ -1673,8 +1673,8 @@ void UI_view2d_region_to_view( void UI_view2d_region_to_view_rctf(const View2D *v2d, const rctf *rect_src, rctf *rect_dst) { const float cur_size[2] = {BLI_rctf_size_x(&v2d->cur), BLI_rctf_size_y(&v2d->cur)}; - const float mask_size[2] = {(float)BLI_rcti_size_x(&v2d->mask), - (float)BLI_rcti_size_y(&v2d->mask)}; + const float mask_size[2] = {float(BLI_rcti_size_x(&v2d->mask)), + float(BLI_rcti_size_y(&v2d->mask))}; rect_dst->xmin = (v2d->cur.xmin + (cur_size[0] * (rect_src->xmin - v2d->mask.xmin) / mask_size[0])); @@ -1706,8 +1706,8 @@ bool UI_view2d_view_to_region_clip( /* check if values are within bounds */ if ((x >= 0.0f) && (x <= 1.0f) && (y >= 0.0f) && (y <= 1.0f)) { - *r_region_x = (int)(v2d->mask.xmin + (x * BLI_rcti_size_x(&v2d->mask))); - *r_region_y = (int)(v2d->mask.ymin + (y * BLI_rcti_size_y(&v2d->mask))); + *r_region_x = int(v2d->mask.xmin + (x * BLI_rcti_size_x(&v2d->mask))); + *r_region_y = int(v2d->mask.ymin + (y * BLI_rcti_size_y(&v2d->mask))); return true; } @@ -1770,10 +1770,10 @@ bool UI_view2d_view_to_region_segment_clip(const View2D *v2d, r_region_a[0] = r_region_b[0] = r_region_a[1] = r_region_b[1] = V2D_IS_CLIPPED; if (BLI_rctf_isect_segment(&rect_unit, s_a, s_b)) { - r_region_a[0] = (int)(v2d->mask.xmin + (s_a[0] * BLI_rcti_size_x(&v2d->mask))); - r_region_a[1] = (int)(v2d->mask.ymin + (s_a[1] * BLI_rcti_size_y(&v2d->mask))); - r_region_b[0] = (int)(v2d->mask.xmin + (s_b[0] * BLI_rcti_size_x(&v2d->mask))); - r_region_b[1] = (int)(v2d->mask.ymin + (s_b[1] * BLI_rcti_size_y(&v2d->mask))); + r_region_a[0] = int(v2d->mask.xmin + (s_a[0] * BLI_rcti_size_x(&v2d->mask))); + r_region_a[1] = int(v2d->mask.ymin + (s_a[1] * BLI_rcti_size_y(&v2d->mask))); + r_region_b[0] = int(v2d->mask.xmin + (s_b[0] * BLI_rcti_size_x(&v2d->mask))); + r_region_b[1] = int(v2d->mask.ymin + (s_b[1] * BLI_rcti_size_y(&v2d->mask))); return true; } @@ -1784,8 +1784,8 @@ bool UI_view2d_view_to_region_segment_clip(const View2D *v2d, void UI_view2d_view_to_region_rcti(const View2D *v2d, const rctf *rect_src, rcti *rect_dst) { const float cur_size[2] = {BLI_rctf_size_x(&v2d->cur), BLI_rctf_size_y(&v2d->cur)}; - const float mask_size[2] = {(float)BLI_rcti_size_x(&v2d->mask), - (float)BLI_rcti_size_y(&v2d->mask)}; + const float mask_size[2] = {float(BLI_rcti_size_x(&v2d->mask)), + float(BLI_rcti_size_y(&v2d->mask))}; rctf rect_tmp; /* Step 1: express given coordinates as proportional values. */ @@ -1814,8 +1814,8 @@ void UI_view2d_view_to_region_m4(const View2D *v2d, float matrix[4][4]) bool UI_view2d_view_to_region_rcti_clip(const View2D *v2d, const rctf *rect_src, rcti *rect_dst) { const float cur_size[2] = {BLI_rctf_size_x(&v2d->cur), BLI_rctf_size_y(&v2d->cur)}; - const float mask_size[2] = {(float)BLI_rcti_size_x(&v2d->mask), - (float)BLI_rcti_size_y(&v2d->mask)}; + const float mask_size[2] = {float(BLI_rcti_size_x(&v2d->mask)), + float(BLI_rcti_size_y(&v2d->mask))}; rctf rect_tmp; BLI_assert(rect_src->xmin <= rect_src->xmax && rect_src->ymin <= rect_src->ymax); @@ -2153,8 +2153,8 @@ void UI_view2d_text_cache_draw(ARegion *region) /* Don't use clipping if `v2s->rect` is not set. */ if (BLI_rcti_size_x(&v2s->rect) == 0 && BLI_rcti_size_y(&v2s->rect) == 0) { - BLF_draw_default((float)(v2s->mval[0] + xofs), - (float)(v2s->mval[1] + yofs), + BLF_draw_default(float(v2s->mval[0] + xofs), + float(v2s->mval[1] + yofs), 0.0, v2s->str, BLF_DRAW_STR_DUMMY_MAX); diff --git a/source/blender/editors/interface/view2d_draw.cc b/source/blender/editors/interface/view2d_draw.cc index ea4cf399a57..ca96c2abb9d 100644 --- a/source/blender/editors/interface/view2d_draw.cc +++ b/source/blender/editors/interface/view2d_draw.cc @@ -319,11 +319,11 @@ static void draw_horizontal_scale_indicators(const ARegion *region, const float right_text_width = BLF_width(font_id, text, strlen(text)); const float max_text_width = max_ff(left_text_width, right_text_width); const float max_label_count = BLI_rcti_size_x(&v2d->mask) / (max_text_width + 10.0f); - draw_frequency = ceil((float)steps / max_label_count); + draw_frequency = ceil(float(steps) / max_label_count); } if (draw_frequency != 0) { - const int start_index = abs((int)(start / distance)) % draw_frequency; + const int start_index = abs(int(start / distance)) % draw_frequency; for (uint i = start_index; i < steps; i += draw_frequency) { const float xpos_view = start + i * distance; const float xpos_region = UI_view2d_view_to_region_x(v2d, xpos_view); @@ -410,7 +410,7 @@ static void draw_vertical_scale_indicators(const ARegion *region, static void view_to_string__frame_number( void *UNUSED(user_data), float v2d_pos, float UNUSED(v2d_step), uint max_len, char *r_str) { - BLI_snprintf(r_str, max_len, "%d", (int)v2d_pos); + BLI_snprintf(r_str, max_len, "%d", int(v2d_pos)); } static void view_to_string__time( @@ -424,14 +424,14 @@ static void view_to_string__time( } BLI_timecode_string_from_time( - r_str, max_len, brevity_level, v2d_pos / (float)FPS, FPS, U.timecode_style); + r_str, max_len, brevity_level, v2d_pos / float(FPS), FPS, U.timecode_style); } static void view_to_string__value( void *UNUSED(user_data), float v2d_pos, float v2d_step, uint max_len, char *r_str) { if (v2d_step >= 1.0f) { - BLI_snprintf(r_str, max_len, "%d", (int)v2d_pos); + BLI_snprintf(r_str, max_len, "%d", int(v2d_pos)); } else if (v2d_step >= 0.1f) { BLI_snprintf(r_str, max_len, "%.1f", v2d_pos); diff --git a/source/blender/editors/interface/view2d_edge_pan.cc b/source/blender/editors/interface/view2d_edge_pan.cc index 82959d96043..2d8c6970332 100644 --- a/source/blender/editors/interface/view2d_edge_pan.cc +++ b/source/blender/editors/interface/view2d_edge_pan.cc @@ -80,8 +80,8 @@ void UI_view2d_edge_pan_init(bContext *C, vpd->enabled = false; /* Calculate translation factor, based on size of view. */ - const float winx = (float)(BLI_rcti_size_x(&vpd->region->winrct) + 1); - const float winy = (float)(BLI_rcti_size_y(&vpd->region->winrct) + 1); + const float winx = float(BLI_rcti_size_x(&vpd->region->winrct) + 1); + const float winy = float(BLI_rcti_size_y(&vpd->region->winrct) + 1); vpd->facx = (BLI_rctf_size_x(&vpd->v2d->cur)) / winx; vpd->facy = (BLI_rctf_size_y(&vpd->v2d->cur)) / winy; @@ -165,16 +165,16 @@ static float edge_pan_speed(View2DEdgePanData *vpd, /* Apply a fade in to the speed based on a start time delay. */ const double start_time = x_dir ? vpd->edge_pan_start_time_x : vpd->edge_pan_start_time_y; const float delay_factor = vpd->delay > 0.01f ? - smootherstep(vpd->delay, (float)(current_time - start_time)) : + smootherstep(vpd->delay, float(current_time - start_time)) : 1.0f; /* Zoom factor increases speed when zooming in and decreases speed when zooming out. */ - const float zoomx = (float)(BLI_rcti_size_x(®ion->winrct) + 1) / + const float zoomx = float(BLI_rcti_size_x(®ion->winrct) + 1) / BLI_rctf_size_x(®ion->v2d.cur); const float zoom_factor = 1.0f + CLAMPIS(vpd->zoom_influence, 0.0f, 1.0f) * (zoomx - 1.0f); return distance_factor * delay_factor * zoom_factor * vpd->max_speed * U.widget_unit * - (float)U.dpi_fac; + float(U.dpi_fac); } static void edge_pan_apply_delta(bContext *C, View2DEdgePanData *vpd, float dx, float dy) @@ -252,15 +252,15 @@ void UI_view2d_edge_pan_apply(bContext *C, View2DEdgePanData *vpd, const int xy[ edge_pan_manage_delay_timers(vpd, pan_dir_x, pan_dir_y, current_time); /* Calculate the delta since the last time the operator was called. */ - const float dtime = (float)(current_time - vpd->edge_pan_last_time); + const float dtime = float(current_time - vpd->edge_pan_last_time); float dx = 0.0f, dy = 0.0f; if (pan_dir_x != 0) { const float speed = edge_pan_speed(vpd, xy[0], true, current_time); - dx = dtime * speed * (float)pan_dir_x; + dx = dtime * speed * float(pan_dir_x); } if (pan_dir_y != 0) { const float speed = edge_pan_speed(vpd, xy[1], false, current_time); - dy = dtime * speed * (float)pan_dir_y; + dy = dtime * speed * float(pan_dir_y); } vpd->edge_pan_last_time = current_time; diff --git a/source/blender/editors/interface/view2d_ops.cc b/source/blender/editors/interface/view2d_ops.cc index 5f7d82e7b9a..1df2acd5ef7 100644 --- a/source/blender/editors/interface/view2d_ops.cc +++ b/source/blender/editors/interface/view2d_ops.cc @@ -127,8 +127,8 @@ static void view_pan_init(bContext *C, wmOperator *op) vpd->v2d = &vpd->region->v2d; /* calculate translation factor - based on size of view */ - const float winx = (float)(BLI_rcti_size_x(&vpd->region->winrct) + 1); - const float winy = (float)(BLI_rcti_size_y(&vpd->region->winrct) + 1); + const float winx = float(BLI_rcti_size_x(&vpd->region->winrct) + 1); + const float winy = float(BLI_rcti_size_y(&vpd->region->winrct) + 1); vpd->facx = (BLI_rctf_size_x(&vpd->v2d->cur)) / winx; vpd->facy = (BLI_rctf_size_y(&vpd->v2d->cur)) / winy; @@ -712,7 +712,7 @@ static void view_zoomstep_apply_ex(bContext *C, if (vzd->zoom_to_mouse_pos) { /* get zoom fac the same way as in * ui_view2d_curRect_validate_resize - better keep in sync! */ - const float zoomx = (float)(BLI_rcti_size_x(&v2d->mask) + 1) / BLI_rctf_size_x(&v2d->cur); + const float zoomx = float(BLI_rcti_size_x(&v2d->mask) + 1) / BLI_rctf_size_x(&v2d->cur); /* only move view to mouse if zoom fac is inside minzoom/maxzoom */ if (((v2d->keepzoom & V2D_LIMITZOOM) == 0) || @@ -747,7 +747,7 @@ static void view_zoomstep_apply_ex(bContext *C, if (vzd->zoom_to_mouse_pos) { /* get zoom fac the same way as in * ui_view2d_curRect_validate_resize - better keep in sync! */ - const float zoomy = (float)(BLI_rcti_size_y(&v2d->mask) + 1) / BLI_rctf_size_y(&v2d->cur); + const float zoomy = float(BLI_rcti_size_y(&v2d->mask) + 1) / BLI_rctf_size_y(&v2d->cur); /* only move view to mouse if zoom fac is inside minzoom/maxzoom */ if (((v2d->keepzoom & V2D_LIMITZOOM) == 0) || @@ -958,7 +958,7 @@ static void view_zoomdrag_apply(bContext *C, wmOperator *op) * never uses the "Continuous" zoom method, and the 'timer' is not initialized. */ if ((U.viewzoom == USER_ZOOM_CONTINUE) && vzd->timer) { /* XXX store this setting as RNA prop? */ const double time = PIL_check_seconds_timer(); - const float time_step = (float)(time - vzd->timer_lastdraw); + const float time_step = float(time - vzd->timer_lastdraw); dx *= time_step * 5.0f; dy *= time_step * 5.0f; diff --git a/source/blender/editors/interface/views/grid_view.cc b/source/blender/editors/interface/views/grid_view.cc index 52ff1460cbd..ee2fa87b1dc 100644 --- a/source/blender/editors/interface/views/grid_view.cc +++ b/source/blender/editors/interface/views/grid_view.cc @@ -237,7 +237,7 @@ IndexRange BuildOnlyVisibleButtonsHelper::get_visible_range() const const float scroll_ofs_y = abs(v2d_.cur.ymax - v2d_.tot.ymax); if (!IS_EQF(scroll_ofs_y, 0)) { - const int scrolled_away_rows = (int)scroll_ofs_y / style_.tile_height; + const int scrolled_away_rows = int(scroll_ofs_y) / style_.tile_height; first_idx_in_view = scrolled_away_rows * cols_per_row_; } @@ -263,7 +263,7 @@ void BuildOnlyVisibleButtonsHelper::fill_layout_before_visible(uiBlock &block) c return; } - const int scrolled_away_rows = (int)scroll_ofs_y / style_.tile_height; + const int scrolled_away_rows = int(scroll_ofs_y) / style_.tile_height; add_spacer_button(block, scrolled_away_rows); } diff --git a/source/blender/editors/mesh/editface.cc b/source/blender/editors/mesh/editface.cc index ac8dd87bed6..888a8340d51 100644 --- a/source/blender/editors/mesh/editface.cc +++ b/source/blender/editors/mesh/editface.cc @@ -230,7 +230,7 @@ static void select_linked_tfaces_with_seams(Mesh *me, const uint index, const bo bke::SpanAttributeWriter select_poly = attributes.lookup_or_add_for_write_span( ".select_poly", ATTR_DOMAIN_FACE); - if (index != (uint)-1) { + if (index != uint(-1)) { /* only put face under cursor in array */ const MPoly &poly = polys[index]; BKE_mesh_poly_edgebitmap_insert(edge_tag, &poly, &loops[poly.loopstart]); @@ -295,7 +295,7 @@ static void select_linked_tfaces_with_seams(Mesh *me, const uint index, const bo void paintface_select_linked(bContext *C, Object *ob, const int mval[2], const bool select) { - uint index = (uint)-1; + uint index = uint(-1); Mesh *me = BKE_mesh_from_object(ob); if (me == nullptr || me->totpoly == 0) { @@ -451,7 +451,7 @@ bool paintface_mouse_select(bContext *C, } if (found) { - me->act_face = (int)index; + me->act_face = int(index); switch (params->sel_op) { case SEL_OP_SET: diff --git a/source/blender/editors/mesh/mesh_data.cc b/source/blender/editors/mesh/mesh_data.cc index dc3389844b8..ea03117a525 100644 --- a/source/blender/editors/mesh/mesh_data.cc +++ b/source/blender/editors/mesh/mesh_data.cc @@ -161,9 +161,9 @@ static void mesh_uv_reset_array(float **fuv, const int len) /* Make sure we ignore 2-sided faces. */ } else if (len > 2) { - float fac = 0.0f, dfac = 1.0f / (float)len; + float fac = 0.0f, dfac = 1.0f / float(len); - dfac *= (float)M_PI * 2.0f; + dfac *= float(M_PI) * 2.0f; for (int i = 0; i < len; i++) { fuv[i][0] = 0.5f * sinf(fac) + 0.5f; diff --git a/source/blender/editors/mesh/meshtools.cc b/source/blender/editors/mesh/meshtools.cc index 93754e2ef87..917e019c05a 100644 --- a/source/blender/editors/mesh/meshtools.cc +++ b/source/blender/editors/mesh/meshtools.cc @@ -1210,7 +1210,7 @@ bool ED_mesh_pick_face(bContext *C, Object *ob, const int mval[2], uint dist_px, *r_index = DRW_select_buffer_sample_point(vc.depsgraph, vc.region, vc.v3d, mval); } - if ((*r_index) == 0 || (*r_index) > (uint)me->totpoly) { + if ((*r_index) == 0 || (*r_index) > uint(me->totpoly)) { return false; } @@ -1267,7 +1267,7 @@ bool ED_mesh_pick_face_vert( int v_idx_best = ORIGINDEX_NONE; /* find the vert closest to 'mval' */ - const float mval_f[2] = {(float)mval[0], (float)mval[1]}; + const float mval_f[2] = {float(mval[0]), float(mval[1])}; float len_best = FLT_MAX; const Span verts = me_eval->verts(); @@ -1379,7 +1379,7 @@ bool ED_mesh_pick_vert( *r_index = DRW_select_buffer_sample_point(vc.depsgraph, vc.region, vc.v3d, mval); } - if ((*r_index) == 0 || (*r_index) > (uint)me->totvert) { + if ((*r_index) == 0 || (*r_index) > uint(me->totvert)) { return false; } @@ -1395,7 +1395,7 @@ bool ED_mesh_pick_vert( RegionView3D *rv3d = static_cast(region->regiondata); /* find the vert closest to 'mval' */ - const float mval_f[2] = {(float)mval[0], (float)mval[1]}; + const float mval_f[2] = {float(mval[0]), float(mval[1])}; VertPickData data = {nullptr}; diff --git a/source/blender/editors/object/object_add.cc b/source/blender/editors/object/object_add.cc index 9d06a6d5f40..a24b6ed4830 100644 --- a/source/blender/editors/object/object_add.cc +++ b/source/blender/editors/object/object_add.cc @@ -287,7 +287,7 @@ void ED_object_rotation_from_quat(float rot[3], const float viewquat[4], const c } case 'Y': { quat_to_eul(rot, viewquat); - rot[0] -= (float)M_PI_2; + rot[0] -= float(M_PI_2); break; } case 'Z': { diff --git a/source/blender/editors/object/object_modifier.cc b/source/blender/editors/object/object_modifier.cc index 3d995c84639..424bf3c73e2 100644 --- a/source/blender/editors/object/object_modifier.cc +++ b/source/blender/editors/object/object_modifier.cc @@ -2814,7 +2814,7 @@ static int correctivesmooth_bind_exec(bContext *C, wmOperator *op) /* Signal to modifier to recalculate. */ CorrectiveSmoothModifierData *csmd_eval = (CorrectiveSmoothModifierData *) BKE_modifier_get_evaluated(depsgraph, ob, &csmd->modifier); - csmd_eval->bind_coords_num = (uint)-1; + csmd_eval->bind_coords_num = uint(-1); /* Force modifier to run, it will call binding routine * (this has to happen outside of depsgraph evaluation). */ diff --git a/source/blender/editors/object/object_remesh.cc b/source/blender/editors/object/object_remesh.cc index 4fe4b087042..9f59549d3db 100644 --- a/source/blender/editors/object/object_remesh.cc +++ b/source/blender/editors/object/object_remesh.cc @@ -246,7 +246,7 @@ static void voxel_size_parallel_lines_draw(uint pos3d, const float spacing) { const float total_len = len_v3v3(initial_co, end_co); - const int tot_lines = (int)(total_len / spacing); + const int tot_lines = int(total_len / spacing); const int tot_lines_half = (tot_lines / 2) + 1; float spacing_dir[3], lines_start[3]; float line_dir[3]; @@ -261,7 +261,7 @@ static void voxel_size_parallel_lines_draw(uint pos3d, mid_v3_v3v3(lines_start, initial_co, end_co); - immBegin(GPU_PRIM_LINES, (uint)tot_lines_half * 2); + immBegin(GPU_PRIM_LINES, uint(tot_lines_half) * 2); for (int i = 0; i < tot_lines_half; i++) { float line_start[3]; float line_end[3]; @@ -274,7 +274,7 @@ static void voxel_size_parallel_lines_draw(uint pos3d, mul_v3_fl(spacing_dir, -1.0f); - immBegin(GPU_PRIM_LINES, (uint)(tot_lines_half - 1) * 2); + immBegin(GPU_PRIM_LINES, uint(tot_lines_half - 1) * 2); for (int i = 1; i < tot_lines_half; i++) { float line_start[3]; float line_end[3]; @@ -320,7 +320,7 @@ static void voxel_size_edit_draw(const bContext *C, ARegion *UNUSED(ar), void *a GPU_line_width(1.0f); const float total_len = len_v3v3(cd->preview_plane[0], cd->preview_plane[1]); - const int tot_lines = (int)(total_len / cd->voxel_size); + const int tot_lines = int(total_len / cd->voxel_size); /* Smooth-step to reduce the alpha of the grid as the line number increases. */ const float a = VOXEL_SIZE_EDIT_MAX_GRIDS_LINES * 0.1f; @@ -346,7 +346,7 @@ static void voxel_size_edit_draw(const bContext *C, ARegion *UNUSED(ar), void *a UnitSettings *unit = &scene->unit; BKE_unit_value_as_string(str, VOXEL_SIZE_EDIT_MAX_STR_LEN, - (double)(cd->voxel_size * unit->scale_length), + double(cd->voxel_size * unit->scale_length), -3, B_UNIT_LENGTH, unit, diff --git a/source/blender/editors/object/object_transform.cc b/source/blender/editors/object/object_transform.cc index 0a86ae28b3e..0735e93437d 100644 --- a/source/blender/editors/object/object_transform.cc +++ b/source/blender/editors/object/object_transform.cc @@ -1288,7 +1288,7 @@ static int object_origin_set_exec(bContext *C, wmOperator *op) } else { /* #V3D_AROUND_CENTER_MEDIAN. */ if (em->bm->totvert) { - const float total_div = 1.0f / (float)em->bm->totvert; + const float total_div = 1.0f / float(em->bm->totvert); BM_ITER_MESH (eve, &iter, em->bm, BM_VERTS_OF_MESH) { madd_v3_v3fl(cent, eve->co, total_div); } @@ -2079,7 +2079,7 @@ static int object_transform_axis_target_modal(bContext *C, wmOperator *op, const if (event->type == MOUSEMOVE || is_translate_init) { const ViewDepths *depths = xfd->depths; - if (depths && ((uint)event->mval[0] < depths->w) && ((uint)event->mval[1] < depths->h)) { + if (depths && (uint(event->mval[0]) < depths->w) && (uint(event->mval[1]) < depths->h)) { float depth_fl = 1.0f; ED_view3d_depth_read_cached(depths, event->mval, 0, &depth_fl); float location_world[3]; diff --git a/source/blender/editors/render/render_preview.cc b/source/blender/editors/render/render_preview.cc index 10de7063bbc..2e844aa5185 100644 --- a/source/blender/editors/render/render_preview.cc +++ b/source/blender/editors/render/render_preview.cc @@ -1088,10 +1088,10 @@ static void shader_preview_texture(ShaderPreview *sp, Tex *tex, Scene *sce, Rend for (int y = 0; y < height; y++) { /* Tex coords between -1.0f and 1.0f. */ - tex_coord[1] = ((float)y / (float)height) * 2.0f - 1.0f; + tex_coord[1] = (float(y) / float(height)) * 2.0f - 1.0f; for (int x = 0; x < width; x++) { - tex_coord[0] = ((float)x / (float)height) * 2.0f - 1.0f; + tex_coord[0] = (float(x) / float(height)) * 2.0f - 1.0f; /* Evaluate texture at tex_coord. */ TexResult texres = {0}; @@ -1186,7 +1186,7 @@ static void shader_preview_render(ShaderPreview *sp, ID *id, int split, int firs /* lens adjust */ oldlens = ((Camera *)sce->camera->data)->lens; if (sizex > sp->sizey) { - ((Camera *)sce->camera->data)->lens *= (float)sp->sizey / (float)sizex; + ((Camera *)sce->camera->data)->lens *= float(sp->sizey) / float(sizex); } /* entire cycle for render engine */ @@ -1364,17 +1364,17 @@ static void icon_copy_rect(ImBuf *ibuf, uint w, uint h, uint *rect) } if (ima->x > ima->y) { - scaledx = (float)w; - scaledy = ((float)ima->y / (float)ima->x) * (float)w; + scaledx = float(w); + scaledy = (float(ima->y) / float(ima->x)) * float(w); } else { - scaledx = ((float)ima->x / (float)ima->y) * (float)h; - scaledy = (float)h; + scaledx = (float(ima->x) / float(ima->y)) * float(h); + scaledy = float(h); } /* Scaling down must never assign zero width/height, see: T89868. */ - ex = MAX2(1, (short)scaledx); - ey = MAX2(1, (short)scaledy); + ex = MAX2(1, short(scaledx)); + ey = MAX2(1, short(scaledy)); dx = (w - ex) / 2; dy = (h - ey) / 2; diff --git a/source/blender/editors/render/render_shading.cc b/source/blender/editors/render/render_shading.cc index f784346ec8f..ba74541be73 100644 --- a/source/blender/editors/render/render_shading.cc +++ b/source/blender/editors/render/render_shading.cc @@ -534,7 +534,7 @@ static int material_slot_copy_exec(bContext *C, wmOperator *UNUSED(op)) Material ***matar_object = &ob->mat; Material **matar = static_cast( - MEM_callocN(sizeof(*matar) * (size_t)ob->totcol, __func__)); + MEM_callocN(sizeof(*matar) * size_t(ob->totcol), __func__)); for (int i = ob->totcol; i--;) { matar[i] = ob->matbits[i] ? (*matar_object)[i] : (*matar_obdata)[i]; } diff --git a/source/blender/editors/sculpt_paint/curves_sculpt_brush.cc b/source/blender/editors/sculpt_paint/curves_sculpt_brush.cc index 02bf7aacd93..abfcee81e8a 100644 --- a/source/blender/editors/sculpt_paint/curves_sculpt_brush.cc +++ b/source/blender/editors/sculpt_paint/curves_sculpt_brush.cc @@ -59,7 +59,7 @@ static std::optional find_curves_brush_position(const CurvesGeometry &cu const Span positions) { /* This value might have to be adjusted based on user feedback. */ - const float brush_inner_radius_re = std::min(brush_radius_re, (float)UI_UNIT_X / 3.0f); + const float brush_inner_radius_re = std::min(brush_radius_re, float(UI_UNIT_X) / 3.0f); const float brush_inner_radius_sq_re = pow2f(brush_inner_radius_re); float4x4 projection; diff --git a/source/blender/editors/sculpt_paint/curves_sculpt_density.cc b/source/blender/editors/sculpt_paint/curves_sculpt_density.cc index 1e598e6bc5b..2cd4528503e 100644 --- a/source/blender/editors/sculpt_paint/curves_sculpt_density.cc +++ b/source/blender/editors/sculpt_paint/curves_sculpt_density.cc @@ -642,7 +642,7 @@ struct DensitySubtractOperationExecutor { * strength. */ Array allow_remove_curve(curves_->curves_num(), false); threading::parallel_for(curves_->curves_range(), 512, [&](const IndexRange range) { - RandomNumberGenerator rng((int)(PIL_check_seconds_timer() * 1000000.0)); + RandomNumberGenerator rng(int(PIL_check_seconds_timer() * 1000000.0)); for (const int curve_i : range) { if (curves_to_delete[curve_i]) { @@ -731,7 +731,7 @@ struct DensitySubtractOperationExecutor { * strength. */ Array allow_remove_curve(curves_->curves_num(), false); threading::parallel_for(curves_->curves_range(), 512, [&](const IndexRange range) { - RandomNumberGenerator rng((int)(PIL_check_seconds_timer() * 1000000.0)); + RandomNumberGenerator rng(int(PIL_check_seconds_timer() * 1000000.0)); for (const int curve_i : range) { if (curves_to_delete[curve_i]) { diff --git a/source/blender/editors/sculpt_paint/curves_sculpt_ops.cc b/source/blender/editors/sculpt_paint/curves_sculpt_ops.cc index ee12afeb506..3068ce9417b 100644 --- a/source/blender/editors/sculpt_paint/curves_sculpt_ops.cc +++ b/source/blender/editors/sculpt_paint/curves_sculpt_ops.cc @@ -1093,7 +1093,7 @@ static void min_distance_edit_draw(bContext *C, int UNUSED(x), int UNUSED(y), vo GPU_scissor(scissor[0], scissor[1], scissor[2], scissor[3]); /* Draw the brush circle. */ - GPU_matrix_translate_2f((float)op_data.initial_mouse.x, (float)op_data.initial_mouse.y); + GPU_matrix_translate_2f(float(op_data.initial_mouse.x), float(op_data.initial_mouse.y)); GPUVertFormat *format = immVertexFormat(); uint pos2d = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); diff --git a/source/blender/editors/sculpt_paint/paint_image_2d_curve_mask.cc b/source/blender/editors/sculpt_paint/paint_image_2d_curve_mask.cc index d3c61508726..6c7029cccd1 100644 --- a/source/blender/editors/sculpt_paint/paint_image_2d_curve_mask.cc +++ b/source/blender/editors/sculpt_paint/paint_image_2d_curve_mask.cc @@ -52,20 +52,20 @@ static void update_curve_mask(CurveMaskCache *curve_mask_cache, const float cursor_position[2]) { BLI_assert(curve_mask_cache->curve_mask != nullptr); - int offset = (int)floorf(diameter / 2.0f); + int offset = int(floorf(diameter / 2.0f)); int clamped_radius = max_ff(radius, 1.0); ushort *m = curve_mask_cache->curve_mask; const int aa_samples = aa_samples_per_texel_axis(brush, radius); - const float aa_offset = 1.0f / (2.0f * (float)aa_samples); - const float aa_step = 1.0f / (float)aa_samples; + const float aa_offset = 1.0f / (2.0f * float(aa_samples)); + const float aa_step = 1.0f / float(aa_samples); float bpos[2]; bpos[0] = cursor_position[0] - floorf(cursor_position[0]) + offset; bpos[1] = cursor_position[1] - floorf(cursor_position[1]) + offset; - float weight_factor = 65535.0f / (float)(aa_samples * aa_samples); + float weight_factor = 65535.0f / float(aa_samples * aa_samples); for (int y = 0; y < diameter; y++) { for (int x = 0; x < diameter; x++, m++) { @@ -87,7 +87,7 @@ static void update_curve_mask(CurveMaskCache *curve_mask_cache, } pixel_xy[0] += aa_step; } - *m = (ushort)(total_weight * weight_factor); + *m = ushort(total_weight * weight_factor); } } } diff --git a/source/blender/editors/sculpt_paint/paint_vertex.cc b/source/blender/editors/sculpt_paint/paint_vertex.cc index c6eefb0b50e..03925b5ebc3 100644 --- a/source/blender/editors/sculpt_paint/paint_vertex.cc +++ b/source/blender/editors/sculpt_paint/paint_vertex.cc @@ -171,8 +171,8 @@ static void view_angle_limits_init(NormalAnglePrecalc *a, float angle, bool do_m a->angle_inner = a->angle = angle; } - a->angle_inner *= (float)(M_PI_2 / 90); - a->angle *= (float)(M_PI_2 / 90); + a->angle_inner *= float(M_PI_2 / 90); + a->angle *= float(M_PI_2 / 90); a->angle_range = a->angle - a->angle_inner; if (a->angle_range <= 0.0f) { @@ -894,7 +894,7 @@ static void do_weight_paint_vertex_single( else { /* dv and dv_mirr are the same */ int totweight_prev = dv_mirr->totweight; - int dw_offset = (int)(dw - dv_mirr->dw); + int dw_offset = int(dw - dv_mirr->dw); dw_mirr = BKE_defvert_ensure_index(dv_mirr, vgroup_mirr); /* if we added another, get our old one back */ @@ -2128,7 +2128,7 @@ static void do_wpaint_brush_smear_task_cb_ex(void *__restrict userdata, } do_weight_paint_vertex( - data->vp, data->ob, data->wpi, v_index, final_alpha, (float)weight_final); + data->vp, data->ob, data->wpi, v_index, final_alpha, float(weight_final)); } } } @@ -2282,7 +2282,7 @@ static void calculate_average_weight(SculptThreadedTaskData *data, } if (accum_len != 0) { accum_weight /= accum_len; - data->strength = (float)accum_weight; + data->strength = float(accum_weight); } MEM_SAFE_FREE(data->custom_data); /* 'accum' */ diff --git a/source/blender/editors/sculpt_paint/sculpt_automasking.cc b/source/blender/editors/sculpt_paint/sculpt_automasking.cc index f4da70faad7..e8d934f146c 100644 --- a/source/blender/editors/sculpt_paint/sculpt_automasking.cc +++ b/source/blender/editors/sculpt_paint/sculpt_automasking.cc @@ -311,7 +311,7 @@ static void SCULPT_boundary_automasking_init(Object *ob, if (edge_distance[i] == EDGE_DISTANCE_INF) { continue; } - const float p = 1.0f - ((float)edge_distance[i] / (float)propagation_steps); + const float p = 1.0f - (float(edge_distance[i]) / float(propagation_steps)); const float edge_boundary_automask = pow2f(p); *(float *)SCULPT_vertex_attr_get( diff --git a/source/blender/editors/sculpt_paint/sculpt_face_set.cc b/source/blender/editors/sculpt_paint/sculpt_face_set.cc index 473caa18050..3f65248bc78 100644 --- a/source/blender/editors/sculpt_paint/sculpt_face_set.cc +++ b/source/blender/editors/sculpt_paint/sculpt_face_set.cc @@ -947,7 +947,7 @@ static int sculpt_face_sets_change_visibility_invoke(bContext *C, /* Update the active vertex and Face Set using the cursor position to avoid relying on the paint * cursor updates. */ SculptCursorGeometryInfo sgi; - const float mval_fl[2] = {(float)event->mval[0], (float)event->mval[1]}; + const float mval_fl[2] = {float(event->mval[0]), float(event->mval[1])}; SCULPT_vertex_random_access_ensure(ss); SCULPT_cursor_geometry_info_update(C, &sgi, mval_fl, false); @@ -1416,7 +1416,7 @@ static int sculpt_face_set_edit_invoke(bContext *C, wmOperator *op, const wmEven /* Update the current active Face Set and Vertex as the operator can be used directly from the * tool without brush cursor. */ SculptCursorGeometryInfo sgi; - const float mval_fl[2] = {(float)event->mval[0], (float)event->mval[1]}; + const float mval_fl[2] = {float(event->mval[0]), float(event->mval[1])}; if (!SCULPT_cursor_geometry_info_update(C, &sgi, mval_fl, false)) { /* The cursor is not over the mesh. Cancel to avoid editing the last updated Face Set ID. */ return OPERATOR_CANCELLED; diff --git a/source/blender/editors/space_file/filelist.cc b/source/blender/editors/space_file/filelist.cc index 2f3eaf87836..06224b3a28c 100644 --- a/source/blender/editors/space_file/filelist.cc +++ b/source/blender/editors/space_file/filelist.cc @@ -457,8 +457,8 @@ static int compare_date(void *user_data, const void *a1, const void *a2) return ret; } - time1 = (int64_t)entry1->st.st_mtime; - time2 = (int64_t)entry2->st.st_mtime; + time1 = int64_t(entry1->st.st_mtime); + time2 = int64_t(entry2->st.st_mtime); if (time1 < time2) { return compare_apply_inverted(1, sort_data); } @@ -919,7 +919,7 @@ void filelist_filter(FileList *filelist) } filtered_tmp = static_cast( - MEM_mallocN(sizeof(*filtered_tmp) * (size_t)num_files, __func__)); + MEM_mallocN(sizeof(*filtered_tmp) * size_t(num_files), __func__)); /* Filter remap & count how many files are left after filter in a single loop. */ LISTBASE_FOREACH (FileListInternEntry *, file, &filelist->filelist_intern.entries) { @@ -932,10 +932,10 @@ void filelist_filter(FileList *filelist) MEM_freeN(filelist->filelist_intern.filtered); } filelist->filelist_intern.filtered = static_cast( - MEM_mallocN(sizeof(*filelist->filelist_intern.filtered) * (size_t)num_filtered, __func__)); + MEM_mallocN(sizeof(*filelist->filelist_intern.filtered) * size_t(num_filtered), __func__)); memcpy(filelist->filelist_intern.filtered, filtered_tmp, - sizeof(*filelist->filelist_intern.filtered) * (size_t)num_filtered); + sizeof(*filelist->filelist_intern.filtered) * size_t(num_filtered)); filelist->filelist.entries_filtered_num = num_filtered; // printf("Filetered: %d over %d entries\n", num_filtered, filelist->filelist.entries_num); @@ -2436,7 +2436,7 @@ bool filelist_file_cache_block(struct FileList *filelist, const int index) do { int offs_idx = index + offs; if (start_index <= offs_idx && offs_idx < end_index) { - int offs_block_idx = (block_index + offs) % (int)cache_size; + int offs_block_idx = (block_index + offs) % int(cache_size); filelist_cache_previews_push(filelist, cache->block_entries[offs_block_idx], offs_idx); } } while ((offs = -offs) < 0); /* Switch between negative and positive offset. */ @@ -3543,7 +3543,7 @@ static void filelist_readjob_recursive_dir_add_items(const bool do_lib, filelist_readjob_append_entries(job_params, &entries, entries_num, do_update); dirs_done_count++; - *progress = (float)dirs_done_count / (float)dirs_todo_count; + *progress = float(dirs_done_count) / float(dirs_todo_count); MEM_freeN(subdir); } diff --git a/source/blender/editors/space_node/drawnode.cc b/source/blender/editors/space_node/drawnode.cc index b2510df9105..a4c054155dd 100644 --- a/source/blender/editors/space_node/drawnode.cc +++ b/source/blender/editors/space_node/drawnode.cc @@ -1764,7 +1764,7 @@ static void nodelink_batch_init() /* curve strip */ for (int i = 0; i < LINK_RESOL; i++) { - uv[0] = 255 * (i / (float)(LINK_RESOL - 1)); + uv[0] = 255 * (i / float(LINK_RESOL - 1)); uv[1] = 0; set_nodelink_vertex(vbo, uv_id, pos_id, expand_id, v++, uv, pos, exp); uv[1] = 255; diff --git a/source/blender/editors/space_node/node_draw.cc b/source/blender/editors/space_node/node_draw.cc index 98f10bfdfe5..8f72d292740 100644 --- a/source/blender/editors/space_node/node_draw.cc +++ b/source/blender/editors/space_node/node_draw.cc @@ -432,7 +432,7 @@ static void node_update_basis(const bContext &C, float aspect = 1.0f; if (node.preview_xsize && node.preview_ysize) { - aspect = (float)node.preview_ysize / (float)node.preview_xsize; + aspect = float(node.preview_ysize) / float(node.preview_xsize); } dy -= NODE_DYS / 2; @@ -597,7 +597,7 @@ static void node_update_hidden(bNode &node, uiBlock &block) float hiddenrad = HIDDEN_RAD; float tot = MAX2(totin, totout); if (tot > 4) { - hiddenrad += 5.0f * (float)(tot - 4); + hiddenrad += 5.0f * float(tot - 4); } node.totr.xmin = loc.x; @@ -606,7 +606,7 @@ static void node_update_hidden(bNode &node, uiBlock &block) node.totr.ymin = node.totr.ymax - 2 * hiddenrad; /* Output sockets. */ - float rad = (float)M_PI / (1.0f + (float)totout); + float rad = float(M_PI) / (1.0f + float(totout)); float drad = rad; LISTBASE_FOREACH (bNodeSocket *, socket, &node.outputs) { @@ -619,7 +619,7 @@ static void node_update_hidden(bNode &node, uiBlock &block) } /* Input sockets. */ - rad = drad = -(float)M_PI / (1.0f + (float)totin); + rad = drad = -float(M_PI) / (1.0f + float(totin)); LISTBASE_FOREACH (bNodeSocket *, socket, &node.inputs) { if (!nodeSocketIsHidden(socket)) { @@ -1293,20 +1293,20 @@ static void node_draw_preview(bNodePreview *preview, rctf *prv) { float xrect = BLI_rctf_size_x(prv); float yrect = BLI_rctf_size_y(prv); - float xscale = xrect / ((float)preview->xsize); - float yscale = yrect / ((float)preview->ysize); + float xscale = xrect / float(preview->xsize); + float yscale = yrect / float(preview->ysize); float scale; /* Uniform scale and offset. */ rctf draw_rect = *prv; if (xscale < yscale) { - float offset = 0.5f * (yrect - ((float)preview->ysize) * xscale); + float offset = 0.5f * (yrect - float(preview->ysize) * xscale); draw_rect.ymin += offset; draw_rect.ymax -= offset; scale = xscale; } else { - float offset = 0.5f * (xrect - ((float)preview->xsize) * yscale); + float offset = 0.5f * (xrect - float(preview->xsize) * yscale); draw_rect.xmin += offset; draw_rect.xmax -= offset; scale = yscale; @@ -1930,8 +1930,8 @@ static void node_draw_extra_info_row(const bNode &node, UI_BTYPE_BUT, 0, extra_info_row.icon, - (int)but_icon_left, - (int)(rect.ymin + row * (20.0f * U.dpi_fac)), + int(but_icon_left), + int(rect.ymin + row * (20.0f * U.dpi_fac)), but_icon_width, UI_UNIT_Y, nullptr, @@ -1956,10 +1956,10 @@ static void node_draw_extra_info_row(const bNode &node, UI_BTYPE_LABEL, 0, extra_info_row.text.c_str(), - (int)but_text_left, - (int)(rect.ymin + row * (20.0f * U.dpi_fac)), - (short)but_text_width, - (short)NODE_DY, + int(but_text_left), + int(rect.ymin + row * (20.0f * U.dpi_fac)), + short(but_text_width), + short(NODE_DY), nullptr, 0, 0, @@ -2195,10 +2195,10 @@ static void node_draw_basis(const bContext &C, UI_BTYPE_LABEL, 0, showname, - (int)(rct.xmin + NODE_MARGIN_X + 0.4f), - (int)(rct.ymax - NODE_DY), - (short)(iconofs - rct.xmin - (18.0f * U.dpi_fac)), - (short)NODE_DY, + int(rct.xmin + NODE_MARGIN_X + 0.4f), + int(rct.ymax - NODE_DY), + short(iconofs - rct.xmin - (18.0f * U.dpi_fac)), + short(NODE_DY), nullptr, 0, 0, @@ -2425,8 +2425,8 @@ static void node_draw_hidden(const bContext &C, showname, round_fl_to_int(rct.xmin + NODE_MARGIN_X), round_fl_to_int(centy - NODE_DY * 0.5f), - (short)(BLI_rctf_size_x(&rct) - ((18.0f + 12.0f) * U.dpi_fac)), - (short)NODE_DY, + short(BLI_rctf_size_x(&rct) - ((18.0f + 12.0f) * U.dpi_fac)), + short(NODE_DY), nullptr, 0, 0, @@ -2722,7 +2722,7 @@ static void frame_node_draw_label(const bNodeTree &ntree, UI_GetThemeColorBlendShade3ubv(TH_TEXT, color_id, 0.4f, 10, color); BLF_color3ubv(fontid, color); - const float margin = (float)(NODE_DY / 4); + const float margin = float(NODE_DY / 4); const float width = BLF_width(fontid, label, sizeof(label)); const float ascender = BLF_ascender(fontid); const int label_height = ((margin / aspect) + (ascender * aspect)); @@ -2866,7 +2866,7 @@ static void reroute_node_draw( x, y, width, - (short)NODE_DY, + short(NODE_DY), nullptr, 0, 0, @@ -3013,7 +3013,7 @@ static void snode_setup_v2d(SpaceNode &snode, ARegion ®ion, const float2 &cen UI_view2d_view_ortho(&v2d); /* Aspect + font, set each time. */ - snode.runtime->aspect = BLI_rctf_size_x(&v2d.cur) / (float)region.winx; + snode.runtime->aspect = BLI_rctf_size_x(&v2d.cur) / float(region.winx); // XXX snode->curfont = uiSetCurFont_ext(snode->aspect); } diff --git a/source/blender/editors/space_node/node_edit.cc b/source/blender/editors/space_node/node_edit.cc index 31d99eafbc1..e446d5421e7 100644 --- a/source/blender/editors/space_node/node_edit.cc +++ b/source/blender/editors/space_node/node_edit.cc @@ -2859,8 +2859,8 @@ static void viewer_border_corner_to_backdrop(SpaceNode *snode, float bufx = backdrop_width * snode->zoom; float bufy = backdrop_height * snode->zoom; - *fx = (bufx > 0.0f ? ((float)x - 0.5f * region->winx - snode->xof) / bufx + 0.5f : 0.0f); - *fy = (bufy > 0.0f ? ((float)y - 0.5f * region->winy - snode->yof) / bufy + 0.5f : 0.0f); + *fx = (bufx > 0.0f ? (float(x) - 0.5f * region->winx - snode->xof) / bufx + 0.5f : 0.0f); + *fy = (bufy > 0.0f ? (float(y) - 0.5f * region->winy - snode->yof) / bufy + 0.5f : 0.0f); } static int viewer_border_exec(bContext *C, wmOperator *op) diff --git a/source/blender/editors/space_node/node_gizmo.cc b/source/blender/editors/space_node/node_gizmo.cc index f9126556b71..a6c9538d782 100644 --- a/source/blender/editors/space_node/node_gizmo.cc +++ b/source/blender/editors/space_node/node_gizmo.cc @@ -252,7 +252,7 @@ static void gizmo_node_crop_prop_matrix_get(const wmGizmo *gz, const float *dims = crop_group->state.dims; const bNode *node = (const bNode *)gz_prop->custom_func.user_data; const NodeTwoXYs *nxy = (const NodeTwoXYs *)node->storage; - bool is_relative = (bool)node->custom2; + bool is_relative = bool(node->custom2); rctf rct; two_xy_to_rect(nxy, &rct, dims, is_relative); matrix[0][0] = fabsf(BLI_rctf_size_x(&rct)); @@ -271,7 +271,7 @@ static void gizmo_node_crop_prop_matrix_set(const wmGizmo *gz, const float *dims = crop_group->state.dims; bNode *node = (bNode *)gz_prop->custom_func.user_data; NodeTwoXYs *nxy = (NodeTwoXYs *)node->storage; - bool is_relative = (bool)node->custom2; + bool is_relative = bool(node->custom2); rctf rct; two_xy_to_rect(nxy, &rct, dims, is_relative); const bool nx = rct.xmin > rct.xmax; diff --git a/source/blender/editors/space_node/node_relationships.cc b/source/blender/editors/space_node/node_relationships.cc index e12ab3191cb..f597bf20b55 100644 --- a/source/blender/editors/space_node/node_relationships.cc +++ b/source/blender/editors/space_node/node_relationships.cc @@ -2323,7 +2323,7 @@ static int node_insert_offset_modal(bContext *C, wmOperator *op, const wmEvent * return OPERATOR_PASS_THROUGH; } - const float duration = (float)iofsd->anim_timer->duration; + const float duration = float(iofsd->anim_timer->duration); /* handle animation - do this before possibly aborting due to duration, since * main thread might be so busy that node hasn't reached final position yet */ diff --git a/source/blender/editors/space_node/node_select.cc b/source/blender/editors/space_node/node_select.cc index d93b205b1b7..1b47316ebd0 100644 --- a/source/blender/editors/space_node/node_select.cc +++ b/source/blender/editors/space_node/node_select.cc @@ -843,8 +843,7 @@ static int node_circleselect_exec(bContext *C, wmOperator *op) int x, y, radius; float2 offset; - float zoom = (float)(BLI_rcti_size_x(®ion->winrct)) / - (float)(BLI_rctf_size_x(®ion->v2d.cur)); + float zoom = float(BLI_rcti_size_x(®ion->winrct)) / float(BLI_rctf_size_x(®ion->v2d.cur)); const eSelectOp sel_op = ED_select_op_modal( (eSelectOp)RNA_enum_get(op->ptr, "mode"), @@ -867,7 +866,7 @@ static int node_circleselect_exec(bContext *C, wmOperator *op) /* Frame nodes are selectable by their borders (including their whole rect - as for other * nodes - would prevent selection of _only_ other nodes inside that frame. */ rctf frame_inside = node_frame_rect_inside(*node); - const float radius_adjusted = (float)radius / zoom; + const float radius_adjusted = float(radius) / zoom; BLI_rctf_pad(&frame_inside, -2.0f * radius_adjusted, -2.0f * radius_adjusted); if (BLI_rctf_isect_circle(&node->totr, offset, radius_adjusted) && !BLI_rctf_isect_circle(&frame_inside, offset, radius_adjusted)) { diff --git a/source/blender/editors/space_node/node_view.cc b/source/blender/editors/space_node/node_view.cc index 33a75385022..2c02e3c6ecc 100644 --- a/source/blender/editors/space_node/node_view.cc +++ b/source/blender/editors/space_node/node_view.cc @@ -464,9 +464,9 @@ bool ED_space_node_get_position( /* map the mouse coords to the backdrop image space */ float bufx = ibuf->x * snode->zoom; float bufy = ibuf->y * snode->zoom; - fpos[0] = (bufx > 0.0f ? ((float)mval[0] - 0.5f * region->winx - snode->xof) / bufx + 0.5f : + fpos[0] = (bufx > 0.0f ? (float(mval[0]) - 0.5f * region->winx - snode->xof) / bufx + 0.5f : 0.0f); - fpos[1] = (bufy > 0.0f ? ((float)mval[1] - 0.5f * region->winy - snode->yof) / bufy + 0.5f : + fpos[1] = (bufy > 0.0f ? (float(mval[1]) - 0.5f * region->winy - snode->yof) / bufy + 0.5f : 0.0f); BKE_image_release_ibuf(ima, ibuf, lock); @@ -498,13 +498,13 @@ bool ED_space_node_color_sample( /* map the mouse coords to the backdrop image space */ bufx = ibuf->x * snode->zoom; bufy = ibuf->y * snode->zoom; - fx = (bufx > 0.0f ? ((float)mval[0] - 0.5f * region->winx - snode->xof) / bufx + 0.5f : 0.0f); - fy = (bufy > 0.0f ? ((float)mval[1] - 0.5f * region->winy - snode->yof) / bufy + 0.5f : 0.0f); + fx = (bufx > 0.0f ? (float(mval[0]) - 0.5f * region->winx - snode->xof) / bufx + 0.5f : 0.0f); + fy = (bufy > 0.0f ? (float(mval[1]) - 0.5f * region->winy - snode->yof) / bufy + 0.5f : 0.0f); if (fx >= 0.0f && fy >= 0.0f && fx < 1.0f && fy < 1.0f) { const float *fp; uchar *cp; - int x = (int)(fx * ibuf->x), y = (int)(fy * ibuf->y); + int x = int(fx * ibuf->x), y = int(fy * ibuf->y); CLAMP(x, 0, ibuf->x - 1); CLAMP(y, 0, ibuf->y - 1); @@ -555,15 +555,15 @@ static void sample_apply(bContext *C, wmOperator *op, const wmEvent *event) /* map the mouse coords to the backdrop image space */ bufx = ibuf->x * snode->zoom; bufy = ibuf->y * snode->zoom; - fx = (bufx > 0.0f ? ((float)event->mval[0] - 0.5f * region->winx - snode->xof) / bufx + 0.5f : + fx = (bufx > 0.0f ? (float(event->mval[0]) - 0.5f * region->winx - snode->xof) / bufx + 0.5f : 0.0f); - fy = (bufy > 0.0f ? ((float)event->mval[1] - 0.5f * region->winy - snode->yof) / bufy + 0.5f : + fy = (bufy > 0.0f ? (float(event->mval[1]) - 0.5f * region->winy - snode->yof) / bufy + 0.5f : 0.0f); if (fx >= 0.0f && fy >= 0.0f && fx < 1.0f && fy < 1.0f) { const float *fp; uchar *cp; - int x = (int)(fx * ibuf->x), y = (int)(fy * ibuf->y); + int x = int(fx * ibuf->x), y = int(fy * ibuf->y); CLAMP(x, 0, ibuf->x - 1); CLAMP(y, 0, ibuf->y - 1); @@ -584,10 +584,10 @@ static void sample_apply(bContext *C, wmOperator *op, const wmEvent *event) info->col[2] = cp[2]; info->col[3] = cp[3]; - info->colf[0] = (float)cp[0] / 255.0f; - info->colf[1] = (float)cp[1] / 255.0f; - info->colf[2] = (float)cp[2] / 255.0f; - info->colf[3] = (float)cp[3] / 255.0f; + info->colf[0] = float(cp[0]) / 255.0f; + info->colf[1] = float(cp[1]) / 255.0f; + info->colf[2] = float(cp[2]) / 255.0f; + info->colf[3] = float(cp[3]) / 255.0f; copy_v4_v4(info->linearcol, info->colf); IMB_colormanagement_colorspace_to_scene_linear_v4( diff --git a/source/blender/editors/space_node/space_node.cc b/source/blender/editors/space_node/space_node.cc index fae3eb1a143..b02f22f378f 100644 --- a/source/blender/editors/space_node/space_node.cc +++ b/source/blender/editors/space_node/space_node.cc @@ -672,14 +672,14 @@ static void node_group_drop_copy(bContext *UNUSED(C), wmDrag *drag, wmDropBox *d { ID *id = WM_drag_get_local_ID_or_import_from_asset(drag, 0); - RNA_int_set(drop->ptr, "session_uuid", (int)id->session_uuid); + RNA_int_set(drop->ptr, "session_uuid", int(id->session_uuid)); } static void node_id_drop_copy(bContext *UNUSED(C), wmDrag *drag, wmDropBox *drop) { ID *id = WM_drag_get_local_ID_or_import_from_asset(drag, 0); - RNA_int_set(drop->ptr, "session_uuid", (int)id->session_uuid); + RNA_int_set(drop->ptr, "session_uuid", int(id->session_uuid)); } static void node_id_path_drop_copy(bContext *UNUSED(C), wmDrag *drag, wmDropBox *drop) @@ -687,7 +687,7 @@ static void node_id_path_drop_copy(bContext *UNUSED(C), wmDrag *drag, wmDropBox ID *id = WM_drag_get_local_ID_or_import_from_asset(drag, 0); if (id) { - RNA_int_set(drop->ptr, "session_uuid", (int)id->session_uuid); + RNA_int_set(drop->ptr, "session_uuid", int(id->session_uuid)); RNA_struct_property_unset(drop->ptr, "filepath"); } else if (drag->path[0]) { diff --git a/source/blender/editors/space_outliner/outliner_draw.cc b/source/blender/editors/space_outliner/outliner_draw.cc index 3c52f79a80e..76f93e5f518 100644 --- a/source/blender/editors/space_outliner/outliner_draw.cc +++ b/source/blender/editors/space_outliner/outliner_draw.cc @@ -1123,7 +1123,7 @@ static void outliner_draw_restrictbuts(uiBlock *block, VIEW_LAYER_RENDER, 0, ICON_RESTRICT_RENDER_OFF, - (int)(region->v2d.cur.xmax - restrict_offsets.render), + int(region->v2d.cur.xmax - restrict_offsets.render), te->ys, UI_UNIT_X, UI_UNIT_Y, @@ -1158,7 +1158,7 @@ static void outliner_draw_restrictbuts(uiBlock *block, UI_BTYPE_ICON_TOGGLE, 0, 0, - (int)(region->v2d.cur.xmax - restrict_offsets.hide), + int(region->v2d.cur.xmax - restrict_offsets.hide), te->ys, UI_UNIT_X, UI_UNIT_Y, @@ -1185,7 +1185,7 @@ static void outliner_draw_restrictbuts(uiBlock *block, UI_BTYPE_ICON_TOGGLE, 0, 0, - (int)(region->v2d.cur.xmax - restrict_offsets.select), + int(region->v2d.cur.xmax - restrict_offsets.select), te->ys, UI_UNIT_X, UI_UNIT_Y, @@ -1210,7 +1210,7 @@ static void outliner_draw_restrictbuts(uiBlock *block, UI_BTYPE_ICON_TOGGLE, 0, 0, - (int)(region->v2d.cur.xmax - restrict_offsets.viewport), + int(region->v2d.cur.xmax - restrict_offsets.viewport), te->ys, UI_UNIT_X, UI_UNIT_Y, @@ -1235,7 +1235,7 @@ static void outliner_draw_restrictbuts(uiBlock *block, UI_BTYPE_ICON_TOGGLE, 0, 0, - (int)(region->v2d.cur.xmax - restrict_offsets.render), + int(region->v2d.cur.xmax - restrict_offsets.render), te->ys, UI_UNIT_X, UI_UNIT_Y, @@ -1266,7 +1266,7 @@ static void outliner_draw_restrictbuts(uiBlock *block, UI_BTYPE_ICON_TOGGLE, 0, 0, - (int)(region->v2d.cur.xmax - restrict_offsets.hide), + int(region->v2d.cur.xmax - restrict_offsets.hide), te->ys, UI_UNIT_X, UI_UNIT_Y, @@ -1295,7 +1295,7 @@ static void outliner_draw_restrictbuts(uiBlock *block, UI_BTYPE_ICON_TOGGLE, 0, 0, - (int)(region->v2d.cur.xmax - restrict_offsets.viewport), + int(region->v2d.cur.xmax - restrict_offsets.viewport), te->ys, UI_UNIT_X, UI_UNIT_Y, @@ -1318,7 +1318,7 @@ static void outliner_draw_restrictbuts(uiBlock *block, UI_BTYPE_ICON_TOGGLE, 0, 0, - (int)(region->v2d.cur.xmax - restrict_offsets.render), + int(region->v2d.cur.xmax - restrict_offsets.render), te->ys, UI_UNIT_X, UI_UNIT_Y, @@ -1350,7 +1350,7 @@ static void outliner_draw_restrictbuts(uiBlock *block, UI_BTYPE_ICON_TOGGLE, 0, 0, - (int)(region->v2d.cur.xmax - restrict_offsets.viewport), + int(region->v2d.cur.xmax - restrict_offsets.viewport), te->ys, UI_UNIT_X, UI_UNIT_Y, @@ -1374,7 +1374,7 @@ static void outliner_draw_restrictbuts(uiBlock *block, BONE_UNSELECTABLE, 0, ICON_RESTRICT_SELECT_OFF, - (int)(region->v2d.cur.xmax - restrict_offsets.select), + int(region->v2d.cur.xmax - restrict_offsets.select), te->ys, UI_UNIT_X, UI_UNIT_Y, @@ -1400,7 +1400,7 @@ static void outliner_draw_restrictbuts(uiBlock *block, BONE_HIDDEN_A, 0, ICON_RESTRICT_VIEW_OFF, - (int)(region->v2d.cur.xmax - restrict_offsets.viewport), + int(region->v2d.cur.xmax - restrict_offsets.viewport), te->ys, UI_UNIT_X, UI_UNIT_Y, @@ -1422,7 +1422,7 @@ static void outliner_draw_restrictbuts(uiBlock *block, BONE_UNSELECTABLE, 0, ICON_RESTRICT_SELECT_OFF, - (int)(region->v2d.cur.xmax - restrict_offsets.select), + int(region->v2d.cur.xmax - restrict_offsets.select), te->ys, UI_UNIT_X, UI_UNIT_Y, @@ -1448,7 +1448,7 @@ static void outliner_draw_restrictbuts(uiBlock *block, GP_LAYER_HIDE, 0, ICON_HIDE_OFF, - (int)(region->v2d.cur.xmax - restrict_offsets.hide), + int(region->v2d.cur.xmax - restrict_offsets.hide), te->ys, UI_UNIT_X, UI_UNIT_Y, @@ -1469,7 +1469,7 @@ static void outliner_draw_restrictbuts(uiBlock *block, GP_LAYER_LOCKED, 0, ICON_UNLOCKED, - (int)(region->v2d.cur.xmax - restrict_offsets.select), + int(region->v2d.cur.xmax - restrict_offsets.select), te->ys, UI_UNIT_X, UI_UNIT_Y, @@ -1501,7 +1501,7 @@ static void outliner_draw_restrictbuts(uiBlock *block, UI_BTYPE_ICON_TOGGLE, 0, 0, - (int)(region->v2d.cur.xmax) - restrict_offsets.enable, + int(region->v2d.cur.xmax) - restrict_offsets.enable, te->ys, UI_UNIT_X, UI_UNIT_Y, @@ -1521,7 +1521,7 @@ static void outliner_draw_restrictbuts(uiBlock *block, UI_BTYPE_ICON_TOGGLE, 0, 0, - (int)(region->v2d.cur.xmax - restrict_offsets.hide), + int(region->v2d.cur.xmax - restrict_offsets.hide), te->ys, UI_UNIT_X, UI_UNIT_Y, @@ -1550,7 +1550,7 @@ static void outliner_draw_restrictbuts(uiBlock *block, UI_BTYPE_ICON_TOGGLE, 0, 0, - (int)(region->v2d.cur.xmax - restrict_offsets.holdout), + int(region->v2d.cur.xmax - restrict_offsets.holdout), te->ys, UI_UNIT_X, UI_UNIT_Y, @@ -1580,7 +1580,7 @@ static void outliner_draw_restrictbuts(uiBlock *block, UI_BTYPE_ICON_TOGGLE, 0, 0, - (int)(region->v2d.cur.xmax - restrict_offsets.indirect_only), + int(region->v2d.cur.xmax - restrict_offsets.indirect_only), te->ys, UI_UNIT_X, UI_UNIT_Y, @@ -1612,7 +1612,7 @@ static void outliner_draw_restrictbuts(uiBlock *block, UI_BTYPE_ICON_TOGGLE, 0, 0, - (int)(region->v2d.cur.xmax - restrict_offsets.viewport), + int(region->v2d.cur.xmax - restrict_offsets.viewport), te->ys, UI_UNIT_X, UI_UNIT_Y, @@ -1649,7 +1649,7 @@ static void outliner_draw_restrictbuts(uiBlock *block, UI_BTYPE_ICON_TOGGLE, 0, 0, - (int)(region->v2d.cur.xmax - restrict_offsets.render), + int(region->v2d.cur.xmax - restrict_offsets.render), te->ys, UI_UNIT_X, UI_UNIT_Y, @@ -1684,7 +1684,7 @@ static void outliner_draw_restrictbuts(uiBlock *block, UI_BTYPE_ICON_TOGGLE, 0, 0, - (int)(region->v2d.cur.xmax - restrict_offsets.select), + int(region->v2d.cur.xmax - restrict_offsets.select), te->ys, UI_UNIT_X, UI_UNIT_Y, @@ -1759,7 +1759,7 @@ static void outliner_draw_userbuts(uiBlock *block, UI_BTYPE_BUT, 1, buf, - (int)(region->v2d.cur.xmax - OL_TOG_USER_BUTS_USERS), + int(region->v2d.cur.xmax - OL_TOG_USER_BUTS_USERS), te->ys, UI_UNIT_X, UI_UNIT_Y, @@ -1782,7 +1782,7 @@ static void outliner_draw_userbuts(uiBlock *block, LIB_FAKEUSER, 1, ICON_FAKE_USER_OFF, - (int)(region->v2d.cur.xmax - OL_TOG_USER_BUTS_STATUS), + int(region->v2d.cur.xmax - OL_TOG_USER_BUTS_STATUS), te->ys, UI_UNIT_X, UI_UNIT_Y, @@ -2093,7 +2093,7 @@ static void outliner_buttons(const bContext *C, UI_UNIT_Y - 1, (void *)te->name, 1.0, - (float)len, + float(len), 0, 0, ""); @@ -2367,7 +2367,7 @@ static BIFIconID tree_element_get_icon_from_id(const ID *id) /* TODO(sergey): Casting to short here just to handle ID_NLA which is * NOT inside of IDType enum. */ - switch ((short)GS(id->name)) { + switch (short(GS(id->name))) { case ID_SCE: return ICON_SCENE_DATA; case ID_ME: @@ -2952,16 +2952,16 @@ static void outliner_draw_iconrow_number(const uiFontStyle *fstyle, { const float color[4] = {0.0f, 0.0f, 0.0f, 1.0f}; float ufac = 0.25f * UI_UNIT_X; - float offset_x = (float)offsx + UI_UNIT_X * 0.35f; + float offset_x = float(offsx) + UI_UNIT_X * 0.35f; rctf rect{}; BLI_rctf_init(&rect, offset_x + ufac, offset_x + UI_UNIT_X - ufac, - (float)ys - UI_UNIT_Y * 0.2f + ufac, - (float)ys - UI_UNIT_Y * 0.2f + UI_UNIT_Y - ufac); + float(ys) - UI_UNIT_Y * 0.2f + ufac, + float(ys) - UI_UNIT_Y * 0.2f + UI_UNIT_Y - ufac); UI_draw_roundbox_corner_set(UI_CNR_ALL); - UI_draw_roundbox_aa(&rect, true, (float)UI_UNIT_Y / 2.0f - ufac, color); + UI_draw_roundbox_aa(&rect, true, float(UI_UNIT_Y) / 2.0f - ufac, color); /* Now the numbers. */ uchar text_col[4]; @@ -2981,7 +2981,7 @@ static void outliner_draw_iconrow_number(const uiFontStyle *fstyle, } UI_fontstyle_draw_simple(&fstyle_small, (offset_x + ufac + UI_UNIT_X * (2 - num_digits) * 0.12f), - (float)ys - UI_UNIT_Y * 0.095f + ufac, + float(ys) - UI_UNIT_Y * 0.095f + ufac, number_text, text_col); UI_fontstyle_set(fstyle); @@ -3038,10 +3038,10 @@ static void outliner_draw_iconrow_doit(uiBlock *block, icon_border[3] = 0.3f; } - outliner_draw_active_indicator((float)*offsx, - (float)ys, - (float)*offsx + UI_UNIT_X, - (float)ys + UI_UNIT_Y, + outliner_draw_active_indicator(float(*offsx), + float(ys), + float(*offsx) + UI_UNIT_X, + float(ys) + UI_UNIT_Y, icon_color, icon_border); } @@ -3049,10 +3049,10 @@ static void outliner_draw_iconrow_doit(uiBlock *block, if (tselem->flag & TSE_HIGHLIGHTED_ICON) { alpha_fac += 0.5; } - tselem_draw_icon(block, xmax, (float)*offsx, (float)ys, tselem, te, alpha_fac, false); + tselem_draw_icon(block, xmax, float(*offsx), float(ys), tselem, te, alpha_fac, false); te->xs = *offsx; te->ys = ys; - te->xend = (short)*offsx + UI_UNIT_X; + te->xend = short(*offsx) + UI_UNIT_X; if (num_elements > 1) { outliner_draw_iconrow_number(fstyle, *offsx, ys, num_elements); @@ -3327,10 +3327,10 @@ static void outliner_draw_tree_element(bContext *C, /* Active circle. */ if (active != OL_DRAWSEL_NONE) { - outliner_draw_active_indicator((float)startx + offsx + UI_UNIT_X, - (float)*starty, - (float)startx + offsx + 2.0f * UI_UNIT_X, - (float)*starty + UI_UNIT_Y, + outliner_draw_active_indicator(float(startx) + offsx + UI_UNIT_X, + float(*starty), + float(startx) + offsx + 2.0f * UI_UNIT_X, + float(*starty) + UI_UNIT_Y, icon_bgcolor, icon_border); @@ -3347,14 +3347,14 @@ static void outliner_draw_tree_element(bContext *C, /* Icons a bit higher. */ if (TSELEM_OPEN(tselem, space_outliner)) { - UI_icon_draw_alpha((float)icon_x + 2 * ufac, - (float)*starty + 1 * ufac, + UI_icon_draw_alpha(float(icon_x) + 2 * ufac, + float(*starty) + 1 * ufac, ICON_DISCLOSURE_TRI_DOWN, alpha_fac); } else { - UI_icon_draw_alpha((float)icon_x + 2 * ufac, - (float)*starty + 1 * ufac, + UI_icon_draw_alpha(float(icon_x) + 2 * ufac, + float(*starty) + 1 * ufac, ICON_DISCLOSURE_TRI_RIGHT, alpha_fac); } @@ -3365,8 +3365,8 @@ static void outliner_draw_tree_element(bContext *C, if (!(ELEM(tselem->type, TSE_RNA_PROPERTY, TSE_RNA_ARRAY_ELEM, TSE_ID_BASE)) && tselem_draw_icon(block, xmax, - (float)startx + offsx, - (float)*starty, + float(startx) + offsx, + float(*starty), tselem, te, (tselem->flag & TSE_HIGHLIGHTED_ICON) ? alpha_fac + 0.5f : alpha_fac, @@ -3383,7 +3383,7 @@ static void outliner_draw_tree_element(bContext *C, const BIFIconID lib_icon = (BIFIconID)UI_icon_from_library(tselem->id); if (lib_icon != ICON_NONE) { UI_icon_draw_alpha( - (float)startx + offsx + 2 * ufac, (float)*starty + 2 * ufac, lib_icon, alpha_fac); + float(startx) + offsx + 2 * ufac, float(*starty) + 2 * ufac, lib_icon, alpha_fac); offsx += UI_UNIT_X + 4 * ufac; } } @@ -3399,7 +3399,7 @@ static void outliner_draw_tree_element(bContext *C, UI_fontstyle_draw_simple(fstyle, startx + offsx, *starty + 5 * ufac, te->name, text_color); } - offsx += (int)(UI_UNIT_X + UI_fontstyle_string_width(fstyle, te->name)); + offsx += int(UI_UNIT_X + UI_fontstyle_string_width(fstyle, te->name)); /* Closed item, we draw the icons, not when it's a scene, or master-server list though. */ if (!TSELEM_OPEN(tselem, space_outliner)) { @@ -3590,7 +3590,7 @@ static void outliner_draw_struct_marks(ARegion *region, uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_I32, 2, GPU_FETCH_INT_TO_FLOAT); immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR); immThemeColorShadeAlpha(TH_BACK, -15, -200); - immRecti(pos, 0, *starty + 1, (int)region->v2d.cur.xmax, *starty + UI_UNIT_Y - 1); + immRecti(pos, 0, *starty + 1, int(region->v2d.cur.xmax), *starty + UI_UNIT_Y - 1); immUnbindProgram(); } } @@ -3636,16 +3636,16 @@ static void outliner_draw_highlights(uint pos, /* Selection status. */ if ((tselem->flag & TSE_ACTIVE) && (tselem->flag & TSE_SELECTED)) { immUniformColor4fv(col_active); - immRecti(pos, 0, start_y, (int)region->v2d.cur.xmax, start_y + UI_UNIT_Y); + immRecti(pos, 0, start_y, int(region->v2d.cur.xmax), start_y + UI_UNIT_Y); } else if (tselem->flag & TSE_SELECTED) { immUniformColor4fv(col_selection); - immRecti(pos, 0, start_y, (int)region->v2d.cur.xmax, start_y + UI_UNIT_Y); + immRecti(pos, 0, start_y, int(region->v2d.cur.xmax), start_y + UI_UNIT_Y); } /* Highlights. */ if (tselem->flag & (TSE_DRAG_ANY | TSE_HIGHLIGHTED | TSE_SEARCHMATCH)) { - const int end_x = (int)region->v2d.cur.xmax; + const int end_x = int(region->v2d.cur.xmax); if (tselem->flag & TSE_DRAG_ANY) { /* Drag and drop highlight. */ @@ -3749,19 +3749,19 @@ static void outliner_draw_tree(bContext *C, if (space_outliner->outlinevis == SO_DATA_API) { /* struct marks */ - starty = (int)region->v2d.tot.ymax - UI_UNIT_Y - OL_Y_OFFSET; + starty = int(region->v2d.tot.ymax) - UI_UNIT_Y - OL_Y_OFFSET; outliner_draw_struct_marks(region, space_outliner, &space_outliner->tree, &starty); } /* Draw highlights before hierarchy. */ - starty = (int)region->v2d.tot.ymax - UI_UNIT_Y - OL_Y_OFFSET; + starty = int(region->v2d.tot.ymax) - UI_UNIT_Y - OL_Y_OFFSET; startx = 0; outliner_draw_highlights(region, space_outliner, startx, &starty); /* Set scissor so tree elements or lines can't overlap restriction icons. */ int scissor[4] = {0}; if (right_column_width > 0.0f) { - int mask_x = BLI_rcti_size_x(®ion->v2d.mask) - (int)right_column_width + 1; + int mask_x = BLI_rcti_size_x(®ion->v2d.mask) - int(right_column_width) + 1; CLAMP_MIN(mask_x, 0); GPU_scissor_get(scissor); @@ -3769,12 +3769,12 @@ static void outliner_draw_tree(bContext *C, } /* Draw hierarchy lines for collections and object children. */ - starty = (int)region->v2d.tot.ymax - OL_Y_OFFSET; + starty = int(region->v2d.tot.ymax) - OL_Y_OFFSET; startx = columns_offset + UI_UNIT_X / 2 - (U.pixelsize + 1) / 2; outliner_draw_hierarchy_lines(space_outliner, &space_outliner->tree, startx, &starty); /* Items themselves. */ - starty = (int)region->v2d.tot.ymax - UI_UNIT_Y - OL_Y_OFFSET; + starty = int(region->v2d.tot.ymax) - UI_UNIT_Y - OL_Y_OFFSET; startx = columns_offset; LISTBASE_FOREACH (TreeElement *, te, &space_outliner->tree) { outliner_draw_tree_element(C, @@ -3801,7 +3801,7 @@ static void outliner_back(ARegion *region) { int ystart; - ystart = (int)region->v2d.tot.ymax; + ystart = int(region->v2d.tot.ymax); ystart = UI_UNIT_Y * (ystart / (UI_UNIT_Y)) - OL_Y_OFFSET; GPUVertFormat *format = immVertexFormat(); @@ -3815,7 +3815,7 @@ static void outliner_back(ARegion *region) const float x1 = 0.0f, x2 = region->v2d.cur.xmax; float y1 = ystart, y2; - int tot = (int)floor(ystart - region->v2d.cur.ymin + 2 * UI_UNIT_Y) / (2 * UI_UNIT_Y); + int tot = int(floor(ystart - region->v2d.cur.ymin + 2 * UI_UNIT_Y)) / (2 * UI_UNIT_Y); if (tot > 0) { immBegin(GPU_PRIM_TRIS, 6 * tot); diff --git a/source/blender/editors/space_outliner/outliner_edit.cc b/source/blender/editors/space_outliner/outliner_edit.cc index be3c1547579..7a66644b5a8 100644 --- a/source/blender/editors/space_outliner/outliner_edit.cc +++ b/source/blender/editors/space_outliner/outliner_edit.cc @@ -596,7 +596,7 @@ static int outliner_id_remap_exec(bContext *C, wmOperator *op) Main *bmain = CTX_data_main(C); SpaceOutliner *space_outliner = CTX_wm_space_outliner(C); - const short id_type = (short)RNA_enum_get(op->ptr, "id_type"); + const short id_type = short(RNA_enum_get(op->ptr, "id_type")); ID *old_id = static_cast( BLI_findlink(which_libbase(CTX_data_main(C), id_type), RNA_enum_get(op->ptr, "old_id"))); ID *new_id = static_cast( @@ -692,7 +692,7 @@ static const EnumPropertyItem *outliner_id_itemf(bContext *C, int totitem = 0; int i = 0; - short id_type = (short)RNA_enum_get(ptr, "id_type"); + short id_type = short(RNA_enum_get(ptr, "id_type")); ID *id = static_cast(which_libbase(CTX_data_main(C), id_type)->first); for (; id; id = static_cast(id->next)) { @@ -1233,12 +1233,12 @@ void OUTLINER_OT_select_all(wmOperatorType *ot) void outliner_set_coordinates(const ARegion *region, const SpaceOutliner *space_outliner) { - int starty = (int)(region->v2d.tot.ymax) - UI_UNIT_Y; + int starty = int(region->v2d.tot.ymax) - UI_UNIT_Y; tree_iterator::all_open(*space_outliner, [&](TreeElement *te) { /* store coord and continue, we need coordinates for elements outside view too */ te->xs = 0; - te->ys = (float)starty; + te->ys = float(starty); starty -= UI_UNIT_Y; }); } diff --git a/source/blender/editors/space_outliner/outliner_tools.cc b/source/blender/editors/space_outliner/outliner_tools.cc index 1628945c4cd..69ab9a2950e 100644 --- a/source/blender/editors/space_outliner/outliner_tools.cc +++ b/source/blender/editors/space_outliner/outliner_tools.cc @@ -118,7 +118,7 @@ static void get_element_operation_type( *datalevel = tselem->type; } else { - const int idcode = (int)GS(tselem->id->name); + const int idcode = int(GS(tselem->id->name)); bool is_standard_id = false; switch ((ID_Type)idcode) { case ID_SCE: diff --git a/source/blender/editors/space_spreadsheet/spreadsheet_layout.cc b/source/blender/editors/space_spreadsheet/spreadsheet_layout.cc index 3fe4c7c8ee0..7e6b0ab18c3 100644 --- a/source/blender/editors/space_spreadsheet/spreadsheet_layout.cc +++ b/source/blender/editors/space_spreadsheet/spreadsheet_layout.cc @@ -283,7 +283,7 @@ class SpreadsheetLayoutDrawer : public SpreadsheetDrawer { void draw_float_vector(const CellDrawParams ¶ms, const Span values) const { BLI_assert(!values.is_empty()); - const float segment_width = (float)params.width / values.size(); + const float segment_width = float(params.width) / values.size(); for (const int i : values.index_range()) { std::stringstream ss; const float value = values[i]; @@ -314,7 +314,7 @@ class SpreadsheetLayoutDrawer : public SpreadsheetDrawer { { const ColorGeometry4f float_color = color.decode(); Span values(&float_color.r, 4); - const float segment_width = (float)params.width / values.size(); + const float segment_width = float(params.width) / values.size(); for (const int i : values.index_range()) { std::stringstream ss; const float value = values[i]; diff --git a/source/blender/editors/space_spreadsheet/spreadsheet_row_filter.cc b/source/blender/editors/space_spreadsheet/spreadsheet_row_filter.cc index 03cf0116dce..96827692a25 100644 --- a/source/blender/editors/space_spreadsheet/spreadsheet_row_filter.cc +++ b/source/blender/editors/space_spreadsheet/spreadsheet_row_filter.cc @@ -242,14 +242,14 @@ static void apply_row_filter(const SpreadsheetRowFilter &row_filter, switch (row_filter.operation) { case SPREADSHEET_ROW_FILTER_EQUAL: { const float4 value_floats = { - (float)value.r, (float)value.g, (float)value.b, (float)value.a}; + float(value.r), float(value.g), float(value.b), float(value.a)}; const float threshold_sq = pow2f(row_filter.threshold); apply_filter_operation( column_data.typed(), [&](const ColorGeometry4b cell_bytes) { const ColorGeometry4f cell = cell_bytes.decode(); const float4 cell_floats = { - (float)cell.r, (float)cell.g, (float)cell.b, (float)cell.a}; + float(cell.r), float(cell.g), float(cell.b), float(cell.a)}; return len_squared_v4v4(value_floats, cell_floats) <= threshold_sq; }, prev_mask, diff --git a/source/blender/editors/space_spreadsheet/spreadsheet_row_filter_ui.cc b/source/blender/editors/space_spreadsheet/spreadsheet_row_filter_ui.cc index 548e6cf29e4..a1f6de56bb2 100644 --- a/source/blender/editors/space_spreadsheet/spreadsheet_row_filter_ui.cc +++ b/source/blender/editors/space_spreadsheet/spreadsheet_row_filter_ui.cc @@ -309,7 +309,7 @@ static short get_filter_expand_flag(const bContext *UNUSED(C), Panel *panel) PointerRNA *filter_ptr = UI_panel_custom_data_get(panel); SpreadsheetRowFilter *filter = (SpreadsheetRowFilter *)filter_ptr->data; - return (short)filter->flag & SPREADSHEET_ROW_FILTER_UI_EXPAND; + return short(filter->flag) & SPREADSHEET_ROW_FILTER_UI_EXPAND; } static void set_filter_expand_flag(const bContext *UNUSED(C), Panel *panel, short expand_flag) diff --git a/source/blender/editors/space_view3d/space_view3d.cc b/source/blender/editors/space_view3d/space_view3d.cc index 418330d1e70..1bbe6ccc529 100644 --- a/source/blender/editors/space_view3d/space_view3d.cc +++ b/source/blender/editors/space_view3d/space_view3d.cc @@ -778,7 +778,7 @@ static void view3d_collection_drop_copy_local_id(bContext *UNUSED(C), wmDropBox *drop) { ID *id = WM_drag_get_local_ID(drag, ID_GR); - RNA_int_set(drop->ptr, "session_uuid", (int)id->session_uuid); + RNA_int_set(drop->ptr, "session_uuid", int(id->session_uuid)); } /* Mostly the same logic as #view3d_ob_drop_copy_external_asset(), just different enough to make @@ -803,7 +803,7 @@ static void view3d_collection_drop_copy_external_asset(bContext *UNUSED(C), DEG_relations_tag_update(CTX_data_main(C)); WM_event_add_notifier(C, NC_SCENE | ND_LAYER_CONTENT, scene); - RNA_int_set(drop->ptr, "session_uuid", (int)id->session_uuid); + RNA_int_set(drop->ptr, "session_uuid", int(id->session_uuid)); /* Make an object active, just use the first one in the collection. */ CollectionObject *cobject = static_cast(collection->gobject.first); diff --git a/source/blender/editors/space_view3d/view3d_select.cc b/source/blender/editors/space_view3d/view3d_select.cc index 9a2512adc31..f38b22fce4d 100644 --- a/source/blender/editors/space_view3d/view3d_select.cc +++ b/source/blender/editors/space_view3d/view3d_select.cc @@ -2246,7 +2246,7 @@ static Base *mouse_select_object_center(ViewContext *vc, Base *startbase, const BKE_view_layer_synced_ensure(scene, view_layer); Base *oldbasact = BKE_view_layer_active_base_get(view_layer); - const float mval_fl[2] = {(float)mval[0], (float)mval[1]}; + const float mval_fl[2] = {float(mval[0]), float(mval[1])}; float dist = ED_view3d_select_dist_px() * 1.3333f; Base *basact = nullptr; @@ -4068,7 +4068,7 @@ static bool mesh_circle_select(ViewContext *vc, if (use_zbuf) { if (esel->select_bitmap == nullptr) { esel->select_bitmap = DRW_select_buffer_bitmap_from_circle( - vc->depsgraph, vc->region, vc->v3d, mval, (int)(rad + 1.0f), nullptr); + vc->depsgraph, vc->region, vc->v3d, mval, int(rad + 1.0f), nullptr); } } @@ -4144,7 +4144,7 @@ static bool paint_facesel_circle_select(ViewContext *vc, { EditSelectBuf_Cache *esel = static_cast(wm_userdata->data); esel->select_bitmap = DRW_select_buffer_bitmap_from_circle( - vc->depsgraph, vc->region, vc->v3d, mval, (int)(rad + 1.0f), nullptr); + vc->depsgraph, vc->region, vc->v3d, mval, int(rad + 1.0f), nullptr); if (esel->select_bitmap != nullptr) { changed |= edbm_backbuf_check_and_select_faces_obmode(me, esel, sel_op); MEM_freeN(esel->select_bitmap); @@ -4206,7 +4206,7 @@ static bool paint_vertsel_circle_select(ViewContext *vc, if (use_zbuf) { EditSelectBuf_Cache *esel = static_cast(wm_userdata->data); esel->select_bitmap = DRW_select_buffer_bitmap_from_circle( - vc->depsgraph, vc->region, vc->v3d, mval, (int)(rad + 1.0f), nullptr); + vc->depsgraph, vc->region, vc->v3d, mval, int(rad + 1.0f), nullptr); if (esel->select_bitmap != nullptr) { changed |= edbm_backbuf_check_and_select_verts_obmode(me, esel, sel_op); MEM_freeN(esel->select_bitmap); @@ -4770,16 +4770,16 @@ static int view3d_circle_select_exec(bContext *C, wmOperator *op) obedit = vc.obedit; if (obedit) { - obedit_circle_select(C, &vc, wm_userdata, sel_op, mval, (float)radius); + obedit_circle_select(C, &vc, wm_userdata, sel_op, mval, float(radius)); } else if (BKE_paint_select_face_test(obact)) { - paint_facesel_circle_select(&vc, wm_userdata, sel_op, mval, (float)radius); + paint_facesel_circle_select(&vc, wm_userdata, sel_op, mval, float(radius)); } else if (BKE_paint_select_vert_test(obact)) { - paint_vertsel_circle_select(&vc, wm_userdata, sel_op, mval, (float)radius); + paint_vertsel_circle_select(&vc, wm_userdata, sel_op, mval, float(radius)); } else if (obact->mode & OB_MODE_POSE) { - pose_circle_select(&vc, sel_op, mval, (float)radius); + pose_circle_select(&vc, sel_op, mval, float(radius)); ED_outliner_select_sync_from_pose_bone_tag(C); } else { @@ -4789,7 +4789,7 @@ static int view3d_circle_select_exec(bContext *C, wmOperator *op) FOREACH_OBJECT_IN_MODE_END; } else if (obact && (obact->mode & OB_MODE_PARTICLE_EDIT)) { - if (PE_circle_select(C, wm_userdata, sel_op, mval, (float)radius)) { + if (PE_circle_select(C, wm_userdata, sel_op, mval, float(radius))) { return OPERATOR_FINISHED; } return OPERATOR_CANCELLED; @@ -4798,7 +4798,7 @@ static int view3d_circle_select_exec(bContext *C, wmOperator *op) return OPERATOR_CANCELLED; } else { - if (object_circle_select(&vc, sel_op, mval, (float)radius)) { + if (object_circle_select(&vc, sel_op, mval, float(radius))) { DEG_id_tag_update(&vc.scene->id, ID_RECALC_SELECT); WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, vc.scene); diff --git a/source/blender/editors/transform/transform_snap_object.cc b/source/blender/editors/transform/transform_snap_object.cc index 6d643ae7180..422ab85279b 100644 --- a/source/blender/editors/transform/transform_snap_object.cc +++ b/source/blender/editors/transform/transform_snap_object.cc @@ -1293,7 +1293,7 @@ static bool nearest_world_tree(SnapObjectContext *UNUSED(sctx), *r_dist_sq = dist_sq; /* scale to make `snap_face_nearest_steps` steps */ - float step_scale_factor = 1.0f / max_ff(1.0f, (float)params->face_nearest_steps); + float step_scale_factor = 1.0f / max_ff(1.0f, float(params->face_nearest_steps)); mul_v3_fl(delta_local, step_scale_factor); float co_local[3]; diff --git a/source/blender/editors/uvedit/uvedit_islands.cc b/source/blender/editors/uvedit/uvedit_islands.cc index 42415be656a..793b72b67de 100644 --- a/source/blender/editors/uvedit/uvedit_islands.cc +++ b/source/blender/editors/uvedit/uvedit_islands.cc @@ -539,7 +539,7 @@ void ED_uvedit_pack_islands_multi(const Scene *scene, /* Logic matches behavior from #param_pack, * use area so multiply the margin by the area to give * predictable results not dependent on UV scale. */ - margin = (margin * (float)area) * 0.1f; + margin = (margin * float(area)) * 0.1f; for (int i = 0; i < island_list_len; i++) { struct FaceIsland *island = island_array[i]; BoxPack *box = &boxarray[i]; diff --git a/source/blender/freestyle/intern/application/AppCanvas.cpp b/source/blender/freestyle/intern/application/AppCanvas.cpp index 0367f5c1d6d..109afd48b1b 100644 --- a/source/blender/freestyle/intern/application/AppCanvas.cpp +++ b/source/blender/freestyle/intern/application/AppCanvas.cpp @@ -118,8 +118,8 @@ void AppCanvas::readColorPixels(int x, int y, int w, int h, RGBImage &oImage) co int ymax = border().getMax().y(); int rectx = _pass_diffuse.width; int recty = _pass_diffuse.height; - float xfac = ((float)rectx) / ((float)(xmax - xmin)); - float yfac = ((float)recty) / ((float)(ymax - ymin)); + float xfac = float(rectx) / float(xmax - xmin); + float yfac = float(recty) / float(ymax - ymin); #if 0 if (G.debug & G_DEBUG_FREESTYLE) { printf("readColorPixels %d x %d @ (%d, %d) in %d x %d [%d x %d] -- %d x %d @ %d%%\n", @@ -138,12 +138,12 @@ void AppCanvas::readColorPixels(int x, int y, int w, int h, RGBImage &oImage) co #endif int ii, jj; for (int j = 0; j < h; j++) { - jj = (int)((y - ymin + j) * yfac); + jj = int((y - ymin + j) * yfac); if (jj < 0 || jj >= recty) { continue; } for (int i = 0; i < w; i++) { - ii = (int)((x - xmin + i) * xfac); + ii = int((x - xmin + i) * xfac); if (ii < 0 || ii >= rectx) { continue; } @@ -167,8 +167,8 @@ void AppCanvas::readDepthPixels(int x, int y, int w, int h, GrayImage &oImage) c int ymax = border().getMax().y(); int rectx = _pass_z.width; int recty = _pass_z.height; - float xfac = ((float)rectx) / ((float)(xmax - xmin)); - float yfac = ((float)recty) / ((float)(ymax - ymin)); + float xfac = float(rectx) / float(xmax - xmin); + float yfac = float(recty) / float(ymax - ymin); #if 0 if (G.debug & G_DEBUG_FREESTYLE) { printf("readDepthPixels %d x %d @ (%d, %d) in %d x %d [%d x %d] -- %d x %d @ %d%%\n", @@ -187,12 +187,12 @@ void AppCanvas::readDepthPixels(int x, int y, int w, int h, GrayImage &oImage) c #endif int ii, jj; for (int j = 0; j < h; j++) { - jj = (int)((y - ymin + j) * yfac); + jj = int((y - ymin + j) * yfac); if (jj < 0 || jj >= recty) { continue; } for (int i = 0; i < w; i++) { - ii = (int)((x - xmin + i) * xfac); + ii = int((x - xmin + i) * xfac); if (ii < 0 || ii >= rectx) { continue; } diff --git a/source/blender/freestyle/intern/blender_interface/BlenderFileLoader.cpp b/source/blender/freestyle/intern/blender_interface/BlenderFileLoader.cpp index 27c4bbe9bc4..dec443064de 100644 --- a/source/blender/freestyle/intern/blender_interface/BlenderFileLoader.cpp +++ b/source/blender/freestyle/intern/blender_interface/BlenderFileLoader.cpp @@ -754,7 +754,7 @@ void BlenderFileLoader::insertShapeNode(Object *ob, Mesh *me, int id) if (G.debug & G_DEBUG_FREESTYLE) { printf("Warning: Object %s contains %lu degenerated triangle%s (strokes may be incorrect)\n", name, - (ulong)detriList.size(), + ulong(detriList.size()), (detriList.size() > 1) ? "s" : ""); } } diff --git a/source/blender/freestyle/intern/geometry/Bezier.cpp b/source/blender/freestyle/intern/geometry/Bezier.cpp index b12b189853c..30eece55d5f 100644 --- a/source/blender/freestyle/intern/geometry/Bezier.cpp +++ b/source/blender/freestyle/intern/geometry/Bezier.cpp @@ -50,7 +50,7 @@ void BezierCurveSegment::Build() y[3] = p0->y(); int nvertices = 12; - float increment = 1.0 / (float)nvertices; + float increment = 1.0 / float(nvertices); float t = 0.0f; for (int i = 0; i <= nvertices; ++i) { _Vertices.emplace_back((x[3] + t * (x[2] + t * (x[1] + t * x[0]))), diff --git a/source/blender/freestyle/intern/geometry/GeomCleaner.cpp b/source/blender/freestyle/intern/geometry/GeomCleaner.cpp index 736191da87e..1bbea79d793 100644 --- a/source/blender/freestyle/intern/geometry/GeomCleaner.cpp +++ b/source/blender/freestyle/intern/geometry/GeomCleaner.cpp @@ -172,9 +172,9 @@ struct GeomCleanerHasher { #define _MOD 2147483647UL inline size_t operator()(const Vec3r &p) const { - size_t res = ((ulong)(p[0] * _MUL)) % _MOD; - res = (res + (ulong)(p[1]) * _MUL) % _MOD; - return (res + (ulong)(p[2]) * _MUL) % _MOD; + size_t res = ulong(p[0] * _MUL) % _MOD; + res = (res + ulong(p[1]) * _MUL) % _MOD; + return (res + ulong(p[2]) * _MUL) % _MOD; } #undef _MUL #undef _MOD diff --git a/source/blender/freestyle/intern/geometry/Grid.cpp b/source/blender/freestyle/intern/geometry/Grid.cpp index 33c7d04cb4c..ad45ab4eb42 100644 --- a/source/blender/freestyle/intern/geometry/Grid.cpp +++ b/source/blender/freestyle/intern/geometry/Grid.cpp @@ -355,7 +355,7 @@ bool Grid::initInfiniteRay(const Vec3r &orig, const Vec3r &dir, unsigned timesta BBox box(boxMin, boxMax); if (box.inside(orig)) { for (uint i = 0; i < 3; i++) { - _current_cell[i] = (uint)floor((orig[i] - _orig[i]) / _cell_size[i]); + _current_cell[i] = uint(floor((orig[i] - _orig[i]) / _cell_size[i])); // soc unused - unsigned u = _current_cell[i]; _pt[i] = orig[i] - _orig[i] - _current_cell[i] * _cell_size[i]; } diff --git a/source/blender/freestyle/intern/geometry/Noise.cpp b/source/blender/freestyle/intern/geometry/Noise.cpp index d8a09bd8ab7..95a742e9d0d 100644 --- a/source/blender/freestyle/intern/geometry/Noise.cpp +++ b/source/blender/freestyle/intern/geometry/Noise.cpp @@ -45,7 +45,7 @@ namespace Freestyle { (t) = (i) + (N); \ (r0) = modff((t), &(u)); \ (r1) = (r0)-1.0; \ - (b0) = ((int)(u)) & BM; \ + (b0) = int(u) & BM; \ (b1) = ((b0) + 1) & BM; \ } \ (void)0 @@ -229,15 +229,15 @@ Noise::Noise(long seed) for (i = 0; i < _NOISE_B; i++) { p[i] = i; - g1[i] = (float)((BLI_rng_get_int(rng) % (_NOISE_B + _NOISE_B)) - _NOISE_B) / _NOISE_B; + g1[i] = float((BLI_rng_get_int(rng) % (_NOISE_B + _NOISE_B)) - _NOISE_B) / _NOISE_B; for (j = 0; j < 2; j++) { - g2[i][j] = (float)((BLI_rng_get_int(rng) % (_NOISE_B + _NOISE_B)) - _NOISE_B) / _NOISE_B; + g2[i][j] = float((BLI_rng_get_int(rng) % (_NOISE_B + _NOISE_B)) - _NOISE_B) / _NOISE_B; } normalize2(g2[i]); for (j = 0; j < 3; j++) { - g3[i][j] = (float)((BLI_rng_get_int(rng) % (_NOISE_B + _NOISE_B)) - _NOISE_B) / _NOISE_B; + g3[i][j] = float((BLI_rng_get_int(rng) % (_NOISE_B + _NOISE_B)) - _NOISE_B) / _NOISE_B; } normalize3(g3[i]); } diff --git a/source/blender/freestyle/intern/image/GaussianFilter.cpp b/source/blender/freestyle/intern/image/GaussianFilter.cpp index 7e523311d4c..421b739197b 100644 --- a/source/blender/freestyle/intern/image/GaussianFilter.cpp +++ b/source/blender/freestyle/intern/image/GaussianFilter.cpp @@ -46,7 +46,7 @@ GaussianFilter::~GaussianFilter() int GaussianFilter::computeMaskSize(float sigma) { - int maskSize = (int)floor(4 * sigma) + 1; + int maskSize = int(floor(4 * sigma)) + 1; if (0 == (maskSize % 2)) { ++maskSize; } diff --git a/source/blender/freestyle/intern/image/ImagePyramid.cpp b/source/blender/freestyle/intern/image/ImagePyramid.cpp index f595efabe0b..d1a41fc82db 100644 --- a/source/blender/freestyle/intern/image/ImagePyramid.cpp +++ b/source/blender/freestyle/intern/image/ImagePyramid.cpp @@ -96,7 +96,7 @@ float ImagePyramid::pixel(int x, int y, int level) else { P2 = P1; } - return (1.0f / (float)(1 << (2 * level))) * (C * P1 + D * P2); + return (1.0f / float(1 << (2 * level))) * (C * P1 + D * P2); } int ImagePyramid::width(int level) diff --git a/source/blender/freestyle/intern/python/BPy_Interface1D.cpp b/source/blender/freestyle/intern/python/BPy_Interface1D.cpp index fbe81d26e79..1a353c2174f 100644 --- a/source/blender/freestyle/intern/python/BPy_Interface1D.cpp +++ b/source/blender/freestyle/intern/python/BPy_Interface1D.cpp @@ -278,7 +278,7 @@ static PyObject *Interface1D_length_2d_get(BPy_Interface1D *self, void *UNUSED(c if (PyErr_Occurred()) { return nullptr; } - return PyFloat_FromDouble((double)length); + return PyFloat_FromDouble(double(length)); } PyDoc_STRVAR(Interface1D_time_stamp_doc, diff --git a/source/blender/freestyle/intern/python/Interface0D/CurvePoint/BPy_StrokeVertex.cpp b/source/blender/freestyle/intern/python/Interface0D/CurvePoint/BPy_StrokeVertex.cpp index 54996067e72..228be7f4f76 100644 --- a/source/blender/freestyle/intern/python/Interface0D/CurvePoint/BPy_StrokeVertex.cpp +++ b/source/blender/freestyle/intern/python/Interface0D/CurvePoint/BPy_StrokeVertex.cpp @@ -153,8 +153,8 @@ static int StrokeVertex_mathutils_check(BaseMathObject *bmo) static int StrokeVertex_mathutils_get(BaseMathObject *bmo, int /*subtype*/) { BPy_StrokeVertex *self = (BPy_StrokeVertex *)bmo->cb_user; - bmo->data[0] = (float)self->sv->x(); - bmo->data[1] = (float)self->sv->y(); + bmo->data[0] = float(self->sv->x()); + bmo->data[1] = float(self->sv->y()); return 0; } @@ -171,10 +171,10 @@ static int StrokeVertex_mathutils_get_index(BaseMathObject *bmo, int /*subtype*/ BPy_StrokeVertex *self = (BPy_StrokeVertex *)bmo->cb_user; switch (index) { case 0: - bmo->data[0] = (float)self->sv->x(); + bmo->data[0] = float(self->sv->x()); break; case 1: - bmo->data[1] = (float)self->sv->y(); + bmo->data[1] = float(self->sv->y()); break; default: return -1; diff --git a/source/blender/freestyle/intern/stroke/AdvancedFunctions0D.cpp b/source/blender/freestyle/intern/stroke/AdvancedFunctions0D.cpp index 0bd2b960de3..37f5fb5cfbb 100644 --- a/source/blender/freestyle/intern/stroke/AdvancedFunctions0D.cpp +++ b/source/blender/freestyle/intern/stroke/AdvancedFunctions0D.cpp @@ -25,13 +25,13 @@ int DensityF0D::operator()(Interface0DIterator &iter) } RGBImage image; - canvas->readColorPixels((int)iter->getProjectedX() - bound, - (int)iter->getProjectedY() - bound, + canvas->readColorPixels(int(iter->getProjectedX()) - bound, + int(iter->getProjectedY()) - bound, _filter.maskSize(), _filter.maskSize(), image); result = _filter.getSmoothedPixel( - &image, (int)iter->getProjectedX(), (int)iter->getProjectedY()); + &image, int(iter->getProjectedX()), int(iter->getProjectedY())); return 0; } @@ -48,13 +48,13 @@ int LocalAverageDepthF0D::operator()(Interface0DIterator &iter) } GrayImage image; - iViewer->readDepthPixels((int)iter->getProjectedX() - bound, - (int)iter->getProjectedY() - bound, + iViewer->readDepthPixels(int(iter->getProjectedX()) - bound, + int(iter->getProjectedY()) - bound, _filter.maskSize(), _filter.maskSize(), image); result = _filter.getSmoothedPixel( - &image, (int)iter->getProjectedX(), (int)iter->getProjectedY()); + &image, int(iter->getProjectedX()), int(iter->getProjectedY())); return 0; } @@ -63,7 +63,7 @@ int ReadMapPixelF0D::operator()(Interface0DIterator &iter) { Canvas *canvas = Canvas::getInstance(); result = canvas->readMapPixel( - _mapName, _level, (int)iter->getProjectedX(), (int)iter->getProjectedY()); + _mapName, _level, int(iter->getProjectedX()), int(iter->getProjectedY())); return 0; } @@ -71,7 +71,7 @@ int ReadSteerableViewMapPixelF0D::operator()(Interface0DIterator &iter) { SteerableViewMap *svm = Canvas::getInstance()->getSteerableViewMap(); result = svm->readSteerableViewMapPixel( - _orientation, _level, (int)iter->getProjectedX(), (int)iter->getProjectedY()); + _orientation, _level, int(iter->getProjectedX()), int(iter->getProjectedY())); return 0; } @@ -79,7 +79,7 @@ int ReadCompleteViewMapPixelF0D::operator()(Interface0DIterator &iter) { SteerableViewMap *svm = Canvas::getInstance()->getSteerableViewMap(); result = svm->readCompleteViewMapPixel( - _level, (int)iter->getProjectedX(), (int)iter->getProjectedY()); + _level, int(iter->getProjectedX()), int(iter->getProjectedY())); return 0; } @@ -87,12 +87,12 @@ int GetViewMapGradientNormF0D::operator()(Interface0DIterator &iter) { SteerableViewMap *svm = Canvas::getInstance()->getSteerableViewMap(); float pxy = svm->readCompleteViewMapPixel( - _level, (int)iter->getProjectedX(), (int)iter->getProjectedY()); + _level, int(iter->getProjectedX()), int(iter->getProjectedY())); float gx = svm->readCompleteViewMapPixel( - _level, (int)iter->getProjectedX() + _step, (int)iter->getProjectedY()) - + _level, int(iter->getProjectedX()) + _step, int(iter->getProjectedY())) - pxy; float gy = svm->readCompleteViewMapPixel( - _level, (int)iter->getProjectedX(), (int)iter->getProjectedY() + _step) - + _level, int(iter->getProjectedX()), int(iter->getProjectedY()) + _step) - pxy; result = Vec2f(gx, gy).norm(); return 0; diff --git a/source/blender/freestyle/intern/stroke/AdvancedFunctions1D.cpp b/source/blender/freestyle/intern/stroke/AdvancedFunctions1D.cpp index a759cc333f1..d12aab45215 100644 --- a/source/blender/freestyle/intern/stroke/AdvancedFunctions1D.cpp +++ b/source/blender/freestyle/intern/stroke/AdvancedFunctions1D.cpp @@ -38,7 +38,7 @@ int GetSteerableViewMapDensityF1D::operator()(Interface1D &inter) } Vec2r m((i0D.getProjectedX() + i0Dnext.getProjectedX()) / 2.0, (i0D.getProjectedY() + i0Dnext.getProjectedY()) / 2.0); - values.push_back(svm->readSteerableViewMapPixel(nSVM, _level, (int)m[0], (int)m[1])); + values.push_back(svm->readSteerableViewMapPixel(nSVM, _level, int(m[0]), int(m[1]))); ++it; ++itnext; } diff --git a/source/blender/freestyle/intern/stroke/BasicStrokeShaders.cpp b/source/blender/freestyle/intern/stroke/BasicStrokeShaders.cpp index 75115b4abac..dd0239322ab 100644 --- a/source/blender/freestyle/intern/stroke/BasicStrokeShaders.cpp +++ b/source/blender/freestyle/intern/stroke/BasicStrokeShaders.cpp @@ -80,11 +80,11 @@ int IncreasingThicknessShader::shade(Stroke &stroke) const for (i = 0, v = stroke.strokeVerticesBegin(), vend = stroke.strokeVerticesEnd(); v != vend; ++v, ++i) { float t; - if (i < (float)n / 2.0f) { - t = (1.0 - (float)i / (float)n) * _ThicknessMin + (float)i / (float)n * _ThicknessMax; + if (i < float(n) / 2.0f) { + t = (1.0 - float(i) / float(n)) * _ThicknessMin + float(i) / float(n) * _ThicknessMax; } else { - t = (1.0 - (float)i / (float)n) * _ThicknessMax + (float)i / (float)n * _ThicknessMin; + t = (1.0 - float(i) / float(n)) * _ThicknessMax + float(i) / float(n) * _ThicknessMin; } v->attribute().setThickness(t / 2.0, t / 2.0); } @@ -102,11 +102,11 @@ int ConstrainedIncreasingThicknessShader::shade(Stroke &stroke) const // XXX Why not using an if/else here? Else, if last condition is true, everything else is // computed for nothing! float t; - if (i < (float)n / 2.0f) { - t = (1.0 - (float)i / (float)n) * _ThicknessMin + (float)i / (float)n * maxT; + if (i < float(n) / 2.0f) { + t = (1.0 - float(i) / float(n)) * _ThicknessMin + float(i) / float(n) * maxT; } else { - t = (1.0 - (float)i / (float)n) * maxT + (float)i / (float)n * _ThicknessMin; + t = (1.0 - float(i) / float(n)) * maxT + float(i) / float(n) * _ThicknessMin; } v->attribute().setThickness(t / 2.0, t / 2.0); if (i == n - 1) { @@ -157,13 +157,13 @@ static const unsigned NB_VALUE_NOISE = 512; ThicknessNoiseShader::ThicknessNoiseShader() { _amplitude = 1.0f; - _scale = 1.0f / 2.0f / (float)NB_VALUE_NOISE; + _scale = 1.0f / 2.0f / float(NB_VALUE_NOISE); } ThicknessNoiseShader::ThicknessNoiseShader(float iAmplitude, float iPeriod) { _amplitude = iAmplitude; - _scale = 1.0f / iPeriod / (float)NB_VALUE_NOISE; + _scale = 1.0f / iPeriod / float(NB_VALUE_NOISE); } int ThicknessNoiseShader::shade(Stroke &stroke) const @@ -213,8 +213,8 @@ int IncreasingColorShader::shade(Stroke &stroke) const for (yo = 0, v = stroke.strokeVerticesBegin(), vend = stroke.strokeVerticesEnd(); v != vend; ++v, ++yo) { for (int i = 0; i < 4; ++i) { - newcolor[i] = (1.0 - (float)yo / (float)n) * _colorMin[i] + - (float)yo / (float)n * _colorMax[i]; + newcolor[i] = (1.0 - float(yo) / float(n)) * _colorMin[i] + + float(yo) / float(n) * _colorMax[i]; } v->attribute().setColor(newcolor[0], newcolor[1], newcolor[2]); v->attribute().setAlpha(newcolor[3]); @@ -243,13 +243,13 @@ int MaterialColorShader::shade(Stroke &stroke) const ColorNoiseShader::ColorNoiseShader() { _amplitude = 1.0f; - _scale = 1.0f / 2.0f / (float)NB_VALUE_NOISE; + _scale = 1.0f / 2.0f / float(NB_VALUE_NOISE); } ColorNoiseShader::ColorNoiseShader(float iAmplitude, float iPeriod) { _amplitude = iAmplitude; - _scale = 1.0f / iPeriod / (float)NB_VALUE_NOISE; + _scale = 1.0f / iPeriod / float(NB_VALUE_NOISE); } int ColorNoiseShader::shade(Stroke &stroke) const @@ -467,7 +467,7 @@ int BezierCurveShader::shade(Stroke &stroke) const vector::iterator a = attributes.begin(), aend = attributes.end(); int index = 0; - int index1 = (int)floor((float)originalSize / 2.0); + int index1 = int(floor(float(originalSize) / 2.0)); int index2 = index1 + nExtraVertex; for (it = stroke.strokeVerticesBegin(), itend = stroke.strokeVerticesEnd(); (it != itend) && (a != aend); @@ -666,7 +666,7 @@ int TipRemoverShader::shade(Stroke &stroke) const // Resample so that our new stroke have the same number of vertices than before stroke.Resample(originalSize); - if ((int)stroke.strokeVerticesSize() != originalSize) { // soc + if (int(stroke.strokeVerticesSize()) != originalSize) { // soc cerr << "Warning: resampling problem" << endl; } diff --git a/source/blender/freestyle/intern/stroke/Stroke.cpp b/source/blender/freestyle/intern/stroke/Stroke.cpp index 101b89d720a..7aacf61c604 100644 --- a/source/blender/freestyle/intern/stroke/Stroke.cpp +++ b/source/blender/freestyle/intern/stroke/Stroke.cpp @@ -486,11 +486,11 @@ void Stroke::setLength(float iLength) float Stroke::ComputeSampling(int iNVertices) { - if (iNVertices <= (int)_Vertices.size()) { // soc + if (iNVertices <= int(_Vertices.size())) { // soc return _sampling; } - float sampling = _Length / (float)(iNVertices - _Vertices.size() + 1); + float sampling = _Length / float(iNVertices - _Vertices.size() + 1); return sampling; } @@ -542,8 +542,8 @@ int Stroke::Resample(int iNPoints) Vec2r b((next)->getPoint()); Vec2r vec_tmp(b - a); real norm_var = vec_tmp.norm(); - int numberOfPointsToAdd = (int)floor(NPointsToAdd * norm_var / _Length); - float csampling = norm_var / (float)(numberOfPointsToAdd + 1); + int numberOfPointsToAdd = int(floor(NPointsToAdd * norm_var / _Length)); + float csampling = norm_var / float(numberOfPointsToAdd + 1); strokeSegments.emplace_back(it, next, norm_var, numberOfPointsToAdd, csampling); N += numberOfPointsToAdd; meanlength += norm_var; @@ -551,7 +551,7 @@ int Stroke::Resample(int iNPoints) ++it; ++next; } - meanlength /= (float)nsegments; + meanlength /= float(nsegments); // if we don't have enough points let's resample finer some segments bool checkEveryone = false; @@ -571,7 +571,7 @@ int Stroke::Resample(int iNPoints) } // resample s->_n = s->_n + 1; - s->_sampling = s->_length / (float)(s->_n + 1); + s->_sampling = s->_length / float(s->_n + 1); s->_resampled = resampled = true; N++; if (N == NPointsToAdd) { diff --git a/source/blender/freestyle/intern/stroke/StrokeRep.cpp b/source/blender/freestyle/intern/stroke/StrokeRep.cpp index e8ff46df731..282c72617f0 100644 --- a/source/blender/freestyle/intern/stroke/StrokeRep.cpp +++ b/source/blender/freestyle/intern/stroke/StrokeRep.cpp @@ -360,7 +360,7 @@ void Strip::createStrip(const vector &iStrokeVertices) } } - if (i != 2 * (int)iStrokeVertices.size()) { + if (i != 2 * int(iStrokeVertices.size())) { if (G.debug & G_DEBUG_FREESTYLE) { cout << "Warning: problem with stripe size\n"; } diff --git a/source/blender/freestyle/intern/system/PseudoNoise.cpp b/source/blender/freestyle/intern/system/PseudoNoise.cpp index 354aef13115..9bb597a8a67 100644 --- a/source/blender/freestyle/intern/system/PseudoNoise.cpp +++ b/source/blender/freestyle/intern/system/PseudoNoise.cpp @@ -15,7 +15,7 @@ static int modf_to_index(Freestyle::real x, uint range) { if (isfinite(x)) { Freestyle::real tmp; - int i = abs((int)(modf(x, &tmp) * range)); + int i = abs(int(modf(x, &tmp) * range)); BLI_assert(i >= 0 && i < range); return i; } diff --git a/source/blender/freestyle/intern/system/RandGen.cpp b/source/blender/freestyle/intern/system/RandGen.cpp index c5559f39147..bb6970bc27a 100644 --- a/source/blender/freestyle/intern/system/RandGen.cpp +++ b/source/blender/freestyle/intern/system/RandGen.cpp @@ -32,13 +32,13 @@ namespace Freestyle { #define MUL(x, y, z) \ { \ - long l = (long)(x) * (long)(y); \ + long l = long(x) * long(y); \ (z)[0] = LOW(l); \ (z)[1] = HIGH(l); \ } \ ((void)0) -#define CARRY(x, y) ((ulong)((long)(x) + (long)(y)) > MASK) +#define CARRY(x, y) (ulong(long(x) + long(y)) > MASK) #define ADDEQU(x, y, z) (z = CARRY(x, (y)), x = LOW(x + (y))) #define SET3(x, x0, x1, x2) ((x)[0] = (x0), (x)[1] = (x1), (x)[2] = (x2)) #if 0 // XXX, unused diff --git a/source/blender/freestyle/intern/view_map/BoxGrid.cpp b/source/blender/freestyle/intern/view_map/BoxGrid.cpp index eac6765da99..4c79d6c2fa1 100644 --- a/source/blender/freestyle/intern/view_map/BoxGrid.cpp +++ b/source/blender/freestyle/intern/view_map/BoxGrid.cpp @@ -188,8 +188,8 @@ void BoxGrid::reorganizeCells() void BoxGrid::getCellCoordinates(const Vec3r &point, unsigned &x, unsigned &y) { - x = min(_cellsX - 1, (unsigned)floor(max((double)0.0f, point[0] - _cellOrigin[0]) / _cellSize)); - y = min(_cellsY - 1, (unsigned)floor(max((double)0.0f, point[1] - _cellOrigin[1]) / _cellSize)); + x = min(_cellsX - 1, (unsigned)floor(max(double(0.0f), point[0] - _cellOrigin[0]) / _cellSize)); + y = min(_cellsY - 1, (unsigned)floor(max(double(0.0f), point[1] - _cellOrigin[1]) / _cellSize)); } BoxGrid::Cell *BoxGrid::findCell(const Vec3r &point) diff --git a/source/blender/freestyle/intern/view_map/SphericalGrid.cpp b/source/blender/freestyle/intern/view_map/SphericalGrid.cpp index 70f10058411..5e27e344c28 100644 --- a/source/blender/freestyle/intern/view_map/SphericalGrid.cpp +++ b/source/blender/freestyle/intern/view_map/SphericalGrid.cpp @@ -184,8 +184,8 @@ void SphericalGrid::reorganizeCells() void SphericalGrid::getCellCoordinates(const Vec3r &point, unsigned &x, unsigned &y) { - x = min(_cellsX - 1, (unsigned)floor(max((double)0.0f, point[0] - _cellOrigin[0]) / _cellSize)); - y = min(_cellsY - 1, (unsigned)floor(max((double)0.0f, point[1] - _cellOrigin[1]) / _cellSize)); + x = min(_cellsX - 1, (unsigned)floor(max(double(0.0f), point[0] - _cellOrigin[0]) / _cellSize)); + y = min(_cellsY - 1, (unsigned)floor(max(double(0.0f), point[1] - _cellOrigin[1]) / _cellSize)); } SphericalGrid::Cell *SphericalGrid::findCell(const Vec3r &point) diff --git a/source/blender/freestyle/intern/view_map/SteerableViewMap.cpp b/source/blender/freestyle/intern/view_map/SteerableViewMap.cpp index 88f94e152a1..0a05d469585 100644 --- a/source/blender/freestyle/intern/view_map/SteerableViewMap.cpp +++ b/source/blender/freestyle/intern/view_map/SteerableViewMap.cpp @@ -29,10 +29,10 @@ using namespace Geometry; SteerableViewMap::SteerableViewMap(uint nbOrientations) { _nbOrientations = nbOrientations; - _bound = cos(M_PI / (float)_nbOrientations); + _bound = cos(M_PI / float(_nbOrientations)); for (uint i = 0; i < _nbOrientations; ++i) { - _directions.emplace_back(cos((float)i * M_PI / (float)_nbOrientations), - sin((float)i * M_PI / (float)_nbOrientations)); + _directions.emplace_back(cos(float(i) * M_PI / float(_nbOrientations)), + sin(float(i) * M_PI / float(_nbOrientations))); } Build(); } @@ -101,7 +101,7 @@ double SteerableViewMap::ComputeWeight(const Vec2d &dir, unsigned i) dotp = 1.0; } - return cos((float)_nbOrientations / 2.0 * acos(dotp)); + return cos(float(_nbOrientations) / 2.0 * acos(dotp)); } double *SteerableViewMap::AddFEdge(FEdge *iFEdge) @@ -246,7 +246,7 @@ void SteerableViewMap::saveSteerableViewMap() const for (int y = 0; y < oh; ++y) { // soc for (int x = 0; x < ow; ++x) { // soc - int c = (int)(coeff * _imagesPyramids[i]->pixel(x, y, j)); + int c = int(coeff * _imagesPyramids[i]->pixel(x, y, j)); if (c > 255) { c = 255; } diff --git a/source/blender/freestyle/intern/view_map/ViewMapBuilder.cpp b/source/blender/freestyle/intern/view_map/ViewMapBuilder.cpp index bbf9962b0e6..343f6a8f761 100644 --- a/source/blender/freestyle/intern/view_map/ViewMapBuilder.cpp +++ b/source/blender/freestyle/intern/view_map/ViewMapBuilder.cpp @@ -445,7 +445,7 @@ static void computeCumulativeVisibility(ViewMap *ioViewMap, stringstream ss; ss << "Freestyle: Visibility computations " << (100 * count / vedges.size()) << "%"; iRenderMonitor->setInfo(ss.str()); - iRenderMonitor->progress((float)count / vedges.size()); + iRenderMonitor->progress(float(count) / vedges.size()); } count++; } @@ -607,7 +607,7 @@ static void computeCumulativeVisibility(ViewMap *ioViewMap, #endif // occludee -- if (!wFaces.empty()) { - if (wFaces.size() <= (float)nSamples / 2.0f) { + if (wFaces.size() <= float(nSamples) / 2.0f) { (*ve)->setaShape(nullptr); } else { @@ -623,7 +623,7 @@ static void computeCumulativeVisibility(ViewMap *ioViewMap, stringstream ss; ss << "Freestyle: Visibility computations " << (100 * count / vedges.size()) << "%"; iRenderMonitor->setInfo(ss.str()); - iRenderMonitor->progress((float)count / vedges.size()); + iRenderMonitor->progress(float(count) / vedges.size()); } } @@ -796,7 +796,7 @@ static void computeDetailedVisibility(ViewMap *ioViewMap, #endif // occludee -- if (!wFaces.empty()) { - if (wFaces.size() <= (float)nSamples / 2.0f) { + if (wFaces.size() <= float(nSamples) / 2.0f) { (*ve)->setaShape(nullptr); } else { @@ -1668,7 +1668,7 @@ void ViewMapBuilder::ComputeRayCastingVisibility(ViewMap *ioViewMap, real epsilo #endif // occludee -- if (!aFaces.empty()) { - if (aFaces.size() <= (float)nSamples / 2.0f) { + if (aFaces.size() <= float(nSamples) / 2.0f) { (*ve)->setaShape(nullptr); } else { diff --git a/source/blender/freestyle/intern/winged_edge/WXEdge.cpp b/source/blender/freestyle/intern/winged_edge/WXEdge.cpp index c60088a219f..f04c6e3f2be 100644 --- a/source/blender/freestyle/intern/winged_edge/WXEdge.cpp +++ b/source/blender/freestyle/intern/winged_edge/WXEdge.cpp @@ -243,7 +243,7 @@ void WXFace::ComputeCenter() ++wv) { center += (*wv)->GetVertex(); } - center /= (float)iVertexList.size(); + center /= float(iVertexList.size()); setCenter(center); } @@ -270,7 +270,7 @@ WFace *WXShape::MakeFace(vector &iVertexList, ++wv) { center += (*wv)->GetVertex(); } - center /= (float)iVertexList.size(); + center /= float(iVertexList.size()); ((WXFace *)face)->setCenter(center); return face; diff --git a/source/blender/functions/intern/multi_function_builder.cc b/source/blender/functions/intern/multi_function_builder.cc index 020d6ba0139..f21de46b74e 100644 --- a/source/blender/functions/intern/multi_function_builder.cc +++ b/source/blender/functions/intern/multi_function_builder.cc @@ -42,7 +42,7 @@ void CustomMF_GenericConstant::call(IndexMask mask, uint64_t CustomMF_GenericConstant::hash() const { - return type_.hash_or_fallback(value_, (uintptr_t)this); + return type_.hash_or_fallback(value_, uintptr_t(this)); } bool CustomMF_GenericConstant::equals(const MultiFunction &other) const diff --git a/source/blender/functions/intern/multi_function_procedure_executor.cc b/source/blender/functions/intern/multi_function_procedure_executor.cc index 7d9b2fcd1f0..554395b91d7 100644 --- a/source/blender/functions/intern/multi_function_procedure_executor.cc +++ b/source/blender/functions/intern/multi_function_procedure_executor.cc @@ -289,7 +289,7 @@ class ValueAllocator : NonCopyable, NonMovable { } } - Stack &stack = variable_value_free_lists_[(int)value->type]; + Stack &stack = variable_value_free_lists_[int(value->type)]; stack.push(value); } @@ -297,7 +297,7 @@ class ValueAllocator : NonCopyable, NonMovable { template T *obtain(Args &&...args) { static_assert(std::is_base_of_v); - Stack &stack = variable_value_free_lists_[(int)T::static_type]; + Stack &stack = variable_value_free_lists_[int(T::static_type)]; if (stack.is_empty()) { void *buffer = linear_allocator_.allocate(sizeof(T), alignof(T)); return new (buffer) T(std::forward(args)...); diff --git a/source/blender/functions/tests/FN_multi_function_test.cc b/source/blender/functions/tests/FN_multi_function_test.cc index 577b09cb014..c82cde2abce 100644 --- a/source/blender/functions/tests/FN_multi_function_test.cc +++ b/source/blender/functions/tests/FN_multi_function_test.cc @@ -198,7 +198,7 @@ TEST(multi_function, CustomMF_SI_SI_SI_SO) { CustomMF_SI_SI_SI_SO fn{ "custom", - [](int a, const std::string &b, bool c) { return (uint)((uint)a + b.size() + (uint)c); }}; + [](int a, const std::string &b, bool c) { return uint(uint(a) + b.size() + uint(c)); }}; Array values_a = {5, 7, 3, 8}; Array values_b = {"hello", "world", "another", "test"}; diff --git a/source/blender/geometry/intern/add_curves_on_mesh.cc b/source/blender/geometry/intern/add_curves_on_mesh.cc index bb5e2a0a28a..25935691bf4 100644 --- a/source/blender/geometry/intern/add_curves_on_mesh.cc +++ b/source/blender/geometry/intern/add_curves_on_mesh.cc @@ -51,7 +51,7 @@ static void initialize_straight_curve_positions(const float3 &p1, const float3 &p2, MutableSpan r_positions) { - const float step = 1.0f / (float)(r_positions.size() - 1); + const float step = 1.0f / float(r_positions.size() - 1); for (const int i : r_positions.index_range()) { r_positions[i] = math::interpolate(p1, p2, i * step); } diff --git a/source/blender/geometry/intern/mesh_merge_by_distance.cc b/source/blender/geometry/intern/mesh_merge_by_distance.cc index d7c35a4fcc1..55d757d0e81 100644 --- a/source/blender/geometry/intern/mesh_merge_by_distance.cc +++ b/source/blender/geometry/intern/mesh_merge_by_distance.cc @@ -21,11 +21,11 @@ namespace blender::geometry { /* Indicates when the element was not computed. */ -#define OUT_OF_CONTEXT (int)(-1) +#define OUT_OF_CONTEXT int(-1) /* Indicates if the edge or face will be collapsed. */ -#define ELEM_COLLAPSED (int)(-2) +#define ELEM_COLLAPSED int(-2) /* indicates whether an edge or vertex in groups_map will be merged. */ -#define ELEM_MERGED (int)(-2) +#define ELEM_MERGED int(-2) /* Used to indicate a range in an array specifying a group. */ struct WeldGroup { @@ -702,7 +702,7 @@ static bool weld_iter_loop_of_poly_next(WeldLoopOfPolyIter &iter) else { const MLoop &ml = iter.mloop[l]; #ifdef USE_WELD_DEBUG - BLI_assert((uint)iter.v != ml.v); + BLI_assert(uint(iter.v) != ml.v); #endif iter.v = ml.v; iter.e = ml.e; @@ -1311,9 +1311,9 @@ static void customdata_weld( #ifdef USE_WELD_NORMALS mul_v3_fl(no, fac); short *mv_no = mv->no; - mv_no[0] = (short)no[0]; - mv_no[1] = (short)no[1]; - mv_no[2] = (short)no[2]; + mv_no[0] = short(no[0]); + mv_no[1] = short(no[1]); + mv_no[2] = short(no[2]); #endif } else if (type == CD_MEDGE) { @@ -1532,7 +1532,7 @@ static Mesh *create_merged_mesh(const Mesh &mesh, r_i++; } - BLI_assert((int)r_i == result_npolys); + BLI_assert(int(r_i) == result_npolys); BLI_assert(loop_cur == result_nloops); return result; diff --git a/source/blender/geometry/intern/realize_instances.cc b/source/blender/geometry/intern/realize_instances.cc index 99b6bb29051..7b3c307cf37 100644 --- a/source/blender/geometry/intern/realize_instances.cc +++ b/source/blender/geometry/intern/realize_instances.cc @@ -495,10 +495,10 @@ static void gather_realize_tasks_for_instances(GatherTasksInfo &gather_info, uint32_t local_instance_id = 0; if (gather_info.create_id_attribute_on_any_component) { if (stored_instance_ids.is_empty()) { - local_instance_id = (uint32_t)i; + local_instance_id = uint32_t(i); } else { - local_instance_id = (uint32_t)stored_instance_ids[i]; + local_instance_id = uint32_t(stored_instance_ids[i]); } } const uint32_t instance_id = noise::hash(base_instance_context.id, local_instance_id); diff --git a/source/blender/geometry/intern/set_curve_type.cc b/source/blender/geometry/intern/set_curve_type.cc index 92609a45bdc..4233c62c7b3 100644 --- a/source/blender/geometry/intern/set_curve_type.cc +++ b/source/blender/geometry/intern/set_curve_type.cc @@ -186,12 +186,12 @@ static Vector create_nurbs_to_bezier_handles(const Span nurbs_po const int segments_num = nurbs_positions_num - 1; const bool ignore_interior_segment = segments_num == 3 && is_periodic == false; if (ignore_interior_segment == false) { - const float mid_offset = (float)(segments_num - 1) / 2.0f; + const float mid_offset = float(segments_num - 1) / 2.0f; for (const int i : IndexRange(1, segments_num - 2)) { /* Divisor can have values: 1, 2 or 3. */ const int divisor = is_periodic ? 3 : - std::min(3, (int)(-std::abs(i - mid_offset) + mid_offset + 1.0f)); + std::min(3, int(-std::abs(i - mid_offset) + mid_offset + 1.0f)); const float3 &p1 = nurbs_positions[i]; const float3 &p2 = nurbs_positions[i + 1]; const float3 displacement = (p2 - p1) / divisor; diff --git a/source/blender/geometry/intern/trim_curves.cc b/source/blender/geometry/intern/trim_curves.cc index bda44e09da8..370abe159b4 100644 --- a/source/blender/geometry/intern/trim_curves.cc +++ b/source/blender/geometry/intern/trim_curves.cc @@ -21,7 +21,7 @@ namespace blender::geometry { /** \name Curve Enums * \{ */ -#define CURVE_TYPE_AS_MASK(curve_type) ((CurveTypeMask)(1 << (int)(curve_type))) +#define CURVE_TYPE_AS_MASK(curve_type) ((CurveTypeMask)(1 << int(curve_type))) typedef enum CurveTypeMask { CURVE_TYPE_MASK_CATMULL_ROM = (1 << 0), @@ -165,7 +165,7 @@ static bke::curves::CurvePoint lookup_bezier_point(const Span bezier_offset const int left = offset - bezier_offsets.begin(); const int right = left == last_index ? 0 : left + 1; - const int prev_offset = left == 0 ? 0 : bezier_offsets[(int64_t)left - 1]; + const int prev_offset = left == 0 ? 0 : bezier_offsets[int64_t(left) - 1]; const float offset_in_segment = eval_factor + eval_index - prev_offset; const int segment_resolution = bezier_offsets[left] - prev_offset; const float parameter = std::clamp(offset_in_segment / segment_resolution, 0.0f, 1.0f); @@ -267,13 +267,13 @@ Array lookup_curve_points(const bke::CurvesGeometry * Determine curve type(s) for the copied curves given the supported set of types and knot modes. * If a curve type is not supported the default type is set. */ -static void determine_copyable_curve_types(const bke::CurvesGeometry &src_curves, - bke::CurvesGeometry &dst_curves, - const IndexMask selection, - const IndexMask selection_inverse, - const CurveTypeMask supported_curve_type_mask, - const int8_t default_curve_type = (int8_t) - CURVE_TYPE_POLY) +static void determine_copyable_curve_types( + const bke::CurvesGeometry &src_curves, + bke::CurvesGeometry &dst_curves, + const IndexMask selection, + const IndexMask selection_inverse, + const CurveTypeMask supported_curve_type_mask, + const int8_t default_curve_type = int8_t(CURVE_TYPE_POLY)) { const VArray src_curve_types = src_curves.curve_types(); const VArray src_knot_modes = src_curves.nurbs_knots_modes(); @@ -332,7 +332,7 @@ static void compute_trim_result_offsets(const bke::CurvesGeometry &src_curves, src_point_count = src_curves.evaluated_points_for_curve(curve_i).size(); } else { - src_point_count = (int64_t)src_curves.points_num_for_curve(curve_i); + src_point_count = int64_t(src_curves.points_num_for_curve(curve_i)); } BLI_assert(src_point_count > 0); @@ -376,8 +376,8 @@ static void fill_bezier_data(bke::CurvesGeometry &dst_curves, const IndexMask se threading::parallel_for(selection.index_range(), 4096, [&](const IndexRange range) { for (const int64_t curve_i : selection.slice(range)) { const IndexRange points = dst_curves.points_for_curve(curve_i); - handle_types_right.slice(points).fill((int8_t)BEZIER_HANDLE_FREE); - handle_types_left.slice(points).fill((int8_t)BEZIER_HANDLE_FREE); + handle_types_right.slice(points).fill(int8_t(BEZIER_HANDLE_FREE)); + handle_types_left.slice(points).fill(int8_t(BEZIER_HANDLE_FREE)); handle_positions_left.slice(points).fill({0.0f, 0.0f, 0.0f}); handle_positions_right.slice(points).fill({0.0f, 0.0f, 0.0f}); } @@ -743,7 +743,7 @@ static void sample_interval_bezier(const Span src_positions, dst_positions, dst_handles_l, dst_handles_r, - {{(int)dst_range.first(), (int)(dst_range.first() + 1)}, parameter}); + {{int(dst_range.first()), int(dst_range.first() + 1)}, parameter}); } else { /* General case, compute the insertion point. */ diff --git a/source/blender/geometry/intern/uv_parametrizer.cc b/source/blender/geometry/intern/uv_parametrizer.cc index b15c8b6e319..1829f943a5d 100644 --- a/source/blender/geometry/intern/uv_parametrizer.cc +++ b/source/blender/geometry/intern/uv_parametrizer.cc @@ -195,7 +195,7 @@ static int PHashSizes[] = { 1048583, 2097169, 4194319, 8388617, 16777259, 33554467, 67108879, 134217757, 268435459, }; -#define PHASH_hash(ph, item) (((uintptr_t)(item)) % ((uint)(ph)->cursize)) +#define PHASH_hash(ph, item) (uintptr_t(item) % ((uint)(ph)->cursize)) #define PHASH_edge(v1, v2) (((v1) < (v2)) ? ((v1)*39) ^ ((v2)*31) : ((v1)*31) ^ ((v2)*39)) static PHash *phash_new(PHashLink **list, int sizehint) @@ -319,7 +319,7 @@ static void fix_large_angle(const float v_fix[3], float *r_a1, float *r_a2) { - const float max_angle = (float)M_PI * (179.0f / 180.0f); + const float max_angle = float(M_PI) * (179.0f / 180.0f); const float fix_amount = *r_fix - max_angle; if (fix_amount < 0.0f) { return; /* angle is reasonable, i.e. less than 179 degrees. */ @@ -4218,7 +4218,7 @@ void GEO_uv_parametrizer_pack(ParamHandle *handle, * ...Without using the area running pack multiple times also gives a bad feedback loop. * multiply by 0.1 so the margin value from the UI can be from * 0.0 to 1.0 but not give a massive margin */ - margin = (margin * (float)area) * 0.1f; + margin = (margin * float(area)) * 0.1f; unpacked = 0; for (i = 0; i < handle->ncharts; i++) { chart = handle->charts[i]; diff --git a/source/blender/gpu/intern/gpu_codegen.cc b/source/blender/gpu/intern/gpu_codegen.cc index fdd0fe97a02..51644bc9307 100644 --- a/source/blender/gpu/intern/gpu_codegen.cc +++ b/source/blender/gpu/intern/gpu_codegen.cc @@ -874,7 +874,7 @@ void GPU_pass_cache_garbage_collect(void) { static int lasttime = 0; const int shadercollectrate = 60; /* hardcoded for now. */ - int ctime = (int)PIL_check_seconds_timer(); + int ctime = int(PIL_check_seconds_timer()); if (ctime < shadercollectrate + lasttime) { return; diff --git a/source/blender/gpu/intern/gpu_index_buffer.cc b/source/blender/gpu/intern/gpu_index_buffer.cc index 3a66f547403..42f4e048131 100644 --- a/source/blender/gpu/intern/gpu_index_buffer.cc +++ b/source/blender/gpu/intern/gpu_index_buffer.cc @@ -76,7 +76,7 @@ void GPU_indexbuf_init(GPUIndexBufBuilder *builder, #if TRUST_NO_ONE assert(verts_per_prim != -1); #endif - GPU_indexbuf_init_ex(builder, prim_type, prim_len * (uint)verts_per_prim, vertex_len); + GPU_indexbuf_init_ex(builder, prim_type, prim_len * uint(verts_per_prim), vertex_len); } GPUIndexBuf *GPU_indexbuf_build_on_device(uint index_len) diff --git a/source/blender/gpu/intern/gpu_matrix.cc b/source/blender/gpu/intern/gpu_matrix.cc index 94fd44f832b..12bbe13a296 100644 --- a/source/blender/gpu/intern/gpu_matrix.cc +++ b/source/blender/gpu/intern/gpu_matrix.cc @@ -429,7 +429,7 @@ void GPU_matrix_frustum_set( void GPU_matrix_perspective_set(float fovy, float aspect, float near, float far) { - float half_height = tanf(fovy * (float)(M_PI / 360.0)) * near; + float half_height = tanf(fovy * float(M_PI / 360.0)) * near; float half_width = half_height * aspect; GPU_matrix_frustum_set(-half_width, +half_width, -half_height, +half_height, near, far); } @@ -669,13 +669,13 @@ BLI_STATIC_ASSERT(GPU_PY_MATRIX_STACK_LEN + 1 == MATRIX_STACK_DEPTH, "define mis int GPU_matrix_stack_level_get_model_view() { GPUMatrixState *state = Context::get()->matrix_state; - return (int)state->model_view_stack.top; + return int(state->model_view_stack.top); } int GPU_matrix_stack_level_get_projection() { GPUMatrixState *state = Context::get()->matrix_state; - return (int)state->projection_stack.top; + return int(state->projection_stack.top); } /** \} */ diff --git a/source/blender/gpu/intern/gpu_shader_log.cc b/source/blender/gpu/intern/gpu_shader_log.cc index dbc36c5afd0..e593c4fa508 100644 --- a/source/blender/gpu/intern/gpu_shader_log.cc +++ b/source/blender/gpu/intern/gpu_shader_log.cc @@ -93,10 +93,10 @@ void Shader::print_log(Span sources, } /* Silence not useful lines. */ - StringRef logref = StringRefNull(log_line).substr(0, (size_t)line_end - (size_t)log_line); + StringRef logref = StringRefNull(log_line).substr(0, size_t(line_end) - size_t(log_line)); if (logref.endswith(" shader failed to compile with the following errors:") || logref.endswith(" No code generated")) { - log_line += (size_t)line_end - (size_t)log_line; + log_line += size_t(line_end) - size_t(log_line); continue; } @@ -291,7 +291,7 @@ bool GPULogParser::at_any(const char *log_line, const StringRef chars) const int GPULogParser::parse_number(const char *log_line, char **r_new_position) const { - return (int)strtol(log_line, r_new_position, 10); + return int(strtol(log_line, r_new_position, 10)); } /** \} */ diff --git a/source/blender/gpu/intern/gpu_state.cc b/source/blender/gpu/intern/gpu_state.cc index a1e0b8867a0..8e9d5cb3184 100644 --- a/source/blender/gpu/intern/gpu_state.cc +++ b/source/blender/gpu/intern/gpu_state.cc @@ -97,10 +97,10 @@ void GPU_color_mask(bool r, bool g, bool b, bool a) StateManager *stack = Context::get()->state_manager; auto &state = stack->state; uint32_t write_mask = state.write_mask; - SET_FLAG_FROM_TEST(write_mask, r, (uint32_t)GPU_WRITE_RED); - SET_FLAG_FROM_TEST(write_mask, g, (uint32_t)GPU_WRITE_GREEN); - SET_FLAG_FROM_TEST(write_mask, b, (uint32_t)GPU_WRITE_BLUE); - SET_FLAG_FROM_TEST(write_mask, a, (uint32_t)GPU_WRITE_ALPHA); + SET_FLAG_FROM_TEST(write_mask, r, uint32_t(GPU_WRITE_RED)); + SET_FLAG_FROM_TEST(write_mask, g, uint32_t(GPU_WRITE_GREEN)); + SET_FLAG_FROM_TEST(write_mask, b, uint32_t(GPU_WRITE_BLUE)); + SET_FLAG_FROM_TEST(write_mask, a, uint32_t(GPU_WRITE_ALPHA)); state.write_mask = write_mask; } @@ -109,7 +109,7 @@ void GPU_depth_mask(bool depth) StateManager *stack = Context::get()->state_manager; auto &state = stack->state; uint32_t write_mask = state.write_mask; - SET_FLAG_FROM_TEST(write_mask, depth, (uint32_t)GPU_WRITE_DEPTH); + SET_FLAG_FROM_TEST(write_mask, depth, uint32_t(GPU_WRITE_DEPTH)); state.write_mask = write_mask; } @@ -133,13 +133,13 @@ void GPU_state_set(eGPUWriteMask write_mask, { StateManager *stack = Context::get()->state_manager; auto &state = stack->state; - state.write_mask = (uint32_t)write_mask; - state.blend = (uint32_t)blend; - state.culling_test = (uint32_t)culling_test; - state.depth_test = (uint32_t)depth_test; - state.stencil_test = (uint32_t)stencil_test; - state.stencil_op = (uint32_t)stencil_op; - state.provoking_vert = (uint32_t)provoking_vert; + state.write_mask = uint32_t(write_mask); + state.blend = uint32_t(blend); + state.culling_test = uint32_t(culling_test); + state.depth_test = uint32_t(depth_test); + state.stencil_test = uint32_t(stencil_test); + state.stencil_op = uint32_t(stencil_op); + state.provoking_vert = uint32_t(provoking_vert); } /** \} */ @@ -196,17 +196,17 @@ void GPU_viewport(int x, int y, int width, int height) void GPU_stencil_reference_set(uint reference) { - SET_MUTABLE_STATE(stencil_reference, (uint8_t)reference); + SET_MUTABLE_STATE(stencil_reference, uint8_t(reference)); } void GPU_stencil_write_mask_set(uint write_mask) { - SET_MUTABLE_STATE(stencil_write_mask, (uint8_t)write_mask); + SET_MUTABLE_STATE(stencil_write_mask, uint8_t(write_mask)); } void GPU_stencil_compare_mask_set(uint compare_mask) { - SET_MUTABLE_STATE(stencil_compare_mask, (uint8_t)compare_mask); + SET_MUTABLE_STATE(stencil_compare_mask, uint8_t(compare_mask)); } /** \} */ diff --git a/source/blender/gpu/opengl/gl_context.cc b/source/blender/gpu/opengl/gl_context.cc index 31bd7e0c4dd..375194c09f3 100644 --- a/source/blender/gpu/opengl/gl_context.cc +++ b/source/blender/gpu/opengl/gl_context.cc @@ -191,11 +191,11 @@ void GLSharedOrphanLists::orphans_clear() lists_mutex.lock(); if (!buffers.is_empty()) { - glDeleteBuffers((uint)buffers.size(), buffers.data()); + glDeleteBuffers(uint(buffers.size()), buffers.data()); buffers.clear(); } if (!textures.is_empty()) { - glDeleteTextures((uint)textures.size(), textures.data()); + glDeleteTextures(uint(textures.size()), textures.data()); textures.clear(); } lists_mutex.unlock(); @@ -208,11 +208,11 @@ void GLContext::orphans_clear() lists_mutex_.lock(); if (!orphaned_vertarrays_.is_empty()) { - glDeleteVertexArrays((uint)orphaned_vertarrays_.size(), orphaned_vertarrays_.data()); + glDeleteVertexArrays(uint(orphaned_vertarrays_.size()), orphaned_vertarrays_.data()); orphaned_vertarrays_.clear(); } if (!orphaned_framebuffers_.is_empty()) { - glDeleteFramebuffers((uint)orphaned_framebuffers_.size(), orphaned_framebuffers_.data()); + glDeleteFramebuffers(uint(orphaned_framebuffers_.size()), orphaned_framebuffers_.data()); orphaned_framebuffers_.clear(); } lists_mutex_.unlock(); diff --git a/source/blender/gpu/opengl/gl_framebuffer.cc b/source/blender/gpu/opengl/gl_framebuffer.cc index 1ab22a16df4..e94f5b66b97 100644 --- a/source/blender/gpu/opengl/gl_framebuffer.cc +++ b/source/blender/gpu/opengl/gl_framebuffer.cc @@ -352,7 +352,7 @@ void GLFrameBuffer::clear_attachment(GPUAttachmentType type, if (type == GPU_FB_DEPTH_STENCIL_ATTACHMENT) { BLI_assert(data_format == GPU_DATA_UINT_24_8); - float depth = ((*(uint32_t *)clear_value) & 0x00FFFFFFu) / (float)0x00FFFFFFu; + float depth = ((*(uint32_t *)clear_value) & 0x00FFFFFFu) / float(0x00FFFFFFu); int stencil = ((*(uint32_t *)clear_value) >> 24); glClearBufferfi(GL_DEPTH_STENCIL, 0, depth, stencil); } @@ -361,7 +361,7 @@ void GLFrameBuffer::clear_attachment(GPUAttachmentType type, glClearBufferfv(GL_DEPTH, 0, (GLfloat *)clear_value); } else if (data_format == GPU_DATA_UINT) { - float depth = *(uint32_t *)clear_value / (float)0xFFFFFFFFu; + float depth = *(uint32_t *)clear_value / float(0xFFFFFFFFu); glClearBufferfv(GL_DEPTH, 0, &depth); } else { diff --git a/source/blender/gpu/opengl/gl_shader.cc b/source/blender/gpu/opengl/gl_shader.cc index 1f2ef36716e..a1570735723 100644 --- a/source/blender/gpu/opengl/gl_shader.cc +++ b/source/blender/gpu/opengl/gl_shader.cc @@ -1138,7 +1138,7 @@ void GLShader::uniform_int(int location, int comp_len, int array_size, const int int GLShader::program_handle_get() const { - return (int)this->shader_program_; + return int(this->shader_program_); } /** \} */ diff --git a/source/blender/gpu/opengl/gl_shader_interface.cc b/source/blender/gpu/opengl/gl_shader_interface.cc index b230706b020..c9432fca561 100644 --- a/source/blender/gpu/opengl/gl_shader_interface.cc +++ b/source/blender/gpu/opengl/gl_shader_interface.cc @@ -295,7 +295,7 @@ GLShaderInterface::GLShaderInterface(GLuint program) enabled_attr_mask_ |= (1 << input->location); /* Used in `GPU_shader_get_attribute_info`. */ - attr_types_[input->location] = (uint8_t)gpu_type_from_gl_type(type); + attr_types_[input->location] = uint8_t(gpu_type_from_gl_type(type)); } /* Uniform Blocks */ @@ -457,7 +457,7 @@ GLShaderInterface::GLShaderInterface(GLuint program, const shader::ShaderCreateI enabled_attr_mask_ |= (1 << input->location); /* Used in `GPU_shader_get_attribute_info`. */ - attr_types_[input->location] = (uint8_t)attr.type; + attr_types_[input->location] = uint8_t(attr.type); } input++; diff --git a/source/blender/gpu/opengl/gl_vertex_array.cc b/source/blender/gpu/opengl/gl_vertex_array.cc index 6897ac9f4a2..9a6df38cb05 100644 --- a/source/blender/gpu/opengl/gl_vertex_array.cc +++ b/source/blender/gpu/opengl/gl_vertex_array.cc @@ -47,7 +47,7 @@ static uint16_t vbo_bind(const ShaderInterface *interface, } /* This is in fact an offset in memory. */ - const GLvoid *pointer = (const GLubyte *)(intptr_t)(offset + v_first * stride); + const GLvoid *pointer = (const GLubyte *)intptr_t(offset + v_first * stride); const GLenum type = to_gl(static_cast(a->comp_type)); for (uint n_idx = 0; n_idx < a->name_len; n_idx++) { @@ -137,7 +137,7 @@ void GLVertArray::update_bindings(const GLuint vao, GLContext *ctx = GLContext::get(); /* This replaces glVertexAttrib4f(a, 0.0f, 0.0f, 0.0f, 1.0f); with a more modern style. * Fix issues for some drivers (see T75069). */ - glBindVertexBuffer(a, ctx->default_attr_vbo_, (intptr_t)0, (intptr_t)0); + glBindVertexBuffer(a, ctx->default_attr_vbo_, intptr_t(0), intptr_t(0)); glEnableVertexAttribArray(a); glVertexAttribFormat(a, 4, GL_FLOAT, GL_FALSE, 0); glVertexAttribBinding(a, a); diff --git a/source/blender/ikplugin/intern/itasc_plugin.cpp b/source/blender/ikplugin/intern/itasc_plugin.cpp index 8e3d4e7686f..a3a3fb3aa94 100644 --- a/source/blender/ikplugin/intern/itasc_plugin.cpp +++ b/source/blender/ikplugin/intern/itasc_plugin.cpp @@ -761,7 +761,7 @@ static void copypose_error(const iTaSC::ConstraintValues *values, for (i = 0, error = 0.0, value = values->values; i < values->number; i++, value++) { error += KDL::sqr(value->y - value->yd); } - iktarget->blenderConstraint->lin_error = (float)KDL::sqrt(error); + iktarget->blenderConstraint->lin_error = float(KDL::sqrt(error)); values++; } if (iktarget->controlType & iTaSC::CopyPose::CTL_ROTATION) { @@ -769,7 +769,7 @@ static void copypose_error(const iTaSC::ConstraintValues *values, for (i = 0, error = 0.0, value = values->values; i < values->number; i++, value++) { error += KDL::sqr(value->y - value->yd); } - iktarget->blenderConstraint->rot_error = (float)KDL::sqrt(error); + iktarget->blenderConstraint->rot_error = float(KDL::sqrt(error)); values++; } } @@ -829,7 +829,7 @@ static void distance_error(const iTaSC::ConstraintValues *values, uint _nvalues, IK_Target *iktarget) { - iktarget->blenderConstraint->lin_error = (float)(values->values[0].y - values->values[0].yd); + iktarget->blenderConstraint->lin_error = float(values->values[0].y - values->values[0].yd); } static bool joint_callback(const iTaSC::Timestamp ×tamp, diff --git a/source/blender/imbuf/intern/oiio/openimageio_api.cpp b/source/blender/imbuf/intern/oiio/openimageio_api.cpp index 5c7b7d9fae4..f8d00b5222f 100644 --- a/source/blender/imbuf/intern/oiio/openimageio_api.cpp +++ b/source/blender/imbuf/intern/oiio/openimageio_api.cpp @@ -193,7 +193,7 @@ struct ImBuf *imb_load_photoshop(const char *filename, int flags, char colorspac } ImageSpec spec, config; - config.attribute("oiio:UnassociatedAlpha", (int)1); + config.attribute("oiio:UnassociatedAlpha", int(1)); if (!in->open(filename, spec, config)) { std::cerr << __func__ << ": ImageInput::open() failed:" << std::endl diff --git a/source/blender/imbuf/intern/openexr/openexr_api.cpp b/source/blender/imbuf/intern/openexr/openexr_api.cpp index e8818a8b55e..7a94a938861 100644 --- a/source/blender/imbuf/intern/openexr/openexr_api.cpp +++ b/source/blender/imbuf/intern/openexr/openexr_api.cpp @@ -552,10 +552,10 @@ static bool imb_save_openexr_half(ImBuf *ibuf, const char *name, const int flags from = (uchar *)ibuf->rect + 4 * i * width; for (int j = ibuf->x; j > 0; j--) { - to->r = srgb_to_linearrgb((float)from[0] / 255.0f); - to->g = srgb_to_linearrgb((float)from[1] / 255.0f); - to->b = srgb_to_linearrgb((float)from[2] / 255.0f); - to->a = channels >= 4 ? (float)from[3] / 255.0f : 1.0f; + to->r = srgb_to_linearrgb(float(from[0]) / 255.0f); + to->g = srgb_to_linearrgb(float(from[1]) / 255.0f); + to->b = srgb_to_linearrgb(float(from[2]) / 255.0f); + to->a = channels >= 4 ? float(from[3]) / 255.0f : 1.0f; to++; from += 4; } @@ -838,7 +838,7 @@ static void imb_exr_insert_view_name(char *name_full, const char *passname, cons len = BLI_str_rpartition(passname, delims, &sep, &token); if (sep) { - BLI_snprintf(name_full, EXR_PASS_MAXNAME, "%.*s.%s.%s", (int)len, passname, viewname, token); + BLI_snprintf(name_full, EXR_PASS_MAXNAME, "%.*s.%s.%s", int(len), passname, viewname, token); } else { BLI_snprintf(name_full, EXR_PASS_MAXNAME, "%s.%s", passname, viewname); @@ -1171,7 +1171,7 @@ void IMB_exr_write_channels(void *handle) ExrChannel *echan; if (data->channels.first) { - const size_t num_pixels = ((size_t)data->width) * data->height; + const size_t num_pixels = size_t(data->width) * data->height; half *rect_half = nullptr, *current_rect_half = nullptr; /* We allocate temporary storage for half pixels for all the channels at once. */ @@ -1454,7 +1454,7 @@ static int imb_exr_split_token(const char *str, const char *end, const char **to *token = str; } - return (int)(end - *token); + return int(end - *token); } static int imb_exr_split_channel_name(ExrChannel *echan, char *layname, char *passname) @@ -1551,7 +1551,7 @@ static int imb_exr_split_channel_name(ExrChannel *echan, char *layname, char *pa /* all preceding tokens combined as layer name */ if (end > name) { - BLI_strncpy(layname, name, (int)(end - name) + 1); + BLI_strncpy(layname, name, int(end - name) + 1); } else { layname[0] = '\0'; @@ -1670,29 +1670,29 @@ static bool imb_exr_multilayer_parse_channels_from_file(ExrHandle *data) if (ELEM(pass->totchan, 3, 4)) { if (pass->chan[0]->chan_id == 'B' || pass->chan[1]->chan_id == 'B' || pass->chan[2]->chan_id == 'B') { - lookup[(uint)'R'] = 0; - lookup[(uint)'G'] = 1; - lookup[(uint)'B'] = 2; - lookup[(uint)'A'] = 3; + lookup[uint('R')] = 0; + lookup[uint('G')] = 1; + lookup[uint('B')] = 2; + lookup[uint('A')] = 3; } else if (pass->chan[0]->chan_id == 'Y' || pass->chan[1]->chan_id == 'Y' || pass->chan[2]->chan_id == 'Y') { - lookup[(uint)'X'] = 0; - lookup[(uint)'Y'] = 1; - lookup[(uint)'Z'] = 2; - lookup[(uint)'W'] = 3; + lookup[uint('X')] = 0; + lookup[uint('Y')] = 1; + lookup[uint('Z')] = 2; + lookup[uint('W')] = 3; } else { - lookup[(uint)'U'] = 0; - lookup[(uint)'V'] = 1; - lookup[(uint)'A'] = 2; + lookup[uint('U')] = 0; + lookup[uint('V')] = 1; + lookup[uint('A')] = 2; } for (int a = 0; a < pass->totchan; a++) { echan = pass->chan[a]; - echan->rect = pass->rect + lookup[(uint)echan->chan_id]; + echan->rect = pass->rect + lookup[uint(echan->chan_id)]; echan->xstride = pass->totchan; echan->ystride = data->width * pass->totchan; - pass->chan_id[(uint)lookup[(uint)echan->chan_id]] = echan->chan_id; + pass->chan_id[uint(lookup[uint(echan->chan_id)])] = echan->chan_id; } } else { /* unknown */ @@ -2015,8 +2015,8 @@ struct ImBuf *imb_load_openexr(const uchar *mem, if (hasXDensity(file->header(0))) { /* Convert inches to meters. */ - ibuf->ppm[0] = (double)xDensity(file->header(0)) / 0.0254; - ibuf->ppm[1] = ibuf->ppm[0] * (double)file->header(0).pixelAspectRatio(); + ibuf->ppm[0] = double(xDensity(file->header(0))) / 0.0254; + ibuf->ppm[1] = ibuf->ppm[0] * double(file->header(0).pixelAspectRatio()); } ibuf->ftype = IMB_FTYPE_OPENEXR; @@ -2115,7 +2115,7 @@ struct ImBuf *imb_load_openexr(const uchar *mem, #endif if (num_rgb_channels == 0 && has_luma && exr_has_chroma(*file)) { - for (size_t a = 0; a < (size_t)ibuf->x * ibuf->y; a++) { + for (size_t a = 0; a < size_t(ibuf->x) * ibuf->y; a++) { float *color = ibuf->rect_float + a * 4; ycc_to_rgb(color[0] * 255.0f, color[1] * 255.0f, @@ -2128,7 +2128,7 @@ struct ImBuf *imb_load_openexr(const uchar *mem, } else if (num_rgb_channels <= 1) { /* Convert 1 to 3 channels. */ - for (size_t a = 0; a < (size_t)ibuf->x * ibuf->y; a++) { + for (size_t a = 0; a < size_t(ibuf->x) * ibuf->y; a++) { float *color = ibuf->rect_float + a * 4; if (num_rgb_channels <= 1) { color[1] = color[0]; @@ -2222,10 +2222,10 @@ struct ImBuf *imb_load_filepath_thumbnail_openexr(const char *filepath, colorspace_set_default_role(colorspace, IM_MAX_SPACE, COLOR_ROLE_DEFAULT_FLOAT); } - float scale_factor = MIN2((float)max_thumb_size / (float)source_w, - (float)max_thumb_size / (float)source_h); - int dest_w = (int)(source_w * scale_factor); - int dest_h = (int)(source_h * scale_factor); + float scale_factor = MIN2(float(max_thumb_size) / float(source_w), + float(max_thumb_size) / float(source_h)); + int dest_w = int(source_w * scale_factor); + int dest_h = int(source_h * scale_factor); struct ImBuf *ibuf = IMB_allocImBuf(dest_w, dest_h, 32, IB_rectfloat); @@ -2236,13 +2236,13 @@ struct ImBuf *imb_load_filepath_thumbnail_openexr(const char *filepath, for (int h = 0; h < dest_h; h++) { /* Load the single source row that corresponds with destination row. */ - int source_y = (int)((float)h / scale_factor) + dw.min.y; + int source_y = int(float(h) / scale_factor) + dw.min.y; file->setFrameBuffer(&pixels[0] - dw.min.x - source_y * source_w, 1, source_w); file->readPixels(source_y); for (int w = 0; w < dest_w; w++) { /* For each destination pixel find single corresponding source pixel. */ - int source_x = (int)(MIN2((w / scale_factor), dw.max.x - 1)); + int source_x = int(MIN2((w / scale_factor), dw.max.x - 1)); float *dest_px = &ibuf->rect_float[(h * dest_w + w) * 4]; dest_px[0] = pixels[source_x].r; dest_px[1] = pixels[source_x].g; diff --git a/source/blender/imbuf/intern/transform.cc b/source/blender/imbuf/intern/transform.cc index 276d31c0557..532652df189 100644 --- a/source/blender/imbuf/intern/transform.cc +++ b/source/blender/imbuf/intern/transform.cc @@ -165,7 +165,7 @@ class PixelPointer { public: void init_pixel_pointer(const ImBuf *image_buffer, int x, int y) { - const size_t offset = (y * (size_t)image_buffer->x + x) * NumChannels; + const size_t offset = (y * size_t(image_buffer->x) + x) * NumChannels; if constexpr (std::is_same_v) { pointer = image_buffer->rect_float + offset; @@ -235,7 +235,7 @@ class WrapRepeatUV : public BaseUVWrapping { float modify_u(const ImBuf *source_buffer, float u) override { - int x = (int)floor(u); + int x = int(floor(u)); x = x % source_buffer->x; if (x < 0) { x += source_buffer->x; @@ -245,7 +245,7 @@ class WrapRepeatUV : public BaseUVWrapping { float modify_v(const ImBuf *source_buffer, float v) override { - int y = (int)floor(v); + int y = int(floor(v)); y = y % source_buffer->y; if (y < 0) { y += source_buffer->y; @@ -349,8 +349,8 @@ class Sampler { BLI_STATIC_ASSERT(std::is_same_v); /* ImBuf in must have a valid rect or rect_float, assume this is already checked */ - int x1 = (int)(u); - int y1 = (int)(v); + int x1 = int(u); + int y1 = int(v); /* Break when sample outside image is requested. */ if (x1 < 0 || x1 >= source->x || y1 < 0 || y1 >= source->y) { @@ -360,7 +360,7 @@ class Sampler { return; } - const size_t offset = ((size_t)source->x * y1 + x1) * NumChannels; + const size_t offset = (size_t(source->x) * y1 + x1) * NumChannels; const float *dataF = source->rect_float + offset; for (int i = 0; i < NumChannels; i++) { r_sample[i] = dataF[i]; diff --git a/source/blender/io/collada/AnimationImporter.cpp b/source/blender/io/collada/AnimationImporter.cpp index 094f62e3c13..2b56cf188f1 100644 --- a/source/blender/io/collada/AnimationImporter.cpp +++ b/source/blender/io/collada/AnimationImporter.cpp @@ -55,7 +55,7 @@ void AnimationImporter::add_bezt(FCurve *fcu, float value, eBezTriple_Interpolation ipo) { - // float fps = (float)FPS; + // float fps = float(FPS); BezTriple bez; memset(&bez, 0, sizeof(BezTriple)); bez.vec[1][0] = frame; @@ -72,7 +72,7 @@ void AnimationImporter::animation_to_fcurves(COLLADAFW::AnimationCurve *curve) COLLADAFW::FloatOrDoubleArray &input = curve->getInputValues(); COLLADAFW::FloatOrDoubleArray &output = curve->getOutputValues(); - float fps = (float)FPS; + float fps = float(FPS); size_t dim = curve->getOutDimension(); uint i; @@ -141,7 +141,7 @@ void AnimationImporter::animation_to_fcurves(COLLADAFW::AnimationCurve *curve) default: fprintf(stderr, "Output dimension of %d is not yet supported (animation id = %s)\n", - (int)dim, + int(dim), curve->getOriginalId().c_str()); } } @@ -262,7 +262,7 @@ AnimationImporter::~AnimationImporter() } if (!unused_curves.empty()) { - fprintf(stderr, "removed %d unused curves\n", (int)unused_curves.size()); + fprintf(stderr, "removed %d unused curves\n", int(unused_curves.size())); } } @@ -530,7 +530,7 @@ void AnimationImporter::Assign_transform_animations( binding->animationClass == COLLADAFW::AnimationList::POSITION_XYZ); if (!((!xyz && curves->size() == 1) || (xyz && curves->size() == 3) || is_matrix)) { - fprintf(stderr, "expected %d curves, got %d\n", xyz ? 3 : 1, (int)curves->size()); + fprintf(stderr, "expected %d curves, got %d\n", xyz ? 3 : 1, int(curves->size())); return; } @@ -1536,7 +1536,7 @@ void AnimationImporter::find_frames_old(std::vector *frames, } } else { - fprintf(stderr, "expected %d curves, got %d\n", xyz ? 3 : 1, (int)curves.size()); + fprintf(stderr, "expected %d curves, got %d\n", xyz ? 3 : 1, int(curves.size())); } } } @@ -1934,7 +1934,7 @@ bool AnimationImporter::evaluate_animation(COLLADAFW::Transformation *tm, if (type == COLLADAFW::Transformation::ROTATE) { if (curves.size() != 1) { - fprintf(stderr, "expected 1 curve, got %d\n", (int)curves.size()); + fprintf(stderr, "expected 1 curve, got %d\n", int(curves.size())); return false; } @@ -1946,7 +1946,7 @@ bool AnimationImporter::evaluate_animation(COLLADAFW::Transformation *tm, COLLADABU::Math::Vector3 &axis = ((COLLADAFW::Rotate *)tm)->getRotationAxis(); - float ax[3] = {(float)axis[0], (float)axis[1], (float)axis[2]}; + float ax[3] = {float(axis[0]), float(axis[1]), float(axis[2])}; float angle = evaluate_fcurve(curves[0], fra); axis_angle_to_mat4(mat, ax, angle); @@ -1957,10 +1957,10 @@ bool AnimationImporter::evaluate_animation(COLLADAFW::Transformation *tm, if ((!is_xyz && curves.size() != 1) || (is_xyz && curves.size() != 3)) { if (is_xyz) { - fprintf(stderr, "%s: expected 3 curves, got %d\n", path, (int)curves.size()); + fprintf(stderr, "%s: expected 3 curves, got %d\n", path, int(curves.size())); } else { - fprintf(stderr, "%s: expected 1 curve, got %d\n", path, (int)curves.size()); + fprintf(stderr, "%s: expected 1 curve, got %d\n", path, int(curves.size())); } return false; } @@ -1989,7 +1989,7 @@ bool AnimationImporter::evaluate_animation(COLLADAFW::Transformation *tm, /* for now, of matrix animation, * support only the case when all values are packed into one animation */ if (curves.size() != 16) { - fprintf(stderr, "%s: expected 16 curves, got %d\n", path, (int)curves.size()); + fprintf(stderr, "%s: expected 16 curves, got %d\n", path, int(curves.size())); return false; } diff --git a/source/blender/io/collada/BCAnimationCurve.cpp b/source/blender/io/collada/BCAnimationCurve.cpp index fe90dc5d5fa..710758bd77b 100644 --- a/source/blender/io/collada/BCAnimationCurve.cpp +++ b/source/blender/io/collada/BCAnimationCurve.cpp @@ -426,10 +426,10 @@ bool BCAnimationCurve::add_value_from_rna(const int frame_index) if ((array_index >= 0) && (array_index < RNA_property_array_length(&ptr, prop))) { switch (RNA_property_type(prop)) { case PROP_BOOLEAN: - value = (float)RNA_property_boolean_get_index(&ptr, prop, array_index); + value = float(RNA_property_boolean_get_index(&ptr, prop, array_index)); break; case PROP_INT: - value = (float)RNA_property_int_get_index(&ptr, prop, array_index); + value = float(RNA_property_int_get_index(&ptr, prop, array_index)); break; case PROP_FLOAT: value = RNA_property_float_get_index(&ptr, prop, array_index); @@ -449,16 +449,16 @@ bool BCAnimationCurve::add_value_from_rna(const int frame_index) /* not an array */ switch (RNA_property_type(prop)) { case PROP_BOOLEAN: - value = (float)RNA_property_boolean_get(&ptr, prop); + value = float(RNA_property_boolean_get(&ptr, prop)); break; case PROP_INT: - value = (float)RNA_property_int_get(&ptr, prop); + value = float(RNA_property_int_get(&ptr, prop)); break; case PROP_FLOAT: value = RNA_property_float_get(&ptr, prop); break; case PROP_ENUM: - value = (float)RNA_property_enum_get(&ptr, prop); + value = float(RNA_property_enum_get(&ptr, prop)); break; default: fprintf(stderr, diff --git a/source/blender/io/collada/BCMath.cpp b/source/blender/io/collada/BCMath.cpp index 924cee7f3b2..6e052ee960d 100644 --- a/source/blender/io/collada/BCMath.cpp +++ b/source/blender/io/collada/BCMath.cpp @@ -140,9 +140,9 @@ void BCMatrix::sanitize(Matrix &mat, int precision) { for (auto &row : mat) { for (float &cell : row) { - double val = (double)cell; + double val = double(cell); val = double_round(val, precision); - cell = (float)val; + cell = float(val); } } } diff --git a/source/blender/io/collada/CameraExporter.cpp b/source/blender/io/collada/CameraExporter.cpp index 45a73914256..7c3f304b722 100644 --- a/source/blender/io/collada/CameraExporter.cpp +++ b/source/blender/io/collada/CameraExporter.cpp @@ -51,7 +51,7 @@ void CamerasExporter::operator()(Object *ob, Scene *sce) case CAM_PERSP: { COLLADASW::PerspectiveOptic persp(mSW); persp.setXFov(RAD2DEGF(focallength_to_fov(cam->lens, cam->sensor_x)), "xfov"); - persp.setAspectRatio((float)(sce->r.xsch) / (float)(sce->r.ysch), false, "aspect_ratio"); + persp.setAspectRatio(float(sce->r.xsch) / float(sce->r.ysch), false, "aspect_ratio"); persp.setZFar(cam->clip_end, false, "zfar"); persp.setZNear(cam->clip_start, false, "znear"); COLLADASW::Camera ccam(mSW, &persp, cam_id, cam_name); @@ -64,7 +64,7 @@ void CamerasExporter::operator()(Object *ob, Scene *sce) default: { COLLADASW::OrthographicOptic ortho(mSW); ortho.setXMag(cam->ortho_scale / 2, "xmag"); - ortho.setAspectRatio((float)(sce->r.xsch) / (float)(sce->r.ysch), false, "aspect_ratio"); + ortho.setAspectRatio(float(sce->r.xsch) / float(sce->r.ysch), false, "aspect_ratio"); ortho.setZFar(cam->clip_end, false, "zfar"); ortho.setZNear(cam->clip_start, false, "znear"); COLLADASW::Camera ccam(mSW, &ortho, cam_id, cam_name); diff --git a/source/blender/io/collada/DocumentImporter.cpp b/source/blender/io/collada/DocumentImporter.cpp index 851e57bb750..660bbd7edb2 100644 --- a/source/blender/io/collada/DocumentImporter.cpp +++ b/source/blender/io/collada/DocumentImporter.cpp @@ -241,7 +241,7 @@ void DocumentImporter::finish() if (!libnode_ob.empty()) { - fprintf(stderr, "| Cleanup: free %d library nodes\n", (int)libnode_ob.size()); + fprintf(stderr, "| Cleanup: free %d library nodes\n", int(libnode_ob.size())); /* free all library_nodes */ std::vector::iterator it; for (it = libnode_ob.begin(); it != libnode_ob.end(); it++) { @@ -434,7 +434,7 @@ Object *DocumentImporter::create_instance_node(Object *source_ob, Object *new_child = nullptr; if (inodes.getCount()) { /* \todo loop through instance nodes */ const COLLADAFW::UniqueId &id = inodes[0]->getInstanciatedObjectId(); - fprintf(stderr, "Doing %d child nodes\n", (int)node_map.count(id)); + fprintf(stderr, "Doing %d child nodes\n", int(node_map.count(id))); new_child = create_instance_node( object_map.find(id)->second, node_map[id], child_node, sce, is_library_node); } @@ -869,7 +869,7 @@ bool DocumentImporter::writeCamera(const COLLADAFW::Camera *camera) double ymag = 2 * camera->getYMag().getValue(); double aspect = camera->getAspectRatio().getValue(); double xmag = aspect * ymag; - cam->ortho_scale = (float)xmag; + cam->ortho_scale = float(xmag); } break; case CAM_PERSP: default: { @@ -890,7 +890,7 @@ bool DocumentImporter::writeCamera(const COLLADAFW::Camera *camera) case COLLADAFW::Camera::X_AND_Y: { switch (cam->type) { case CAM_ORTHO: - cam->ortho_scale = (float)camera->getXMag().getValue() * 2; + cam->ortho_scale = float(camera->getXMag().getValue()) * 2; break; case CAM_PERSP: default: { @@ -903,7 +903,7 @@ bool DocumentImporter::writeCamera(const COLLADAFW::Camera *camera) case COLLADAFW::Camera::SINGLE_Y: { switch (cam->type) { case CAM_ORTHO: - cam->ortho_scale = (float)camera->getYMag().getValue(); + cam->ortho_scale = float(camera->getYMag().getValue()); break; case CAM_PERSP: default: { diff --git a/source/blender/io/collada/ExtraTags.cpp b/source/blender/io/collada/ExtraTags.cpp index 398718f1133..9fb7bbb2295 100644 --- a/source/blender/io/collada/ExtraTags.cpp +++ b/source/blender/io/collada/ExtraTags.cpp @@ -49,7 +49,7 @@ float ExtraTags::asFloat(std::string tag, bool *ok) return -1.0f; } *ok = true; - return (float)atof(tags[tag].c_str()); + return float(atof(tags[tag].c_str())); } std::string ExtraTags::asString(std::string tag, bool *ok) @@ -67,7 +67,7 @@ bool ExtraTags::setData(std::string tag, short *data) bool ok = false; int tmp = asInt(tag, &ok); if (ok) { - *data = (short)tmp; + *data = short(tmp); } return ok; } @@ -97,7 +97,7 @@ bool ExtraTags::setData(std::string tag, char *data) bool ok = false; int tmp = asInt(tag, &ok); if (ok) { - *data = (char)tmp; + *data = char(tmp); } return ok; } diff --git a/source/blender/io/collada/GeometryExporter.cpp b/source/blender/io/collada/GeometryExporter.cpp index 0e74c3ed516..a069c32026b 100644 --- a/source/blender/io/collada/GeometryExporter.cpp +++ b/source/blender/io/collada/GeometryExporter.cpp @@ -64,7 +64,7 @@ void GeometryExporter::operator()(Object *ob) exportedGeometry.insert(geom_id); - bool has_color = (bool)CustomData_has_layer(&me->fdata, CD_MCOL); + bool has_color = bool(CustomData_has_layer(&me->fdata, CD_MCOL)); create_normals(nor, norind, me); @@ -77,7 +77,7 @@ void GeometryExporter::operator()(Object *ob) /* writes for normal coords */ createNormalsSource(geom_id, me, nor); - bool has_uvs = (bool)CustomData_has_layer(&me->ldata, CD_MLOOPUV); + bool has_uvs = bool(CustomData_has_layer(&me->ldata, CD_MLOOPUV)); /* writes for uv coords if mesh has uv coords */ if (has_uvs) { @@ -147,7 +147,7 @@ void GeometryExporter::export_key_mesh(Object *ob, Mesh *me, KeyBlock *kb) exportedGeometry.insert(geom_id); - bool has_color = (bool)CustomData_has_layer(&me->fdata, CD_MCOL); + bool has_color = bool(CustomData_has_layer(&me->fdata, CD_MCOL)); create_normals(nor, norind, me); @@ -160,7 +160,7 @@ void GeometryExporter::export_key_mesh(Object *ob, Mesh *me, KeyBlock *kb) /* writes for normal coords */ createNormalsSource(geom_id, me, nor); - bool has_uvs = (bool)CustomData_has_layer(&me->ldata, CD_MLOOPUV); + bool has_uvs = bool(CustomData_has_layer(&me->ldata, CD_MLOOPUV)); /* writes for uv coords if mesh has uv coords */ if (has_uvs) { @@ -585,7 +585,7 @@ void GeometryExporter::createNormalsSource(std::string geom_id, Mesh *me, std::v COLLADASW::FloatSourceF source(mSW); source.setId(getIdBySemantics(geom_id, COLLADASW::InputSemantic::NORMAL)); source.setArrayId(getIdBySemantics(geom_id, COLLADASW::InputSemantic::NORMAL) + ARRAY_ID_SUFFIX); - source.setAccessorCount((ulong)nor.size()); + source.setAccessorCount(ulong(nor.size())); source.setAccessorStride(3); COLLADASW::SourceBase::ParameterNameList ¶m = source.getParameterNameList(); param.push_back("X"); diff --git a/source/blender/io/collada/MeshImporter.cpp b/source/blender/io/collada/MeshImporter.cpp index fea57698261..6f77c233aac 100644 --- a/source/blender/io/collada/MeshImporter.cpp +++ b/source/blender/io/collada/MeshImporter.cpp @@ -1172,7 +1172,7 @@ bool MeshImporter::write_geometry(const COLLADAFW::Geometry *geom) fprintf(stderr, "Can't apply custom normals, me->totloop != loop_normals.size() (%d != %d)\n", me->totloop, - (int)loop_normals.size()); + int(loop_normals.size())); } else { BKE_mesh_set_custom_normals(me, reinterpret_cast(loop_normals.data())); diff --git a/source/blender/io/collada/TransformReader.cpp b/source/blender/io/collada/TransformReader.cpp index 47deddb5feb..cc1334bd99b 100644 --- a/source/blender/io/collada/TransformReader.cpp +++ b/source/blender/io/collada/TransformReader.cpp @@ -87,8 +87,8 @@ void TransformReader::dae_rotate_to_mat4(COLLADAFW::Transformation *tm, float m[ { COLLADAFW::Rotate *ro = (COLLADAFW::Rotate *)tm; COLLADABU::Math::Vector3 &axis = ro->getRotationAxis(); - const float angle = (float)DEG2RAD(ro->getRotationAngle()); - const float ax[] = {(float)axis[0], (float)axis[1], (float)axis[2]}; + const float angle = float(DEG2RAD(ro->getRotationAngle())); + const float ax[] = {float(axis[0]), float(axis[1]), float(axis[2])}; #if 0 float quat[4]; axis_angle_to_quat(quat, axis, angle); @@ -104,15 +104,15 @@ void TransformReader::dae_translate_to_mat4(COLLADAFW::Transformation *tm, float unit_m4(m); - m[3][0] = (float)t[0]; - m[3][1] = (float)t[1]; - m[3][2] = (float)t[2]; + m[3][0] = float(t[0]); + m[3][1] = float(t[1]); + m[3][2] = float(t[2]); } void TransformReader::dae_scale_to_mat4(COLLADAFW::Transformation *tm, float m[4][4]) { COLLADABU::Math::Vector3 &s = ((COLLADAFW::Scale *)tm)->getScale(); - float size[3] = {(float)s[0], (float)s[1], (float)s[2]}; + float size[3] = {float(s[0]), float(s[1]), float(s[2])}; size_to_mat4(m, size); } diff --git a/source/blender/io/collada/collada_internal.cpp b/source/blender/io/collada/collada_internal.cpp index c4f13f1cbd2..60e8edaa3bc 100644 --- a/source/blender/io/collada/collada_internal.cpp +++ b/source/blender/io/collada/collada_internal.cpp @@ -47,7 +47,7 @@ UnitConverter::UnitSystem UnitConverter::isMetricSystem() float UnitConverter::getLinearMeter() { - return (float)unit.getLinearUnitMeter(); + return float(unit.getLinearUnitMeter()); } void UnitConverter::convertVector3(COLLADABU::Math::Vector3 &vec, float *v) @@ -212,9 +212,9 @@ std::string translate_id(const std::string &id) } std::string id_translated = id; - id_translated[0] = translate_start_name_map[(uint)id_translated[0]]; + id_translated[0] = translate_start_name_map[uint(id_translated[0])]; for (uint i = 1; i < id_translated.size(); i++) { - id_translated[i] = translate_name_map[(uint)id_translated[i]]; + id_translated[i] = translate_name_map[uint(id_translated[i])]; } /* It's so much workload now, the if () should speed up things. */ if (id_translated != id) { diff --git a/source/blender/io/collada/collada_utils.cpp b/source/blender/io/collada/collada_utils.cpp index bfa150faf8b..22a73cd7db2 100644 --- a/source/blender/io/collada/collada_utils.cpp +++ b/source/blender/io/collada/collada_utils.cpp @@ -710,13 +710,13 @@ float bc_get_property(Bone *bone, std::string key, float def) if (property) { switch (property->type) { case IDP_INT: - result = (float)(IDP_Int(property)); + result = float(IDP_Int(property)); break; case IDP_FLOAT: - result = (float)(IDP_Float(property)); + result = float(IDP_Float(property)); break; case IDP_DOUBLE: - result = (float)(IDP_Double(property)); + result = float(IDP_Double(property)); break; default: result = def; @@ -1008,9 +1008,9 @@ void bc_create_restpose_mat(BCExportSettings &export_settings, void bc_sanitize_v3(float v[3], int precision) { for (int i = 0; i < 3; i++) { - double val = (double)v[i]; + double val = double(v[i]); val = double_round(val, precision); - v[i] = (float)val; + v[i] = float(val); } } @@ -1339,7 +1339,7 @@ bool bc_get_float_from_shader(bNode *shader, double &val, std::string nodeid) bNodeSocket *socket = nodeFindSocket(shader, SOCK_IN, nodeid.c_str()); if (socket) { bNodeSocketValueFloat *ref = (bNodeSocketValueFloat *)socket->default_value; - val = (double)ref->value; + val = double(ref->value); return true; } return false; diff --git a/source/blender/io/gpencil/intern/gpencil_io_base.cc b/source/blender/io/gpencil/intern/gpencil_io_base.cc index bcf9a36c200..b9d7b6719b1 100644 --- a/source/blender/io/gpencil/intern/gpencil_io_base.cc +++ b/source/blender/io/gpencil/intern/gpencil_io_base.cc @@ -227,16 +227,16 @@ float2 GpencilIO::gpencil_3D_point_to_render_space(const float3 co) float2 r_co; mul_v2_project_m4_v3(&r_co.x, persmat_, &parent_co.x); - r_co.x = (r_co.x + 1.0f) / 2.0f * (float)render_x_; - r_co.y = (r_co.y + 1.0f) / 2.0f * (float)render_y_; + r_co.x = (r_co.x + 1.0f) / 2.0f * float(render_x_); + r_co.y = (r_co.y + 1.0f) / 2.0f * float(render_y_); /* Invert X axis. */ if (invert_axis_[0]) { - r_co.x = (float)render_x_ - r_co.x; + r_co.x = float(render_x_) - r_co.x; } /* Invert Y axis. */ if (invert_axis_[1]) { - r_co.y = (float)render_y_ - r_co.y; + r_co.y = float(render_y_) - r_co.y; } return r_co; @@ -244,7 +244,7 @@ float2 GpencilIO::gpencil_3D_point_to_render_space(const float3 co) float2 GpencilIO::gpencil_3D_point_to_2D(const float3 co) { - const bool is_camera = (bool)(rv3d_->persp == RV3D_CAMOB); + const bool is_camera = bool(rv3d_->persp == RV3D_CAMOB); if (is_camera) { return gpencil_3D_point_to_render_space(co); } @@ -292,9 +292,9 @@ void GpencilIO::prepare_stroke_export_colors(Object *ob, bGPDstroke *gps) avg_opacity_ += pt.strength; } - mul_v4_v4fl(avg_color, avg_color, 1.0f / (float)gps->totpoints); + mul_v4_v4fl(avg_color, avg_color, 1.0f / float(gps->totpoints)); interp_v3_v3v3(stroke_color_, stroke_color_, avg_color, avg_color[3]); - avg_opacity_ /= (float)gps->totpoints; + avg_opacity_ /= float(gps->totpoints); /* Fill color. */ copy_v4_v4(fill_color_, gp_style->fill_rgba); diff --git a/source/blender/io/gpencil/intern/gpencil_io_import_base.cc b/source/blender/io/gpencil/intern/gpencil_io_import_base.cc index 6d4439243fd..f6d02d36a17 100644 --- a/source/blender/io/gpencil/intern/gpencil_io_import_base.cc +++ b/source/blender/io/gpencil/intern/gpencil_io_import_base.cc @@ -31,7 +31,7 @@ Object *GpencilImporter::create_object() const float *cur_loc = scene_->cursor.location; const float rot[3] = {0.0f}; ushort local_view_bits = (params_.v3d && params_.v3d->localvd) ? params_.v3d->local_view_uuid : - (ushort)0; + ushort(0); Object *ob_gpencil = ED_object_add_type(params_.C, OB_GPENCIL, diff --git a/source/blender/io/gpencil/intern/gpencil_io_import_svg.cc b/source/blender/io/gpencil/intern/gpencil_io_import_svg.cc index ebad236bada..23c80900659 100644 --- a/source/blender/io/gpencil/intern/gpencil_io_import_svg.cc +++ b/source/blender/io/gpencil/intern/gpencil_io_import_svg.cc @@ -93,8 +93,8 @@ bool GpencilImporterSVG::read() /* Check frame. */ bGPDframe *gpf = BKE_gpencil_layer_frame_get(gpl, cfra_, GP_GETFRAME_ADD_NEW); /* Create materials. */ - bool is_stroke = (bool)shape->stroke.type; - bool is_fill = (bool)shape->fill.type; + bool is_stroke = bool(shape->stroke.type); + bool is_fill = bool(shape->fill.type); if ((!is_stroke) && (!is_fill)) { is_stroke = true; } @@ -148,11 +148,11 @@ void GpencilImporterSVG::create_stroke(bGPdata *gpd, const int32_t mat_index, const float matrix[4][4]) { - const bool is_stroke = (bool)shape->stroke.type; - const bool is_fill = (bool)shape->fill.type; + const bool is_stroke = bool(shape->stroke.type); + const bool is_fill = bool(shape->fill.type); const int edges = params_.resolution; - const float step = 1.0f / (float)(edges - 1); + const float step = 1.0f / float(edges - 1); const int totpoints = (path->npts / 3) * params_.resolution; @@ -221,10 +221,10 @@ static void unpack_nano_color(const uint pack, float r_col[4]) rgb_u[2] = ((pack) >> 16) & 0xFF; rgb_u[3] = ((pack) >> 24) & 0xFF; - r_col[0] = (float)rgb_u[0] / 255.0f; - r_col[1] = (float)rgb_u[1] / 255.0f; - r_col[2] = (float)rgb_u[2] / 255.0f; - r_col[3] = (float)rgb_u[3] / 255.0f; + r_col[0] = float(rgb_u[0]) / 255.0f; + r_col[1] = float(rgb_u[1]) / 255.0f; + r_col[2] = float(rgb_u[2]) / 255.0f; + r_col[3] = float(rgb_u[3]) / 255.0f; } void GpencilImporterSVG::convert_color(const int32_t color, float r_linear_rgba[4]) diff --git a/source/blender/io/usd/intern/usd_reader_curve.cc b/source/blender/io/usd/intern/usd_reader_curve.cc index 0d3c2feb8f3..ca48f3c2391 100644 --- a/source/blender/io/usd/intern/usd_reader_curve.cc +++ b/source/blender/io/usd/intern/usd_reader_curve.cc @@ -139,9 +139,9 @@ void USDCurvesReader::read_curve_sample(Curve *cu, const double motionSampleTime BPoint *bp = nu->bp; for (int j = 0; j < nu->pntsu; j++, bp++, idx++) { - bp->vec[0] = (float)usdPoints[idx][0]; - bp->vec[1] = (float)usdPoints[idx][1]; - bp->vec[2] = (float)usdPoints[idx][2]; + bp->vec[0] = float(usdPoints[idx][0]); + bp->vec[1] = float(usdPoints[idx][1]); + bp->vec[2] = float(usdPoints[idx][2]); bp->vec[3] = weight; bp->f1 = SELECT; bp->weight = weight; diff --git a/source/blender/io/usd/intern/usd_reader_light.cc b/source/blender/io/usd/intern/usd_reader_light.cc index 55b9557dfb5..7204ea91896 100644 --- a/source/blender/io/usd/intern/usd_reader_light.cc +++ b/source/blender/io/usd/intern/usd_reader_light.cc @@ -203,7 +203,7 @@ void USDLightReader::read_object_data(Main *bmain, const double motionSampleTime if (pxr::UsdAttribute cone_angle_attr = shaping_api.GetShapingConeAngleAttr()) { float cone_angle = 0.0f; if (cone_angle_attr.Get(&cone_angle, motionSampleTime)) { - blight->spotsize = cone_angle * ((float)M_PI / 180.0f) * 2.0f; + blight->spotsize = cone_angle * (float(M_PI) / 180.0f) * 2.0f; } } @@ -226,7 +226,7 @@ void USDLightReader::read_object_data(Main *bmain, const double motionSampleTime if (pxr::UsdAttribute angle_attr = distant_light.GetAngleAttr()) { float angle = 0.0f; if (angle_attr.Get(&angle, motionSampleTime)) { - blight->sun_angle = angle * (float)M_PI / 180.0f; + blight->sun_angle = angle * float(M_PI) / 180.0f; } } } diff --git a/source/blender/io/usd/intern/usd_reader_nurbs.cc b/source/blender/io/usd/intern/usd_reader_nurbs.cc index a838450a4c0..0a7058fb100 100644 --- a/source/blender/io/usd/intern/usd_reader_nurbs.cc +++ b/source/blender/io/usd/intern/usd_reader_nurbs.cc @@ -33,7 +33,7 @@ static bool set_knots(const pxr::VtDoubleArray &knots, float *&nu_knots) nu_knots = static_cast(MEM_callocN(num_knots * sizeof(float), __func__)); for (size_t i = 0; i < num_knots; i++) { - nu_knots[i] = (float)knots[i]; + nu_knots[i] = float(knots[i]); } return true; @@ -141,9 +141,9 @@ void USDNurbsReader::read_curve_sample(Curve *cu, const double motionSampleTime) BPoint *bp = nu->bp; for (int j = 0; j < nu->pntsu; j++, bp++, idx++) { - bp->vec[0] = (float)usdPoints[idx][0]; - bp->vec[1] = (float)usdPoints[idx][1]; - bp->vec[2] = (float)usdPoints[idx][2]; + bp->vec[0] = float(usdPoints[idx][0]); + bp->vec[1] = float(usdPoints[idx][1]); + bp->vec[2] = float(usdPoints[idx][2]); bp->vec[3] = weight; bp->f1 = SELECT; bp->weight = weight; diff --git a/source/blender/io/usd/intern/usd_writer_volume.cc b/source/blender/io/usd/intern/usd_writer_volume.cc index 12db6d73901..8cc3c65ee70 100644 --- a/source/blender/io/usd/intern/usd_writer_volume.cc +++ b/source/blender/io/usd/intern/usd_writer_volume.cc @@ -145,7 +145,7 @@ std::optional USDVolumeWriter::construct_vdb_file_path(const Volume BLI_strncpy(vdb_file_name, volume->id.name + 2, FILE_MAXFILE); const pxr::UsdTimeCode timecode = get_export_time_code(); if (!timecode.IsDefault()) { - const int frame = (int)timecode.GetValue(); + const int frame = int(timecode.GetValue()); const int num_frame_digits = frame == 0 ? 1 : integer_digits_i(abs(frame)); BLI_path_frame(vdb_file_name, frame, num_frame_digits); } diff --git a/source/blender/io/wavefront_obj/exporter/obj_export_file_writer.cc b/source/blender/io/wavefront_obj/exporter/obj_export_file_writer.cc index f2547e6fc14..95be927589e 100644 --- a/source/blender/io/wavefront_obj/exporter/obj_export_file_writer.cc +++ b/source/blender/io/wavefront_obj/exporter/obj_export_file_writer.cc @@ -503,7 +503,7 @@ static const char *tex_map_type_to_string[] = { "map_d", "map_Bump", }; -BLI_STATIC_ASSERT(ARRAY_SIZE(tex_map_type_to_string) == (int)MTLTexMapType::Count, +BLI_STATIC_ASSERT(ARRAY_SIZE(tex_map_type_to_string) == int(MTLTexMapType::Count), "array size mismatch"); /** @@ -641,7 +641,7 @@ void MTLWriter::write_texture_map(const MTLMaterial &mtl_material, /* Always emit forward slashes for cross-platform compatibility. */ std::replace(path.begin(), path.end(), '\\', '/'); - fmt_handler_.write_mtl_map(tex_map_type_to_string[(int)texture_key], options, path); + fmt_handler_.write_mtl_map(tex_map_type_to_string[int(texture_key)], options, path); } static bool is_pbr_map(MTLTexMapType type) @@ -677,7 +677,7 @@ void MTLWriter::write_materials(const char *blen_filepath, fmt_handler_.write_string(""); fmt_handler_.write_mtl_newmtl(mtlmat.name); write_bsdf_properties(mtlmat, write_pbr); - for (int key = 0; key < (int)MTLTexMapType::Count; key++) { + for (int key = 0; key < int(MTLTexMapType::Count); key++) { const MTLTexMap &tex = mtlmat.texture_maps[key]; if (!tex.is_valid()) { continue; diff --git a/source/blender/io/wavefront_obj/exporter/obj_export_mtl.cc b/source/blender/io/wavefront_obj/exporter/obj_export_mtl.cc index 851358f8762..0231bc79b89 100644 --- a/source/blender/io/wavefront_obj/exporter/obj_export_mtl.cc +++ b/source/blender/io/wavefront_obj/exporter/obj_export_mtl.cc @@ -33,7 +33,7 @@ const char *tex_map_type_to_socket_id[] = { "Alpha", "Normal", }; -BLI_STATIC_ASSERT(ARRAY_SIZE(tex_map_type_to_socket_id) == (int)MTLTexMapType::Count, +BLI_STATIC_ASSERT(ARRAY_SIZE(tex_map_type_to_socket_id) == int(MTLTexMapType::Count), "array size mismatch"); /** @@ -312,12 +312,12 @@ static void store_image_textures(const bNode *bsdf_node, * - finding "Strength" property of the node for `-bm` option. */ - for (int key = 0; key < (int)MTLTexMapType::Count; ++key) { + for (int key = 0; key < int(MTLTexMapType::Count); ++key) { MTLTexMap &value = r_mtl_mat.texture_maps[key]; Vector linked_sockets; const bNode *normal_map_node{nullptr}; - if (key == (int)MTLTexMapType::Normal) { + if (key == int(MTLTexMapType::Normal)) { /* Find sockets linked to destination "Normal" socket in P-BSDF node. */ linked_sockets_to_dest_id(bsdf_node, *node_tree, "Normal", linked_sockets); /* Among the linked sockets, find Normal Map shader node. */ @@ -328,7 +328,7 @@ static void store_image_textures(const bNode *bsdf_node, } else { /* Skip emission map if emission strength is zero. */ - if (key == (int)MTLTexMapType::Emission) { + if (key == int(MTLTexMapType::Emission)) { float emission_strength = 0.0f; copy_property_from_node( SOCK_FLOAT, bsdf_node, "Emission Strength", {&emission_strength, 1}); diff --git a/source/blender/io/wavefront_obj/importer/obj_import_file_reader.cc b/source/blender/io/wavefront_obj/importer/obj_import_file_reader.cc index a30dfda24d8..bd1c2d32a12 100644 --- a/source/blender/io/wavefront_obj/importer/obj_import_file_reader.cc +++ b/source/blender/io/wavefront_obj/importer/obj_import_file_reader.cc @@ -216,7 +216,7 @@ static void geom_add_polygon(Geometry *geom, fprintf(stderr, "Invalid vertex index %i (valid range [0, %zu)), ignoring face\n", corner.vert_index, - (size_t)global_vertices.vertices.size()); + size_t(global_vertices.vertices.size())); face_valid = false; } else { @@ -228,7 +228,7 @@ static void geom_add_polygon(Geometry *geom, fprintf(stderr, "Invalid UV index %i (valid range [0, %zu)), ignoring face\n", corner.uv_vert_index, - (size_t)global_vertices.uv_vertices.size()); + size_t(global_vertices.uv_vertices.size())); face_valid = false; } } @@ -244,7 +244,7 @@ static void geom_add_polygon(Geometry *geom, fprintf(stderr, "Invalid normal index %i (valid range [0, %zu)), ignoring face\n", corner.vertex_normal_index, - (size_t)global_vertices.vertex_normals.size()); + size_t(global_vertices.vertex_normals.size())); face_valid = false; } } @@ -485,7 +485,7 @@ void OBJParser::parse(Vector> &r_all_geometries, /* Parse the buffer (until last newline) that we have so far, * line by line. */ - StringRef buffer_str{buffer.data(), (int64_t)last_nl}; + StringRef buffer_str{buffer.data(), int64_t(last_nl)}; while (!buffer_str.is_empty()) { StringRef line = read_next_line(buffer_str); const char *p = line.begin(), *end = line.end(); @@ -768,7 +768,7 @@ void MTLParser::parse_and_store(Map> &r_mat MTLMaterial *material = nullptr; - StringRef buffer_str{(const char *)buffer, (int64_t)buffer_len}; + StringRef buffer_str{(const char *)buffer, int64_t(buffer_len)}; while (!buffer_str.is_empty()) { const StringRef line = read_next_line(buffer_str); const char *p = line.begin(), *end = line.end(); diff --git a/source/blender/io/wavefront_obj/importer/obj_import_mesh.cc b/source/blender/io/wavefront_obj/importer/obj_import_mesh.cc index ef05534928a..4a4d1eeadb6 100644 --- a/source/blender/io/wavefront_obj/importer/obj_import_mesh.cc +++ b/source/blender/io/wavefront_obj/importer/obj_import_mesh.cc @@ -166,7 +166,7 @@ void MeshFromGeometry::create_vertices(Mesh *mesh) if (!mesh_geometry_.vertices_.contains(vi)) { continue; } - int local_vi = (int)mesh_geometry_.global_to_local_vertices_.size(); + int local_vi = int(mesh_geometry_.global_to_local_vertices_.size()); BLI_assert(local_vi >= 0 && local_vi < mesh->totvert); copy_v3_v3(verts[local_vi].co, global_vertices_.vertices[vi]); mesh_geometry_.global_to_local_vertices_.add_new(vi, local_vi); diff --git a/source/blender/io/wavefront_obj/importer/obj_import_mtl.cc b/source/blender/io/wavefront_obj/importer/obj_import_mtl.cc index 439a5fa8f05..787b1fc9730 100644 --- a/source/blender/io/wavefront_obj/importer/obj_import_mtl.cc +++ b/source/blender/io/wavefront_obj/importer/obj_import_mtl.cc @@ -356,7 +356,7 @@ static void add_image_textures(Main *bmain, bool relative_paths) { float node_locy = node_locy_top; - for (int key = 0; key < (int)MTLTexMapType::Count; ++key) { + for (int key = 0; key < int(MTLTexMapType::Count); ++key) { const MTLTexMap &value = mtl_mat.texture_maps[key]; if (!value.is_valid()) { /* No Image texture node of this map type can be added to this material. */ @@ -375,7 +375,7 @@ static void add_image_textures(Main *bmain, /* Add normal map node if needed. */ bNode *normal_map = nullptr; - if (key == (int)MTLTexMapType::Normal) { + if (key == int(MTLTexMapType::Normal)) { normal_map = add_node(ntree, SH_NODE_NORMAL_MAP, node_locx_normalmap, node_locy); const float bump = std::max(0.0f, mtl_mat.normal_strength); set_property_of_socket(SOCK_FLOAT, "Strength", {bump}, normal_map); @@ -396,7 +396,7 @@ static void add_image_textures(Main *bmain, link_sockets(ntree, image_node, "Color", normal_map, "Color"); link_sockets(ntree, normal_map, "Normal", bsdf, "Normal"); } - else if (key == (int)MTLTexMapType::Alpha) { + else if (key == int(MTLTexMapType::Alpha)) { link_sockets(ntree, image_node, "Alpha", bsdf, tex_map_type_to_socket_id[key]); mat->blend_method = MA_BM_BLEND; } diff --git a/source/blender/io/wavefront_obj/tests/obj_mtl_parser_tests.cc b/source/blender/io/wavefront_obj/tests/obj_mtl_parser_tests.cc index e473d629673..ce3c14a2939 100644 --- a/source/blender/io/wavefront_obj/tests/obj_mtl_parser_tests.cc +++ b/source/blender/io/wavefront_obj/tests/obj_mtl_parser_tests.cc @@ -67,7 +67,7 @@ class obj_mtl_parser_test : public testing::Test { EXPECT_NEAR(exp.cc_roughness, got.cc_roughness, tol); EXPECT_NEAR(exp.aniso, got.aniso, tol); EXPECT_NEAR(exp.aniso_rot, got.aniso_rot, tol); - for (int key = 0; key < (int)MTLTexMapType::Count; key++) { + for (int key = 0; key < int(MTLTexMapType::Count); key++) { const MTLTexMap &exp_tex = exp.texture_maps[key]; const MTLTexMap &got_tex = got.texture_maps[key]; EXPECT_STREQ(exp_tex.image_path.c_str(), got_tex.image_path.c_str()); diff --git a/source/blender/modifiers/intern/MOD_meshsequencecache.cc b/source/blender/modifiers/intern/MOD_meshsequencecache.cc index f30e6a95787..82098aa1358 100644 --- a/source/blender/modifiers/intern/MOD_meshsequencecache.cc +++ b/source/blender/modifiers/intern/MOD_meshsequencecache.cc @@ -135,7 +135,7 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh * Scene *scene = DEG_get_evaluated_scene(ctx->depsgraph); CacheFile *cache_file = mcmd->cache_file; const float frame = DEG_get_ctime(ctx->depsgraph); - const double time = BKE_cachefile_time_offset(cache_file, (double)frame, FPS); + const double time = BKE_cachefile_time_offset(cache_file, double(frame), FPS); const char *err_str = nullptr; if (!mcmd->reader || !STREQ(mcmd->reader_object_path, mcmd->object_path)) { diff --git a/source/blender/modifiers/intern/MOD_nodes.cc b/source/blender/modifiers/intern/MOD_nodes.cc index a878793a34d..7c5bb988012 100644 --- a/source/blender/modifiers/intern/MOD_nodes.cc +++ b/source/blender/modifiers/intern/MOD_nodes.cc @@ -443,8 +443,8 @@ id_property_create_from_socket(const bNodeSocket &socket) auto property = bke::idprop::create(socket.identifier, value->value); IDPropertyUIDataFloat *ui_data = (IDPropertyUIDataFloat *)IDP_ui_data_ensure(property.get()); ui_data->base.rna_subtype = value->subtype; - ui_data->min = ui_data->soft_min = (double)value->min; - ui_data->max = ui_data->soft_max = (double)value->max; + ui_data->min = ui_data->soft_min = double(value->min); + ui_data->max = ui_data->soft_max = double(value->max); ui_data->default_value = value->value; return property; } @@ -466,8 +466,8 @@ id_property_create_from_socket(const bNodeSocket &socket) socket.identifier, Span{value->value[0], value->value[1], value->value[2]}); IDPropertyUIDataFloat *ui_data = (IDPropertyUIDataFloat *)IDP_ui_data_ensure(property.get()); ui_data->base.rna_subtype = value->subtype; - ui_data->min = ui_data->soft_min = (double)value->min; - ui_data->max = ui_data->soft_max = (double)value->max; + ui_data->min = ui_data->soft_min = double(value->min); + ui_data->max = ui_data->soft_max = double(value->max); ui_data->default_array = (double *)MEM_mallocN(sizeof(double[3]), "mod_prop_default"); ui_data->default_array_len = 3; for (const int i : IndexRange(3)) { @@ -579,7 +579,7 @@ static void init_socket_cpp_value_from_property(const IDProperty &property, value = IDP_Float(&property); } else if (property.type == IDP_DOUBLE) { - value = (float)IDP_Double(&property); + value = float(IDP_Double(&property)); } new (r_value) ValueOrField(value); break; diff --git a/source/blender/nodes/function/nodes/node_fn_float_to_int.cc b/source/blender/nodes/function/nodes/node_fn_float_to_int.cc index aad2f532d20..452768208c5 100644 --- a/source/blender/nodes/function/nodes/node_fn_float_to_int.cc +++ b/source/blender/nodes/function/nodes/node_fn_float_to_int.cc @@ -43,13 +43,13 @@ static const fn::MultiFunction *get_multi_function(const bNode &bnode) { static auto exec_preset = fn::CustomMF_presets::AllSpanOrSingle(); static fn::CustomMF_SI_SO round_fn{ - "Round", [](float a) { return (int)round(a); }, exec_preset}; + "Round", [](float a) { return int(round(a)); }, exec_preset}; static fn::CustomMF_SI_SO floor_fn{ - "Floor", [](float a) { return (int)floor(a); }, exec_preset}; + "Floor", [](float a) { return int(floor(a)); }, exec_preset}; static fn::CustomMF_SI_SO ceil_fn{ - "Ceiling", [](float a) { return (int)ceil(a); }, exec_preset}; + "Ceiling", [](float a) { return int(ceil(a)); }, exec_preset}; static fn::CustomMF_SI_SO trunc_fn{ - "Truncate", [](float a) { return (int)trunc(a); }, exec_preset}; + "Truncate", [](float a) { return int(trunc(a)); }, exec_preset}; switch (static_cast(bnode.custom1)) { case FN_NODE_FLOAT_TO_INT_ROUND: diff --git a/source/blender/nodes/geometry/nodes/node_geo_convex_hull.cc b/source/blender/nodes/geometry/nodes/node_geo_convex_hull.cc index c8b692651e9..038309785fb 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_convex_hull.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_convex_hull.cc @@ -56,7 +56,7 @@ static Mesh *hull_from_bullet(const Mesh *mesh, Span coords) # if 0 /* Disabled because it only works for meshes, not predictable enough. */ /* Copy custom data on vertices, like vertex groups etc. */ if (mesh && original_index < mesh->totvert) { - CustomData_copy_data(&mesh->vdata, &result->vdata, (int)original_index, (int)i, 1); + CustomData_copy_data(&mesh->vdata, &result->vdata, int(original_index), int(i), 1); } # endif /* Copy the position of the original point. */ @@ -81,7 +81,7 @@ static Mesh *hull_from_bullet(const Mesh *mesh, Span coords) int v_to; plConvexHullGetLoop(hull, i, &v_from, &v_to); - mloop_src[i].v = (uint)v_from; + mloop_src[i].v = uint(v_from); /* Add edges for ascending order loops only. */ if (v_from < v_to) { MEdge &edge = edges[edge_index]; diff --git a/source/blender/nodes/geometry/nodes/node_geo_curve_fill.cc b/source/blender/nodes/geometry/nodes/node_geo_curve_fill.cc index c675ee472cd..eb8c1e02fb7 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_curve_fill.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_curve_fill.cc @@ -85,7 +85,7 @@ static Mesh *cdt_to_mesh(const meshintersect::CDT_result &result) MutableSpan loops = mesh->loops_for_write(); for (const int i : IndexRange(result.vert.size())) { - copy_v3_v3(verts[i].co, float3((float)result.vert[i].x, (float)result.vert[i].y, 0.0f)); + copy_v3_v3(verts[i].co, float3(float(result.vert[i].x), float(result.vert[i].y), 0.0f)); } for (const int i : IndexRange(result.edge.size())) { edges[i].v1 = result.edge[i].first; diff --git a/source/blender/nodes/geometry/nodes/node_geo_curve_handle_type_selection.cc b/source/blender/nodes/geometry/nodes/node_geo_curve_handle_type_selection.cc index b34b22e995d..b1c3bbfb81e 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_curve_handle_type_selection.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_curve_handle_type_selection.cc @@ -97,7 +97,7 @@ class HandleTypeFieldInput final : public bke::CurvesFieldInput { uint64_t hash() const override { - return get_default_hash_2((int)mode_, (int)type_); + return get_default_hash_2(int(mode_), int(type_)); } bool is_equal_to(const fn::FieldNode &other) const override diff --git a/source/blender/nodes/geometry/nodes/node_geo_curve_primitive_circle.cc b/source/blender/nodes/geometry/nodes/node_geo_curve_primitive_circle.cc index c33ba3e2a4c..56a9601ce7e 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_curve_primitive_circle.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_curve_primitive_circle.cc @@ -144,7 +144,7 @@ static Curves *create_point_circle_curve( /* Get the radius from the center-point to p1. */ const float r = math::distance(p1, center); - const float theta_step = ((2 * M_PI) / (float)resolution); + const float theta_step = ((2 * M_PI) / float(resolution)); for (const int i : IndexRange(resolution)) { /* Formula for a circle around a point and 2 unit vectors perpendicular diff --git a/source/blender/nodes/geometry/nodes/node_geo_curve_primitive_spiral.cc b/source/blender/nodes/geometry/nodes/node_geo_curve_primitive_spiral.cc index 4aaf57d57cb..66284fe77db 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_curve_primitive_spiral.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_curve_primitive_spiral.cc @@ -43,9 +43,9 @@ static Curves *create_spiral_curve(const float rotations, const bool direction) { const int totalpoints = std::max(int(resolution * rotations), 1); - const float delta_radius = (end_radius - start_radius) / (float)totalpoints; - const float delta_height = height / (float)totalpoints; - const float delta_theta = (M_PI * 2 * rotations) / (float)totalpoints * + const float delta_radius = (end_radius - start_radius) / float(totalpoints); + const float delta_height = height / float(totalpoints); + const float delta_theta = (M_PI * 2 * rotations) / float(totalpoints) * (direction ? 1.0f : -1.0f); Curves *curves_id = bke::curves_new_nomain_single(totalpoints + 1, CURVE_TYPE_POLY); diff --git a/source/blender/nodes/geometry/nodes/node_geo_distribute_points_in_volume.cc b/source/blender/nodes/geometry/nodes/node_geo_distribute_points_in_volume.cc index aa9070268f0..83bff91c4b3 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_distribute_points_in_volume.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_distribute_points_in_volume.cc @@ -99,7 +99,7 @@ class PositionsVDBWrapper { void add(const openvdb::Vec3R &pos) { - vector_.append(float3((float)pos[0], (float)pos[1], (float)pos[2]) + offset_fix_); + vector_.append(float3(float(pos[0]), float(pos[1]), float(pos[2])) + offset_fix_); } }; @@ -117,9 +117,9 @@ static void point_scatter_density_random(const openvdb::FloatGrid &grid, Vector &r_positions) { /* Offset points by half a voxel so that grid points are aligned with world grid points. */ - const float3 offset_fix = {0.5f * (float)grid.voxelSize().x(), - 0.5f * (float)grid.voxelSize().y(), - 0.5f * (float)grid.voxelSize().z()}; + const float3 offset_fix = {0.5f * float(grid.voxelSize().x()), + 0.5f * float(grid.voxelSize().y()), + 0.5f * float(grid.voxelSize().z())}; /* Setup and call into OpenVDB's point scatter API. */ PositionsVDBWrapper vdb_position_wrapper = PositionsVDBWrapper(r_positions, offset_fix); RNGType random_generator(seed); @@ -133,9 +133,9 @@ static void point_scatter_density_grid(const openvdb::FloatGrid &grid, Vector &r_positions) { const openvdb::Vec3d half_voxel(0.5, 0.5, 0.5); - const openvdb::Vec3d voxel_spacing((double)spacing.x / grid.voxelSize().x(), - (double)spacing.y / grid.voxelSize().y(), - (double)spacing.z / grid.voxelSize().z()); + const openvdb::Vec3d voxel_spacing(double(spacing.x) / grid.voxelSize().x(), + double(spacing.y) / grid.voxelSize().y(), + double(spacing.z) / grid.voxelSize().z()); /* Abort if spacing is zero. */ const double min_spacing = std::min(voxel_spacing.x(), @@ -170,7 +170,7 @@ static void point_scatter_density_grid(const openvdb::FloatGrid &grid, /* Transform with grid matrix and add point. */ const openvdb::Vec3d idx_pos(x, y, z); const openvdb::Vec3d local_pos = grid.indexToWorld(idx_pos + half_voxel); - r_positions.append({(float)local_pos.x(), (float)local_pos.y(), (float)local_pos.z()}); + r_positions.append({float(local_pos.x()), float(local_pos.y()), float(local_pos.z())}); } } } diff --git a/source/blender/nodes/geometry/nodes/node_geo_image_texture.cc b/source/blender/nodes/geometry/nodes/node_geo_image_texture.cc index 4b8af1649d4..725fc6d6db7 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_image_texture.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_image_texture.cc @@ -122,9 +122,9 @@ class ImageFieldsFunction : public fn::MultiFunction { static float frac(const float x, int *ix) { - const int i = (int)x - ((x < 0.0f) ? 1 : 0); + const int i = int(x) - ((x < 0.0f) ? 1 : 0); *ix = i; - return x - (float)i; + return x - float(i); } static float4 image_cubic_texture_lookup(const ImBuf *ibuf, @@ -135,8 +135,8 @@ class ImageFieldsFunction : public fn::MultiFunction { const int width = ibuf->x; const int height = ibuf->y; int pix, piy, nix, niy; - const float tx = frac(px * (float)width - 0.5f, &pix); - const float ty = frac(py * (float)height - 0.5f, &piy); + const float tx = frac(px * float(width) - 0.5f, &pix); + const float ty = frac(py * float(height) - 0.5f, &piy); int ppix, ppiy, nnix, nniy; switch (extension) { @@ -215,8 +215,8 @@ class ImageFieldsFunction : public fn::MultiFunction { const int width = ibuf->x; const int height = ibuf->y; int pix, piy, nix, niy; - const float nfx = frac(px * (float)width - 0.5f, &pix); - const float nfy = frac(py * (float)height - 0.5f, &piy); + const float nfx = frac(px * float(width) - 0.5f, &pix); + const float nfy = frac(py * float(height) - 0.5f, &piy); switch (extension) { case SHD_IMAGE_EXTENSION_CLIP: { @@ -257,8 +257,8 @@ class ImageFieldsFunction : public fn::MultiFunction { const int width = ibuf->x; const int height = ibuf->y; int ix, iy; - const float tx = frac(px * (float)width, &ix); - const float ty = frac(py * (float)height, &iy); + const float tx = frac(px * float(width), &ix); + const float ty = frac(py * float(height), &iy); switch (extension) { case SHD_IMAGE_EXTENSION_REPEAT: { diff --git a/source/blender/nodes/geometry/nodes/node_geo_input_scene_time.cc b/source/blender/nodes/geometry/nodes/node_geo_input_scene_time.cc index 0222ccbbd02..74d10c286a0 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_input_scene_time.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_input_scene_time.cc @@ -18,7 +18,7 @@ static void node_exec(GeoNodeExecParams params) { const Scene *scene = DEG_get_input_scene(params.depsgraph()); const float scene_ctime = BKE_scene_ctime_get(scene); - const double frame_rate = (((double)scene->r.frs_sec) / (double)scene->r.frs_sec_base); + const double frame_rate = (double(scene->r.frs_sec) / double(scene->r.frs_sec_base)); params.set_output("Seconds", float(scene_ctime / frame_rate)); params.set_output("Frame", scene_ctime); } diff --git a/source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_line.cc b/source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_line.cc index 4fd6399f4eb..fcc76fcdc1e 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_line.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_line.cc @@ -153,7 +153,7 @@ static void node_geo_exec(GeoNodeExecParams params) mesh = create_line_mesh(start, float3(0), count); } else { - const float3 delta = total_delta / (float)(count - 1); + const float3 delta = total_delta / float(count - 1); mesh = create_line_mesh(start, delta, count); } } diff --git a/source/blender/nodes/geometry/nodes/node_geo_points_to_volume.cc b/source/blender/nodes/geometry/nodes/node_geo_points_to_volume.cc index 0990eebb903..5181b23f51a 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_points_to_volume.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_points_to_volume.cc @@ -83,7 +83,7 @@ struct ParticleList { size_t size() const { - return (size_t)positions.size(); + return size_t(positions.size()); } void getPos(size_t n, openvdb::Vec3R &xyz) const diff --git a/source/blender/nodes/intern/geometry_nodes_log.cc b/source/blender/nodes/intern/geometry_nodes_log.cc index 110573c9119..aadf69f10c5 100644 --- a/source/blender/nodes/intern/geometry_nodes_log.cc +++ b/source/blender/nodes/intern/geometry_nodes_log.cc @@ -35,8 +35,8 @@ FieldInfoLog::FieldInfoLog(const GField &field) : type(field.cpp_type()) std::sort( field_inputs.begin(), field_inputs.end(), [](const FieldInput &a, const FieldInput &b) { - const int index_a = (int)a.category(); - const int index_b = (int)b.category(); + const int index_a = int(a.category()); + const int index_b = int(b.category()); if (index_a == index_b) { return a.socket_inspection_name().size() < b.socket_inspection_name().size(); } diff --git a/source/blender/nodes/intern/node_socket.cc b/source/blender/nodes/intern/node_socket.cc index 098f766589d..79ce9b76e82 100644 --- a/source/blender/nodes/intern/node_socket.cc +++ b/source/blender/nodes/intern/node_socket.cc @@ -59,14 +59,14 @@ struct bNodeSocket *node_add_socket_from_template(struct bNodeTree *ntree, } case SOCK_INT: { bNodeSocketValueInt *dval = (bNodeSocketValueInt *)sock->default_value; - dval->value = (int)stemp->val1; - dval->min = (int)stemp->min; - dval->max = (int)stemp->max; + dval->value = int(stemp->val1); + dval->min = int(stemp->min); + dval->max = int(stemp->max); break; } case SOCK_BOOLEAN: { bNodeSocketValueBoolean *dval = (bNodeSocketValueBoolean *)sock->default_value; - dval->value = (int)stemp->val1; + dval->value = int(stemp->val1); break; } case SOCK_VECTOR: { diff --git a/source/blender/nodes/shader/node_shader_tree.cc b/source/blender/nodes/shader/node_shader_tree.cc index cb9fbc8407c..2edcd160345 100644 --- a/source/blender/nodes/shader/node_shader_tree.cc +++ b/source/blender/nodes/shader/node_shader_tree.cc @@ -300,7 +300,7 @@ static bool ntree_shader_expand_socket_default(bNodeTree *localtree, BLI_assert(value_socket != nullptr); src_int = static_cast(socket->default_value); dst_float = static_cast(value_socket->default_value); - dst_float->value = (float)(src_int->value); + dst_float->value = float(src_int->value); break; case SOCK_FLOAT: value_node = nodeAddStaticNode(nullptr, localtree, SH_NODE_VALUE); diff --git a/source/blender/nodes/shader/nodes/node_shader_bsdf_hair_principled.cc b/source/blender/nodes/shader/nodes/node_shader_bsdf_hair_principled.cc index a0579372a15..766c926916a 100644 --- a/source/blender/nodes/shader/nodes/node_shader_bsdf_hair_principled.cc +++ b/source/blender/nodes/shader/nodes/node_shader_bsdf_hair_principled.cc @@ -44,7 +44,7 @@ static void node_declare(NodeDeclarationBuilder &b) .subtype(PROP_FACTOR); b.add_input(N_("IOR")).default_value(1.55f).min(0.0f).max(1000.0f); b.add_input(N_("Offset")) - .default_value(2.0f * ((float)M_PI) / 180.0f) + .default_value(2.0f * float(M_PI) / 180.0f) .min(-M_PI_2) .max(M_PI_2) .subtype(PROP_ANGLE); diff --git a/source/blender/nodes/shader/nodes/node_shader_tex_brick.cc b/source/blender/nodes/shader/nodes/node_shader_tex_brick.cc index a1c51a440d0..9b5b7677b5d 100644 --- a/source/blender/nodes/shader/nodes/node_shader_tex_brick.cc +++ b/source/blender/nodes/shader/nodes/node_shader_tex_brick.cc @@ -147,7 +147,7 @@ class BrickFunction : public fn::MultiFunction { n = (n + 1013) & 0x7fffffff; n = (n >> 13) ^ n; const uint nn = (n * (n * n * 60493 + 19990303) + 1376312589) & 0x7fffffff; - return 0.5f * ((float)nn / 1073741824.0f); + return 0.5f * (float(nn) / 1073741824.0f); } static float smoothstepf(const float f) @@ -169,14 +169,14 @@ class BrickFunction : public fn::MultiFunction { { float offset = 0.0f; - const int rownum = (int)floorf(p.y / row_height); + const int rownum = int(floorf(p.y / row_height)); if (offset_frequency && squash_frequency) { brick_width *= (rownum % squash_frequency) ? 1.0f : squash_amount; offset = (rownum % offset_frequency) ? 0.0f : (brick_width * offset_amount); } - const int bricknum = (int)floorf((p.x + offset) / brick_width); + const int bricknum = int(floorf((p.x + offset) / brick_width)); const float x = (p.x + offset) - brick_width * bricknum; const float y = p.y - row_height * rownum; diff --git a/source/blender/nodes/shader/nodes/node_shader_tex_checker.cc b/source/blender/nodes/shader/nodes/node_shader_tex_checker.cc index b0e5639c893..a78103c0f94 100644 --- a/source/blender/nodes/shader/nodes/node_shader_tex_checker.cc +++ b/source/blender/nodes/shader/nodes/node_shader_tex_checker.cc @@ -77,9 +77,9 @@ class NodeTexChecker : public fn::MultiFunction { /* Avoid precision issues on unit coordinates. */ const float3 p = (vector[i] * scale[i] + 0.000001f) * 0.999999f; - const int xi = abs((int)(floorf(p.x))); - const int yi = abs((int)(floorf(p.y))); - const int zi = abs((int)(floorf(p.z))); + const int xi = abs(int(floorf(p.x))); + const int yi = abs(int(floorf(p.y))); + const int zi = abs(int(floorf(p.z))); r_fac[i] = ((xi % 2 == yi % 2) == (zi % 2)) ? 1.0f : 0.0f; } diff --git a/source/blender/nodes/shader/nodes/node_shader_tex_sky.cc b/source/blender/nodes/shader/nodes/node_shader_tex_sky.cc index 97b7f2616ae..23fb4052c7e 100644 --- a/source/blender/nodes/shader/nodes/node_shader_tex_sky.cc +++ b/source/blender/nodes/shader/nodes/node_shader_tex_sky.cc @@ -189,12 +189,12 @@ static int node_shader_gpu_tex_sky(GPUMaterial *mat, /* Pass sky_state->configs[3][9] as 3*(vec4+vec4)+vec3 */ float config_x07[8], config_y07[8], config_z07[8], config_xyz8[3]; for (int i = 0; i < 8; ++i) { - config_x07[i] = (float)sky_state->configs[0][i]; - config_y07[i] = (float)sky_state->configs[1][i]; - config_z07[i] = (float)sky_state->configs[2][i]; + config_x07[i] = float(sky_state->configs[0][i]); + config_y07[i] = float(sky_state->configs[1][i]); + config_z07[i] = float(sky_state->configs[2][i]); } for (int i = 0; i < 3; ++i) { - config_xyz8[i] = (float)sky_state->configs[i][8]; + config_xyz8[i] = float(sky_state->configs[i][8]); } float radiance[3]; for (int i = 0; i < 3; i++) { diff --git a/source/blender/nodes/shader/nodes/node_shader_tex_white_noise.cc b/source/blender/nodes/shader/nodes/node_shader_tex_white_noise.cc index 64075a903ab..b738dff413e 100644 --- a/source/blender/nodes/shader/nodes/node_shader_tex_white_noise.cc +++ b/source/blender/nodes/shader/nodes/node_shader_tex_white_noise.cc @@ -177,7 +177,7 @@ class WhiteNoiseFunction : public fn::MultiFunction { static void sh_node_noise_build_multi_function(NodeMultiFunctionBuilder &builder) { const bNode &node = builder.node(); - builder.construct_and_set_matching_fn((int)node.custom1); + builder.construct_and_set_matching_fn(int(node.custom1)); } } // namespace blender::nodes::node_shader_tex_white_noise_cc diff --git a/source/blender/python/gpu/gpu_py_shader_create_info.cc b/source/blender/python/gpu/gpu_py_shader_create_info.cc index f191e6cc71c..7bd0bf4aedf 100644 --- a/source/blender/python/gpu/gpu_py_shader_create_info.cc +++ b/source/blender/python/gpu/gpu_py_shader_create_info.cc @@ -59,21 +59,21 @@ static const struct PyC_FlagSet pygpu_qualifiers[] = { " - ``IVEC4``\n" \ " - ``BOOL``\n" const struct PyC_StringEnumItems pygpu_attrtype_items[] = { - {(int)Type::FLOAT, "FLOAT"}, - {(int)Type::VEC2, "VEC2"}, - {(int)Type::VEC3, "VEC3"}, - {(int)Type::VEC4, "VEC4"}, - {(int)Type::MAT3, "MAT3"}, - {(int)Type::MAT4, "MAT4"}, - {(int)Type::UINT, "UINT"}, - {(int)Type::UVEC2, "UVEC2"}, - {(int)Type::UVEC3, "UVEC3"}, - {(int)Type::UVEC4, "UVEC4"}, - {(int)Type::INT, "INT"}, - {(int)Type::IVEC2, "IVEC2"}, - {(int)Type::IVEC3, "IVEC3"}, - {(int)Type::IVEC4, "IVEC4"}, - {(int)Type::BOOL, "BOOL"}, + {int(Type::FLOAT), "FLOAT"}, + {int(Type::VEC2), "VEC2"}, + {int(Type::VEC3), "VEC3"}, + {int(Type::VEC4), "VEC4"}, + {int(Type::MAT3), "MAT3"}, + {int(Type::MAT4), "MAT4"}, + {int(Type::UINT), "UINT"}, + {int(Type::UVEC2), "UVEC2"}, + {int(Type::UVEC3), "UVEC3"}, + {int(Type::UVEC4), "UVEC4"}, + {int(Type::INT), "INT"}, + {int(Type::IVEC2), "IVEC2"}, + {int(Type::IVEC3), "IVEC3"}, + {int(Type::IVEC4), "IVEC4"}, + {int(Type::BOOL), "BOOL"}, {0, nullptr}, }; @@ -111,45 +111,45 @@ const struct PyC_StringEnumItems pygpu_attrtype_items[] = { " - ``DEPTH_CUBE``\n" \ " - ``DEPTH_CUBE_ARRAY``\n" static const struct PyC_StringEnumItems pygpu_imagetype_items[] = { - {(int)ImageType::FLOAT_BUFFER, "FLOAT_BUFFER"}, - {(int)ImageType::FLOAT_1D, "FLOAT_1D"}, - {(int)ImageType::FLOAT_1D_ARRAY, "FLOAT_1D_ARRAY"}, - {(int)ImageType::FLOAT_2D, "FLOAT_2D"}, - {(int)ImageType::FLOAT_2D_ARRAY, "FLOAT"}, - {(int)ImageType::FLOAT_3D, "FLOAT_2D_ARRAY"}, - {(int)ImageType::FLOAT_CUBE, "FLOAT_CUBE"}, - {(int)ImageType::FLOAT_CUBE_ARRAY, "FLOAT_CUBE_ARRAY"}, - {(int)ImageType::INT_BUFFER, "INT_BUFFER"}, - {(int)ImageType::INT_1D, "INT_1D"}, - {(int)ImageType::INT_1D_ARRAY, "INT_1D_ARRAY"}, - {(int)ImageType::INT_2D, "INT_2D"}, - {(int)ImageType::INT_2D_ARRAY, "INT_2D_ARRAY"}, - {(int)ImageType::INT_3D, "INT_3D"}, - {(int)ImageType::INT_CUBE, "INT_CUBE"}, - {(int)ImageType::INT_CUBE_ARRAY, "INT_CUBE_ARRAY"}, - {(int)ImageType::UINT_BUFFER, "UINT_BUFFER"}, - {(int)ImageType::UINT_1D, "UINT_1D"}, - {(int)ImageType::UINT_1D_ARRAY, "UINT_1D_ARRAY"}, - {(int)ImageType::UINT_2D, "UINT_2D"}, - {(int)ImageType::UINT_2D_ARRAY, "UINT_2D_ARRAY"}, - {(int)ImageType::UINT_3D, "UINT_3D"}, - {(int)ImageType::UINT_CUBE, "UINT_CUBE"}, - {(int)ImageType::UINT_CUBE_ARRAY, "UINT_CUBE_ARRAY"}, - {(int)ImageType::SHADOW_2D, "SHADOW_2D"}, - {(int)ImageType::SHADOW_2D_ARRAY, "SHADOW_2D_ARRAY"}, - {(int)ImageType::SHADOW_CUBE, "SHADOW_CUBE"}, - {(int)ImageType::SHADOW_CUBE_ARRAY, "SHADOW_CUBE_ARRAY"}, - {(int)ImageType::DEPTH_2D, "DEPTH_2D"}, - {(int)ImageType::DEPTH_2D_ARRAY, "DEPTH_2D_ARRAY"}, - {(int)ImageType::DEPTH_CUBE, "DEPTH_CUBE"}, - {(int)ImageType::DEPTH_CUBE_ARRAY, "DEPTH_CUBE_ARRAY"}, + {int(ImageType::FLOAT_BUFFER), "FLOAT_BUFFER"}, + {int(ImageType::FLOAT_1D), "FLOAT_1D"}, + {int(ImageType::FLOAT_1D_ARRAY), "FLOAT_1D_ARRAY"}, + {int(ImageType::FLOAT_2D), "FLOAT_2D"}, + {int(ImageType::FLOAT_2D_ARRAY), "FLOAT"}, + {int(ImageType::FLOAT_3D), "FLOAT_2D_ARRAY"}, + {int(ImageType::FLOAT_CUBE), "FLOAT_CUBE"}, + {int(ImageType::FLOAT_CUBE_ARRAY), "FLOAT_CUBE_ARRAY"}, + {int(ImageType::INT_BUFFER), "INT_BUFFER"}, + {int(ImageType::INT_1D), "INT_1D"}, + {int(ImageType::INT_1D_ARRAY), "INT_1D_ARRAY"}, + {int(ImageType::INT_2D), "INT_2D"}, + {int(ImageType::INT_2D_ARRAY), "INT_2D_ARRAY"}, + {int(ImageType::INT_3D), "INT_3D"}, + {int(ImageType::INT_CUBE), "INT_CUBE"}, + {int(ImageType::INT_CUBE_ARRAY), "INT_CUBE_ARRAY"}, + {int(ImageType::UINT_BUFFER), "UINT_BUFFER"}, + {int(ImageType::UINT_1D), "UINT_1D"}, + {int(ImageType::UINT_1D_ARRAY), "UINT_1D_ARRAY"}, + {int(ImageType::UINT_2D), "UINT_2D"}, + {int(ImageType::UINT_2D_ARRAY), "UINT_2D_ARRAY"}, + {int(ImageType::UINT_3D), "UINT_3D"}, + {int(ImageType::UINT_CUBE), "UINT_CUBE"}, + {int(ImageType::UINT_CUBE_ARRAY), "UINT_CUBE_ARRAY"}, + {int(ImageType::SHADOW_2D), "SHADOW_2D"}, + {int(ImageType::SHADOW_2D_ARRAY), "SHADOW_2D_ARRAY"}, + {int(ImageType::SHADOW_CUBE), "SHADOW_CUBE"}, + {int(ImageType::SHADOW_CUBE_ARRAY), "SHADOW_CUBE_ARRAY"}, + {int(ImageType::DEPTH_2D), "DEPTH_2D"}, + {int(ImageType::DEPTH_2D_ARRAY), "DEPTH_2D_ARRAY"}, + {int(ImageType::DEPTH_CUBE), "DEPTH_CUBE"}, + {int(ImageType::DEPTH_CUBE_ARRAY), "DEPTH_CUBE_ARRAY"}, {0, nullptr}, }; static const struct PyC_StringEnumItems pygpu_dualblend_items[] = { - {(int)DualBlend::NONE, "NONE"}, - {(int)DualBlend::SRC_0, "SRC_0"}, - {(int)DualBlend::SRC_1, "SRC_1"}, + {int(DualBlend::NONE), "NONE"}, + {int(DualBlend::SRC_0), "SRC_0"}, + {int(DualBlend::SRC_1), "SRC_1"}, {0, nullptr}, }; @@ -479,7 +479,7 @@ static PyObject *pygpu_shader_info_fragment_out(BPyGPUShaderCreateInfo *self, int slot; struct PyC_StringEnum pygpu_type = {pygpu_attrtype_items}; const char *name; - struct PyC_StringEnum blend_type = {pygpu_dualblend_items, (int)DualBlend::NONE}; + struct PyC_StringEnum blend_type = {pygpu_dualblend_items, int(DualBlend::NONE)}; static const char *_keywords[] = {"slot", "type", "name", "blend", nullptr}; static _PyArg_Parser _parser = { diff --git a/source/blender/render/intern/engine.cc b/source/blender/render/intern/engine.cc index 87152822fab..9b5a5fff6b0 100644 --- a/source/blender/render/intern/engine.cc +++ b/source/blender/render/intern/engine.cc @@ -802,7 +802,7 @@ void RE_engine_frame_set(RenderEngine *engine, int frame, float subframe) DEG_ids_clear_recalc(engine->depsgraph, false); Render *re = engine->re; - double cfra = (double)frame + (double)subframe; + double cfra = double(frame) + double(subframe); CLAMP(cfra, MINAFRAME, MAXFRAME); BKE_scene_frame_set(re->scene, cfra); diff --git a/source/blender/render/intern/initrender.cc b/source/blender/render/intern/initrender.cc index 1ea93cbf6c8..591791587fe 100644 --- a/source/blender/render/intern/initrender.cc +++ b/source/blender/render/intern/initrender.cc @@ -128,7 +128,7 @@ float RE_filter_value(int type, float x) case R_FILTER_FAST_GAUSS: { const float two_gaussfac2 = 2.0f * gaussfac * gaussfac; x *= 3.0f * gaussfac; - return 1.0f / sqrtf((float)M_PI * two_gaussfac2) * expf(-x * x / two_gaussfac2); + return 1.0f / sqrtf(float(M_PI) * two_gaussfac2) * expf(-x * x / two_gaussfac2); } case R_FILTER_MITCH: diff --git a/source/blender/render/intern/pipeline.cc b/source/blender/render/intern/pipeline.cc index 74db967885c..6bb3a1ffe11 100644 --- a/source/blender/render/intern/pipeline.cc +++ b/source/blender/render/intern/pipeline.cc @@ -1368,7 +1368,7 @@ static void do_render_sequencer(Render *re) /* set overall progress of sequence rendering */ if (re->r.efra != re->r.sfra) { - re->progress(re->prh, (float)(cfra - re->r.sfra) / (re->r.efra - re->r.sfra)); + re->progress(re->prh, float(cfra - re->r.sfra) / (re->r.efra - re->r.sfra)); } else { re->progress(re->prh, 1.0f); diff --git a/source/blender/render/intern/render_result.cc b/source/blender/render/intern/render_result.cc index c628ed8d6fb..7c4b0713d7c 100644 --- a/source/blender/render/intern/render_result.cc +++ b/source/blender/render/intern/render_result.cc @@ -169,7 +169,7 @@ static void render_layer_allocate_pass(RenderResult *rr, RenderPass *rp) return; } - const size_t rectsize = ((size_t)rr->rectx) * rr->recty * rp->channels; + const size_t rectsize = size_t(rr->rectx) * rr->recty * rp->channels; rp->rect = MEM_cnew_array(rectsize, rp->name); if (STREQ(rp->name, RE_PASSNAME_VECTOR)) { @@ -780,7 +780,7 @@ static void do_merge_tile( copylen = tilex = rrpart->rectx; tiley = rrpart->recty; - ofs = (((size_t)rrpart->tilerect.ymin) * rr->rectx + rrpart->tilerect.xmin); + ofs = (size_t(rrpart->tilerect.ymin) * rr->rectx + rrpart->tilerect.xmin); target += pixsize * ofs; copylen *= sizeof(float) * pixsize; diff --git a/source/blender/render/intern/texture_margin.cc b/source/blender/render/intern/texture_margin.cc index dda9999b843..201908234fe 100644 --- a/source/blender/render/intern/texture_margin.cc +++ b/source/blender/render/intern/texture_margin.cc @@ -245,8 +245,8 @@ class TextureMarginMap { for (int i = 0; i < maxPolygonSteps; i++) { /* Force to pixel grid. */ - int nx = (int)round(destX); - int ny = (int)round(destY); + int nx = int(round(destX)); + int ny = int(round(destY)); uint32_t polygon_from_map = get_pixel(nx, ny); if (other_poly == polygon_from_map) { found_pixel_in_polygon = true; @@ -562,8 +562,8 @@ static void generate_margin(ImBuf *ibuf, * our intersection tests where a pixel gets in between 2 faces or the middle of a quad, * camera aligned quads also have this problem but they are less common. * Add a small offset to the UVs, fixes bug T18685. */ - vec[a][0] = (uv[0] - uv_offset[0]) * (float)ibuf->x - (0.5f + 0.001f); - vec[a][1] = (uv[1] - uv_offset[1]) * (float)ibuf->y - (0.5f + 0.002f); + vec[a][0] = (uv[0] - uv_offset[0]) * float(ibuf->x) - (0.5f + 0.001f); + vec[a][1] = (uv[1] - uv_offset[1]) * float(ibuf->y) - (0.5f + 0.002f); } /* NOTE: we need the top bit for the dijkstra distance map. */ diff --git a/source/blender/simulation/intern/hair_volume.cpp b/source/blender/simulation/intern/hair_volume.cpp index ada357e3595..cd2f1ae33ec 100644 --- a/source/blender/simulation/intern/hair_volume.cpp +++ b/source/blender/simulation/intern/hair_volume.cpp @@ -39,7 +39,7 @@ static float I[3][3] = {{1, 0, 0}, {0, 1, 0}, {0, 0, 1}}; BLI_INLINE int floor_int(float value) { - return value > 0.0f ? (int)value : ((int)value) - 1; + return value > 0.0f ? int(value) : int(value) - 1; } BLI_INLINE float floor_mod(float value) @@ -68,7 +68,7 @@ struct HairGrid { }; #define HAIR_GRID_INDEX_AXIS(vec, res, gmin, scale, axis) \ - (min_ii(max_ii((int)((vec[axis] - gmin[axis]) * scale), 0), res[axis] - 2)) + (min_ii(max_ii(int((vec[axis] - gmin[axis]) * scale), 0), res[axis] - 2)) BLI_INLINE int hair_grid_offset(const float vec[3], const int res[3], @@ -92,9 +92,9 @@ BLI_INLINE int hair_grid_interp_weights( k = HAIR_GRID_INDEX_AXIS(vec, res, gmin, scale, 2); offset = i + (j + k * res[1]) * res[0]; - uvw[0] = (vec[0] - gmin[0]) * scale - (float)i; - uvw[1] = (vec[1] - gmin[1]) * scale - (float)j; - uvw[2] = (vec[2] - gmin[2]) * scale - (float)k; + uvw[0] = (vec[0] - gmin[0]) * scale - float(i); + uvw[1] = (vec[1] - gmin[1]) * scale - float(j); + uvw[2] = (vec[2] - gmin[2]) * scale - float(k); #if 0 BLI_assert(0.0f <= uvw[0] && uvw[0] <= 1.0001f); @@ -327,14 +327,14 @@ BLI_INLINE int hair_grid_weights( uvw[1] = (vec[1] - gmin[1]) * scale; uvw[2] = (vec[2] - gmin[2]) * scale; - weights[0] = dist_tent_v3f3(uvw, (float)i, (float)j, (float)k); - weights[1] = dist_tent_v3f3(uvw, (float)(i + 1), (float)j, (float)k); - weights[2] = dist_tent_v3f3(uvw, (float)i, (float)(j + 1), (float)k); - weights[3] = dist_tent_v3f3(uvw, (float)(i + 1), (float)(j + 1), (float)k); - weights[4] = dist_tent_v3f3(uvw, (float)i, (float)j, (float)(k + 1)); - weights[5] = dist_tent_v3f3(uvw, (float)(i + 1), (float)j, (float)(k + 1)); - weights[6] = dist_tent_v3f3(uvw, (float)i, (float)(j + 1), (float)(k + 1)); - weights[7] = dist_tent_v3f3(uvw, (float)(i + 1), (float)(j + 1), (float)(k + 1)); + weights[0] = dist_tent_v3f3(uvw, float(i), float(j), float(k)); + weights[1] = dist_tent_v3f3(uvw, float(i + 1), float(j), float(k)); + weights[2] = dist_tent_v3f3(uvw, float(i), float(j + 1), float(k)); + weights[3] = dist_tent_v3f3(uvw, float(i + 1), float(j + 1), float(k)); + weights[4] = dist_tent_v3f3(uvw, float(i), float(j), float(k + 1)); + weights[5] = dist_tent_v3f3(uvw, float(i + 1), float(j), float(k + 1)); + weights[6] = dist_tent_v3f3(uvw, float(i), float(j + 1), float(k + 1)); + weights[7] = dist_tent_v3f3(uvw, float(i + 1), float(j + 1), float(k + 1)); // BLI_assert(fabsf(weights_sum(weights) - 1.0f) < 0.0001f); @@ -646,7 +646,7 @@ void SIM_hair_volume_add_segment(HairGrid *grid, float x[3], v[3]; int i, j, k; - float f = (float)s / (float)(num_samples - 1); + float f = float(s) / float(num_samples - 1); interp_v3_v3v3(x, x2, x3, f); interp_v3_v3v3(v, v2, v3, f); @@ -660,7 +660,7 @@ void SIM_hair_volume_add_segment(HairGrid *grid, for (k = kmin; k <= kmax; k++) { for (j = jmin; j <= jmax; j++) { for (i = imin; i <= imax; i++) { - float loc[3] = {(float)i, (float)j, (float)k}; + float loc[3] = {float(i), float(j), float(k)}; HairGridVert *vert = grid->verts + i * stride[0] + j * stride[1] + k * stride[2]; hair_volume_eval_grid_vertex_sample(vert, loc, radius, dist_scale, x, v); @@ -884,7 +884,7 @@ bool SIM_hair_volume_solve_divergence(HairGrid *grid, for (n = 0; n < neighbors_lo; n++) { A.insert(neighbor_lo_index[n], u) = -1.0f; } - A.insert(u, u) = (float)non_solid_neighbors; + A.insert(u, u) = float(non_solid_neighbors); for (n = 0; n < neighbors_hi; n++) { A.insert(neighbor_hi_index[n], u) = -1.0f; } @@ -1139,8 +1139,8 @@ HairGrid *SIM_hair_volume_create_vertex_grid(float cellsize, resmax[i] = resmin[i] + MAX_HAIR_GRID_RES; } - gmin_margin[i] = (float)resmin[i] * cellsize; - gmax_margin[i] = (float)resmax[i] * cellsize; + gmin_margin[i] = float(resmin[i]) * cellsize; + gmax_margin[i] = float(resmax[i]) * cellsize; } size = hair_grid_size(res); diff --git a/source/blender/windowmanager/intern/wm_event_system.cc b/source/blender/windowmanager/intern/wm_event_system.cc index 79bf8020caf..9fe7a6b23b0 100644 --- a/source/blender/windowmanager/intern/wm_event_system.cc +++ b/source/blender/windowmanager/intern/wm_event_system.cc @@ -2185,26 +2185,26 @@ static bool wm_eventmatch(const wmEvent *winevent, const wmKeyMapItem *kmi) /* Account for rare case of when these keys are used as the 'type' not as modifiers. */ if (kmi->shift != KM_ANY) { const bool shift = (winevent->modifier & KM_SHIFT) != 0; - if ((shift != (bool)kmi->shift) && + if ((shift != bool(kmi->shift)) && !ELEM(winevent->type, EVT_LEFTSHIFTKEY, EVT_RIGHTSHIFTKEY)) { return false; } } if (kmi->ctrl != KM_ANY) { const bool ctrl = (winevent->modifier & KM_CTRL) != 0; - if (ctrl != (bool)kmi->ctrl && !ELEM(winevent->type, EVT_LEFTCTRLKEY, EVT_RIGHTCTRLKEY)) { + if (ctrl != bool(kmi->ctrl) && !ELEM(winevent->type, EVT_LEFTCTRLKEY, EVT_RIGHTCTRLKEY)) { return false; } } if (kmi->alt != KM_ANY) { const bool alt = (winevent->modifier & KM_ALT) != 0; - if (alt != (bool)kmi->alt && !ELEM(winevent->type, EVT_LEFTALTKEY, EVT_RIGHTALTKEY)) { + if (alt != bool(kmi->alt) && !ELEM(winevent->type, EVT_LEFTALTKEY, EVT_RIGHTALTKEY)) { return false; } } if (kmi->oskey != KM_ANY) { const bool oskey = (winevent->modifier & KM_OSKEY) != 0; - if ((oskey != (bool)kmi->oskey) && (winevent->type != EVT_OSKEY)) { + if ((oskey != bool(kmi->oskey)) && (winevent->type != EVT_OSKEY)) { return false; } } @@ -4678,16 +4678,16 @@ void WM_event_add_mousemove(wmWindow *win) static int convert_key(GHOST_TKey key) { if (key >= GHOST_kKeyA && key <= GHOST_kKeyZ) { - return (EVT_AKEY + ((int)key - GHOST_kKeyA)); + return (EVT_AKEY + (int(key) - GHOST_kKeyA)); } if (key >= GHOST_kKey0 && key <= GHOST_kKey9) { - return (EVT_ZEROKEY + ((int)key - GHOST_kKey0)); + return (EVT_ZEROKEY + (int(key) - GHOST_kKey0)); } if (key >= GHOST_kKeyNumpad0 && key <= GHOST_kKeyNumpad9) { - return (EVT_PAD0 + ((int)key - GHOST_kKeyNumpad0)); + return (EVT_PAD0 + (int(key) - GHOST_kKeyNumpad0)); } if (key >= GHOST_kKeyF1 && key <= GHOST_kKeyF24) { - return (EVT_F1KEY + ((int)key - GHOST_kKeyF1)); + return (EVT_F1KEY + (int(key) - GHOST_kKeyF1)); } switch (key) { @@ -4830,7 +4830,7 @@ static int convert_key(GHOST_TKey key) #endif } - CLOG_WARN(WM_LOG_EVENTS, "unknown event type %d from ghost", (int)key); + CLOG_WARN(WM_LOG_EVENTS, "unknown event type %d from ghost", int(key)); return EVENT_NONE; } @@ -4943,7 +4943,7 @@ void WM_event_tablet_data_default_set(wmTabletData *tablet_data) void wm_tablet_data_from_ghost(const GHOST_TabletData *tablet_data, wmTabletData *wmtab) { if ((tablet_data != nullptr) && tablet_data->Active != GHOST_kTabletModeNone) { - wmtab->active = (int)tablet_data->Active; + wmtab->active = int(tablet_data->Active); wmtab->pressure = wm_pressure_curve(tablet_data->Pressure); wmtab->x_tilt = tablet_data->Xtilt; wmtab->y_tilt = tablet_data->Ytilt; @@ -5470,7 +5470,7 @@ void wm_event_add_ghostevent(wmWindowManager *wm, wmWindow *win, int type, void * special handling of Latin1 when building without UTF8 support. * Avoid regressions by adding this conversions, it should eventually be removed. */ if ((event.utf8_buf[0] >= 0x80) && (event.utf8_buf[1] == '\0')) { - const uint c = (uint)event.utf8_buf[0]; + const uint c = uint(event.utf8_buf[0]); int utf8_buf_len = BLI_str_utf8_from_unicode(c, event.utf8_buf, sizeof(event.utf8_buf)); CLOG_ERROR(WM_LOG_EVENTS, "ghost detected non-ASCII single byte character '%u', converting to utf8 " @@ -5484,7 +5484,7 @@ void wm_event_add_ghostevent(wmWindowManager *wm, wmWindow *win, int type, void if (BLI_str_utf8_size(event.utf8_buf) == -1) { CLOG_ERROR(WM_LOG_EVENTS, "ghost detected an invalid unicode character '%d'", - (int)(uchar)event.utf8_buf[0]); + int(uchar(event.utf8_buf[0]))); event.utf8_buf[0] = '\0'; } } -- cgit v1.2.3