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
diff options
context:
space:
mode:
authorJoshua Leung <aligorith@gmail.com>2009-10-12 15:27:34 +0400
committerJoshua Leung <aligorith@gmail.com>2009-10-12 15:27:34 +0400
commit237cd688aaead5592393db58cf2e39e2ab3ce9b2 (patch)
tree9a03690d8ea68f67a4d552ce7e4db7650f31c3a2 /source/blender/editors/animation/anim_filter.c
parentb4a113669d8fecad28369b3d777aa285addacf46 (diff)
Animation Editors: 'Only Selected' filtering option now works on Pose Channels too
* Only F-Curves and Drivers that affect selected bones will be visible when this happens. * Moved the function to grab text within a pair of "" following some prefix to blenlib.
Diffstat (limited to 'source/blender/editors/animation/anim_filter.c')
-rw-r--r--source/blender/editors/animation/anim_filter.c123
1 files changed, 81 insertions, 42 deletions
diff --git a/source/blender/editors/animation/anim_filter.c b/source/blender/editors/animation/anim_filter.c
index 13b050e4497..6b953d2460d 100644
--- a/source/blender/editors/animation/anim_filter.c
+++ b/source/blender/editors/animation/anim_filter.c
@@ -77,6 +77,7 @@
#include "BLI_blenlib.h"
#include "BKE_animsys.h"
+#include "BKE_action.h"
#include "BKE_context.h"
#include "BKE_global.h"
#include "BKE_key.h"
@@ -676,7 +677,7 @@ bAnimListElem *make_new_animlistelem (void *data, short datatype, void *owner, s
/* ----------------------------------------- */
-static int animdata_filter_fcurves (ListBase *anim_data, FCurve *first, bActionGroup *grp, void *owner, short ownertype, int filter_mode, ID *owner_id)
+static int animdata_filter_fcurves (ListBase *anim_data, bDopeSheet *ads, FCurve *first, bActionGroup *grp, void *owner, short ownertype, int filter_mode, ID *owner_id)
{
bAnimListElem *ale = NULL;
FCurve *fcu;
@@ -686,6 +687,35 @@ static int animdata_filter_fcurves (ListBase *anim_data, FCurve *first, bActionG
* NOTE: we need to check if the F-Curves belong to the same group, as this gets called for groups too...
*/
for (fcu= first; ((fcu) && (fcu->grp==grp)); fcu= fcu->next) {
+ /* special exception for Pose-Channel Based F-Curves:
+ * - the 'Only Selected' data filter should be applied to Pose-Channel data too, but those are
+ * represented as F-Curves. The way the filter for objects worked was to be the first check
+ * after 'normal' visibility, so this is done first here too...
+ * - we currently use an 'approximate' method for getting these F-Curves that doesn't require
+ * carefully checking the entire path
+ * - this will also affect things like Drivers, and also works for Bone Constraints
+ */
+ if ( ((ads) && (ads->filterflag & ADS_FILTER_ONLYSEL)) &&
+ ((owner_id) && (GS(owner_id->name) == ID_OB)) )
+ {
+ Object *ob= (Object *)owner_id;
+
+ /* only consider if F-Curve involves pose_channels */
+ if ((fcu->rna_path) && strstr(fcu->rna_path, "pose_channels")) {
+ bPoseChannel *pchan;
+ char *bone_name;
+
+ /* get bone-name, and check if this bone is selected */
+ bone_name= BLI_getQuotedStr(fcu->rna_path, "pose_channels[");
+ pchan= get_pose_channel(ob->pose, bone_name);
+ if (bone_name) MEM_freeN(bone_name);
+
+ /* can only add this F-Curve if it is selected */
+ if ((pchan) && (pchan->bone) && (pchan->bone->flag & BONE_SELECTED)==0)
+ continue;
+ }
+ }
+
/* only include if visible (Graph Editor check, not channels check) */
if (!(filter_mode & ANIMFILTER_CURVEVISIBLE) || (fcu->flag & FCURVE_VISIBLE)) {
/* only work with this channel and its subchannels if it is editable */
@@ -710,7 +740,7 @@ static int animdata_filter_fcurves (ListBase *anim_data, FCurve *first, bActionG
return items;
}
-static int animdata_filter_action (ListBase *anim_data, bAction *act, int filter_mode, void *owner, short ownertype, ID *owner_id)
+static int animdata_filter_action (ListBase *anim_data, bDopeSheet *ads, bAction *act, int filter_mode, void *owner, short ownertype, ID *owner_id)
{
bAnimListElem *ale=NULL;
bActionGroup *agrp;
@@ -718,16 +748,21 @@ static int animdata_filter_action (ListBase *anim_data, bAction *act, int filter
int items = 0;
/* loop over groups */
- // XXX in future, we need to be prepared for nestled groups...
+ // TODO: in future, should we expect to need nested groups?
for (agrp= act->groups.first; agrp; agrp= agrp->next) {
+ ListBase tmp_channels = {NULL, NULL};
+ short grp_channel=0;
+ int tmp_items = 0;
+
+
/* add this group as a channel first */
if ((filter_mode & ANIMFILTER_CHANNELS) || !(filter_mode & ANIMFILTER_CURVESONLY)) {
/* check if filtering by selection */
if ( ANIMCHANNEL_SELOK(SEL_AGRP(agrp)) ) {
ale= make_new_animlistelem(agrp, ANIMTYPE_GROUP, NULL, ANIMTYPE_NONE, owner_id);
if (ale) {
- BLI_addtail(anim_data, ale);
- items++;
+ BLI_addtail(&tmp_channels, ale);
+ grp_channel=1;
}
}
}
@@ -758,28 +793,30 @@ static int animdata_filter_action (ListBase *anim_data, bAction *act, int filter
{
if (!(filter_mode & ANIMFILTER_FOREDIT) || EDITABLE_AGRP(agrp)) {
// XXX the 'owner' info here needs review...
- items += animdata_filter_fcurves(anim_data, agrp->channels.first, agrp, owner, ownertype, filter_mode, owner_id);
-
- /* remove group from filtered list if last element is group
- * (i.e. only if group had channels, which were all hidden)
- */
- // XXX this is really hacky... it should be fixed in a much more elegant way!
- if ( (ale) && (anim_data->last == ale) &&
- (ale->data == agrp) && (agrp->channels.first) )
- {
- BLI_freelinkN(anim_data, ale);
- items--;
- }
+ tmp_items += animdata_filter_fcurves(&tmp_channels, ads, agrp->channels.first, agrp, owner, ownertype, filter_mode, owner_id);
}
}
}
}
+
+ /* check group had any F-Curves visible */
+ // TODO: this needs more work to truly work so that closed group with no visible channels, and visible group with visible channels are differentiated between
+ if (/*tmp_items*/1) {
+ /* add the temp channels to the list of filtered channels */
+ addlisttolist(anim_data, &tmp_channels);
+
+ /* increase the counts as appropriate */
+ items += tmp_items + grp_channel;
+ }
+ else {
+ BLI_freelistN(&tmp_channels);
+ }
}
/* loop over un-grouped F-Curves (only if we're not only considering those channels in the animive group) */
if (!(filter_mode & ANIMFILTER_ACTGROUPED)) {
// XXX the 'owner' info here needs review...
- items += animdata_filter_fcurves(anim_data, (lastchan)?(lastchan->next):(act->curves.first), NULL, owner, ownertype, filter_mode, owner_id);
+ items += animdata_filter_fcurves(anim_data, ads, (lastchan)?(lastchan->next):(act->curves.first), NULL, owner, ownertype, filter_mode, owner_id);
}
/* return the number of items added to the list */
@@ -794,7 +831,7 @@ static int animdata_filter_action (ListBase *anim_data, bAction *act, int filter
* - for normal filtering (i.e. for editing), we only need the NLA-tracks but they can be in 'normal' evaluation
* order, i.e. first to last. Otherwise, some tools may get screwed up.
*/
-static int animdata_filter_nla (ListBase *anim_data, AnimData *adt, int filter_mode, void *owner, short ownertype, ID *owner_id)
+static int animdata_filter_nla (ListBase *anim_data, bDopeSheet *ads, AnimData *adt, int filter_mode, void *owner, short ownertype, ID *owner_id)
{
bAnimListElem *ale;
NlaTrack *nlt;
@@ -996,9 +1033,9 @@ static int animdata_filter_dopesheet_mats (ListBase *anim_data, bDopeSheet *ads,
if (FILTER_MAT_OBJD(ma) || (filter_mode & ANIMFILTER_CURVESONLY)) {
ANIMDATA_FILTER_CASES(ma,
{ /* AnimData blocks - do nothing... */ },
- items += animdata_filter_nla(anim_data, ma->adt, filter_mode, ma, ANIMTYPE_DSMAT, (ID *)ma);,
- items += animdata_filter_fcurves(anim_data, ma->adt->drivers.first, NULL, ma, ANIMTYPE_DSMAT, filter_mode, (ID *)ma);,
- items += animdata_filter_action(anim_data, ma->adt->action, filter_mode, ma, ANIMTYPE_DSMAT, (ID *)ma);)
+ items += animdata_filter_nla(anim_data, ads, ma->adt, filter_mode, ma, ANIMTYPE_DSMAT, (ID *)ma);,
+ items += animdata_filter_fcurves(anim_data, ads, ma->adt->drivers.first, NULL, ma, ANIMTYPE_DSMAT, filter_mode, (ID *)ma);,
+ items += animdata_filter_action(anim_data, ads, ma->adt->action, filter_mode, ma, ANIMTYPE_DSMAT, (ID *)ma);)
}
}
}
@@ -1056,9 +1093,9 @@ static int animdata_filter_dopesheet_particles (ListBase *anim_data, bDopeSheet
if (FILTER_PART_OBJD(psys->part) || (filter_mode & ANIMFILTER_CURVESONLY)) {
ANIMDATA_FILTER_CASES(psys->part,
{ /* AnimData blocks - do nothing... */ },
- items += animdata_filter_nla(anim_data, psys->part->adt, filter_mode, psys->part, ANIMTYPE_DSPART, (ID *)psys->part);,
- items += animdata_filter_fcurves(anim_data, psys->part->adt->drivers.first, NULL, psys->part, ANIMTYPE_DSPART, filter_mode, (ID *)psys->part);,
- items += animdata_filter_action(anim_data, psys->part->adt->action, filter_mode, psys->part, ANIMTYPE_DSPART, (ID *)psys->part);)
+ items += animdata_filter_nla(anim_data, ads, psys->part->adt, filter_mode, psys->part, ANIMTYPE_DSPART, (ID *)psys->part);,
+ items += animdata_filter_fcurves(anim_data, ads, psys->part->adt->drivers.first, NULL, psys->part, ANIMTYPE_DSPART, filter_mode, (ID *)psys->part);,
+ items += animdata_filter_action(anim_data, ads, psys->part->adt->action, filter_mode, psys->part, ANIMTYPE_DSPART, (ID *)psys->part);)
}
}
}
@@ -1138,9 +1175,9 @@ static int animdata_filter_dopesheet_obdata (ListBase *anim_data, bDopeSheet *ad
/* filtering for channels - nla, drivers, keyframes */
ANIMDATA_FILTER_CASES(iat,
{ /* AnimData blocks - do nothing... */ },
- items+= animdata_filter_nla(anim_data, iat->adt, filter_mode, iat, type, (ID *)iat);,
- items+= animdata_filter_fcurves(anim_data, adt->drivers.first, NULL, iat, type, filter_mode, (ID *)iat);,
- items += animdata_filter_action(anim_data, iat->adt->action, filter_mode, iat, type, (ID *)iat);)
+ items+= animdata_filter_nla(anim_data, ads, iat->adt, filter_mode, iat, type, (ID *)iat);,
+ items+= animdata_filter_fcurves(anim_data, ads, adt->drivers.first, NULL, iat, type, filter_mode, (ID *)iat);,
+ items += animdata_filter_action(anim_data, ads, iat->adt->action, filter_mode, iat, type, (ID *)iat);)
}
/* return the number of items added to the list */
@@ -1182,7 +1219,7 @@ static int animdata_filter_dopesheet_ob (ListBase *anim_data, bDopeSheet *ads, B
{ /* AnimData blocks - do nothing... */ },
{ /* nla */
/* add NLA tracks */
- items += animdata_filter_nla(anim_data, adt, filter_mode, ob, ANIMTYPE_OBJECT, (ID *)ob);
+ items += animdata_filter_nla(anim_data, ads, adt, filter_mode, ob, ANIMTYPE_OBJECT, (ID *)ob);
},
{ /* drivers */
/* include drivers-expand widget? */
@@ -1197,7 +1234,7 @@ static int animdata_filter_dopesheet_ob (ListBase *anim_data, bDopeSheet *ads, B
/* add F-Curve channels (drivers are F-Curves) */
if (EXPANDED_DRVD(adt) || !(filter_mode & ANIMFILTER_CHANNELS)) {
// need to make the ownertype normal object here... (maybe type should be a separate one for clarity?)
- items += animdata_filter_fcurves(anim_data, adt->drivers.first, NULL, ob, ANIMTYPE_OBJECT, filter_mode, (ID *)ob);
+ items += animdata_filter_fcurves(anim_data, ads, adt->drivers.first, NULL, ob, ANIMTYPE_OBJECT, filter_mode, (ID *)ob);
}
},
{ /* action (keyframes) */
@@ -1213,7 +1250,7 @@ static int animdata_filter_dopesheet_ob (ListBase *anim_data, bDopeSheet *ads, B
/* add F-Curve channels? */
if (EXPANDED_ACTC(adt->action) || !(filter_mode & ANIMFILTER_CHANNELS)) {
// need to make the ownertype normal object here... (maybe type should be a separate one for clarity?)
- items += animdata_filter_action(anim_data, adt->action, filter_mode, ob, ANIMTYPE_OBJECT, (ID *)ob);
+ items += animdata_filter_action(anim_data, ads, adt->action, filter_mode, ob, ANIMTYPE_OBJECT, (ID *)ob);
}
}
);
@@ -1240,7 +1277,7 @@ static int animdata_filter_dopesheet_ob (ListBase *anim_data, bDopeSheet *ads, B
/* add NLA tracks - only if expanded or so */
if (FILTER_SKE_OBJD(key) || (filter_mode & ANIMFILTER_CURVESONLY))
- items += animdata_filter_nla(anim_data, adt, filter_mode, ob, ANIMTYPE_OBJECT, (ID *)ob);
+ items += animdata_filter_nla(anim_data, ads, adt, filter_mode, ob, ANIMTYPE_OBJECT, (ID *)ob);
},
{ /* drivers */
/* include shapekey-expand widget? */
@@ -1254,7 +1291,7 @@ static int animdata_filter_dopesheet_ob (ListBase *anim_data, bDopeSheet *ads, B
/* add channels */
if (FILTER_SKE_OBJD(key) || (filter_mode & ANIMFILTER_CURVESONLY)) {
- items += animdata_filter_fcurves(anim_data, adt->drivers.first, NULL, key, ANIMTYPE_DSSKEY, filter_mode, (ID *)key);
+ items += animdata_filter_fcurves(anim_data, ads, adt->drivers.first, NULL, key, ANIMTYPE_DSSKEY, filter_mode, (ID *)key);
}
},
{ /* action (keyframes) */
@@ -1272,7 +1309,7 @@ static int animdata_filter_dopesheet_ob (ListBase *anim_data, bDopeSheet *ads, B
/* add channels */
if (FILTER_SKE_OBJD(key) || (filter_mode & ANIMFILTER_CURVESONLY)) {
- items += animdata_filter_action(anim_data, adt->action, filter_mode, key, ANIMTYPE_DSSKEY, (ID *)key);
+ items += animdata_filter_action(anim_data, ads, adt->action, filter_mode, key, ANIMTYPE_DSSKEY, (ID *)key);
}
}
);
@@ -1384,14 +1421,14 @@ static int animdata_filter_dopesheet_scene (ListBase *anim_data, bDopeSheet *ads
if ( (EXPANDED_SCEC(sce) == 0) && !(filter_mode & (ANIMFILTER_CURVESONLY|ANIMFILTER_NLATRACKS)) )
return items;
- /* Action, Drivers, or NLA for Scene */
+ /* Action, Drivers, or NLA for Scene */
if ((ads->filterflag & ADS_FILTER_NOSCE) == 0) {
adt= sce->adt;
ANIMDATA_FILTER_CASES(sce,
{ /* AnimData blocks - do nothing... */ },
{ /* nla */
/* add NLA tracks */
- items += animdata_filter_nla(anim_data, adt, filter_mode, sce, ANIMTYPE_SCENE, (ID *)sce);
+ items += animdata_filter_nla(anim_data, ads, adt, filter_mode, sce, ANIMTYPE_SCENE, (ID *)sce);
},
{ /* drivers */
/* include drivers-expand widget? */
@@ -1405,7 +1442,7 @@ static int animdata_filter_dopesheet_scene (ListBase *anim_data, bDopeSheet *ads
/* add F-Curve channels (drivers are F-Curves) */
if (EXPANDED_DRVD(adt) || !(filter_mode & ANIMFILTER_CHANNELS)) {
- items += animdata_filter_fcurves(anim_data, adt->drivers.first, NULL, sce, ANIMTYPE_SCENE, filter_mode, (ID *)sce);
+ items += animdata_filter_fcurves(anim_data, ads, adt->drivers.first, NULL, sce, ANIMTYPE_SCENE, filter_mode, (ID *)sce);
}
},
{ /* action */
@@ -1420,7 +1457,7 @@ static int animdata_filter_dopesheet_scene (ListBase *anim_data, bDopeSheet *ads
/* add F-Curve channels? */
if (EXPANDED_ACTC(adt->action) || !(filter_mode & ANIMFILTER_CHANNELS)) {
- items += animdata_filter_action(anim_data, adt->action, filter_mode, sce, ANIMTYPE_SCENE, (ID *)sce);
+ items += animdata_filter_action(anim_data, ads, adt->action, filter_mode, sce, ANIMTYPE_SCENE, (ID *)sce);
}
}
)
@@ -1434,7 +1471,7 @@ static int animdata_filter_dopesheet_scene (ListBase *anim_data, bDopeSheet *ads
{ /* AnimData blocks - do nothing... */ },
{ /* nla */
/* add NLA tracks */
- items += animdata_filter_nla(anim_data, adt, filter_mode, wo, ANIMTYPE_DSWOR, (ID *)wo);
+ items += animdata_filter_nla(anim_data, ads, adt, filter_mode, wo, ANIMTYPE_DSWOR, (ID *)wo);
},
{ /* drivers */
/* include world-expand widget? */
@@ -1449,7 +1486,7 @@ static int animdata_filter_dopesheet_scene (ListBase *anim_data, bDopeSheet *ads
/* add F-Curve channels (drivers are F-Curves) */
if (FILTER_WOR_SCED(wo)/*EXPANDED_DRVD(adt)*/ || !(filter_mode & ANIMFILTER_CHANNELS)) {
// XXX owner info is messed up now...
- items += animdata_filter_fcurves(anim_data, adt->drivers.first, NULL, wo, ANIMTYPE_DSWOR, filter_mode, (ID *)wo);
+ items += animdata_filter_fcurves(anim_data, ads, adt->drivers.first, NULL, wo, ANIMTYPE_DSWOR, filter_mode, (ID *)wo);
}
},
{ /* action */
@@ -1464,12 +1501,14 @@ static int animdata_filter_dopesheet_scene (ListBase *anim_data, bDopeSheet *ads
/* add channels */
if (FILTER_WOR_SCED(wo) || (filter_mode & ANIMFILTER_CURVESONLY)) {
- items += animdata_filter_action(anim_data, adt->action, filter_mode, wo, ANIMTYPE_DSWOR, (ID *)wo);
+ items += animdata_filter_action(anim_data, ads, adt->action, filter_mode, wo, ANIMTYPE_DSWOR, (ID *)wo);
}
}
)
}
+ // TODO: scene compositing nodes (these aren't standard node-trees)
+
/* return the number of items added to the list */
return items;
}
@@ -1861,7 +1900,7 @@ int ANIM_animdata_filter (bAnimContext *ac, ListBase *anim_data, int filter_mode
/* firstly filter the data */
switch (datatype) {
case ANIMCONT_ACTION:
- items= animdata_filter_action(anim_data, data, filter_mode, NULL, ANIMTYPE_NONE, (ID *)obact);
+ items= animdata_filter_action(anim_data, NULL, data, filter_mode, NULL, ANIMTYPE_NONE, (ID *)obact);
break;
case ANIMCONT_SHAPEKEY: