2.5 - Adding context iterators for visible/editable (selection is irrelevant) for bones and pose-channels.
I'm not totally sure that these are needed, though it does make some tools simpler.
This commit is contained in:
@@ -91,6 +91,11 @@ enum {
|
||||
|
||||
CTX_DATA_ACTIVE_BONE,
|
||||
CTX_DATA_ACTIVE_PCHAN,
|
||||
|
||||
CTX_DATA_VISIBLE_BONES,
|
||||
CTX_DATA_EDITABLE_BONES,
|
||||
CTX_DATA_VISIBLE_PCHANS,
|
||||
CTX_DATA_EDITABLE_PCHANS,
|
||||
};
|
||||
|
||||
typedef int bContextDataMember;
|
||||
@@ -197,9 +202,12 @@ int CTX_data_selected_nodes(const bContext *C, ListBase *list);
|
||||
struct EditBone *CTX_data_active_bone(const bContext *C);
|
||||
int CTX_data_selected_bones(const bContext *C, ListBase *list);
|
||||
int CTX_data_selected_editable_bones(const bContext *C, ListBase *list);
|
||||
int CTX_data_visible_bones(const bContext *C, ListBase *list);
|
||||
int CTX_data_editable_bones(const bContext *C, ListBase *list);
|
||||
|
||||
struct bPoseChannel *CTX_data_active_pchan(const bContext *C);
|
||||
int CTX_data_selected_pchans(const bContext *C, ListBase *list);
|
||||
int CTX_data_visible_pchans(const bContext *C, ListBase *list);
|
||||
|
||||
/* Data Evaluation Context */
|
||||
|
||||
|
||||
@@ -459,6 +459,16 @@ int CTX_data_selected_editable_bones(const bContext *C, ListBase *list)
|
||||
return ctx_data_collection_get(C, CTX_DATA_SELECTED_EDITABLE_BONES, list);
|
||||
}
|
||||
|
||||
int CTX_data_visible_bones(const bContext *C, ListBase *list)
|
||||
{
|
||||
return ctx_data_collection_get(C, CTX_DATA_VISIBLE_BONES, list);
|
||||
}
|
||||
|
||||
int CTX_data_editable_bones(const bContext *C, ListBase *list)
|
||||
{
|
||||
return ctx_data_collection_get(C, CTX_DATA_EDITABLE_BONES, list);
|
||||
}
|
||||
|
||||
struct bPoseChannel *CTX_data_active_pchan(const bContext *C)
|
||||
{
|
||||
return ctx_data_pointer_get(C, CTX_DATA_ACTIVE_PCHAN);
|
||||
@@ -469,6 +479,12 @@ int CTX_data_selected_pchans(const bContext *C, ListBase *list)
|
||||
return ctx_data_collection_get(C, CTX_DATA_SELECTED_PCHANS, list);
|
||||
}
|
||||
|
||||
int CTX_data_visible_pchans(const bContext *C, ListBase *list)
|
||||
{
|
||||
return ctx_data_collection_get(C, CTX_DATA_VISIBLE_PCHANS, list);
|
||||
}
|
||||
|
||||
|
||||
/* data evaluation */
|
||||
|
||||
float CTX_eval_frame(const bContext *C)
|
||||
|
||||
@@ -557,16 +557,58 @@ static int view3d_context(const bContext *C, bContextDataMember member, bContext
|
||||
if(scene->basact && (scene->basact->lay & v3d->lay))
|
||||
if((scene->basact->object->restrictflag & OB_RESTRICT_VIEW)==0)
|
||||
CTX_data_pointer_set(result, scene->basact);
|
||||
|
||||
|
||||
return 1;
|
||||
}
|
||||
else if(member == CTX_DATA_ACTIVE_OBJECT) {
|
||||
if(scene->basact && (scene->basact->lay & v3d->lay))
|
||||
if((scene->basact->object->restrictflag & OB_RESTRICT_VIEW)==0)
|
||||
CTX_data_pointer_set(result, scene->basact->object);
|
||||
|
||||
|
||||
return 1;
|
||||
}
|
||||
else if(ELEM(member, CTX_DATA_VISIBLE_BONES, CTX_DATA_EDITABLE_BONES)) {
|
||||
Object *obedit= scene->obedit; // XXX get from context?
|
||||
bArmature *arm= (obedit) ? obedit->data : NULL;
|
||||
EditBone *ebone, *flipbone=NULL;
|
||||
|
||||
if (arm && arm->edbo) {
|
||||
/* Attention: X-Axis Mirroring is also handled here... */
|
||||
for (ebone= arm->edbo->first; ebone; ebone= ebone->next) {
|
||||
/* first and foremost, bone must be visible and selected */
|
||||
if (EBONE_VISIBLE(arm, ebone)) {
|
||||
/* Get 'x-axis mirror equivalent' bone if the X-Axis Mirroring option is enabled
|
||||
* so that most users of this data don't need to explicitly check for it themselves.
|
||||
*
|
||||
* We need to make sure that these mirrored copies are not selected, otherwise some
|
||||
* bones will be operated on twice.
|
||||
*/
|
||||
if (arm->flag & ARM_MIRROR_EDIT)
|
||||
flipbone = ED_armature_bone_get_mirrored(arm->edbo, ebone);
|
||||
|
||||
/* if we're filtering for editable too, use the check for that instead, as it has selection check too */
|
||||
if (member == CTX_DATA_EDITABLE_BONES) {
|
||||
/* only selected + editable */
|
||||
if (EBONE_EDITABLE(ebone)) {
|
||||
CTX_data_list_add(result, ebone);
|
||||
|
||||
if ((flipbone) && !(flipbone->flag & BONE_SELECTED))
|
||||
CTX_data_list_add(result, flipbone);
|
||||
}
|
||||
}
|
||||
else {
|
||||
/* only include bones if visible */
|
||||
CTX_data_list_add(result, ebone);
|
||||
|
||||
if ((flipbone) && EBONE_VISIBLE(arm, flipbone)==0)
|
||||
CTX_data_list_add(result, flipbone);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
else if(ELEM(member, CTX_DATA_SELECTED_BONES, CTX_DATA_SELECTED_EDITABLE_BONES)) {
|
||||
Object *obedit= scene->obedit; // XXX get from context?
|
||||
bArmature *arm= (obedit) ? obedit->data : NULL;
|
||||
@@ -609,6 +651,22 @@ static int view3d_context(const bContext *C, bContextDataMember member, bContext
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
else if(member == CTX_DATA_VISIBLE_PCHANS) {
|
||||
Object *obact= OBACT;
|
||||
bArmature *arm= (obact) ? obact->data : NULL;
|
||||
bPoseChannel *pchan;
|
||||
|
||||
if (obact && arm) {
|
||||
for (pchan= obact->pose->chanbase.first; pchan; pchan= pchan->next) {
|
||||
/* ensure that PoseChannel is on visible layer and is not hidden in PoseMode */
|
||||
if ((pchan->bone) && (arm->layer & pchan->bone->layer) && !(pchan->bone->flag & BONE_HIDDEN_P)) {
|
||||
CTX_data_list_add(result, pchan);
|
||||
}
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
else if(member == CTX_DATA_SELECTED_PCHANS) {
|
||||
Object *obact= OBACT;
|
||||
bArmature *arm= (obact) ? obact->data : NULL;
|
||||
|
||||
Reference in New Issue
Block a user