From b690e9d4dbfdbadcb2b4ecc8bbb9b56a8c08d157 Mon Sep 17 00:00:00 2001 From: Christoph Lendenfeld Date: Tue, 20 May 2025 12:58:53 +0200 Subject: [PATCH] Anim: Use bone_is_visible_... functions This is mostly a non-functional change except for * `overlay_armature.cc` was drawing relationship lines to bone hidden by collection logic (except that doesn't seem to work anyway, relationship lines are drawn regardless) * `transform_snap_armature.cc` it was possible to snap to pose bones hidden by collection logic. I assumed those to be oversights so I changed them in this PR. This does *not* remove all usages of `BONE_HIDDEN_P` and `BONE_HIDDEN_A`. Some direct access is required in the UI and for cases where we explicitly don't want to check collection visibility. Part of #138482 Pull Request: https://projects.blender.org/blender/blender/pulls/139151 --- .../blender/draw/engines/overlay/overlay_armature.cc | 2 +- source/blender/editors/animation/anim_filter.cc | 9 +++------ source/blender/editors/animation/keyframing.cc | 10 +++------- .../transform/transform_snap_object_armature.cc | 2 +- 4 files changed, 8 insertions(+), 15 deletions(-) diff --git a/source/blender/draw/engines/overlay/overlay_armature.cc b/source/blender/draw/engines/overlay/overlay_armature.cc index 075862b8cfe..9ff37650da3 100644 --- a/source/blender/draw/engines/overlay/overlay_armature.cc +++ b/source/blender/draw/engines/overlay/overlay_armature.cc @@ -2042,7 +2042,7 @@ void Armatures::draw_armature_pose(Armatures::DrawContext *ctx) } eBone_Flag boneflag = eBone_Flag(bone->flag); - if (bone->parent && (bone->parent->flag & BONE_HIDDEN_P)) { + if (bone->parent && !blender::animrig::bone_is_visible(&arm, bone->parent)) { /* Avoid drawing connection line to hidden parent. */ boneflag &= ~BONE_CONNECTED; } diff --git a/source/blender/editors/animation/anim_filter.cc b/source/blender/editors/animation/anim_filter.cc index c0e1141ea84..b4c6200c826 100644 --- a/source/blender/editors/animation/anim_filter.cc +++ b/source/blender/editors/animation/anim_filter.cc @@ -91,6 +91,7 @@ #include "SEQ_utils.hh" #include "ANIM_action.hh" +#include "ANIM_armature.hh" #include "ANIM_bone_collections.hh" #include "anim_intern.hh" @@ -987,12 +988,8 @@ static bool skip_fcurve_selected_data(bAnimContext *ac, if (skip_hidden) { bArmature *arm = static_cast(ob->data); - /* skipping - not visible on currently visible layers */ - if (!ANIM_bonecoll_is_visible_pchan(arm, pchan)) { - return true; - } - /* skipping - is currently hidden */ - if (pchan->bone->flag & BONE_HIDDEN_P) { + /* Skipping - is currently hidden. */ + if (!blender::animrig::bone_is_visible_pchan(arm, pchan)) { return true; } } diff --git a/source/blender/editors/animation/keyframing.cc b/source/blender/editors/animation/keyframing.cc index 5bbcd254511..a7377d3f778 100644 --- a/source/blender/editors/animation/keyframing.cc +++ b/source/blender/editors/animation/keyframing.cc @@ -45,6 +45,7 @@ #include "ANIM_action.hh" #include "ANIM_action_iterators.hh" #include "ANIM_animdata.hh" +#include "ANIM_armature.hh" #include "ANIM_bone_collections.hh" #include "ANIM_driver.hh" #include "ANIM_fcurve.hh" @@ -809,15 +810,10 @@ static bool can_delete_key(FCurve *fcu, Object *ob, ReportList *reports) /* skip if bone is not selected */ if ((pchan) && (pchan->bone)) { - /* bones are only selected/editable if visible... */ bArmature *arm = static_cast(ob->data); - /* skipping - not visible on currently visible layers */ - if (!ANIM_bonecoll_is_visible_pchan(arm, pchan)) { - return false; - } - /* skipping - is currently hidden */ - if (pchan->bone->flag & BONE_HIDDEN_P) { + /* Invisible bones should not be modified. */ + if (!blender::animrig::bone_is_visible_pchan(arm, pchan)) { return false; } diff --git a/source/blender/editors/transform/transform_snap_object_armature.cc b/source/blender/editors/transform/transform_snap_object_armature.cc index b0245958a6a..a2ebdad5c60 100644 --- a/source/blender/editors/transform/transform_snap_object_armature.cc +++ b/source/blender/editors/transform/transform_snap_object_armature.cc @@ -65,7 +65,7 @@ eSnapMode snapArmature(SnapObjectContext *sctx, else if (ob_eval->pose && ob_eval->pose->chanbase.first) { LISTBASE_FOREACH (bPoseChannel *, pchan, &ob_eval->pose->chanbase) { Bone *bone = pchan->bone; - if (!bone || (bone->flag & BONE_HIDDEN_P)) { + if (!bone || !blender::animrig::bone_is_visible_pchan(arm, pchan)) { /* Skip hidden bones. */ continue; }