Animation: add PBONE_SELECTED macro
Add `PBONE_SELECTED` macro to determine selection state of bones, while also taking visibility into account.
This commit is contained in:
@@ -342,6 +342,8 @@ void BKE_pchan_bbone_deform_segment_index(const struct bPoseChannel *pchan,
|
||||
#define PBONE_SELECTABLE(arm, bone) \
|
||||
(PBONE_VISIBLE(arm, bone) && !((bone)->flag & BONE_UNSELECTABLE))
|
||||
|
||||
#define PBONE_SELECTED(arm, bone) (((bone)->flag & BONE_SELECTED) & PBONE_VISIBLE(arm, bone))
|
||||
|
||||
/* context.selected_pose_bones */
|
||||
#define FOREACH_PCHAN_SELECTED_IN_OBJECT_BEGIN(_ob, _pchan) \
|
||||
for (bPoseChannel *_pchan = (_ob)->pose->chanbase.first; _pchan; _pchan = _pchan->next) { \
|
||||
|
||||
@@ -39,7 +39,7 @@ namespace {
|
||||
using BoneNameSet = blender::Set<std::string>;
|
||||
|
||||
// Forward declarations.
|
||||
BoneNameSet pose_apply_find_selected_bones(const bPose *pose);
|
||||
BoneNameSet pose_apply_find_selected_bones(const bArmature *armature, const bPose *pose);
|
||||
void pose_apply_disable_fcurves_for_unselected_bones(bAction *action,
|
||||
const BoneNameSet &selected_bone_names);
|
||||
void pose_apply_restore_fcurves(bAction *action);
|
||||
@@ -54,7 +54,8 @@ void BKE_pose_apply_action(struct Object *ob,
|
||||
return;
|
||||
}
|
||||
|
||||
const BoneNameSet selected_bone_names = pose_apply_find_selected_bones(pose);
|
||||
const bArmature *armature = (bArmature *)ob->data;
|
||||
const BoneNameSet selected_bone_names = pose_apply_find_selected_bones(armature, pose);
|
||||
const bool limit_to_selected_bones = !selected_bone_names.is_empty();
|
||||
|
||||
if (limit_to_selected_bones) {
|
||||
@@ -74,15 +75,14 @@ void BKE_pose_apply_action(struct Object *ob,
|
||||
}
|
||||
|
||||
namespace {
|
||||
BoneNameSet pose_apply_find_selected_bones(const bPose *pose)
|
||||
BoneNameSet pose_apply_find_selected_bones(const bArmature *armature, const bPose *pose)
|
||||
{
|
||||
BoneNameSet selected_bone_names;
|
||||
bool all_bones_selected = true;
|
||||
bool no_bones_selected = true;
|
||||
|
||||
LISTBASE_FOREACH (bPoseChannel *, pchan, &pose->chanbase) {
|
||||
const bool is_selected = (pchan->bone->flag & BONE_SELECTED) != 0 &&
|
||||
(pchan->bone->flag & BONE_HIDDEN_P) == 0;
|
||||
const bool is_selected = PBONE_SELECTED(armature, pchan->bone);
|
||||
all_bones_selected &= is_selected;
|
||||
no_bones_selected &= !is_selected;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user