From e97e9c29044822b5b81968000e3fbcc8ad4fda75 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 15 May 2025 10:25:32 +1000 Subject: [PATCH] Cleanup: various non functional changes for C++ --- source/blender/blenlib/intern/rct.cc | 2 +- source/blender/blenloader/intern/versioning_450.cc | 2 +- .../editors/interface/regions/interface_region_search.cc | 5 +++-- source/blender/editors/space_sequencer/sequencer_select.cc | 2 +- source/blender/geometry/intern/mesh_boolean_manifold.cc | 6 +++--- .../intern/fallback/fallback_display_cpu_processor.cc | 4 ++-- .../imbuf/opencolorio/intern/libocio/libocio_colorspace.cc | 2 +- .../opencolorio/intern/libocio/libocio_cpu_processor.cc | 6 +++--- .../opencolorio/intern/libocio/libocio_gpu_shader_binder.cc | 6 +++--- .../nodes/composite/nodes/node_composite_file_output.cc | 4 ++-- source/blender/nodes/geometry/nodes/node_geo_boolean.cc | 4 ++-- 11 files changed, 22 insertions(+), 21 deletions(-) diff --git a/source/blender/blenlib/intern/rct.cc b/source/blender/blenlib/intern/rct.cc index a330c58a8a8..52687799fae 100644 --- a/source/blender/blenlib/intern/rct.cc +++ b/source/blender/blenlib/intern/rct.cc @@ -1128,7 +1128,7 @@ void BLI_rctf_rotate_expand(rctf *dst, const rctf *src, const float angle) #undef ROTATE_SINCOS -bool BLI_rctf_clamp_segment(const struct rctf *rect, float s1[2], float s2[2]) +bool BLI_rctf_clamp_segment(const rctf *rect, float s1[2], float s2[2]) { using namespace blender; diff --git a/source/blender/blenloader/intern/versioning_450.cc b/source/blender/blenloader/intern/versioning_450.cc index 24a680667fd..c2770670b0b 100644 --- a/source/blender/blenloader/intern/versioning_450.cc +++ b/source/blender/blenloader/intern/versioning_450.cc @@ -3488,7 +3488,7 @@ static void version_escape_curly_braces_in_compositor_file_output_nodes(bNodeTre } LISTBASE_FOREACH (bNode *, node, &nodetree.nodes) { - if (strcmp(node->idname, "CompositorNodeOutputFile") != 0) { + if (!STREQ(node->idname, "CompositorNodeOutputFile")) { continue; } diff --git a/source/blender/editors/interface/regions/interface_region_search.cc b/source/blender/editors/interface/regions/interface_region_search.cc index 9ee7d0379c2..e67dab1bdad 100644 --- a/source/blender/editors/interface/regions/interface_region_search.cc +++ b/source/blender/editors/interface/regions/interface_region_search.cc @@ -605,7 +605,8 @@ static void ui_searchbox_draw_clip_tri_down(rcti *rect, const float zoom) zoom * UI_ICON_SIZE; const float aspect = U.inv_scale_factor / zoom; GPU_blend(GPU_BLEND_ALPHA); - UI_icon_draw_ex(x, y, ICON_TRIA_DOWN, aspect, 1.0f, 0.0f, NULL, false, UI_NO_ICON_OVERLAY_TEXT); + UI_icon_draw_ex( + x, y, ICON_TRIA_DOWN, aspect, 1.0f, 0.0f, nullptr, false, UI_NO_ICON_OVERLAY_TEXT); GPU_blend(GPU_BLEND_NONE); } @@ -620,7 +621,7 @@ static void ui_searchbox_draw_clip_tri_up(rcti *rect, const float zoom) const float y = rect->ymax + (0.5f * zoom * (UI_SEARCHBOX_TRIA_H - UI_ICON_SIZE) - U.pixelsize); const float aspect = U.inv_scale_factor / zoom; GPU_blend(GPU_BLEND_ALPHA); - UI_icon_draw_ex(x, y, ICON_TRIA_UP, aspect, 1.0f, 0.0f, NULL, false, UI_NO_ICON_OVERLAY_TEXT); + UI_icon_draw_ex(x, y, ICON_TRIA_UP, aspect, 1.0f, 0.0f, nullptr, false, UI_NO_ICON_OVERLAY_TEXT); GPU_blend(GPU_BLEND_NONE); } diff --git a/source/blender/editors/space_sequencer/sequencer_select.cc b/source/blender/editors/space_sequencer/sequencer_select.cc index df4cb1c8b3b..9191d53ac04 100644 --- a/source/blender/editors/space_sequencer/sequencer_select.cc +++ b/source/blender/editors/space_sequencer/sequencer_select.cc @@ -443,7 +443,7 @@ static wmOperatorStatus sequencer_de_select_all_exec(bContext *C, wmOperator *op } } } - if (action == SEL_INVERT || action == SEL_SELECT) { + if (ELEM(action, SEL_INVERT, SEL_SELECT)) { if (action == SEL_INVERT) { for (Strip *strip : strips) { if (strip->flag & STRIP_ALLSEL) { diff --git a/source/blender/geometry/intern/mesh_boolean_manifold.cc b/source/blender/geometry/intern/mesh_boolean_manifold.cc index 37651bf2b49..ebc632cae71 100644 --- a/source/blender/geometry/intern/mesh_boolean_manifold.cc +++ b/source/blender/geometry/intern/mesh_boolean_manifold.cc @@ -132,7 +132,7 @@ static void dump_mesh(const Mesh *mesh, const std::string &name) if (ELEM(iter.name, "position", ".edge_verts", ".corner_vert", ".corner_edge")) { return; } - const int di = static_cast(iter.domain); + const int di = int8_t(iter.domain); const char *domain = (di >= 0 && di < ATTR_DOMAIN_NUM) ? domain_names[di] : "?"; std::string label = std::string(domain) + ": " + iter.name; switch (iter.data_type) { @@ -913,14 +913,14 @@ static bool is_legal_merge(const OutFace &f1, const OutFace &f2, int v1, int v2) * TODO: if the faces are big, sort both together and look for repeats after sorting. */ for (const int v : f1.verts) { - if (v != v1 && v != v2) { + if (!ELEM(v, v1, v2)) { if (f2.find_vert_index(v) != -1) { return false; } } } for (const int v : f2.verts) { - if (v != v1 && v != v2) { + if (!ELEM(v, v1, v2)) { if (f1.find_vert_index(v) != -1) { return false; } diff --git a/source/blender/imbuf/opencolorio/intern/fallback/fallback_display_cpu_processor.cc b/source/blender/imbuf/opencolorio/intern/fallback/fallback_display_cpu_processor.cc index 92b949b6a00..549b7c960f7 100644 --- a/source/blender/imbuf/opencolorio/intern/fallback/fallback_display_cpu_processor.cc +++ b/source/blender/imbuf/opencolorio/intern/fallback/fallback_display_cpu_processor.cc @@ -74,7 +74,7 @@ class DisplayCPUProcessor : public BaseDisplayCPUProcessor { void apply_rgba_predivide(float rgba[4]) const override { - if (rgba[3] == 1.0f || rgba[3] == 0.0f) { + if (ELEM(rgba[3], 1.0f, 0.0f)) { process_rgb(rgba); return; } @@ -184,7 +184,7 @@ std::shared_ptr create_fallback_display_cpu_processor( if (display_parameters.view != "Standard") { return NOOPDisplayCPUProcessor::get(); } - if (display_parameters.look != "" && display_parameters.look != "None") { + if (!ELEM(display_parameters.look, "", "None")) { return NOOPDisplayCPUProcessor::get(); } diff --git a/source/blender/imbuf/opencolorio/intern/libocio/libocio_colorspace.cc b/source/blender/imbuf/opencolorio/intern/libocio/libocio_colorspace.cc index c0d27f7c154..4a023e3b498 100644 --- a/source/blender/imbuf/opencolorio/intern/libocio/libocio_colorspace.cc +++ b/source/blender/imbuf/opencolorio/intern/libocio/libocio_colorspace.cc @@ -38,7 +38,7 @@ static bool color_space_is_invertible(const OCIO_NAMESPACE::ConstColorSpaceRcPtr { const StringRefNull family = ocio_color_space->getFamily(); - if (family == "rrt" || family == "display") { + if (ELEM(family, "rrt", "display")) { /* assume display and rrt transformations are not invertible in fact some of them could be, * but it doesn't make much sense to allow use them as invertible. */ return false; diff --git a/source/blender/imbuf/opencolorio/intern/libocio/libocio_cpu_processor.cc b/source/blender/imbuf/opencolorio/intern/libocio/libocio_cpu_processor.cc index fb5e1ff48dc..50ff0132fb6 100644 --- a/source/blender/imbuf/opencolorio/intern/libocio/libocio_cpu_processor.cc +++ b/source/blender/imbuf/opencolorio/intern/libocio/libocio_cpu_processor.cc @@ -33,7 +33,7 @@ void LibOCIOCPUProcessor::apply_rgba(float rgba[4]) const void LibOCIOCPUProcessor::apply_rgba_predivide(float rgba[4]) const { - if (rgba[3] == 1.0f || rgba[3] == 0.0f) { + if (ELEM(rgba[3], 1.0f, 0.0f)) { apply_rgba(rgba); return; } @@ -80,7 +80,7 @@ void LibOCIOCPUProcessor::apply_predivide(const PackedImage &image) const const size_t pixel_count = image.get_width() * image.get_height(); for (size_t i = 0; i < pixel_count; i++, pixel += 4) { const float alpha = pixel[3]; - if (alpha != 0.0f && alpha != 1.0f) { + if (!ELEM(alpha, 0.0f, 1.0f)) { const float inv_alpha = 1.0f / alpha; pixel[0] *= inv_alpha; pixel[1] *= inv_alpha; @@ -97,7 +97,7 @@ void LibOCIOCPUProcessor::apply_predivide(const PackedImage &image) const const size_t pixel_count = image.get_width() * image.get_height(); for (size_t i = 0; i < pixel_count; i++, pixel += 4) { const float alpha = pixel[3]; - if (alpha != 0.0f && alpha != 1.0f) { + if (!ELEM(alpha, 0.0f, 1.0f)) { pixel[0] *= alpha; pixel[1] *= alpha; pixel[2] *= alpha; diff --git a/source/blender/imbuf/opencolorio/intern/libocio/libocio_gpu_shader_binder.cc b/source/blender/imbuf/opencolorio/intern/libocio/libocio_gpu_shader_binder.cc index 0a760941660..11a584a184b 100644 --- a/source/blender/imbuf/opencolorio/intern/libocio/libocio_gpu_shader_binder.cc +++ b/source/blender/imbuf/opencolorio/intern/libocio/libocio_gpu_shader_binder.cc @@ -59,8 +59,8 @@ static bool add_gpu_lut_1D2D(internal::GPUTextures &textures, { const char *texture_name = nullptr; const char *sampler_name = nullptr; - unsigned int width = 0; - unsigned int height = 0; + uint width = 0; + uint height = 0; GpuShaderCreator::TextureType channel = GpuShaderCreator::TEXTURE_RGB_CHANNEL; Interpolation interpolation = INTERP_LINEAR; @@ -105,7 +105,7 @@ static bool add_gpu_lut_3D(internal::GPUTextures &textures, { const char *texture_name = nullptr; const char *sampler_name = nullptr; - unsigned int edgelen = 0; + uint edgelen = 0; Interpolation interpolation = INTERP_LINEAR; shader_desc->get3DTexture(index, texture_name, sampler_name, edgelen, interpolation); diff --git a/source/blender/nodes/composite/nodes/node_composite_file_output.cc b/source/blender/nodes/composite/nodes/node_composite_file_output.cc index 015f0337a02..c4f0ca103b4 100644 --- a/source/blender/nodes/composite/nodes/node_composite_file_output.cc +++ b/source/blender/nodes/composite/nodes/node_composite_file_output.cc @@ -882,7 +882,7 @@ class FileOutputOperation : public NodeOperation { /* Do template expansion on the node's base path. */ char node_base_path[FILE_MAX] = ""; - BLI_strncpy(node_base_path, get_base_path(), FILE_MAX); + STRNCPY(node_base_path, get_base_path()); { blender::Vector errors = BKE_path_apply_template( node_base_path, FILE_MAX, template_variables); @@ -895,7 +895,7 @@ class FileOutputOperation : public NodeOperation { if (base_name[0]) { /* Do template expansion on the socket's sub path ("base name"). */ char sub_path[FILE_MAX] = ""; - BLI_strncpy(sub_path, base_name, FILE_MAX); + STRNCPY(sub_path, base_name); { blender::Vector errors = BKE_path_apply_template( sub_path, FILE_MAX, template_variables); diff --git a/source/blender/nodes/geometry/nodes/node_geo_boolean.cc b/source/blender/nodes/geometry/nodes/node_geo_boolean.cc index 65084f68636..ce7c9fc8c0d 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_boolean.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_boolean.cc @@ -58,8 +58,8 @@ static void node_declare(NodeDeclarationBuilder &b) const auto operation = geometry::boolean::Operation(node->custom1); const auto solver = geometry::boolean::Solver(node->custom2); - output_edges.available(solver == geometry::boolean::Solver::MeshArr || - solver == geometry::boolean::Solver::Manifold); + output_edges.available( + ELEM(solver, geometry::boolean::Solver::MeshArr, geometry::boolean::Solver::Manifold)); self_intersect.available(solver == geometry::boolean::Solver::MeshArr); hole_tolerant.available(solver == geometry::boolean::Solver::MeshArr);