Cleanup: use EBONE_VISIBLE / EBONE_SELECTABLE to simplify checks

ANIM_bone_is_visible_editbone was being used in situations where the
intention is to check if the bone is visible to the user.

In this case, EBONE_VISIBLE makes more sense as it also accounts
for hidden bones too.
This commit is contained in:
Campbell Barton
2025-01-29 12:12:10 +11:00
parent 73f66f5a72
commit 915ba086ca
5 changed files with 9 additions and 13 deletions
@@ -1253,7 +1253,7 @@ static int armature_delete_selected_exec(bContext *C, wmOperator * /*op*/)
for (curBone = static_cast<EditBone *>(arm->edbo->first); curBone; curBone = ebone_next) {
ebone_next = curBone->next;
if (ANIM_bonecoll_is_visible_editbone(arm, curBone)) {
if (EBONE_VISIBLE(arm, curBone)) {
if (curBone->flag & BONE_SELECTED) {
if (curBone == arm->act_edbone) {
arm->act_edbone = nullptr;
@@ -1395,13 +1395,13 @@ static int armature_dissolve_selected_exec(bContext *C, wmOperator * /*op*/)
LISTBASE_FOREACH (EditBone *, ebone, arm->edbo) {
/* break connections for unseen bones */
if ((ANIM_bonecoll_is_visible_editbone(arm, ebone) &&
if ((EBONE_VISIBLE(arm, ebone) &&
(ED_armature_ebone_selectflag_get(ebone) & (BONE_TIPSEL | BONE_SELECTED))) == 0)
{
ebone->temp.ebone = nullptr;
}
if ((ANIM_bonecoll_is_visible_editbone(arm, ebone) &&
if ((EBONE_VISIBLE(arm, ebone) &&
(ED_armature_ebone_selectflag_get(ebone) & (BONE_ROOTSEL | BONE_SELECTED))) == 0)
{
if (ebone->parent && (ebone->flag & BONE_CONNECTED)) {
@@ -276,7 +276,7 @@ void armature_select_mirrored_ex(bArmature *arm, const int flag)
/* Select mirrored bones */
if (arm->flag & ARM_MIRROR_EDIT) {
LISTBASE_FOREACH (EditBone *, curBone, arm->edbo) {
if (ANIM_bonecoll_is_visible_editbone(arm, curBone)) {
if (EBONE_VISIBLE(arm, curBone)) {
if (curBone->flag & flag) {
EditBone *ebone_mirr = ED_armature_ebone_get_mirrored(arm->edbo, curBone);
if (ebone_mirr) {
@@ -303,7 +303,7 @@ void armature_tag_select_mirrored(bArmature *arm)
/* Select mirrored bones */
if (arm->flag & ARM_MIRROR_EDIT) {
LISTBASE_FOREACH (EditBone *, curBone, arm->edbo) {
if (ANIM_bonecoll_is_visible_editbone(arm, curBone)) {
if (EBONE_VISIBLE(arm, curBone)) {
if (curBone->flag & (BONE_SELECTED | BONE_ROOTSEL | BONE_TIPSEL)) {
EditBone *ebone_mirr = ED_armature_ebone_get_mirrored(arm->edbo, curBone);
if (ebone_mirr && (ebone_mirr->flag & BONE_SELECTED) == 0) {
@@ -642,7 +642,7 @@ static void tree_element_active_ebone__sel(bContext *C, bArmature *arm, EditBone
if (sel) {
arm->act_edbone = ebone;
}
if (ANIM_bone_is_visible_editbone(arm, ebone) && ((ebone->flag & BONE_UNSELECTABLE) == 0)) {
if (EBONE_SELECTABLE(arm, ebone)) {
ED_armature_ebone_select_set(ebone, sel);
}
WM_event_add_notifier(C, NC_OBJECT | ND_BONE_ACTIVE, CTX_data_edit_object(C));
@@ -1362,7 +1362,7 @@ int getTransformOrientation_ex(const Scene *scene,
zero_v3(fallback_plane);
LISTBASE_FOREACH (EditBone *, ebone, arm->edbo) {
if (ANIM_bonecoll_is_visible_editbone(arm, ebone)) {
if (EBONE_VISIBLE(arm, ebone)) {
if (ebone->flag & BONE_SELECTED) {
ED_armature_ebone_to_mat3(ebone, tmat);
add_v3_v3(r_normal, tmat[2]);
@@ -9,6 +9,7 @@
#include "BKE_armature.hh"
#include "DNA_armature_types.h"
#include "ED_armature.hh"
#include "ED_transform_snap_object_context.hh"
#include "ANIM_bone_collections.hh"
@@ -45,12 +46,7 @@ eSnapMode snapArmature(SnapObjectContext *sctx,
if (arm->edbo) {
LISTBASE_FOREACH (EditBone *, eBone, arm->edbo) {
if (ANIM_bonecoll_is_visible_editbone(arm, eBone)) {
if (eBone->flag & BONE_HIDDEN_A) {
/* Skip hidden bones. */
continue;
}
if (EBONE_VISIBLE(arm, eBone)) {
const bool is_selected = (eBone->flag & (BONE_ROOTSEL | BONE_TIPSEL)) != 0;
if (is_selected && skip_selected) {
continue;