diff options
author | Campbell Barton <ideasman42@gmail.com> | 2018-04-18 19:32:32 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2018-04-18 19:56:27 +0300 |
commit | 602f0bc2d47d991672f7b79128f2ed677babb8da (patch) | |
tree | 25575b999cd1a9e27e9ec74f2eaeb33d8c49ea60 /source/blender/editors | |
parent | 42b0cd1ea090a0693f25ccde0ce895671df12292 (diff) |
Use macros for looping over pose bones
Diffstat (limited to 'source/blender/editors')
-rw-r--r-- | source/blender/editors/screen/screen_context.c | 52 |
1 files changed, 15 insertions, 37 deletions
diff --git a/source/blender/editors/screen/screen_context.c b/source/blender/editors/screen/screen_context.c index d51abee2b04..85087d58276 100644 --- a/source/blender/editors/screen/screen_context.c +++ b/source/blender/editors/screen/screen_context.c @@ -308,26 +308,17 @@ int ed_screen_context(const bContext *C, const char *member, bContextDataResult } else if (CTX_data_equals(member, "visible_pose_bones")) { Object *obpose = BKE_object_pose_armature_get(obact); - bArmature *arm = (obpose) ? obpose->data : NULL; - bPoseChannel *pchan; - - if (obpose && obpose->pose && arm) { + if (obpose && obpose->pose && obpose->data) { if (obpose != obact) { - for (pchan = obpose->pose->chanbase.first; pchan; pchan = pchan->next) { - /* ensure that PoseChannel is on visible layer and is not hidden in PoseMode */ - if (PBONE_VISIBLE(arm, pchan->bone)) { - CTX_data_list_add(result, &obpose->id, &RNA_PoseBone, pchan); - } - } + FOREACH_PCHAN_VISIBLE_IN_OBJECT_BEGIN (obpose, pchan) { + CTX_data_list_add(result, &obpose->id, &RNA_PoseBone, pchan); + } FOREACH_PCHAN_SELECTED_IN_OBJECT_END; } else if (obact->mode & OB_MODE_POSE) { - FOREACH_OBJECT_IN_MODE_BEGIN (view_layer, obact->mode, ob_iter) { - for (pchan = ob_iter->pose->chanbase.first; pchan; pchan = pchan->next) { - /* ensure that PoseChannel is on visible layer and is not hidden in PoseMode */ - if (PBONE_VISIBLE(arm, pchan->bone)) { - CTX_data_list_add(result, &ob_iter->id, &RNA_PoseBone, pchan); - } - } + FOREACH_OBJECT_IN_MODE_BEGIN (view_layer, OB_MODE_POSE, ob_iter) { + FOREACH_PCHAN_VISIBLE_IN_OBJECT_BEGIN (ob_iter, pchan) { + CTX_data_list_add(result, &ob_iter->id, &RNA_PoseBone, pchan); + } FOREACH_PCHAN_VISIBLE_IN_OBJECT_END; } FOREACH_OBJECT_IN_MODE_END; } CTX_data_type_set(result, CTX_DATA_TYPE_COLLECTION); @@ -336,30 +327,17 @@ int ed_screen_context(const bContext *C, const char *member, bContextDataResult } else if (CTX_data_equals(member, "selected_pose_bones")) { Object *obpose = BKE_object_pose_armature_get(obact); - bArmature *arm = (obpose) ? obpose->data : NULL; - bPoseChannel *pchan; - - if (obpose && obpose->pose && arm) { + if (obpose && obpose->pose && obpose->data) { if (obpose != obact) { - /* TODO(de-duplicate!) */ - for (pchan = obpose->pose->chanbase.first; pchan; pchan = pchan->next) { - /* ensure that PoseChannel is on visible layer and is not hidden in PoseMode */ - if (PBONE_VISIBLE(arm, pchan->bone)) { - if (pchan->bone->flag & BONE_SELECTED) - CTX_data_list_add(result, &obpose->id, &RNA_PoseBone, pchan); - } - } + FOREACH_PCHAN_SELECTED_IN_OBJECT_BEGIN (obpose, pchan) { + CTX_data_list_add(result, &obpose->id, &RNA_PoseBone, pchan); + } FOREACH_PCHAN_SELECTED_IN_OBJECT_END; } else if (obact->mode & OB_MODE_POSE) { - /* TODO(de-duplicate!) */ FOREACH_OBJECT_IN_MODE_BEGIN (view_layer, OB_MODE_POSE, ob_iter) { - for (pchan = ob_iter->pose->chanbase.first; pchan; pchan = pchan->next) { - /* ensure that PoseChannel is on visible layer and is not hidden in PoseMode */ - if (PBONE_VISIBLE(arm, pchan->bone)) { - if (pchan->bone->flag & BONE_SELECTED) - CTX_data_list_add(result, &ob_iter->id, &RNA_PoseBone, pchan); - } - } + FOREACH_PCHAN_SELECTED_IN_OBJECT_BEGIN (ob_iter, pchan) { + CTX_data_list_add(result, &ob_iter->id, &RNA_PoseBone, pchan); + } FOREACH_PCHAN_SELECTED_IN_OBJECT_END; } FOREACH_OBJECT_IN_MODE_END; } CTX_data_type_set(result, CTX_DATA_TYPE_COLLECTION); |