From a0db0a55804eb396d4a19dd5f692dd7e9eebb81d Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 2 May 2023 09:32:44 +1000 Subject: [PATCH] Cleanup: move comments wrapped with MultiLine control statements In some cases comments at the end of control statements were wrapped onto new lines which made it read as if they applied to the next line instead of the (now) previous line. Relocate comments to the previous line or in some cases the end of the line (before the brace) to avoid confusion. Note that in quite a few cases these blocks didn't read well even before MultiLine was used as comments after the brace caused wrapping across multiple lines in a way that didn't follow formatting used everywhere else. --- intern/cycles/device/metal/device_impl.mm | 4 +- intern/cycles/kernel/svm/closure.h | 19 +- .../ghost/intern/GHOST_XrControllerModel.cc | 4 +- intern/locale/boost_locale_wrapper.cpp | 4 +- source/blender/blenkernel/intern/boids.c | 7 +- source/blender/blenkernel/intern/image.cc | 4 +- .../blenkernel/intern/particle_system.c | 4 +- source/blender/blenkernel/intern/softbody.c | 4 +- .../blenloader/intern/versioning_300.cc | 4 +- .../operations/COM_DoubleEdgeMaskOperation.cc | 268 +++++++++--------- .../operations/COM_SMAAOperation.cc | 8 +- .../blender/editors/render/render_internal.cc | 22 +- .../editors/space_graph/graph_select.c | 5 +- source/blender/editors/space_info/info_ops.c | 5 +- .../blender_interface/FRS_freestyle.cpp | 4 +- .../intern/view_map/FEdgeXDetector.cpp | 4 +- .../intern/view_map/ViewEdgeXBuilder.cpp | 5 +- .../shaders/common/gpu_shader_smaa_lib.glsl | 16 +- source/blender/python/intern/bpy_props.c | 6 +- .../python/mathutils/mathutils_Vector.c | 4 +- 20 files changed, 202 insertions(+), 199 deletions(-) diff --git a/intern/cycles/device/metal/device_impl.mm b/intern/cycles/device/metal/device_impl.mm index 58ac5c378ab..005e2cef96d 100644 --- a/intern/cycles/device/metal/device_impl.mm +++ b/intern/cycles/device/metal/device_impl.mm @@ -1095,8 +1095,8 @@ void MetalDevice::tex_alloc(device_texture &mem) } MTLStorageMode storage_mode = MTLStorageModeManaged; if (@available(macos 10.15, *)) { - if ([mtlDevice hasUnifiedMemory] && device_vendor != METAL_GPU_INTEL) - { /* Intel GPUs don't support MTLStorageModeShared for MTLTextures */ + /* Intel GPUs don't support MTLStorageModeShared for MTLTextures. */ + if ([mtlDevice hasUnifiedMemory] && device_vendor != METAL_GPU_INTEL) { storage_mode = MTLStorageModeShared; } } diff --git a/intern/cycles/kernel/svm/closure.h b/intern/cycles/kernel/svm/closure.h index ea5cb305cb8..2706d9e95f1 100644 --- a/intern/cycles/kernel/svm/closure.h +++ b/intern/cycles/kernel/svm/closure.h @@ -288,12 +288,14 @@ ccl_device_noinline int svm_node_closure_bsdf(KernelGlobals kg, fresnel->color = rgb_to_spectrum(base_color); /* setup bsdf */ - if (distribution == CLOSURE_BSDF_MICROFACET_GGX_GLASS_ID || roughness <= 0.075f) - { /* use single-scatter GGX */ + + /* Use single-scatter GGX. */ + if (distribution == CLOSURE_BSDF_MICROFACET_GGX_GLASS_ID || roughness <= 0.075f) { sd->flag |= bsdf_microfacet_ggx_setup(bsdf); bsdf_microfacet_setup_fresnel_principledv1(bsdf, sd, fresnel); - } - else { /* use multi-scatter GGX */ + } /* Use multi-scatter GGX. */ + else { + bsdf->fresnel = fresnel; sd->flag |= bsdf_microfacet_multi_ggx_fresnel_setup(bsdf, sd); } @@ -313,8 +315,9 @@ ccl_device_noinline int svm_node_closure_bsdf(KernelGlobals kg, Spectrum glass_weight = weight * final_transmission; float3 cspec0 = base_color * specular_tint + make_float3(1.0f - specular_tint); - if (roughness <= 5e-2f || distribution == CLOSURE_BSDF_MICROFACET_GGX_GLASS_ID) - { /* use single-scatter GGX */ + /* Use single-scatter GGX. */ + if (roughness <= 5e-2f || distribution == CLOSURE_BSDF_MICROFACET_GGX_GLASS_ID) { + float refl_roughness = roughness; /* reflection */ @@ -377,8 +380,8 @@ ccl_device_noinline int svm_node_closure_bsdf(KernelGlobals kg, sd->flag |= bsdf_microfacet_ggx_refraction_setup(bsdf); } } - } - else { /* use multi-scatter GGX */ + } /* Use multi-scatter GGX. */ + else { ccl_private MicrofacetBsdf *bsdf = (ccl_private MicrofacetBsdf *)bsdf_alloc( sd, sizeof(MicrofacetBsdf), glass_weight); ccl_private FresnelPrincipledV1 *fresnel = diff --git a/intern/ghost/intern/GHOST_XrControllerModel.cc b/intern/ghost/intern/GHOST_XrControllerModel.cc index 8e00d4ec32d..8855ccdfbb1 100644 --- a/intern/ghost/intern/GHOST_XrControllerModel.cc +++ b/intern/ghost/intern/GHOST_XrControllerModel.cc @@ -142,8 +142,8 @@ static void read_indices(const tinygltf::Accessor &accessor, } constexpr size_t component_size_bytes = sizeof(TSrcIndex); - if (buffer_view.byteStride != 0 && buffer_view.byteStride != component_size_bytes) - { /* Index buffer must be packed per glTF spec. */ + /* Index buffer must be packed per glTF spec. */ + if (buffer_view.byteStride != 0 && buffer_view.byteStride != component_size_bytes) { throw GHOST_XrException( "glTF: Accessor for indices uses bufferview with invalid 'byteStride'."); } diff --git a/intern/locale/boost_locale_wrapper.cpp b/intern/locale/boost_locale_wrapper.cpp index be213f2f4d8..4b2e52f71d8 100644 --- a/intern/locale/boost_locale_wrapper.cpp +++ b/intern/locale/boost_locale_wrapper.cpp @@ -33,8 +33,8 @@ static void bl_locale_global_cache() locale_global = std::locale(); facet_global = &std::use_facet(locale_global); } - catch (const std::bad_cast &e) - { /* if std::has_facet(l) == false, LC_ALL = "C" case */ + /* `if std::has_facet(l) == false`, LC_ALL = "C" case. */ + catch (const std::bad_cast &e) { #ifndef NDEBUG std::cout << "bl_locale_global_cache:" << e.what() << " \n"; #endif diff --git a/source/blender/blenkernel/intern/boids.c b/source/blender/blenkernel/intern/boids.c index 40b81e7d667..f09eef2ed84 100644 --- a/source/blender/blenkernel/intern/boids.c +++ b/source/blender/blenkernel/intern/boids.c @@ -147,9 +147,10 @@ static bool rule_goal_avoid(BoidRule *rule, BoidBrainData *bbd, BoidValues *val, priority = 1.0f; } - /* then use that effector */ - if (priority > (rule->type == eBoidRuleType_Avoid ? gabr->fear_factor : 0.0f)) - { /* with avoid, factor is "fear factor" */ + /* Then use that effector. */ + + /* With avoid, factor is "fear factor". */ + if (priority > (rule->type == eBoidRuleType_Avoid ? gabr->fear_factor : 0.0f)) { Object *eob = eff->ob; PartDeflect *pd = eff->pd; float surface = (pd && pd->shape == PFIELD_SHAPE_SURFACE) ? 1.0f : 0.0f; diff --git a/source/blender/blenkernel/intern/image.cc b/source/blender/blenkernel/intern/image.cc index 34432c8db80..88b8c114b2d 100644 --- a/source/blender/blenkernel/intern/image.cc +++ b/source/blender/blenkernel/intern/image.cc @@ -2949,10 +2949,10 @@ void BKE_image_walk_all_users( { image_walk_id_all_users(&cam->id, false, customdata, callback); } - + /* Only ever 1 `wm`. */ for (wmWindowManager *wm = static_cast(mainp->wm.first); wm; wm = static_cast(wm->id.next)) - { /* only 1 wm */ + { image_walk_id_all_users(&wm->id, false, customdata, callback); } } diff --git a/source/blender/blenkernel/intern/particle_system.c b/source/blender/blenkernel/intern/particle_system.c index e7178d36d54..baa327c0fe7 100644 --- a/source/blender/blenkernel/intern/particle_system.c +++ b/source/blender/blenkernel/intern/particle_system.c @@ -3890,8 +3890,8 @@ static void dynamics_step(ParticleSimulationData *sim, float cfra) ParticleTarget *pt = psys->targets.first; psys_update_particle_bvhtree(psys, cfra); - for (; pt; pt = pt->next) - { /* Updating others systems particle tree for fluid-fluid interaction */ + /* Updating others systems particle tree for fluid-fluid interaction. */ + for (; pt; pt = pt->next) { if (pt->ob) { psys_update_particle_bvhtree(BLI_findlink(&pt->ob->particlesystem, pt->psys - 1), cfra); } diff --git a/source/blender/blenkernel/intern/softbody.c b/source/blender/blenkernel/intern/softbody.c index f2b394a021a..d6d61001de9 100644 --- a/source/blender/blenkernel/intern/softbody.c +++ b/source/blender/blenkernel/intern/softbody.c @@ -2062,8 +2062,8 @@ static int _softbody_calc_forces_slice_in_a_thread(Scene *scene, kd = sb->goalfrict * sb_fric_force_scale(ob); add_v3_v3v3(auxvect, velgoal, bp->vec); - if (forcetime > 0.0f) - { /* make sure friction does not become rocket motor on time reversal */ + /* Make sure friction does not become rocket motor on time reversal. */ + if (forcetime > 0.0f) { bp->force[0] -= kd * (auxvect[0]); bp->force[1] -= kd * (auxvect[1]); bp->force[2] -= kd * (auxvect[2]); diff --git a/source/blender/blenloader/intern/versioning_300.cc b/source/blender/blenloader/intern/versioning_300.cc index aa8fd58c7c8..00c9804b580 100644 --- a/source/blender/blenloader/intern/versioning_300.cc +++ b/source/blender/blenloader/intern/versioning_300.cc @@ -204,8 +204,8 @@ static void version_idproperty_move_data_string(IDPropertyUIDataString *ui_data, static void version_idproperty_ui_data(IDProperty *idprop_group) { - if (idprop_group == nullptr) - { /* nullptr check here to reduce verbosity of calls to this function. */ + /* `nullptr` check here to reduce verbosity of calls to this function. */ + if (idprop_group == nullptr) { return; } diff --git a/source/blender/compositor/operations/COM_DoubleEdgeMaskOperation.cc b/source/blender/compositor/operations/COM_DoubleEdgeMaskOperation.cc index 8487093a7c9..5ff5e1fcf8c 100644 --- a/source/blender/compositor/operations/COM_DoubleEdgeMaskOperation.cc +++ b/source/blender/compositor/operations/COM_DoubleEdgeMaskOperation.cc @@ -29,10 +29,10 @@ static void do_adjacentKeepBorders( else { res[x] = 1.0f; /* Pixel is just part of inner mask, and it's not an edge. */ } - } - else if (lomask[x]) { /* Inner mask was empty, test if outer mask is filled. */ - osz++; /* Increment outer edge size. */ - lres[x] = 3; /* Flag pixel as outer edge. */ + } /* Inner mask was empty, test if outer mask is filled. */ + else if (lomask[x]) { + osz++; /* Increment outer edge size. */ + lres[x] = 3; /* Flag pixel as outer edge. */ } /* Upper right corner. */ x = t; @@ -47,10 +47,10 @@ static void do_adjacentKeepBorders( else { res[x] = 1.0f; /* Pixel is just part of inner mask, and it's not an edge. */ } - } - else if (lomask[x]) { /* Inner mask was empty, test if outer mask is filled. */ - osz++; /* Increment outer edge size. */ - lres[x] = 3; /* Flag pixel as outer edge. */ + } /* Inner mask was empty, test if outer mask is filled. */ + else if (lomask[x]) { + osz++; /* Increment outer edge size. */ + lres[x] = 3; /* Flag pixel as outer edge. */ } /* Lower left corner. */ x = 0; @@ -65,10 +65,10 @@ static void do_adjacentKeepBorders( else { res[x] = 1.0f; /* Pixel is just part of inner mask, and it's not an edge. */ } - } - else if (lomask[x]) { /* Inner mask was empty, test if outer mask is filled. */ - osz++; /* Increment outer edge size. */ - lres[x] = 3; /* Flag pixel as outer edge. */ + } /* Inner mask was empty, test if outer mask is filled. */ + else if (lomask[x]) { + osz++; /* Increment outer edge size. */ + lres[x] = 3; /* Flag pixel as outer edge. */ } /* Lower right corner. */ x = rw - 1; @@ -83,10 +83,10 @@ static void do_adjacentKeepBorders( else { res[x] = 1.0f; /* Pixel is just part of inner mask, and it's not an edge. */ } - } - else if (lomask[x]) { /* Inner mask was empty, test if outer mask is filled. */ - osz++; /* Increment outer edge size. */ - lres[x] = 3; /* Flag pixel as outer edge. */ + } /* Inner mask was empty, test if outer mask is filled. */ + else if (lomask[x]) { + osz++; /* Increment outer edge size. */ + lres[x] = 3; /* Flag pixel as outer edge. */ } /* Test the TOP row of pixels in buffer, except corners */ @@ -102,10 +102,10 @@ static void do_adjacentKeepBorders( else { res[x] = 1.0f; /* Pixel is just part of inner mask, and it's not an edge. */ } - } - else if (lomask[x]) { /* Inner mask was empty, test if outer mask is filled. */ - osz++; /* Increment outer edge size. */ - lres[x] = 3; /* Flag pixel as outer edge. */ + } /* Inner mask was empty, test if outer mask is filled. */ + else if (lomask[x]) { + osz++; /* Increment outer edge size. */ + lres[x] = 3; /* Flag pixel as outer edge. */ } } @@ -122,10 +122,10 @@ static void do_adjacentKeepBorders( else { res[x] = 1.0f; /* Pixel is just part of inner mask, and it's not an edge. */ } - } - else if (lomask[x]) { /* Inner mask was empty, test if outer mask is filled. */ - osz++; /* Increment outer edge size. */ - lres[x] = 3; /* Flag pixel as outer edge. */ + } /* Inner mask was empty, test if outer mask is filled. */ + else if (lomask[x]) { + osz++; /* Increment outer edge size. */ + lres[x] = 3; /* Flag pixel as outer edge. */ } } /* Test the LEFT edge of pixels in buffer, except corners */ @@ -141,10 +141,10 @@ static void do_adjacentKeepBorders( else { res[x] = 1.0f; /* Pixel is just part of inner mask, and it's not an edge. */ } - } - else if (lomask[x]) { /* Inner mask was empty, test if outer mask is filled. */ - osz++; /* Increment outer edge size. */ - lres[x] = 3; /* Flag pixel as outer edge. */ + } /* Inner mask was empty, test if outer mask is filled. */ + else if (lomask[x]) { + osz++; /* Increment outer edge size. */ + lres[x] = 3; /* Flag pixel as outer edge. */ } } @@ -161,10 +161,10 @@ static void do_adjacentKeepBorders( else { res[x] = 1.0f; /* Pixel is just part of inner mask, and it's not an edge. */ } - } - else if (lomask[x]) { /* Inner mask was empty, test if outer mask is filled. */ - osz++; /* Increment outer edge size. */ - lres[x] = 3; /* Flag pixel as outer edge. */ + } /* Inner mask was empty, test if outer mask is filled. */ + else if (lomask[x]) { + osz++; /* Increment outer edge size. */ + lres[x] = 3; /* Flag pixel as outer edge. */ } } @@ -194,10 +194,10 @@ static void do_adjacentBleedBorders( else { res[x] = 1.0f; /* Pixel is just part of inner mask, and it's not an edge. */ } - } - else if (lomask[x]) { /* Inner mask was empty, test if outer mask is filled. */ - if (!lomask[x - rw] || !lomask[x + 1]) - { /* Test if outer mask is empty underneath or to the right. */ + } /* Inner mask was empty, test if outer mask is filled. */ + else if (lomask[x]) { + /* Test if outer mask is empty underneath or to the right. */ + if (!lomask[x - rw] || !lomask[x + 1]) { osz++; /* Increment outer edge size. */ lres[x] = 3; /* Flag pixel as outer edge. */ } @@ -219,10 +219,10 @@ static void do_adjacentBleedBorders( else { res[x] = 1.0f; /* Pixel is just part of inner mask, and it's not an edge. */ } - } - else if (lomask[x]) { /* Inner mask was empty, test if outer mask is filled. */ - if (!lomask[x - rw] || !lomask[x - 1]) - { /* Test if outer mask is empty underneath or to the left. */ + } /* Inner mask was empty, test if outer mask is filled. */ + else if (lomask[x]) { + /* Test if outer mask is empty underneath or to the left. */ + if (!lomask[x - rw] || !lomask[x - 1]) { osz++; /* Increment outer edge size. */ lres[x] = 3; /* Flag pixel as outer edge. */ } @@ -244,10 +244,10 @@ static void do_adjacentBleedBorders( else { res[x] = 1.0f; /* Pixel is just part of inner mask, and it's not an edge. */ } - } - else if (lomask[x]) { /* Inner mask was empty, test if outer mask is filled. */ - if (!lomask[x + rw] || !lomask[x + 1]) - { /* Test if outer mask is empty above or to the right. */ + } /* Inner mask was empty, test if outer mask is filled. */ + else if (lomask[x]) { + /* Test if outer mask is empty above or to the right. */ + if (!lomask[x + rw] || !lomask[x + 1]) { osz++; /* Increment outer edge size. */ lres[x] = 3; /* Flag pixel as outer edge. */ } @@ -269,10 +269,10 @@ static void do_adjacentBleedBorders( else { res[x] = 1.0f; /* Pixel is just part of inner mask, and it's not an edge. */ } - } - else if (lomask[x]) { /* Inner mask was empty, test if outer mask is filled. */ - if (!lomask[x + rw] || !lomask[x - 1]) - { /* Test if outer mask is empty above or to the left. */ + } /* Inner mask was empty, test if outer mask is filled. */ + else if (lomask[x]) { + /* Test if outer mask is empty above or to the left. */ + if (!lomask[x + rw] || !lomask[x - 1]) { osz++; /* Increment outer edge size. */ lres[x] = 3; /* Flag pixel as outer edge. */ } @@ -294,10 +294,10 @@ static void do_adjacentBleedBorders( else { res[x] = 1.0f; /* Pixel is just part of inner mask, and it's not an edge. */ } - } - else if (lomask[x]) { /* Inner mask was empty, test if outer mask is filled. */ - if (!lomask[x - 1] || !lomask[x + 1]) - { /* Test if outer mask is empty to the left or to the right. */ + } /* Inner mask was empty, test if outer mask is filled. */ + else if (lomask[x]) { + /* Test if outer mask is empty to the left or to the right. */ + if (!lomask[x - 1] || !lomask[x + 1]) { osz++; /* Increment outer edge size. */ lres[x] = 3; /* Flag pixel as outer edge. */ } @@ -321,10 +321,10 @@ static void do_adjacentBleedBorders( else { res[x] = 1.0f; /* Pixel is just part of inner mask, and it's not an edge. */ } - } - else if (lomask[x]) { /* Inner mask was empty, test if outer mask is filled. */ - if (!lomask[x - 1] || !lomask[x + 1]) - { /* Test if outer mask is empty to the left or to the right. */ + } /* Inner mask was empty, test if outer mask is filled. */ + else if (lomask[x]) { + /* Test if outer mask is empty to the left or to the right. */ + if (!lomask[x - 1] || !lomask[x + 1]) { osz++; /* Increment outer edge size. */ lres[x] = 3; /* Flag pixel as outer edge. */ } @@ -347,10 +347,10 @@ static void do_adjacentBleedBorders( else { res[x] = 1.0f; /* Pixel is just part of inner mask, and it's not an edge. */ } - } - else if (lomask[x]) { /* Inner mask was empty, test if outer mask is filled. */ - if (!lomask[x - rw] || !lomask[x + rw]) - { /* Test if outer mask is empty underneath or above. */ + } /* Inner mask was empty, test if outer mask is filled. */ + else if (lomask[x]) { + /* Test if outer mask is empty underneath or above. */ + if (!lomask[x - rw] || !lomask[x + rw]) { osz++; /* Increment outer edge size. */ lres[x] = 3; /* Flag pixel as outer edge. */ } @@ -374,10 +374,10 @@ static void do_adjacentBleedBorders( else { res[x] = 1.0f; /* Pixel is just part of inner mask, and it's not an edge. */ } - } - else if (lomask[x]) { /* Inner mask was empty, test if outer mask is filled. */ - if (!lomask[x - rw] || !lomask[x + rw]) - { /* Test if outer mask is empty underneath or above. */ + } /* Inner mask was empty, test if outer mask is filled. */ + else if (lomask[x]) { + /* Test if outer mask is empty underneath or above. */ + if (!lomask[x - rw] || !lomask[x + rw]) { osz++; /* Increment outer edge size. */ lres[x] = 3; /* Flag pixel as outer edge. */ } @@ -413,10 +413,10 @@ static void do_allKeepBorders( else { res[x] = 1.0f; /* Pixel is just part of inner mask, and it's not an edge. */ } - } - else if (lomask[x]) { /* Inner mask was empty, test if outer mask is filled. */ - osz++; /* Increment outer edge size. */ - lres[x] = 3; /* Flag pixel as outer edge. */ + } /* Inner mask was empty, test if outer mask is filled. */ + else if (lomask[x]) { + osz++; /* Increment outer edge size. */ + lres[x] = 3; /* Flag pixel as outer edge. */ } /* Upper right corner. */ x = t; @@ -430,10 +430,10 @@ static void do_allKeepBorders( else { res[x] = 1.0f; /* Pixel is just part of inner mask, and it's not an edge. */ } - } - else if (lomask[x]) { /* Inner mask was empty, test if outer mask is filled. */ - osz++; /* Increment outer edge size. */ - lres[x] = 3; /* Flag pixel as outer edge. */ + } /* Inner mask was empty, test if outer mask is filled. */ + else if (lomask[x]) { + osz++; /* Increment outer edge size. */ + lres[x] = 3; /* Flag pixel as outer edge. */ } /* Lower left corner. */ x = 0; @@ -447,10 +447,10 @@ static void do_allKeepBorders( else { res[x] = 1.0f; /* Pixel is just part of inner mask, and it's not an edge. */ } - } - else if (lomask[x]) { /* Inner mask was empty, test if outer mask is filled. */ - osz++; /* Increment outer edge size. */ - lres[x] = 3; /* Flag pixel as outer edge. */ + } /* Inner mask was empty, test if outer mask is filled. */ + else if (lomask[x]) { + osz++; /* Increment outer edge size. */ + lres[x] = 3; /* Flag pixel as outer edge. */ } /* Lower right corner. */ x = rw - 1; @@ -464,10 +464,10 @@ static void do_allKeepBorders( else { res[x] = 1.0f; /* Pixel is just part of inner mask, and it's not an edge. */ } - } - else if (lomask[x]) { /* Inner mask was empty, test if outer mask is filled. */ - osz++; /* Increment outer edge size. */ - lres[x] = 3; /* Flag pixel as outer edge. */ + } /* Inner mask was empty, test if outer mask is filled. */ + else if (lomask[x]) { + osz++; /* Increment outer edge size. */ + lres[x] = 3; /* Flag pixel as outer edge. */ } /* Test the TOP row of pixels in buffer, except corners */ @@ -482,10 +482,10 @@ static void do_allKeepBorders( else { res[x] = 1.0f; /* Pixel is just part of inner mask, and it's not an edge. */ } - } - else if (lomask[x]) { /* Inner mask was empty, test if outer mask is filled. */ - osz++; /* Increment outer edge size. */ - lres[x] = 3; /* Flag pixel as outer edge. */ + } /* Inner mask was empty, test if outer mask is filled. */ + else if (lomask[x]) { + osz++; /* Increment outer edge size. */ + lres[x] = 3; /* Flag pixel as outer edge. */ } } @@ -501,10 +501,10 @@ static void do_allKeepBorders( else { res[x] = 1.0f; /* Pixel is just part of inner mask, and it's not an edge. */ } - } - else if (lomask[x]) { /* Inner mask was empty, test if outer mask is filled. */ - osz++; /* Increment outer edge size. */ - lres[x] = 3; /* Flag pixel as outer edge. */ + } /* Inner mask was empty, test if outer mask is filled. */ + else if (lomask[x]) { + osz++; /* Increment outer edge size. */ + lres[x] = 3; /* Flag pixel as outer edge. */ } } /* Test the LEFT edge of pixels in buffer, except corners */ @@ -519,10 +519,10 @@ static void do_allKeepBorders( else { res[x] = 1.0f; /* Pixel is just part of inner mask, and it's not an edge. */ } - } - else if (lomask[x]) { /* Inner mask was empty, test if outer mask is filled. */ - osz++; /* Increment outer edge size. */ - lres[x] = 3; /* Flag pixel as outer edge. */ + } /* Inner mask was empty, test if outer mask is filled. */ + else if (lomask[x]) { + osz++; /* Increment outer edge size. */ + lres[x] = 3; /* Flag pixel as outer edge. */ } } @@ -538,10 +538,10 @@ static void do_allKeepBorders( else { res[x] = 1.0f; /* Pixel is just part of inner mask, and it's not an edge. */ } - } - else if (lomask[x]) { /* Inner mask was empty, test if outer mask is filled. */ - osz++; /* Increment outer edge size. */ - lres[x] = 3; /* Flag pixel as outer edge. */ + } /* Inner mask was empty, test if outer mask is filled. */ + else if (lomask[x]) { + osz++; /* Increment outer edge size. */ + lres[x] = 3; /* Flag pixel as outer edge. */ } } @@ -570,10 +570,10 @@ static void do_allBleedBorders( else { res[x] = 1.0f; /* Pixel is just part of inner mask, and it's not an edge. */ } - } - else if (lomask[x]) { /* Inner mask was empty, test if outer mask is filled. */ - if (!lomask[x - rw] || !lomask[x + 1]) - { /* Test if outer mask is empty underneath or to the right. */ + } /* Inner mask was empty, test if outer mask is filled. */ + else if (lomask[x]) { + /* Test if outer mask is empty underneath or to the right. */ + if (!lomask[x - rw] || !lomask[x + 1]) { osz++; /* Increment outer edge size. */ lres[x] = 3; /* Flag pixel as outer edge. */ } @@ -594,10 +594,10 @@ static void do_allBleedBorders( else { res[x] = 1.0f; /* Pixel is just part of inner mask, and it's not an edge. */ } - } - else if (lomask[x]) { /* Inner mask was empty, test if outer mask is filled. */ - if (!lomask[x - rw] || !lomask[x - 1]) - { /* Test if outer mask is empty above or to the left. */ + } /* Inner mask was empty, test if outer mask is filled. */ + else if (lomask[x]) { + /* Test if outer mask is empty above or to the left. */ + if (!lomask[x - rw] || !lomask[x - 1]) { osz++; /* Increment outer edge size. */ lres[x] = 3; /* Flag pixel as outer edge. */ } @@ -618,10 +618,10 @@ static void do_allBleedBorders( else { res[x] = 1.0f; /* Pixel is just part of inner mask, and it's not an edge. */ } - } - else if (lomask[x]) { /* Inner mask was empty, test if outer mask is filled. */ - if (!lomask[x + rw] || !lomask[x + 1]) - { /* Test if outer mask is empty underneath or to the right. */ + } /* Inner mask was empty, test if outer mask is filled. */ + else if (lomask[x]) { + /* Test if outer mask is empty underneath or to the right. */ + if (!lomask[x + rw] || !lomask[x + 1]) { osz++; /* Increment outer edge size. */ lres[x] = 3; /* Flag pixel as outer edge. */ } @@ -642,10 +642,10 @@ static void do_allBleedBorders( else { res[x] = 1.0f; /* Pixel is just part of inner mask, and it's not an edge. */ } - } - else if (lomask[x]) { /* Inner mask was empty, test if outer mask is filled. */ - if (!lomask[x + rw] || !lomask[x - 1]) - { /* Test if outer mask is empty underneath or to the left. */ + } /* Inner mask was empty, test if outer mask is filled. */ + else if (lomask[x]) { + /* Test if outer mask is empty underneath or to the left. */ + if (!lomask[x + rw] || !lomask[x - 1]) { osz++; /* Increment outer edge size. */ lres[x] = 3; /* Flag pixel as outer edge. */ } @@ -666,10 +666,10 @@ static void do_allBleedBorders( else { res[x] = 1.0f; /* Pixel is just part of inner mask, and it's not an edge. */ } - } - else if (lomask[x]) { /* Inner mask was empty, test if outer mask is filled. */ - if (!lomask[x - 1] || !lomask[x + 1]) - { /* Test if outer mask is empty to the left or to the right. */ + } /* Inner mask was empty, test if outer mask is filled. */ + else if (lomask[x]) { + /* Test if outer mask is empty to the left or to the right. */ + if (!lomask[x - 1] || !lomask[x + 1]) { osz++; /* Increment outer edge size. */ lres[x] = 3; /* Flag pixel as outer edge. */ } @@ -692,10 +692,10 @@ static void do_allBleedBorders( else { res[x] = 1.0f; /* Pixel is just part of inner mask, and it's not an edge. */ } - } - else if (lomask[x]) { /* Inner mask was empty, test if outer mask is filled. */ - if (!lomask[x - 1] || !lomask[x + 1]) - { /* Test if outer mask is empty to the left or to the right. */ + } /* Inner mask was empty, test if outer mask is filled. */ + else if (lomask[x]) { + /* Test if outer mask is empty to the left or to the right. */ + if (!lomask[x - 1] || !lomask[x + 1]) { osz++; /* Increment outer edge size. */ lres[x] = 3; /* Flag pixel as outer edge. */ } @@ -717,10 +717,10 @@ static void do_allBleedBorders( else { res[x] = 1.0f; /* Pixel is just part of inner mask, and it's not an edge. */ } - } - else if (lomask[x]) { /* Inner mask was empty, test if outer mask is filled. */ - if (!lomask[x - rw] || !lomask[x + rw]) - { /* Test if outer mask is empty underneath or above. */ + } /* Inner mask was empty, test if outer mask is filled. */ + else if (lomask[x]) { + /* Test if outer mask is empty underneath or above. */ + if (!lomask[x - rw] || !lomask[x + rw]) { osz++; /* Increment outer edge size. */ lres[x] = 3; /* Flag pixel as outer edge. */ } @@ -743,10 +743,10 @@ static void do_allBleedBorders( else { res[x] = 1.0f; /* Pixel is just part of inner mask, and it's not an edge. */ } - } - else if (lomask[x]) { /* Inner mask was empty, test if outer mask is filled. */ - if (!lomask[x - rw] || !lomask[x + rw]) - { /* Test if outer mask is empty underneath or above. */ + } /* Inner mask was empty, test if outer mask is filled. */ + else if (lomask[x]) { + /* Test if outer mask is empty underneath or above. */ + if (!lomask[x - rw] || !lomask[x + rw]) { osz++; /* Increment outer edge size. */ lres[x] = 3; /* Flag pixel as outer edge. */ } @@ -1123,8 +1123,8 @@ static void do_fillGradientBuffer(uint rw, t = gbuf[gradient_fill_offset]; /* Calculate column of pixel indexed by `gbuf[x]`. */ fsz = gbuf[gradient_fill_offset + 1]; /* Calculate row of pixel indexed by `gbuf[x]`. */ dmin = 0xffffffff; /* Reset min distance to edge pixel. */ - for (a = outer_edge_offset + osz - 1; a >= outer_edge_offset; a--) - { /* Loop through all outer edge buffer pixels. */ + /* Loop through all outer edge buffer pixels. */ + for (a = outer_edge_offset + osz - 1; a >= outer_edge_offset; a--) { ud = a << 1; dy = t - gbuf[ud]; /* Set dx to gradient pixel column - outer edge pixel row. */ dx = fsz - gbuf[ud + 1]; /* Set dy to gradient pixel row - outer edge pixel column. */ @@ -1141,14 +1141,14 @@ static void do_fillGradientBuffer(uint rw, odist = odist * (rsopf - (rsf * odist * odist)); /* -- This line can be iterated for more accuracy. -- */ dmin = 0xffffffff; /* Reset min distance to edge pixel. */ - for (a = inner_edge_offset + isz - 1; a >= inner_edge_offset; a--) - { /* Loop through all inside edge pixels. */ + /* Loop through all inside edge pixels. */ + for (a = inner_edge_offset + isz - 1; a >= inner_edge_offset; a--) { ud = a << 1; dy = t - gbuf[ud]; /* Compute delta in Y from gradient pixel to inside edge pixel. */ dx = fsz - gbuf[ud + 1]; /* Compute delta in X from gradient pixel to inside edge pixel. */ ud = dx * dx + dy * dy; /* Compute sum of squares. */ - if (ud < dmin) - { /* If our new sum of squares is less than the current minimum we've found. */ + /* If our new sum of squares is less than the current minimum we've found. */ + if (ud < dmin) { dmin = ud; /* Set a new minimum equal to the new lower value. */ } } diff --git a/source/blender/compositor/operations/COM_SMAAOperation.cc b/source/blender/compositor/operations/COM_SMAAOperation.cc index 19296766165..2de5e6bdd5a 100644 --- a/source/blender/compositor/operations/COM_SMAAOperation.cc +++ b/source/blender/compositor/operations/COM_SMAAOperation.cc @@ -861,8 +861,8 @@ int SMAABlendingWeightCalculationOperation::search_xright(int x, int y) x++; sample_image_fn_(x, y, e); if (e[1] == 0.0f || /* Is the edge not activated? */ - e[0] != 0.0f) - { /* Or is there a crossing edge that breaks the line? */ + e[0] != 0.0f) /* Or is there a crossing edge that breaks the line? */ + { break; } sample_image_fn_(x, y - 1, e); @@ -906,8 +906,8 @@ int SMAABlendingWeightCalculationOperation::search_ydown(int x, int y) y++; sample_image_fn_(x, y, e); if (e[0] == 0.0f || /* Is the edge not activated? */ - e[1] != 0.0f) - { /* Or is there a crossing edge that breaks the line? */ + e[1] != 0.0f) /* Or is there a crossing edge that breaks the line? */ + { break; } sample_image_fn_(x - 1, y, e); diff --git a/source/blender/editors/render/render_internal.cc b/source/blender/editors/render/render_internal.cc index a577eaf57a9..0ceff7edc14 100644 --- a/source/blender/editors/render/render_internal.cc +++ b/source/blender/editors/render/render_internal.cc @@ -523,13 +523,15 @@ static void render_progress_update(void *rjv, float progress) */ static void render_image_update_pass_and_layer(RenderJob *rj, RenderResult *rr, ImageUser *iuser) { - wmWindowManager *wm; ScrArea *first_area = nullptr, *matched_area = nullptr; /* image window, compo node users */ - for (wm = static_cast(rj->main->wm.first); wm && matched_area == nullptr; + + /* Only ever 1 `wm`. */ + for (wmWindowManager *wm = static_cast(rj->main->wm.first); + wm && matched_area == nullptr; wm = static_cast(wm->id.next)) - { /* only 1 wm */ + { wmWindow *win; for (win = static_cast(wm->windows.first); win && matched_area == nullptr; win = win->next) @@ -693,12 +695,10 @@ static void render_startjob(void *rjv, bool *stop, bool *do_update, float *progr static void render_image_restore_layer(RenderJob *rj) { - wmWindowManager *wm; - /* image window, compo node users */ - for (wm = static_cast(rj->main->wm.first); wm; - wm = static_cast(wm->id.next)) - { /* only 1 wm */ + + /* Only ever 1 `wm`. */ + LISTBASE_FOREACH (wmWindowManager *, wm, &rj->main->wm) { wmWindow *win; for (win = static_cast(wm->windows.first); win; win = win->next) { const bScreen *screen = WM_window_get_active_screen(win); @@ -903,9 +903,9 @@ static void clean_viewport_memory(Main *bmain, Scene *scene) BKE_main_id_tag_listbase(&bmain->objects, LIB_TAG_DOIT, true); /* Go over all the visible objects. */ - for (wmWindowManager *wm = static_cast(bmain->wm.first); wm; - wm = static_cast(wm->id.next)) - { + + /* Only ever 1 `wm`. */ + LISTBASE_FOREACH (wmWindowManager *, wm, &bmain->wm) { LISTBASE_FOREACH (wmWindow *, win, &wm->windows) { ViewLayer *view_layer = WM_window_get_active_view_layer(win); BKE_view_layer_synced_ensure(scene, view_layer); diff --git a/source/blender/editors/space_graph/graph_select.c b/source/blender/editors/space_graph/graph_select.c index aaf25f29651..19f6d6bf807 100644 --- a/source/blender/editors/space_graph/graph_select.c +++ b/source/blender/editors/space_graph/graph_select.c @@ -173,9 +173,8 @@ static void get_nearest_fcurve_verts_list(bAnimContext *ac, const int mval[2], L */ filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_FCURVESONLY | ANIMFILTER_NODUPLIS | ANIMFILTER_FCURVESONLY); - if (U.animation_flag & USER_ANIM_ONLY_SHOW_SELECTED_CURVE_KEYS) - { /* FIXME: this should really be check for by the - * filtering code. */ + /* FIXME: this should really be check for by the filtering code. */ + if (U.animation_flag & USER_ANIM_ONLY_SHOW_SELECTED_CURVE_KEYS) { filter |= ANIMFILTER_SEL; } mapping_flag |= ANIM_get_normalization_flags(ac); diff --git a/source/blender/editors/space_info/info_ops.c b/source/blender/editors/space_info/info_ops.c index 3a4a89967d2..f62149523ad 100644 --- a/source/blender/editors/space_info/info_ops.c +++ b/source/blender/editors/space_info/info_ops.c @@ -574,10 +574,9 @@ static int update_reports_display_invoke(bContext *C, wmOperator *UNUSED(op), co /* escape if not our timer */ if ((reports->reporttimer == NULL) || (reports->reporttimer != event->customdata) || - ((report = BKE_reports_last_displayable(reports)) == NULL) - /* may have been deleted */ - ) + ((report = BKE_reports_last_displayable(reports)) == NULL)) { + /* May have been deleted. */ return OPERATOR_PASS_THROUGH; } diff --git a/source/blender/freestyle/intern/blender_interface/FRS_freestyle.cpp b/source/blender/freestyle/intern/blender_interface/FRS_freestyle.cpp index 5359dd945ab..f6cf85e44b6 100644 --- a/source/blender/freestyle/intern/blender_interface/FRS_freestyle.cpp +++ b/source/blender/freestyle/intern/blender_interface/FRS_freestyle.cpp @@ -277,8 +277,8 @@ static void prepare(Render *re, ViewLayer *view_layer, Depsgraph *depsgraph) re->i.infostr = TIP_("Freestyle: Mesh loading"); re->stats_draw(re->sdh, &re->i); re->i.infostr = nullptr; - if (controller->LoadMesh(re, view_layer, depsgraph)) - { // returns if scene cannot be loaded or if empty + if (controller->LoadMesh(re, view_layer, depsgraph)) { + /* Returns if scene cannot be loaded or if empty. */ return; } if (re->test_break(re->tbh)) { diff --git a/source/blender/freestyle/intern/view_map/FEdgeXDetector.cpp b/source/blender/freestyle/intern/view_map/FEdgeXDetector.cpp index 4a5c9d7d271..28be72418c6 100644 --- a/source/blender/freestyle/intern/view_map/FEdgeXDetector.cpp +++ b/source/blender/freestyle/intern/view_map/FEdgeXDetector.cpp @@ -321,8 +321,8 @@ void FEdgeXDetector::ProcessSilhouetteEdge(WXEdge *iEdge) WXFace *fA = (WXFace *)iEdge->GetaOEdge()->GetaFace(); WXFace *fB = (WXFace *)iEdge->GetaOEdge()->GetbFace(); - if (fA->front() ^ fB->front()) - { // fA->visible XOR fB->visible (true if one is 0 and the other is 1) + /* fA->visible XOR fB->visible (true if one is 0 and the other is 1). */ + if (fA->front() ^ fB->front()) { // The only edges we want to set as silhouette edges in this way are the ones with 2 different // normals for 1 vertex for these two faces //-------------------- diff --git a/source/blender/freestyle/intern/view_map/ViewEdgeXBuilder.cpp b/source/blender/freestyle/intern/view_map/ViewEdgeXBuilder.cpp index 6af4cb6ff51..94f7e8e8d24 100644 --- a/source/blender/freestyle/intern/view_map/ViewEdgeXBuilder.cpp +++ b/source/blender/freestyle/intern/view_map/ViewEdgeXBuilder.cpp @@ -477,8 +477,9 @@ FEdge *ViewEdgeXBuilder::BuildSmoothFEdge(FEdge *feprevious, const OWXFaceLayer Vec3r normal; // Make the 2 Svertices - if (feprevious == nullptr) - { // that means that we don't have any vertex already built for that face + + /* That means that we don't have any vertex already built for that face. */ + if (feprevious == nullptr) { Vec3r A1(woea->GetaVertex()->GetVertex()); Vec3r A2(woea->GetbVertex()->GetVertex()); Vec3r A(A1 + ta * (A2 - A1)); diff --git a/source/blender/gpu/shaders/common/gpu_shader_smaa_lib.glsl b/source/blender/gpu/shaders/common/gpu_shader_smaa_lib.glsl index 430fdf47687..03788cfc91f 100644 --- a/source/blender/gpu/shaders/common/gpu_shader_smaa_lib.glsl +++ b/source/blender/gpu/shaders/common/gpu_shader_smaa_lib.glsl @@ -1127,8 +1127,8 @@ float SMAASearchXLeft(SMAATexture2D(edgesTex), */ float2 e = float2(0.0, 1.0); while (texcoord.x > end && e.g > 0.8281 && // Is there some edge not activated? - e.r == 0.0) - { // Or is there a crossing edge that breaks the line? + e.r == 0.0) // Or is there a crossing edge that breaks the line? + { e = SMAASampleLevelZero(edgesTex, texcoord).rg; texcoord = mad(-float2(2.0, 0.0), SMAA_RT_METRICS.xy, texcoord); } @@ -1158,8 +1158,8 @@ float SMAASearchXRight(SMAATexture2D(edgesTex), { float2 e = float2(0.0, 1.0); while (texcoord.x < end && e.g > 0.8281 && // Is there some edge not activated? - e.r == 0.0) - { // Or is there a crossing edge that breaks the line? + e.r == 0.0) // Or is there a crossing edge that breaks the line? + { e = SMAASampleLevelZero(edgesTex, texcoord).rg; texcoord = mad(float2(2.0, 0.0), SMAA_RT_METRICS.xy, texcoord); } @@ -1172,8 +1172,8 @@ float SMAASearchYUp(SMAATexture2D(edgesTex), SMAATexture2D(searchTex), float2 te { float2 e = float2(1.0, 0.0); while (texcoord.y > end && e.r > 0.8281 && // Is there some edge not activated? - e.g == 0.0) - { // Or is there a crossing edge that breaks the line? + e.g == 0.0) // Or is there a crossing edge that breaks the line? + { e = SMAASampleLevelZero(edgesTex, texcoord).rg; texcoord = mad(-float2(0.0, 2.0), SMAA_RT_METRICS.xy, texcoord); } @@ -1189,8 +1189,8 @@ float SMAASearchYDown(SMAATexture2D(edgesTex), { float2 e = float2(1.0, 0.0); while (texcoord.y < end && e.r > 0.8281 && // Is there some edge not activated? - e.g == 0.0) - { // Or is there a crossing edge that breaks the line? + e.g == 0.0) // Or is there a crossing edge that breaks the line? + { e = SMAASampleLevelZero(edgesTex, texcoord).rg; texcoord = mad(float2(0.0, 2.0), SMAA_RT_METRICS.xy, texcoord); } diff --git a/source/blender/python/intern/bpy_props.c b/source/blender/python/intern/bpy_props.c index 49b896ec905..98449e9d810 100644 --- a/source/blender/python/intern/bpy_props.c +++ b/source/blender/python/intern/bpy_props.c @@ -4134,9 +4134,9 @@ static PyObject *BPy_EnumProperty(PyObject *self, PyObject *args, PyObject *kw) default_py = NULL; } - /* items can be a list or a callable */ - if (PyFunction_Check(items)) - { /* don't use PyCallable_Check because we need the function code for errors */ + /* Items can be a list or a callable. + * NOTE: Don't use #PyCallable_Check because we need the function code for errors. */ + if (PyFunction_Check(items)) { PyCodeObject *f_code = (PyCodeObject *)PyFunction_GET_CODE(items); if (f_code->co_argcount != 2) { PyErr_Format(PyExc_ValueError, diff --git a/source/blender/python/mathutils/mathutils_Vector.c b/source/blender/python/mathutils/mathutils_Vector.c index b10dcdc9e98..ceb8bc78804 100644 --- a/source/blender/python/mathutils/mathutils_Vector.c +++ b/source/blender/python/mathutils/mathutils_Vector.c @@ -2203,8 +2203,8 @@ static PyObject *Vector_imul(PyObject *v1, PyObject *v2) /* Element-wise product in-place. */ mul_vn_vn(vec1->vec, vec2->vec, vec1->vec_num); } - else if (vec1 && (((scalar = PyFloat_AsDouble(v2)) == -1.0f && PyErr_Occurred()) == 0)) - { /* VEC *= FLOAT */ + else if (vec1 && (((scalar = PyFloat_AsDouble(v2)) == -1.0f && PyErr_Occurred()) == 0)) { + /* VEC *= FLOAT */ mul_vn_fl(vec1->vec, vec1->vec_num, scalar); } else {