Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
authorJoshua Leung <aligorith@gmail.com>2009-02-14 10:27:12 +0300
committerJoshua Leung <aligorith@gmail.com>2009-02-14 10:27:12 +0300
commitf3fac336880118e2bd74fa00e789b30dd734993f (patch)
treecf60cee39d5e04890c71a20026df17c17a7c9f4c /source
parent11d96459cfff85aaa232fdf935c5743a06ff538b (diff)
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.
Diffstat (limited to 'source')
-rw-r--r--source/blender/blenkernel/BKE_context.h8
-rw-r--r--source/blender/blenkernel/intern/context.c16
-rw-r--r--source/blender/editors/space_view3d/space_view3d.c62
3 files changed, 84 insertions, 2 deletions
diff --git a/source/blender/blenkernel/BKE_context.h b/source/blender/blenkernel/BKE_context.h
index 5af97a7d8d5..869388f9761 100644
--- a/source/blender/blenkernel/BKE_context.h
+++ b/source/blender/blenkernel/BKE_context.h
@@ -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 */
diff --git a/source/blender/blenkernel/intern/context.c b/source/blender/blenkernel/intern/context.c
index 714965102d4..07937d0a901 100644
--- a/source/blender/blenkernel/intern/context.c
+++ b/source/blender/blenkernel/intern/context.c
@@ -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)
diff --git a/source/blender/editors/space_view3d/space_view3d.c b/source/blender/editors/space_view3d/space_view3d.c
index 45e9245d46a..98b6fa98e7e 100644
--- a/source/blender/editors/space_view3d/space_view3d.c
+++ b/source/blender/editors/space_view3d/space_view3d.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;