From 936b90ce56e45ecb29262f98facc7bc96bea5e0c Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Sun, 26 Jan 2025 20:07:58 +0100 Subject: [PATCH] Cleanup: Various clang-tidy warnings in animrig Pull Request: https://projects.blender.org/blender/blender/pulls/133734 --- source/blender/animrig/ANIM_action.hh | 2 +- source/blender/animrig/ANIM_bone_collections.hh | 2 -- source/blender/animrig/ANIM_bonecolor.hh | 2 +- source/blender/animrig/ANIM_evaluation.hh | 1 - source/blender/animrig/ANIM_fcurve.hh | 2 -- source/blender/animrig/ANIM_keyframing.hh | 4 ++-- source/blender/animrig/intern/action.cc | 6 ------ .../blender/animrig/intern/action_legacy_test.cc | 1 - source/blender/animrig/intern/action_runtime.cc | 2 -- .../blender/animrig/intern/action_selection.cc | 3 --- source/blender/animrig/intern/action_test.cc | 6 +++--- source/blender/animrig/intern/anim_rna.cc | 2 +- source/blender/animrig/intern/animdata.cc | 2 -- .../blender/animrig/intern/bone_collections.cc | 1 - .../animrig/intern/bone_collections_test.cc | 16 ++++++++-------- source/blender/animrig/intern/bonecolor.cc | 4 +++- source/blender/animrig/intern/evaluation.cc | 2 -- source/blender/animrig/intern/evaluation_test.cc | 1 - source/blender/animrig/intern/keyframing.cc | 6 +++--- source/blender/animrig/intern/keyframing_auto.cc | 3 --- source/blender/animrig/intern/keyframing_test.cc | 3 --- source/blender/animrig/intern/nla.cc | 6 ------ source/blender/animrig/intern/nla_test.cc | 4 ---- source/blender/animrig/intern/pose.cc | 2 +- source/blender/animrig/intern/versioning_test.cc | 3 --- source/blender/animrig/intern/visualkey.cc | 2 +- 26 files changed, 24 insertions(+), 64 deletions(-) diff --git a/source/blender/animrig/ANIM_action.hh b/source/blender/animrig/ANIM_action.hh index 7adf612c6c1..d511a6011df 100644 --- a/source/blender/animrig/ANIM_action.hh +++ b/source/blender/animrig/ANIM_action.hh @@ -1097,7 +1097,7 @@ class Channelbag : public ::ActionChannelbag { * * \see fcurve_remove */ - void fcurve_remove_by_index(int64_t fcurve_array_index); + void fcurve_remove_by_index(int64_t fcurve_index); /** * Detach an F-Curve from the Channelbag. diff --git a/source/blender/animrig/ANIM_bone_collections.hh b/source/blender/animrig/ANIM_bone_collections.hh index 1cfbee1ab73..12f67f2434c 100644 --- a/source/blender/animrig/ANIM_bone_collections.hh +++ b/source/blender/animrig/ANIM_bone_collections.hh @@ -14,8 +14,6 @@ # error This is a C++ header. #endif -#include - #include "BLI_map.hh" #include "BKE_armature.hh" diff --git a/source/blender/animrig/ANIM_bonecolor.hh b/source/blender/animrig/ANIM_bonecolor.hh index f59d512a71b..e491cfc4c31 100644 --- a/source/blender/animrig/ANIM_bonecolor.hh +++ b/source/blender/animrig/ANIM_bonecolor.hh @@ -14,7 +14,7 @@ # error This is a C++ header. #endif -#include "DNA_anim_types.h" +#include "DNA_armature_types.h" struct bPoseChannel; struct ThemeWireColor; diff --git a/source/blender/animrig/ANIM_evaluation.hh b/source/blender/animrig/ANIM_evaluation.hh index c2d4c1619c3..afb0babe1d1 100644 --- a/source/blender/animrig/ANIM_evaluation.hh +++ b/source/blender/animrig/ANIM_evaluation.hh @@ -92,7 +92,6 @@ class EvaluationResult { EvaluationResult(const EvaluationResult &other) = default; ~EvaluationResult() = default; - public: operator bool() const { return !this->is_empty(); diff --git a/source/blender/animrig/ANIM_fcurve.hh b/source/blender/animrig/ANIM_fcurve.hh index 16c8a5f2e3d..5c6366e2472 100644 --- a/source/blender/animrig/ANIM_fcurve.hh +++ b/source/blender/animrig/ANIM_fcurve.hh @@ -16,8 +16,6 @@ #include "DNA_anim_types.h" -#include "ANIM_keyframing.hh" - struct AnimData; struct FCurve; diff --git a/source/blender/animrig/ANIM_keyframing.hh b/source/blender/animrig/ANIM_keyframing.hh index 5a6ce3a1782..cadeb82bb65 100644 --- a/source/blender/animrig/ANIM_keyframing.hh +++ b/source/blender/animrig/ANIM_keyframing.hh @@ -92,8 +92,8 @@ class CombinedKeyingResult { * For example, for object location/rotation/scale this returns the standard * "Object Transforms" channel group name. */ -const std::optional default_channel_group_for_path( - const PointerRNA *animated_struct, const StringRef prop_rna_path); +std::optional default_channel_group_for_path(const PointerRNA *animated_struct, + const StringRef prop_rna_path); /* -------------------------------------------------------------------- */ diff --git a/source/blender/animrig/intern/action.cc b/source/blender/animrig/intern/action.cc index d28c2e5eb54..0e097f29468 100644 --- a/source/blender/animrig/intern/action.cc +++ b/source/blender/animrig/intern/action.cc @@ -6,7 +6,6 @@ * \ingroup animrig */ -#include "DNA_action_defaults.h" #include "DNA_action_types.h" #include "DNA_anim_types.h" #include "DNA_array_utils.hh" @@ -14,7 +13,6 @@ #include "DNA_scene_types.h" #include "BLI_listbase.h" -#include "BLI_listbase_wrapper.hh" #include "BLI_map.hh" #include "BLI_math_base.h" #include "BLI_string.h" @@ -28,7 +26,6 @@ #include "BKE_lib_id.hh" #include "BKE_main.hh" #include "BKE_nla.hh" -#include "BKE_preview_image.hh" #include "BKE_report.hh" #include "RNA_access.hh" @@ -46,12 +43,9 @@ #include "ANIM_action_legacy.hh" #include "ANIM_animdata.hh" #include "ANIM_fcurve.hh" -#include "ANIM_nla.hh" #include "action_runtime.hh" -#include "atomic_ops.h" - #include #include diff --git a/source/blender/animrig/intern/action_legacy_test.cc b/source/blender/animrig/intern/action_legacy_test.cc index 023e43b8759..299f1562e32 100644 --- a/source/blender/animrig/intern/action_legacy_test.cc +++ b/source/blender/animrig/intern/action_legacy_test.cc @@ -11,7 +11,6 @@ #include "BKE_object.hh" #include "DNA_anim_types.h" -#include "DNA_object_types.h" #include "BLI_listbase.h" diff --git a/source/blender/animrig/intern/action_runtime.cc b/source/blender/animrig/intern/action_runtime.cc index e12167b917e..9a94321204a 100644 --- a/source/blender/animrig/intern/action_runtime.cc +++ b/source/blender/animrig/intern/action_runtime.cc @@ -17,8 +17,6 @@ #include "BLI_set.hh" -#include "DNA_anim_types.h" - #include "ANIM_action.hh" #include "ANIM_action_iterators.hh" diff --git a/source/blender/animrig/intern/action_selection.cc b/source/blender/animrig/intern/action_selection.cc index 3e79b02eda1..8578916cddf 100644 --- a/source/blender/animrig/intern/action_selection.cc +++ b/source/blender/animrig/intern/action_selection.cc @@ -9,15 +9,12 @@ #include "DNA_action_types.h" #include "DNA_anim_types.h" -#include "BLI_listbase.h" #include "BLI_set.hh" -#include "BKE_anim_data.hh" #include "BKE_fcurve.hh" #include "ANIM_action.hh" #include "ANIM_action_legacy.hh" -#include "ANIM_fcurve.hh" namespace blender::animrig { diff --git a/source/blender/animrig/intern/action_test.cc b/source/blender/animrig/intern/action_test.cc index a25ec6a7b91..af389aa78da 100644 --- a/source/blender/animrig/intern/action_test.cc +++ b/source/blender/animrig/intern/action_test.cc @@ -2063,12 +2063,12 @@ TEST_F(ActionFCurveMoveTest, test_fcurve_move_legacy) Action &action_dst = action_add(*this->bmain, "DestinationAction"); /* Add F-Curves to source Action. */ - BLI_addtail(&action_src.curves, this->fcurve_create("source_prop", 0)); - FCurve *fcurve_to_move = this->fcurve_create("source_prop", 2); + BLI_addtail(&action_src.curves, fcurve_create("source_prop", 0)); + FCurve *fcurve_to_move = fcurve_create("source_prop", 2); BLI_addtail(&action_src.curves, fcurve_to_move); /* Add F-Curves to destination Action. */ - BLI_addtail(&action_dst.curves, this->fcurve_create("dest_prop", 0)); + BLI_addtail(&action_dst.curves, fcurve_create("dest_prop", 0)); ASSERT_TRUE(action_src.is_action_legacy()); ASSERT_TRUE(action_dst.is_action_legacy()); diff --git a/source/blender/animrig/intern/anim_rna.cc b/source/blender/animrig/intern/anim_rna.cc index 2167b7a5e6f..87ddcaa83de 100644 --- a/source/blender/animrig/intern/anim_rna.cc +++ b/source/blender/animrig/intern/anim_rna.cc @@ -40,7 +40,7 @@ Vector get_rna_values(PointerRNA *ptr, PropertyRNA *prop) } case PROP_FLOAT: { values.reinitialize(length); - RNA_property_float_get_array(ptr, prop, &values[0]); + RNA_property_float_get_array(ptr, prop, values.data()); break; } default: diff --git a/source/blender/animrig/intern/animdata.cc b/source/blender/animrig/intern/animdata.cc index 02d8e936a70..65dc7ca2ee4 100644 --- a/source/blender/animrig/intern/animdata.cc +++ b/source/blender/animrig/intern/animdata.cc @@ -28,11 +28,9 @@ #include "DNA_anim_types.h" #include "DNA_key_types.h" #include "DNA_material_types.h" -#include "DNA_mesh_types.h" #include "DNA_particle_types.h" #include "RNA_access.hh" -#include "RNA_path.hh" namespace blender::animrig { diff --git a/source/blender/animrig/intern/bone_collections.cc b/source/blender/animrig/intern/bone_collections.cc index a13bc811eae..e1b6ad635dc 100644 --- a/source/blender/animrig/intern/bone_collections.cc +++ b/source/blender/animrig/intern/bone_collections.cc @@ -30,7 +30,6 @@ #include "intern/bone_collections_internal.hh" #include -#include using std::strcmp; diff --git a/source/blender/animrig/intern/bone_collections_test.cc b/source/blender/animrig/intern/bone_collections_test.cc index 1695bdb200c..f01ff5b9bd0 100644 --- a/source/blender/animrig/intern/bone_collections_test.cc +++ b/source/blender/animrig/intern/bone_collections_test.cc @@ -968,13 +968,13 @@ TEST_F(ArmatureBoneCollections, bcoll_move_to_parent__root_unroot) TEST_F(ArmatureBoneCollections, bcoll_move_to_parent__within_siblings) { /* Set up a small hierarchy. */ - auto bcoll_root_0 = ANIM_armature_bonecoll_new(&arm, "root_0"); - auto bcoll_root_1 = ANIM_armature_bonecoll_new(&arm, "root_1"); - auto bcoll_r1_child0 = ANIM_armature_bonecoll_new(&arm, "r1_child0", 1); - auto bcoll_r0_child0 = ANIM_armature_bonecoll_new(&arm, "r0_child0", 0); - auto bcoll_r0_child1 = ANIM_armature_bonecoll_new(&arm, "r0_child1", 0); - auto bcoll_r0_child2 = ANIM_armature_bonecoll_new(&arm, "r0_child2", 0); - auto bcoll_r0_child3 = ANIM_armature_bonecoll_new(&arm, "r0_child3", 0); + auto *bcoll_root_0 = ANIM_armature_bonecoll_new(&arm, "root_0"); + auto *bcoll_root_1 = ANIM_armature_bonecoll_new(&arm, "root_1"); + auto *bcoll_r1_child0 = ANIM_armature_bonecoll_new(&arm, "r1_child0", 1); + auto *bcoll_r0_child0 = ANIM_armature_bonecoll_new(&arm, "r0_child0", 0); + auto *bcoll_r0_child1 = ANIM_armature_bonecoll_new(&arm, "r0_child1", 0); + auto *bcoll_r0_child2 = ANIM_armature_bonecoll_new(&arm, "r0_child2", 0); + auto *bcoll_r0_child3 = ANIM_armature_bonecoll_new(&arm, "r0_child3", 0); ASSERT_EQ(2, arm.collection_root_count); ASSERT_EQ(7, arm.collection_array_num); @@ -1321,7 +1321,7 @@ class ArmatureBoneCollectionsTestList : public testing::Test { { std::vector actual_names; for (const BoneCollection *bcoll : arm.collections_span()) { - actual_names.push_back(bcoll->name); + actual_names.emplace_back(bcoll->name); } if (expect_names == actual_names) { diff --git a/source/blender/animrig/intern/bonecolor.cc b/source/blender/animrig/intern/bonecolor.cc index b58fa1769ae..7b1d981e330 100644 --- a/source/blender/animrig/intern/bonecolor.cc +++ b/source/blender/animrig/intern/bonecolor.cc @@ -10,6 +10,8 @@ #include "BLI_hash.hh" +#include "DNA_action_types.h" + #include "UI_resources.hh" #include @@ -25,7 +27,7 @@ BoneColor::BoneColor(const BoneColor &other) this->palette_index = other.palette_index; std::memcpy(&this->custom, &other.custom, sizeof(this->custom)); } -BoneColor::~BoneColor() {} +BoneColor::~BoneColor() = default; const ThemeWireColor *BoneColor::effective_color() const { diff --git a/source/blender/animrig/intern/evaluation.cc b/source/blender/animrig/intern/evaluation.cc index 043a45ae082..1d03a28aba3 100644 --- a/source/blender/animrig/intern/evaluation.cc +++ b/source/blender/animrig/intern/evaluation.cc @@ -4,8 +4,6 @@ #include "ANIM_evaluation.hh" -#include "RNA_access.hh" - #include "BKE_animsys.h" #include "BKE_fcurve.hh" diff --git a/source/blender/animrig/intern/evaluation_test.cc b/source/blender/animrig/intern/evaluation_test.cc index 374d9aa60e8..a6a6653f798 100644 --- a/source/blender/animrig/intern/evaluation_test.cc +++ b/source/blender/animrig/intern/evaluation_test.cc @@ -19,7 +19,6 @@ #include "RNA_prototypes.hh" #include "BLI_math_base.h" -#include "BLI_string_utf8.h" #include diff --git a/source/blender/animrig/intern/keyframing.cc b/source/blender/animrig/intern/keyframing.cc index d4ee04c3b27..8f117b2e6e8 100644 --- a/source/blender/animrig/intern/keyframing.cc +++ b/source/blender/animrig/intern/keyframing.cc @@ -195,8 +195,8 @@ void CombinedKeyingResult::generate_reports(ReportList *reports, const eReportTy BKE_report(reports, report_level, error_message.c_str()); } -const std::optional default_channel_group_for_path( - const PointerRNA *animated_struct, const StringRef prop_rna_path) +std::optional default_channel_group_for_path(const PointerRNA *animated_struct, + const StringRef prop_rna_path) { if (animated_struct->type == &RNA_PoseBone) { bPoseChannel *pose_channel = static_cast(animated_struct->data); @@ -1154,7 +1154,7 @@ CombinedKeyingResult insert_keyframes(Main *bmain, struct_pointer, prop, channel_group, - rna_path_id_to_prop->c_str(), + *rna_path_id_to_prop, nla_frame, rna_values.as_span(), insert_key_flags_adjusted, diff --git a/source/blender/animrig/intern/keyframing_auto.cc b/source/blender/animrig/intern/keyframing_auto.cc index 279f96f264e..b32fcdb3e50 100644 --- a/source/blender/animrig/intern/keyframing_auto.cc +++ b/source/blender/animrig/intern/keyframing_auto.cc @@ -11,9 +11,6 @@ #include "BKE_fcurve.hh" #include "BKE_scene.hh" -#include "BLI_listbase.h" -#include "BLI_string.h" - #include "DNA_scene_types.h" #include "RNA_access.hh" diff --git a/source/blender/animrig/intern/keyframing_test.cc b/source/blender/animrig/intern/keyframing_test.cc index f93c93c9c24..431f2c40dd0 100644 --- a/source/blender/animrig/intern/keyframing_test.cc +++ b/source/blender/animrig/intern/keyframing_test.cc @@ -27,9 +27,6 @@ #include "BLI_listbase.h" #include "BLI_string.h" -#include "BLI_string_utf8.h" - -#include #include "CLG_log.h" #include "testing/testing.h" diff --git a/source/blender/animrig/intern/nla.cc b/source/blender/animrig/intern/nla.cc index 70cb96d664a..2b001b62fa6 100644 --- a/source/blender/animrig/intern/nla.cc +++ b/source/blender/animrig/intern/nla.cc @@ -8,12 +8,6 @@ #include "ANIM_nla.hh" -#include "BKE_anim_data.hh" -#include "BKE_lib_id.hh" -#include "BKE_nla.hh" - -#include "BLI_string_utf8.h" - namespace blender::animrig::nla { bool assign_action(NlaStrip &strip, Action &action, ID &animated_id) diff --git a/source/blender/animrig/intern/nla_test.cc b/source/blender/animrig/intern/nla_test.cc index f93ecbc190c..3073b494363 100644 --- a/source/blender/animrig/intern/nla_test.cc +++ b/source/blender/animrig/intern/nla_test.cc @@ -7,7 +7,6 @@ #include "BKE_action.hh" #include "BKE_anim_data.hh" -#include "BKE_fcurve.hh" #include "BKE_idtype.hh" #include "BKE_lib_id.hh" #include "BKE_main.hh" @@ -18,9 +17,6 @@ #include "DNA_object_types.h" #include "BLI_listbase.h" -#include "BLI_string_utf8.h" - -#include #include "CLG_log.h" #include "testing/testing.h" diff --git a/source/blender/animrig/intern/pose.cc b/source/blender/animrig/intern/pose.cc index 68676e3d2ca..755218b8c41 100644 --- a/source/blender/animrig/intern/pose.cc +++ b/source/blender/animrig/intern/pose.cc @@ -32,7 +32,7 @@ void pose_apply_restore_fcurves(const Span fcurves) } /* Returns a vector of all FCurves on which the fcurve flag was modified. */ -static Vector pose_apply_disable_fcurves_for_unselected_bones( +Vector pose_apply_disable_fcurves_for_unselected_bones( bAction *action, const slot_handle_t slot_handle, const blender::bke::BoneNameSet &selected_bone_names) diff --git a/source/blender/animrig/intern/versioning_test.cc b/source/blender/animrig/intern/versioning_test.cc index f87829f063a..d0626d2e719 100644 --- a/source/blender/animrig/intern/versioning_test.cc +++ b/source/blender/animrig/intern/versioning_test.cc @@ -8,12 +8,9 @@ #include "ANIM_versioning.hh" #include "DNA_action_types.h" -#include "DNA_anim_types.h" #include "BLI_listbase.h" -#include "MEM_guardedalloc.h" - #include "testing/testing.h" namespace blender::animrig::versioning::tests { diff --git a/source/blender/animrig/intern/visualkey.cc b/source/blender/animrig/intern/visualkey.cc index 372bb28c836..11e6c173b13 100644 --- a/source/blender/animrig/intern/visualkey.cc +++ b/source/blender/animrig/intern/visualkey.cc @@ -254,7 +254,7 @@ Vector visualkey_get_values(PointerRNA *ptr, PropertyRNA *prop) if (strstr(identifier, "rotation_axis_angle")) { /* w = 0, x,y,z = 1,2,3 */ values.resize(4); - mat4_to_axis_angle(&values[1], &values[0], tmat); + mat4_to_axis_angle(values.data() + 1, values.data() + 0, tmat); return values; }