From ca5ff43b1f3efa555b1e52d190c5a97332e01e85 Mon Sep 17 00:00:00 2001 From: Joshua Leung Date: Tue, 9 Jun 2009 12:28:10 +0000 Subject: [PATCH] NLA SoC: Improved anim-channel filtering flags for NLA so that channels don't need to be checked to be NLA-Tracks before being used. --- .../blender/editors/animation/anim_filter.c | 16 ++++++------- source/blender/editors/include/ED_anim_api.h | 3 ++- source/blender/editors/space_nla/nla_select.c | 4 ++-- .../editors/transform/transform_conversions.c | 23 ++++++++----------- 4 files changed, 22 insertions(+), 24 deletions(-) diff --git a/source/blender/editors/animation/anim_filter.c b/source/blender/editors/animation/anim_filter.c index cdda13d999d..6cb24a01711 100644 --- a/source/blender/editors/animation/anim_filter.c +++ b/source/blender/editors/animation/anim_filter.c @@ -1050,7 +1050,7 @@ static int animdata_filter_dopesheet_ob (ListBase *anim_data, bDopeSheet *ads, B int items = 0; /* add this object as a channel first */ - if ((filter_mode & ANIMFILTER_CURVESONLY) == 0) { + if ((filter_mode & (ANIMFILTER_CURVESONLY|ANIMFILTER_NLATRACKS)) == 0) { /* check if filtering by selection */ if ANIMCHANNEL_SELOK((base->flag & SELECT)) { ale= make_new_animlistelem(base, ANIMTYPE_OBJECT, NULL, ANIMTYPE_NONE, NULL); @@ -1062,7 +1062,7 @@ static int animdata_filter_dopesheet_ob (ListBase *anim_data, bDopeSheet *ads, B } /* if collapsed, don't go any further (unless adding keyframes only) */ - if ( (EXPANDED_OBJC(ob) == 0) && !(filter_mode & ANIMFILTER_CURVESONLY) ) + if ( (EXPANDED_OBJC(ob) == 0) && !(filter_mode & (ANIMFILTER_CURVESONLY|ANIMFILTER_NLATRACKS)) ) return items; /* Action, Drivers, or NLA */ @@ -1073,7 +1073,7 @@ static int animdata_filter_dopesheet_ob (ListBase *anim_data, bDopeSheet *ads, B { /* nla */ #if 0 /* include nla-expand widget? */ - if ((filter_mode & ANIMFILTER_CHANNELS) && !(filter_mode & ANIMFILTER_CURVESONLY)) { + if ((filter_mode & ANIMFILTER_CHANNELS) && !(filter_mode & ANIMFILTER_NLATRACKS)) { ale= make_new_animlistelem(adt->action, ANIMTYPE_FILLNLA, base, ANIMTYPE_OBJECT, (ID *)ob); if (ale) { BLI_addtail(anim_data, ale); @@ -1129,7 +1129,7 @@ static int animdata_filter_dopesheet_ob (ListBase *anim_data, bDopeSheet *ads, B { /* nla */ #if 0 /* include nla-expand widget? */ - if ((filter_mode & ANIMFILTER_CHANNELS) && !(filter_mode & ANIMFILTER_CURVESONLY)) { + if ((filter_mode & ANIMFILTER_CHANNELS) && !(filter_mode & ANIMFILTER_NLATRACKS)) { ale= make_new_animlistelem(adt->action, ANIMTYPE_FILLNLA, base, ANIMTYPE_OBJECT, (ID *)ob); if (ale) { BLI_addtail(anim_data, ale); @@ -1235,7 +1235,7 @@ static int animdata_filter_dopesheet_scene (ListBase *anim_data, bDopeSheet *ads int items = 0; /* add scene as a channel first (even if we aren't showing scenes we still need to show the scene's sub-data */ - if ((filter_mode & ANIMFILTER_CURVESONLY) == 0) { + if ((filter_mode & (ANIMFILTER_CURVESONLY|ANIMFILTER_NLATRACKS)) == 0) { /* check if filtering by selection */ if (ANIMCHANNEL_SELOK( (sce->flag & SCE_DS_SELECTED) )) { ale= make_new_animlistelem(sce, ANIMTYPE_SCENE, NULL, ANIMTYPE_NONE, NULL); @@ -1247,7 +1247,7 @@ static int animdata_filter_dopesheet_scene (ListBase *anim_data, bDopeSheet *ads } /* if collapsed, don't go any further (unless adding keyframes only) */ - if ( (EXPANDED_SCEC(sce) == 0) && !(filter_mode & ANIMFILTER_CURVESONLY) ) + if ( (EXPANDED_SCEC(sce) == 0) && !(filter_mode & (ANIMFILTER_CURVESONLY|ANIMFILTER_NLATRACKS)) ) return items; /* Action, Drivers, or NLA for Scene */ @@ -1258,7 +1258,7 @@ static int animdata_filter_dopesheet_scene (ListBase *anim_data, bDopeSheet *ads { /* nla */ #if 0 /* include nla-expand widget? */ - if ((filter_mode & ANIMFILTER_CHANNELS) && !(filter_mode & ANIMFILTER_CURVESONLY)) { + if ((filter_mode & ANIMFILTER_CHANNELS) && !(filter_mode & ANIMFILTER_NLATRACKS)) { ale= make_new_animlistelem(adt->action, ANIMTYPE_FILLNLA, base, ANIMTYPE_SCENE (ID *)sce); if (ale) { BLI_addtail(anim_data, ale); @@ -1312,7 +1312,7 @@ static int animdata_filter_dopesheet_scene (ListBase *anim_data, bDopeSheet *ads { /* nla */ #if 0 /* include nla-expand widget? */ - if ((filter_mode & ANIMFILTER_CHANNELS) && !(filter_mode & ANIMFILTER_CURVESONLY)) { + if ((filter_mode & ANIMFILTER_CHANNELS) && !(filter_mode & ANIMFILTER_NLATRACKS)) { ale= make_new_animlistelem(adt->action, ANIMTYPE_FILLNLA, base, ANIMTYPE_DSWOR (ID *)wo); if (ale) { BLI_addtail(anim_data, ale); diff --git a/source/blender/editors/include/ED_anim_api.h b/source/blender/editors/include/ED_anim_api.h index dcaabb4b369..e44c7ff5603 100644 --- a/source/blender/editors/include/ED_anim_api.h +++ b/source/blender/editors/include/ED_anim_api.h @@ -162,8 +162,9 @@ typedef enum eAnimFilter_Flags { ANIMFILTER_CHANNELS = (1<<5), /* make list for interface drawing */ ANIMFILTER_ACTGROUPED = (1<<6), /* belongs to the active actiongroup */ ANIMFILTER_CURVEVISIBLE = (1<<7), /* F-Curve is visible for editing/viewing in Graph Editor */ - ANIMFILTER_ACTIVE = (1<<8), /* channel should be 'active' */ // FIXME: this is only relevant for F-Curves for now + ANIMFILTER_ACTIVE = (1<<8), /* channel should be 'active' */ ANIMFILTER_ANIMDATA = (1<<9), /* only return the underlying AnimData blocks (not the tracks, etc.) data comes from */ + ANIMFILTER_NLATRACKS = (1<<10), /* only include NLA-tracks */ } eAnimFilter_Flags; diff --git a/source/blender/editors/space_nla/nla_select.c b/source/blender/editors/space_nla/nla_select.c index 463479c0909..730814dc562 100644 --- a/source/blender/editors/space_nla/nla_select.c +++ b/source/blender/editors/space_nla/nla_select.c @@ -120,8 +120,8 @@ static void deselect_nla_strips (bAnimContext *ac, short test, short sel) int filter; short smode; - /* determine type-based settings - curvesonly eliminates all the unnecessary channels... */ - filter= (ANIMFILTER_VISIBLE|ANIMFILTER_CURVESONLY); + /* determine type-based settings */ + filter= (ANIMFILTER_VISIBLE | ANIMFILTER_NLATRACKS); /* filter data */ ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); diff --git a/source/blender/editors/transform/transform_conversions.c b/source/blender/editors/transform/transform_conversions.c index 96f62f1e18e..fb7d9c57eaf 100644 --- a/source/blender/editors/transform/transform_conversions.c +++ b/source/blender/editors/transform/transform_conversions.c @@ -2595,7 +2595,7 @@ static void createTransNlaData(bContext *C, TransInfo *t) return; /* filter data */ - filter= (ANIMFILTER_VISIBLE | ANIMFILTER_FOREDIT); + filter= (ANIMFILTER_VISIBLE | ANIMFILTER_NLATRACKS | ANIMFILTER_FOREDIT); ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype); /* which side of the current frame should be allowed */ @@ -2613,18 +2613,15 @@ static void createTransNlaData(bContext *C, TransInfo *t) /* loop 1: count how many strips are selected (consider each strip as 2 points) */ for (ale= anim_data.first; ale; ale= ale->next) { - /* only if a real NLA-track */ - if (ale->type == ANIMTYPE_NLATRACK) { - NlaTrack *nlt= (NlaTrack *)ale->data; - NlaStrip *strip; - - /* only consider selected strips */ - for (strip= nlt->strips.first; strip; strip= strip->next) { - // TODO: we can make strips have handles later on... - if (strip->flag & NLASTRIP_FLAG_SELECT) { - if (FrameOnMouseSide(side, strip->start, (float)CFRA)) count++; - if (FrameOnMouseSide(side, strip->end, (float)CFRA)) count++; - } + NlaTrack *nlt= (NlaTrack *)ale->data; + NlaStrip *strip; + + /* only consider selected strips */ + for (strip= nlt->strips.first; strip; strip= strip->next) { + // TODO: we can make strips have handles later on... + if (strip->flag & NLASTRIP_FLAG_SELECT) { + if (FrameOnMouseSide(side, strip->start, (float)CFRA)) count++; + if (FrameOnMouseSide(side, strip->end, (float)CFRA)) count++; } } }