From b4eef99973df805b66253b86603a64c2c6c20f62 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 3 Mar 2023 15:55:33 +1100 Subject: [PATCH] Cleanup: use C-style code comments, format --- intern/sky/source/sky_nishita.cpp | 24 +++++++++---------- source/blender/blenkernel/intern/nla.c | 2 +- source/blender/blenkernel/intern/nla_test.cc | 20 ++++++++-------- source/blender/blenlib/intern/voxel.c | 4 ++-- .../editors/animation/anim_motion_paths.c | 2 +- .../io/usd/intern/usd_writer_material.cc | 4 ++-- tests/python/bl_blendfile_liblink.py | 7 +++--- 7 files changed, 31 insertions(+), 32 deletions(-) diff --git a/intern/sky/source/sky_nishita.cpp b/intern/sky/source/sky_nishita.cpp index d00ef51e152..db3431a8678 100644 --- a/intern/sky/source/sky_nishita.cpp +++ b/intern/sky/source/sky_nishita.cpp @@ -9,18 +9,18 @@ #include "sky_model.h" /* Constants */ -static const float rayleigh_scale = 8e3f; // Rayleigh scale height (m) -static const float mie_scale = 1.2e3f; // Mie scale height (m) -static const float mie_coeff = 2e-5f; // Mie scattering coefficient (m^-1) -static const float mie_G = 0.76f; // aerosols anisotropy -static const float sqr_G = mie_G * mie_G; // squared aerosols anisotropy -static const float earth_radius = 6360e3f; // radius of Earth (m) -static const float atmosphere_radius = 6420e3f; // radius of atmosphere (m) -static const int steps = 32; // segments of primary ray -static const int num_wavelengths = 21; // number of wavelengths -static const int min_wavelength = 380; // lowest sampled wavelength (nm) -static const int max_wavelength = 780; // highest sampled wavelength (nm) -// step between each sampled wavelength (nm) +static const float rayleigh_scale = 8e3f; /* Rayleigh scale height (m). */ +static const float mie_scale = 1.2e3f; /* Mie scale height (m). */ +static const float mie_coeff = 2e-5f; /* Mie scattering coefficient (m^-1). */ +static const float mie_G = 0.76f; /* aerosols anisotropy. */ +static const float sqr_G = mie_G * mie_G; /* squared aerosols anisotropy. */ +static const float earth_radius = 6360e3f; /* radius of Earth (m). */ +static const float atmosphere_radius = 6420e3f; /* radius of atmosphere (m). */ +static const int steps = 32; /* segments of primary ray. */ +static const int num_wavelengths = 21; /* number of wavelengths. */ +static const int min_wavelength = 380; /* lowest sampled wavelength (nm). */ +static const int max_wavelength = 780; /* highest sampled wavelength (nm). */ +/* Step between each sampled wavelength (nm). */ static const float step_lambda = (max_wavelength - min_wavelength) / (num_wavelengths - 1); /* Sun irradiance on top of the atmosphere (W*m^-2*nm^-1) */ static const float irradiance[] = { diff --git a/source/blender/blenkernel/intern/nla.c b/source/blender/blenkernel/intern/nla.c index 7cb85f4923c..ab5fd55d43e 100644 --- a/source/blender/blenkernel/intern/nla.c +++ b/source/blender/blenkernel/intern/nla.c @@ -1070,7 +1070,7 @@ void BKE_nlameta_flush_transforms(NlaStrip *mstrip) strip->start = (p1 * nLen) + mstrip->start; strip->end = (p2 * nLen) + mstrip->start; - // Recompute the playback scale, given the new start & end frame of the strip. + /* Recompute the playback scale, given the new start & end frame of the strip. */ const double action_len = strip->actend - strip->actstart; const double repeated_len = action_len * strip->repeat; const double strip_len = strip->end - strip->start; diff --git a/source/blender/blenkernel/intern/nla_test.cc b/source/blender/blenkernel/intern/nla_test.cc index 5a58ece9b20..98259c41c3a 100644 --- a/source/blender/blenkernel/intern/nla_test.cc +++ b/source/blender/blenkernel/intern/nla_test.cc @@ -28,13 +28,13 @@ TEST(nla_strip, BKE_nlastrip_recalculate_blend) EXPECT_FLOAT_EQ(strip.blendin, 4.0); EXPECT_FLOAT_EQ(strip.blendout, 5.0); - /* Scaling a strip down affects the blend-in value before the blend-out value. */ + /* Scaling a strip down affects the blend-in value before the blend-out value. */ strip.end = 7; BKE_nlastrip_recalculate_blend(&strip); EXPECT_FLOAT_EQ(strip.blendin, 1.0); EXPECT_FLOAT_EQ(strip.blendout, 5.0); - /* Scaling a strip down to nothing updates the blend in/out values accordingly. */ + /* Scaling a strip down to nothing updates the blend in/out values accordingly. */ strip.end = 1.1; BKE_nlastrip_recalculate_blend(&strip); EXPECT_FLOAT_EQ(strip.blendin, 0.0); @@ -53,15 +53,15 @@ TEST(nla_strip, BKE_nlastrips_add_strip) strip2.start = 5; strip2.end = 10; - /* can't add a null NLA strip to an NLA Track. */ - EXPECT_FALSE(BKE_nlastrips_add_strip(&strips, NULL)); + /* Can't add a null NLA strip to an NLA Track. */ + EXPECT_FALSE(BKE_nlastrips_add_strip(&strips, nullptr)); - /* can't add an NLA strip to an NLA Track that overlaps another NLA strip. */ + /* Can't add an NLA strip to an NLA Track that overlaps another NLA strip. */ EXPECT_FALSE(BKE_nlastrips_add_strip(&strips, &strip2)); strip2.start = 15; strip2.end = 20; - /* can add an NLA strip to an NLA Track that doesn't overlaps another NLA strip. */ + /* Can add an NLA strip to an NLA Track that doesn't overlaps another NLA strip. */ EXPECT_TRUE(BKE_nlastrips_add_strip(&strips, &strip2)); } @@ -120,11 +120,11 @@ TEST(nla_track, BKE_nlatrack_new_tail) NlaTrack *trackB = BKE_nlatrack_new_tail(&adt.nla_tracks, false); NlaTrack *trackA = BKE_nlatrack_new_tail(&adt.nla_tracks, false); - // Expect that Track B was added before track A + /* Expect that Track B was added before track A. */ EXPECT_EQ(1, BLI_findindex(&adt.nla_tracks, trackA)); EXPECT_EQ(0, BLI_findindex(&adt.nla_tracks, trackB)); - // Free the tracks + /* Free the tracks. */ BKE_nlatrack_remove_and_free(&adt.nla_tracks, trackA, false); BKE_nlatrack_remove_and_free(&adt.nla_tracks, trackB, false); } @@ -135,11 +135,11 @@ TEST(nla_track, BKE_nlatrack_new_head) NlaTrack *trackB = BKE_nlatrack_new_head(&adt.nla_tracks, false); NlaTrack *trackA = BKE_nlatrack_new_head(&adt.nla_tracks, false); - // Expect that Track A was added before track B + /* Expect that Track A was added before track B. */ EXPECT_EQ(0, BLI_findindex(&adt.nla_tracks, trackA)); EXPECT_EQ(1, BLI_findindex(&adt.nla_tracks, trackB)); - // Free the tracks + /* Free the tracks. */ BKE_nlatrack_remove_and_free(&adt.nla_tracks, trackA, false); BKE_nlatrack_remove_and_free(&adt.nla_tracks, trackB, false); } diff --git a/source/blender/blenlib/intern/voxel.c b/source/blender/blenlib/intern/voxel.c index a361118ffa4..6da92f4b10b 100644 --- a/source/blender/blenlib/intern/voxel.c +++ b/source/blender/blenlib/intern/voxel.c @@ -180,7 +180,7 @@ float BLI_voxel_sample_tricubic(const float *data, const float dx = xf - (float)x, dy = yf - (float)y, dz = zf - (float)z; float u[4], v[4], w[4]; - if (bspline) { // B-Spline + if (bspline) { /* B-Spline. */ u[0] = (((-1.0f / 6.0f) * dx + 0.5f) * dx - 0.5f) * dx + (1.0f / 6.0f); u[1] = ((0.5f * dx - 1.0f) * dx) * dx + (2.0f / 3.0f); u[2] = ((-0.5f * dx + 0.5f) * dx + 0.5f) * dx + (1.0f / 6.0f); @@ -194,7 +194,7 @@ float BLI_voxel_sample_tricubic(const float *data, w[2] = ((-0.5f * dz + 0.5f) * dz + 0.5f) * dz + (1.0f / 6.0f); w[3] = (1.0f / 6.0f) * dz * dz * dz; } - else { // Catmull-Rom + else { /* Catmull-Rom. */ u[0] = ((-0.5f * dx + 1.0f) * dx - 0.5f) * dx; u[1] = ((1.5f * dx - 2.5f) * dx) * dx + 1.0f; u[2] = ((-1.5f * dx + 2.0f) * dx + 0.5f) * dx; diff --git a/source/blender/editors/animation/anim_motion_paths.c b/source/blender/editors/animation/anim_motion_paths.c index 5cabb4fd014..b140b2a590b 100644 --- a/source/blender/editors/animation/anim_motion_paths.c +++ b/source/blender/editors/animation/anim_motion_paths.c @@ -370,7 +370,7 @@ void animviz_motionpath_compute_range(Object *ob, Scene *scene) if (ED_keylist_selected_keys_frame_range(keylist, &frame_range)) { break; } - ATTR_FALLTHROUGH; // Fall through if there were no selected keys found. + ATTR_FALLTHROUGH; /* Fall through if there were no selected keys found. */ case MOTIONPATH_RANGE_KEYS_ALL: ED_keylist_all_keys_frame_range(keylist, &frame_range); break; diff --git a/source/blender/io/usd/intern/usd_writer_material.cc b/source/blender/io/usd/intern/usd_writer_material.cc index 813579be22f..6c72b32f62f 100644 --- a/source/blender/io/usd/intern/usd_writer_material.cc +++ b/source/blender/io/usd/intern/usd_writer_material.cc @@ -32,9 +32,9 @@ #include -/* TfToken objects are not cheap to construct, so we do it once. */ +/* `TfToken` objects are not cheap to construct, so we do it once. */ namespace usdtokens { -// Materials +/* Materials. */ static const pxr::TfToken clearcoat("clearcoat", pxr::TfToken::Immortal); static const pxr::TfToken clearcoatRoughness("clearcoatRoughness", pxr::TfToken::Immortal); static const pxr::TfToken diffuse_color("diffuseColor", pxr::TfToken::Immortal); diff --git a/tests/python/bl_blendfile_liblink.py b/tests/python/bl_blendfile_liblink.py index 0e87cdb55be..e090e738386 100644 --- a/tests/python/bl_blendfile_liblink.py +++ b/tests/python/bl_blendfile_liblink.py @@ -530,7 +530,7 @@ class TestBlendLibDataLibrariesLoad(TestBlendLibLinkHelper): # Simple link of a single Object, and reload. self.reset_blender() - + return output_lib_path def do_libload(self, **load_kwargs): @@ -639,7 +639,6 @@ class TestBlendLibDataLibrariesLoadLibOverride(TestBlendLibDataLibrariesLoad): assert bpy.data.collections[1].override_library is not None assert bpy.data.collections[1].override_library.reference == bpy.data.collections[-1] - def test_libload_liboverride_runtime(self): output_lib_path = self.do_libload_init() self.do_libload(filepath=output_lib_path, link=True, @@ -657,7 +656,7 @@ class TestBlendLibDataLibrariesLoadLibOverride(TestBlendLibDataLibrariesLoad): # Only explicitely linked data gets a liboverride, without any handling of hierarchy/dependencies. assert bpy.data.collections[0].library is None - assert bpy.data.collections[0].is_runtime_data == True + assert bpy.data.collections[0].is_runtime_data is True assert bpy.data.collections[0].override_library is not None assert bpy.data.collections[0].override_library.reference == bpy.data.collections[-1] @@ -679,7 +678,7 @@ class TestBlendLibDataLibrariesLoadLibOverride(TestBlendLibDataLibrariesLoad): # Only explicitely linked data gets a liboverride, without any handling of hierarchy/dependencies. assert bpy.data.collections[0].library is None - assert bpy.data.collections[0].is_runtime_data == True + assert bpy.data.collections[0].is_runtime_data is True assert bpy.data.collections[0].override_library is not None assert bpy.data.collections[0].override_library.reference == bpy.data.collections[-1]