return items;
}
+ static size_t animdata_filter_gpencil_data (ListBase *anim_data, bGPdata *gpd, int filter_mode)
+ {
+ bGPDlayer *gpl;
+ size_t items = 0;
+
+ /* loop over layers as the conditions are acceptable */
+ for (gpl= gpd->layers.first; gpl; gpl= gpl->next) {
+ /* only if selected */
+ if ( ANIMCHANNEL_SELOK(SEL_GPL(gpl)) ) {
+ /* only if editable */
+ if (!(filter_mode & ANIMFILTER_FOREDIT) || EDITABLE_GPL(gpl)) {
+ /* active... */
+ if (!(filter_mode & ANIMFILTER_ACTIVE) || (gpl->flag & GP_LAYER_ACTIVE)) {
+ /* add to list */
+ ANIMCHANNEL_NEW_CHANNEL(gpl, ANIMTYPE_GPLAYER, gpd);
+ }
+ }
+ }
+ }
+
+ return items;
+ }
+
/* Grab all Grase Pencil datablocks in file */
// TODO: should this be amalgamated with the dopesheet filtering code?
- static int animdata_filter_gpencil (ListBase *anim_data, void *UNUSED(data), int filter_mode)
+ static size_t animdata_filter_gpencil (ListBase *anim_data, void *UNUSED(data), int filter_mode)
{
- bAnimListElem *ale;
bGPdata *gpd;
- bGPDlayer *gpl;
- int items = 0;
+ size_t items = 0;
- /* check if filtering types are appropriate */
- if (!(filter_mode & (ANIMFILTER_ACTGROUPED|ANIMFILTER_CURVESONLY)))
- {
- /* for now, grab grease pencil datablocks directly from main*/
- for (gpd = G.main->gpencil.first; gpd; gpd = gpd->id.next) {
- /* only show if gpd is used by something... */
- if (ID_REAL_USERS(gpd) < 1)
- continue;
+ /* for now, grab grease pencil datablocks directly from main */
+ // XXX: this is not good...
+ for (gpd = G.main->gpencil.first; gpd; gpd = gpd->id.next) {
+ ListBase tmp_data = {NULL, NULL};
+ size_t tmp_items = 0;
+
+ /* only show if gpd is used by something... */
+ if (ID_REAL_USERS(gpd) < 1)
+ continue;
- /* add gpd as channel too (if for drawing, and it has layers) */
- if ((filter_mode & ANIMFILTER_CHANNELS) && (gpd->layers.first)) {
- /* add to list */
- ale= make_new_animlistelem(gpd, ANIMTYPE_GPDATABLOCK, NULL, ANIMTYPE_NONE, NULL);
- if (ale) {
- BLI_addtail(anim_data, ale);
- items++;
- }
+ /* add gpencil animation channels */
+ BEGIN_ANIMFILTER_SUBCHANNELS(EXPANDED_GPD(gpd))
+ {
+ tmp_items += animdata_filter_gpencil_data(&tmp_data, gpd, filter_mode);
+ }
+ END_ANIMFILTER_SUBCHANNELS;
+
+ /* did we find anything? */
+ if (tmp_items) {
+ /* include data-expand widget first */
+ if (filter_mode & ANIMFILTER_LIST_CHANNELS) {
+ /* add gpd as channel too (if for drawing, and it has layers) */
+ ANIMCHANNEL_NEW_CHANNEL(gpd, ANIMTYPE_GPDATABLOCK, NULL);
}
- /* only add layers if they will be visible (if drawing channels) */
- if ( !(filter_mode & ANIMFILTER_VISIBLE) || (EXPANDED_GPD(gpd)) ) {
- /* loop over layers as the conditions are acceptable */
- for (gpl= gpd->layers.first; gpl; gpl= gpl->next) {
- /* only if selected */
- if ( ANIMCHANNEL_SELOK(SEL_GPL(gpl)) ) {
- /* only if editable */
- if (!(filter_mode & ANIMFILTER_FOREDIT) || EDITABLE_GPL(gpl)) {
- /* add to list */
- ale= make_new_animlistelem(gpl, ANIMTYPE_GPLAYER, gpd, ANIMTYPE_GPDATABLOCK, (ID*)gpd);
- if (ale) {
- BLI_addtail(anim_data, ale);
- items++;
- }
- }
+ /* now add the list of collected channels */
+ BLI_movelisttolist(anim_data, &tmp_data);
+ BLI_assert((tmp_data.first == tmp_data.last) && (tmp_data.first == NULL));
+ items += tmp_items;
+ }
+ }
+
+ /* return the number of items added to the list */
+ return items;
+ }
+
+ /* NOTE: owner_id is scene, material, or texture block, which is the direct owner of the node tree in question */
+ // TODO: how to handle group nodes is still unclear...
+ static size_t animdata_filter_ds_nodetree (bAnimContext *ac, ListBase *anim_data, bDopeSheet *ads, ID *owner_id, bNodeTree *ntree, int filter_mode)
+ {
+ ListBase tmp_data = {NULL, NULL};
+ size_t tmp_items = 0;
+ size_t items = 0;
+
+ /* add nodetree animation channels */
+ BEGIN_ANIMFILTER_SUBCHANNELS(FILTER_NTREE_DATA(ntree))
+ {
+ /* animation data filtering */
+ tmp_items += animfilter_block_data(ac, &tmp_data, ads, (ID *)ntree, filter_mode);
+ }
+ END_ANIMFILTER_SUBCHANNELS;
+
+ /* did we find anything? */
+ if (tmp_items) {
+ /* include data-expand widget first */
+ if (filter_mode & ANIMFILTER_LIST_CHANNELS) {
+ /* check if filtering by active status */
+ if ANIMCHANNEL_ACTIVEOK(ntree) {
+ ANIMCHANNEL_NEW_CHANNEL(ntree, ANIMTYPE_DSNTREE, owner_id);
+ }
+ }
+
+ /* now add the list of collected channels */
+ BLI_movelisttolist(anim_data, &tmp_data);
+ BLI_assert((tmp_data.first == tmp_data.last) && (tmp_data.first == NULL));
+ items += tmp_items;
+ }
+
+ /* return the number of items added to the list */
+ return items;
+ }
+
++static size_t animdata_filter_ds_linestyle (bAnimContext *ac, ListBase *anim_data, bDopeSheet *ads, Scene *sce, int filter_mode)
++{
++ SceneRenderLayer *srl;
++ size_t items = 0;
++
++ for (srl= sce->r.layers.first; srl; srl= srl->next) {
++ FreestyleLineSet *lineset;
++
++ /* skip render layers without Freestyle enabled */
++ if (!(srl->layflag & SCE_LAY_FRS))
++ continue;
++
++ /* loop over linesets defined in the render layer */
++ for (lineset= srl->freestyleConfig.linesets.first; lineset; lineset= lineset->next) {
++ FreestyleLineStyle *linestyle = lineset->linestyle;
++ ListBase tmp_data = {NULL, NULL};
++ size_t tmp_items = 0;
++
++ /* add scene-level animation channels */
++ BEGIN_ANIMFILTER_SUBCHANNELS(FILTER_LS_SCED(linestyle))
++ {
++ /* animation data filtering */
++ tmp_items += animfilter_block_data(ac, &tmp_data, ads, (ID *)linestyle, filter_mode);
++ }
++ END_ANIMFILTER_SUBCHANNELS;
++
++ /* did we find anything? */
++ if (tmp_items) {
++ /* include anim-expand widget first */
++ if (filter_mode & ANIMFILTER_LIST_CHANNELS) {
++ /* check if filtering by active status */
++ if ANIMCHANNEL_ACTIVEOK(linestyle) {
++ ANIMCHANNEL_NEW_CHANNEL(linestyle, ANIMTYPE_DSLINESTYLE, sce);
+ }
+ }
++
++ /* now add the list of collected channels */
++ BLI_movelisttolist(anim_data, &tmp_data);
++ BLI_assert((tmp_data.first == tmp_data.last) && (tmp_data.first == NULL));
++ items += tmp_items;
+ }
+ }
+ }
+
+ /* return the number of items added to the list */
+ return items;
+}
+
/* NOTE: owner_id is either material, lamp, or world block, which is the direct owner of the texture stack in question */
- static int animdata_filter_dopesheet_texs (bAnimContext *ac, ListBase *anim_data, bDopeSheet *ads, ID *owner_id, int filter_mode)
+ static size_t animdata_filter_ds_textures (bAnimContext *ac, ListBase *anim_data, bDopeSheet *ads, ID *owner_id, int filter_mode)
{
- ListBase texs = {NULL, NULL};
- LinkData *ld;
MTex **mtex = NULL;
- short expanded=0;
- int ownertype = ANIMTYPE_NONE;
-
- bAnimListElem *ale=NULL;
- int items=0, a=0;
+ size_t items=0;
+ int a=0;
/* get datatype specific data first */
if (owner_id == NULL)
return items;
}
- static int animdata_filter_dopesheet_ob (bAnimContext *ac, ListBase *anim_data, bDopeSheet *ads, Base *base, int filter_mode)
+ /* shapekey-level animation */
+ static size_t animdata_filter_ds_keyanim (bAnimContext *ac, ListBase *anim_data, bDopeSheet *ads, Object *ob, Key *key, int filter_mode)
{
- bAnimListElem *ale=NULL;
- AnimData *adt = NULL;
- Object *ob= base->object;
- Key *key= ob_get_key(ob);
- short obdata_ok = 0;
- int items = 0;
-
- /* add this object as a channel first */
- if ((filter_mode & (ANIMFILTER_CURVESONLY|ANIMFILTER_NLATRACKS)) == 0) {
- /* check if filtering by selection */
- if ANIMCHANNEL_SELOK((base->flag & SELECT)) {
- /* check if filtering by active status */
- if ANIMCHANNEL_ACTIVEOK(ob) {
- ale= make_new_animlistelem(base, ANIMTYPE_OBJECT, NULL, ANIMTYPE_NONE, (ID *)ob);
- if (ale) {
- BLI_addtail(anim_data, ale);
- items++;
- }
- }
- }
+ ListBase tmp_data = {NULL, NULL};
+ size_t tmp_items = 0;
+ size_t items = 0;
+
+ /* add shapekey-level animation channels */
+ BEGIN_ANIMFILTER_SUBCHANNELS(FILTER_SKE_OBJD(key))
+ {
+ /* animation data filtering */
+ tmp_items += animfilter_block_data(ac, &tmp_data, ads, (ID *)key, filter_mode);
}
+ END_ANIMFILTER_SUBCHANNELS;
- /* if collapsed, don't go any further (unless adding keyframes only) */
- if ( ((filter_mode & ANIMFILTER_VISIBLE) && EXPANDED_OBJC(ob) == 0) &&
- !(filter_mode & (ANIMFILTER_CURVESONLY|ANIMFILTER_NLATRACKS)) )
- return items;
-
- /* Action, Drivers, or NLA */
- if (ob->adt && !(ads->filterflag & ADS_FILTER_NOOBJ)) {
- adt= ob->adt;
- ANIMDATA_FILTER_CASES(ob,
- { /* AnimData blocks - do nothing... */ },
- { /* nla */
- /* add NLA tracks */
- items += animdata_filter_nla(ac, anim_data, ads, adt, filter_mode, ob, ANIMTYPE_OBJECT, (ID *)ob);
- },
- { /* drivers */
- /* include drivers-expand widget? */
- if ((filter_mode & ANIMFILTER_CHANNELS) && !(filter_mode & ANIMFILTER_CURVESONLY)) {
- ale= make_new_animlistelem(adt->action, ANIMTYPE_FILLDRIVERS, base, ANIMTYPE_OBJECT, (ID *)ob);
- if (ale) {
- BLI_addtail(anim_data, ale);
- items++;
- }
- }
-
- /* add F-Curve channels (drivers are F-Curves) */
- if (!(filter_mode & ANIMFILTER_VISIBLE) || 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, ads, adt->drivers.first, NULL, ob, ANIMTYPE_OBJECT, filter_mode, (ID *)ob);
- }
- },
- { /* action (keyframes) */
- /* include action-expand widget? */
- if ((filter_mode & ANIMFILTER_CHANNELS) && !(filter_mode & ANIMFILTER_CURVESONLY)) {
- ale= make_new_animlistelem(adt->action, ANIMTYPE_FILLACTD, base, ANIMTYPE_OBJECT, (ID *)ob);
- if (ale) {
- BLI_addtail(anim_data, ale);
- items++;
- }
- }
-
- /* add F-Curve channels? */
- if (!(filter_mode & ANIMFILTER_VISIBLE) || 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(ac, anim_data, ads, adt->action, filter_mode, ob, ANIMTYPE_OBJECT, (ID *)ob);
- }
+ /* did we find anything? */
+ if (tmp_items) {
+ /* include key-expand widget first */
+ if (filter_mode & ANIMFILTER_LIST_CHANNELS) {
+ if ANIMCHANNEL_ACTIVEOK(key) {
+ ANIMCHANNEL_NEW_CHANNEL(key, ANIMTYPE_DSSKEY, ob);
}
- );
+ }
+
+ /* now add the list of collected channels */
+ BLI_movelisttolist(anim_data, &tmp_data);
+ BLI_assert((tmp_data.first == tmp_data.last) && (tmp_data.first == NULL));
+ items += tmp_items;
}
+ /* return the number of items added to the list */
+ return items;
+ }
+
+ /* object-level animation */
+ static size_t animdata_filter_ds_obanim (bAnimContext *ac, ListBase *anim_data, bDopeSheet *ads, Object *ob, int filter_mode)
+ {
+ ListBase tmp_data = {NULL, NULL};
+ size_t tmp_items = 0;
+ size_t items = 0;
+
+ AnimData *adt = ob->adt;
+ short type=0, expanded=1;
+ void *cdata = NULL;
+
+ /* determine the type of expander channels to use */
+ // this is the best way to do this for now...
+ ANIMDATA_FILTER_CASES(ob,
+ {/* AnimData - no channel, but consider data */},
+ {/* NLA - no channel, but consider data */},
+ {/* Drivers */
+ type = ANIMTYPE_FILLDRIVERS;
+ cdata = adt;
+ expanded = EXPANDED_DRVD(adt);
+ },
+ {/* Keyframes */
+ type = ANIMTYPE_FILLACTD;
+ cdata = adt->action;
+ expanded = EXPANDED_ACTC(adt->action);
+ });
+
+ /* add object-level animation channels */
+ BEGIN_ANIMFILTER_SUBCHANNELS(expanded)
+ {
+ /* animation data filtering */
+ tmp_items += animfilter_block_data(ac, &tmp_data, ads, (ID *)ob, filter_mode);
+ }
+ END_ANIMFILTER_SUBCHANNELS;
- /* ShapeKeys? */
- if ((key) && !(ads->filterflag & ADS_FILTER_NOSHAPEKEYS)) {
- adt= key->adt;
- ANIMDATA_FILTER_CASES(key,
- { /* AnimData blocks - do nothing... */ },
- { /* nla */
- /* include shapekey-expand widget? */
- if ((filter_mode & ANIMFILTER_CHANNELS) && !(filter_mode & ANIMFILTER_CURVESONLY)) {
- /* check if filtering by active status */
- if ANIMCHANNEL_ACTIVEOK(key) {
- ale= make_new_animlistelem(key, ANIMTYPE_DSSKEY, base, ANIMTYPE_OBJECT, (ID *)ob);
- if (ale) {
- BLI_addtail(anim_data, ale);
- items++;
- }
- }
- }
-
- /* add NLA tracks - only if expanded or so */
- if (!(filter_mode & ANIMFILTER_VISIBLE) || FILTER_SKE_OBJD(key) || (filter_mode & ANIMFILTER_CURVESONLY))
- items += animdata_filter_nla(ac, anim_data, ads, adt, filter_mode, ob, ANIMTYPE_OBJECT, (ID *)key);
- },
- { /* drivers */
- /* include shapekey-expand widget? */
- if ((filter_mode & ANIMFILTER_CHANNELS) && !(filter_mode & ANIMFILTER_CURVESONLY)) {
- ale= make_new_animlistelem(key, ANIMTYPE_DSSKEY, base, ANIMTYPE_OBJECT, (ID *)ob);
- if (ale) {
- BLI_addtail(anim_data, ale);
- items++;
- }
- }
-
- /* add channels */
- if (!(filter_mode & ANIMFILTER_VISIBLE) || FILTER_SKE_OBJD(key) || (filter_mode & ANIMFILTER_CURVESONLY)) {
- items += animdata_filter_fcurves(anim_data, ads, adt->drivers.first, NULL, key, ANIMTYPE_DSSKEY, filter_mode, (ID *)key);
- }
- },
- { /* action (keyframes) */
- /* include shapekey-expand widget? */
- if ((filter_mode & ANIMFILTER_CHANNELS) && !(filter_mode & ANIMFILTER_CURVESONLY)) {
- /* check if filtering by active status */
- if ANIMCHANNEL_ACTIVEOK(key) {
- ale= make_new_animlistelem(key, ANIMTYPE_DSSKEY, base, ANIMTYPE_OBJECT, (ID *)ob);
- if (ale) {
- BLI_addtail(anim_data, ale);
- items++;
- }
- }
- }
-
- /* add channels */
- if (!(filter_mode & ANIMFILTER_VISIBLE) || FILTER_SKE_OBJD(key) || (filter_mode & ANIMFILTER_CURVESONLY)) {
- items += animdata_filter_action(ac, anim_data, ads, adt->action, filter_mode, key, ANIMTYPE_DSSKEY, (ID *)key);
- }
+ /* did we find anything? */
+ if (tmp_items) {
+ /* include anim-expand widget first */
+ if (filter_mode & ANIMFILTER_LIST_CHANNELS) {
+ if (type != ANIMTYPE_NONE) {
+ /* NOTE: active-status (and the associated checks) don't apply here... */
+ ANIMCHANNEL_NEW_CHANNEL(cdata, type, ob);
}
- );
+ }
+
+ /* now add the list of collected channels */
+ BLI_movelisttolist(anim_data, &tmp_data);
+ BLI_assert((tmp_data.first == tmp_data.last) && (tmp_data.first == NULL));
+ items += tmp_items;
}
+
+ /* return the number of items added to the list */
+ return items;
+ }
- /* Materials? */
- if ((ob->totcol) && !(ads->filterflag & ADS_FILTER_NOMAT))
- items += animdata_filter_dopesheet_mats(ac, anim_data, ads, base, filter_mode);
+ /* get animation channels from object2 */
+ static size_t animdata_filter_dopesheet_ob (bAnimContext *ac, ListBase *anim_data, bDopeSheet *ads, Base *base, int filter_mode)
+ {
+ ListBase tmp_data = {NULL, NULL};
+ Object *ob= base->object;
+ size_t tmp_items = 0;
+ size_t items = 0;
- /* Object Data */
- switch (ob->type) {
- case OB_CAMERA: /* ------- Camera ------------ */
- {
- Camera *ca= (Camera *)ob->data;
-
- if ((ads->filterflag & ADS_FILTER_NOCAM) == 0) {
- ANIMDATA_FILTER_CASES(ca,
- { /* AnimData blocks - do nothing... */ },
- obdata_ok= 1;,
- obdata_ok= 1;,
- obdata_ok= 1;)
- }
- }
- break;
- case OB_LAMP: /* ---------- Lamp ----------- */
- {
- Lamp *la= (Lamp *)ob->data;
-
- if ((ads->filterflag & ADS_FILTER_NOLAM) == 0) {
- ANIMDATA_FILTER_CASES(la,
- { /* AnimData blocks - do nothing... */ },
- obdata_ok= 1;,
- obdata_ok= 1;,
- obdata_ok= 1;)
- }
+ /* filter data contained under object first */
+ BEGIN_ANIMFILTER_SUBCHANNELS(EXPANDED_OBJC(ob))
+ {
+ Key *key= ob_get_key(ob);
+
+ /* object-level animation */
+ if ((ob->adt) && !(ads->filterflag & ADS_FILTER_NOOBJ)) {
+ tmp_items += animdata_filter_ds_obanim(ac, &tmp_data, ads, ob, filter_mode);
}
- break;
- case OB_CURVE: /* ------- Curve ---------- */
- case OB_SURF: /* ------- Nurbs Surface ---------- */
- case OB_FONT: /* ------- Text Curve ---------- */
- {
- Curve *cu= (Curve *)ob->data;
-
- if ((ads->filterflag & ADS_FILTER_NOCUR) == 0) {
- ANIMDATA_FILTER_CASES(cu,
- { /* AnimData blocks - do nothing... */ },
- obdata_ok= 1;,
- obdata_ok= 1;,
- obdata_ok= 1;)
- }
+
+ /* shape-key */
+ if ((key && key->adt) && !(ads->filterflag & ADS_FILTER_NOSHAPEKEYS)) {
+ tmp_items += animdata_filter_ds_keyanim(ac, &tmp_data, ads, ob, key, filter_mode);
}
- break;
- case OB_MBALL: /* ------- MetaBall ---------- */
- {
- MetaBall *mb= (MetaBall *)ob->data;
-
- if ((ads->filterflag & ADS_FILTER_NOMBA) == 0) {
- ANIMDATA_FILTER_CASES(mb,
- { /* AnimData blocks - do nothing... */ },
- obdata_ok= 1;,
- obdata_ok= 1;,
- obdata_ok= 1;)
- }
+
+ /* materials */
+ if ((ob->totcol) && !(ads->filterflag & ADS_FILTER_NOMAT)) {
+ tmp_items += animdata_filter_ds_materials(ac, &tmp_data, ads, ob, filter_mode);
}
- break;
- case OB_ARMATURE: /* ------- Armature ---------- */
- {
- bArmature *arm= (bArmature *)ob->data;
-
- if ((ads->filterflag & ADS_FILTER_NOARM) == 0) {
- ANIMDATA_FILTER_CASES(arm,
- { /* AnimData blocks - do nothing... */ },
- obdata_ok= 1;,
- obdata_ok= 1;,
- obdata_ok= 1;)
- }
+
+ /* object data */
+ if (ob->data) {
+ tmp_items += animdata_filter_ds_obdata(ac, &tmp_data, ads, ob, filter_mode);
}
- break;
- case OB_MESH: /* ------- Mesh ---------- */
- {
- Mesh *me= (Mesh *)ob->data;
-
- if ((ads->filterflag & ADS_FILTER_NOMESH) == 0) {
- ANIMDATA_FILTER_CASES(me,
- { /* AnimData blocks - do nothing... */ },
- obdata_ok= 1;,
- obdata_ok= 1;,
- obdata_ok= 1;)
- }
+
+ /* particles */
+ if ((ob->particlesystem.first) && !(ads->filterflag & ADS_FILTER_NOPART)) {
+ tmp_items += animdata_filter_ds_particles(ac, &tmp_data, ads, ob, filter_mode);
}
- break;
- case OB_LATTICE: /* ------- Lattice ---------- */
- {
- Lattice *lt= (Lattice *)ob->data;
-
- if ((ads->filterflag & ADS_FILTER_NOLAT) == 0) {
- ANIMDATA_FILTER_CASES(lt,
- { /* AnimData blocks - do nothing... */ },
- obdata_ok= 1;,
- obdata_ok= 1;,
- obdata_ok= 1;)
+ }
+ END_ANIMFILTER_SUBCHANNELS;
+
+
+ /* if we collected some channels, add these to the new list... */
+ if (tmp_items) {
+ /* firstly add object expander if required */
+ if (filter_mode & ANIMFILTER_LIST_CHANNELS) {
+ /* check if filtering by selection */
+ // XXX: double-check on this - most of the time, a lot of tools need to filter out these channels!
+ if ANIMCHANNEL_SELOK((base->flag & SELECT)) {
+ /* check if filtering by active status */
+ if (ANIMCHANNEL_ACTIVEOK(ob)) {
+ ANIMCHANNEL_NEW_CHANNEL(base, ANIMTYPE_OBJECT, ob);
+ }
}
}
- break;
+
+ /* now add the list of collected channels */
+ BLI_movelisttolist(anim_data, &tmp_data);
+ BLI_assert((tmp_data.first == tmp_data.last) && (tmp_data.first == NULL));
+ items += tmp_items;
}
- if (obdata_ok)
- items += animdata_filter_dopesheet_obdata(ac, anim_data, ads, base, filter_mode);
-
- /* particles */
- if (ob->particlesystem.first && !(ads->filterflag & ADS_FILTER_NOPART))
- items += animdata_filter_dopesheet_particles(ac, anim_data, ads, base, filter_mode);
- /* return the number of items added to the list */
+ /* return the number of items added */
return items;
- }
+ }
- static int animdata_filter_dopesheet_scene (bAnimContext *ac, ListBase *anim_data, bDopeSheet *ads, Scene *sce, int filter_mode)
+ static size_t animdata_filter_ds_world (bAnimContext *ac, ListBase *anim_data, bDopeSheet *ads, Scene *sce, World *wo, int filter_mode)
{
- World *wo= sce->world;
- bNodeTree *ntree= sce->nodetree;
- AnimData *adt= NULL;
- bAnimListElem *ale;
- 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|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);
- if (ale) {
- BLI_addtail(anim_data, ale);
- items++;
+ ListBase tmp_data = {NULL, NULL};
+ size_t tmp_items = 0;
+ size_t items = 0;
+
+ /* add world animation channels */
+ BEGIN_ANIMFILTER_SUBCHANNELS(FILTER_WOR_SCED(wo))
+ {
+ /* animation data filtering */
+ tmp_items += animfilter_block_data(ac, &tmp_data, ads, (ID *)wo, filter_mode);
+
+ /* textures for world */
+ if (!(ads->filterflag & ADS_FILTER_NOTEX))
+ items += animdata_filter_ds_textures(ac, &tmp_data, ads, (ID *)wo, filter_mode);
+ }
+ END_ANIMFILTER_SUBCHANNELS;
+
+ /* did we find anything? */
+ if (tmp_items) {
+ /* include data-expand widget first */
+ if (filter_mode & ANIMFILTER_LIST_CHANNELS) {
+ /* check if filtering by active status */
+ if ANIMCHANNEL_ACTIVEOK(wo) {
+ ANIMCHANNEL_NEW_CHANNEL(wo, ANIMTYPE_DSWOR, sce);
}
}
+
+ /* now add the list of collected channels */
+ BLI_movelisttolist(anim_data, &tmp_data);
+ BLI_assert((tmp_data.first == tmp_data.last) && (tmp_data.first == NULL));
+ items += tmp_items;
}
- /* if collapsed, don't go any further (unless adding keyframes only) */
- if ( (EXPANDED_SCEC(sce) == 0) && !(filter_mode & (ANIMFILTER_CURVESONLY|ANIMFILTER_NLATRACKS)) )
- return items;
+ /* return the number of items added to the list */
+ return items;
+ }
+
+ static size_t animdata_filter_ds_scene (bAnimContext *ac, ListBase *anim_data, bDopeSheet *ads, Scene *sce, int filter_mode)
+ {
+ ListBase tmp_data = {NULL, NULL};
+ size_t tmp_items = 0;
+ size_t items = 0;
+
+ AnimData *adt = sce->adt;
+ short type=0, expanded=1;
+ void *cdata = NULL;
+
+ /* determine the type of expander channels to use */
+ // this is the best way to do this for now...
+ ANIMDATA_FILTER_CASES(sce,
+ {/* AnimData - no channel, but consider data */},
+ {/* NLA - no channel, but consider data */},
+ {/* Drivers */
+ type = ANIMTYPE_FILLDRIVERS;
+ cdata = adt;
+ expanded = EXPANDED_DRVD(adt);
+ },
+ {/* Keyframes */
+ type = ANIMTYPE_FILLACTD;
+ cdata = adt->action;
+ expanded = EXPANDED_ACTC(adt->action);
+ });
- /* 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(ac, anim_data, ads, adt, filter_mode, sce, ANIMTYPE_SCENE, (ID *)sce);
- },
- { /* drivers */
- /* include drivers-expand widget? */
- if ((filter_mode & ANIMFILTER_CHANNELS) && !(filter_mode & ANIMFILTER_CURVESONLY)) {
- ale= make_new_animlistelem(adt->action, ANIMTYPE_FILLDRIVERS, sce, ANIMTYPE_SCENE, (ID *)sce);
- if (ale) {
- BLI_addtail(anim_data, ale);
- items++;
- }
- }
-
- /* add F-Curve channels (drivers are F-Curves) */
- if (EXPANDED_DRVD(adt) || !(filter_mode & ANIMFILTER_CHANNELS)) {
- items += animdata_filter_fcurves(anim_data, ads, adt->drivers.first, NULL, sce, ANIMTYPE_SCENE, filter_mode, (ID *)sce);
- }
- },
- { /* action */
- /* include action-expand widget? */
- if ((filter_mode & ANIMFILTER_CHANNELS) && !(filter_mode & ANIMFILTER_CURVESONLY)) {
- ale= make_new_animlistelem(adt->action, ANIMTYPE_FILLACTD, sce, ANIMTYPE_SCENE, (ID *)sce);
- if (ale) {
- BLI_addtail(anim_data, ale);
- items++;
- }
- }
-
- /* add F-Curve channels? */
- if (EXPANDED_ACTC(adt->action) || !(filter_mode & ANIMFILTER_CHANNELS)) {
- items += animdata_filter_action(ac, anim_data, ads, adt->action, filter_mode, sce, ANIMTYPE_SCENE, (ID *)sce);
- }
- }
- )
+ /* add scene-level animation channels */
+ BEGIN_ANIMFILTER_SUBCHANNELS(expanded)
+ {
+ /* animation data filtering */
+ tmp_items += animfilter_block_data(ac, &tmp_data, ads, (ID *)sce, filter_mode);
}
+ END_ANIMFILTER_SUBCHANNELS;
- /* world */
- if ((wo && wo->adt) && !(ads->filterflag & ADS_FILTER_NOWOR)) {
- /* Action, Drivers, or NLA for World */
- adt= wo->adt;
- ANIMDATA_FILTER_CASES(wo,
- { /* AnimData blocks - do nothing... */ },
- { /* nla */
- /* add NLA tracks */
- items += animdata_filter_nla(ac, anim_data, ads, adt, filter_mode, wo, ANIMTYPE_DSWOR, (ID *)wo);
- },
- { /* drivers */
- /* include world-expand widget? */
- if ((filter_mode & ANIMFILTER_CHANNELS) && !(filter_mode & ANIMFILTER_CURVESONLY)) {
- ale= make_new_animlistelem(wo, ANIMTYPE_DSWOR, sce, ANIMTYPE_SCENE, (ID *)wo);
- if (ale) {
- BLI_addtail(anim_data, ale);
- items++;
- }
- }
-
- /* 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, ads, adt->drivers.first, NULL, wo, ANIMTYPE_DSWOR, filter_mode, (ID *)wo);
- }
- },
- { /* action */
- /* include world-expand widget? */
- if ((filter_mode & ANIMFILTER_CHANNELS) && !(filter_mode & ANIMFILTER_CURVESONLY)) {
- ale= make_new_animlistelem(wo, ANIMTYPE_DSWOR, sce, ANIMTYPE_SCENE, (ID *)sce);
- if (ale) {
- BLI_addtail(anim_data, ale);
- items++;
- }
- }
-
- /* add channels */
- if (FILTER_WOR_SCED(wo) || (filter_mode & ANIMFILTER_CURVESONLY)) {
- items += animdata_filter_action(ac, anim_data, ads, adt->action, filter_mode, wo, ANIMTYPE_DSWOR, (ID *)wo);
- }
+ /* did we find anything? */
+ if (tmp_items) {
+ /* include anim-expand widget first */
+ if (filter_mode & ANIMFILTER_LIST_CHANNELS) {
+ if (type != ANIMTYPE_NONE) {
+ /* NOTE: active-status (and the associated checks) don't apply here... */
+ ANIMCHANNEL_NEW_CHANNEL(cdata, type, sce);
}
- )
-
- /* if expanded, check world textures too */
- if (FILTER_WOR_SCED(wo) || (filter_mode & ANIMFILTER_CURVESONLY)) {
- /* textures for world */
- if (!(ads->filterflag & ADS_FILTER_NOTEX))
- items += animdata_filter_dopesheet_texs(ac, anim_data, ads, (ID *)wo, filter_mode);
}
+
+ /* now add the list of collected channels */
+ BLI_movelisttolist(anim_data, &tmp_data);
+ BLI_assert((tmp_data.first == tmp_data.last) && (tmp_data.first == NULL));
+ items += tmp_items;
}
- /* nodetree */
- if ((ntree && ntree->adt) && !(ads->filterflag & ADS_FILTER_NONTREE)) {
- /* Action, Drivers, or NLA for Nodetree */
- adt= ntree->adt;
- ANIMDATA_FILTER_CASES(ntree,
- { /* AnimData blocks - do nothing... */ },
- { /* nla */
- /* add NLA tracks */
- items += animdata_filter_nla(ac, anim_data, ads, adt, filter_mode, ntree, ANIMTYPE_DSNTREE, (ID *)ntree);
- },
- { /* drivers */
- /* include nodetree-expand widget? */
- if ((filter_mode & ANIMFILTER_CHANNELS) && !(filter_mode & ANIMFILTER_CURVESONLY)) {
- ale= make_new_animlistelem(ntree, ANIMTYPE_DSNTREE, sce, ANIMTYPE_SCENE, (ID *)ntree);
- if (ale) {
- BLI_addtail(anim_data, ale);
- items++;
- }
- }
-
- /* add F-Curve channels (drivers are F-Curves) */
- if (FILTER_NTREE_SCED(ntree)/*EXPANDED_DRVD(adt)*/ || !(filter_mode & ANIMFILTER_CHANNELS)) {
- // XXX owner info is messed up now...
- items += animdata_filter_fcurves(anim_data, ads, adt->drivers.first, NULL, ntree, ANIMTYPE_DSNTREE, filter_mode, (ID *)ntree);
- }
- },
- { /* action */
- /* include nodetree-expand widget? */
- if ((filter_mode & ANIMFILTER_CHANNELS) && !(filter_mode & ANIMFILTER_CURVESONLY)) {
- ale= make_new_animlistelem(ntree, ANIMTYPE_DSNTREE, sce, ANIMTYPE_SCENE, (ID *)sce);
- if (ale) {
- BLI_addtail(anim_data, ale);
- items++;
- }
- }
-
- /* add channels */
- if (FILTER_NTREE_SCED(ntree) || (filter_mode & ANIMFILTER_CURVESONLY)) {
- items += animdata_filter_action(ac, anim_data, ads, adt->action, filter_mode, ntree, ANIMTYPE_DSNTREE, (ID *)ntree);
- }
- }
- )
- }
-
- /* line styles */
- if (!(ads->filterflag & ADS_FILTER_NOLINESTYLE)) {
- ListBase linestyles = {NULL, NULL};
- LinkData *link;
- SceneRenderLayer *srl;
- FreestyleLineSet *lineset;
- FreestyleLineStyle *linestyle;
-
- for (srl = (SceneRenderLayer *)sce->r.layers.first; srl; srl = srl->next) {
- if (!(srl->layflag & SCE_LAY_FRS))
- continue;
- for (lineset = (FreestyleLineSet *)srl->freestyleConfig.linesets.first; lineset; lineset = lineset->next) {
- short ok = 0;
-
- linestyle = lineset->linestyle;
- if (!linestyle->adt)
- continue;
-
- ANIMDATA_FILTER_CASES(linestyle,
- { /* AnimData blocks - do nothing... */ },
- ok=1;,
- ok=1;,
- ok=1;)
- if (ok == 0) continue;
-
- /* check if the same linestyle is already in the list */
- for (link = (LinkData *)linestyles.first; link; link = link->next) {
- if (link->data == linestyle) {
- ok = 0;
- break;
- }
- }
- if (ok == 0) continue;
+
+ /* return the number of items added to the list */
+ return items;
+ }
- /* add this linestyle to the list */
- link= MEM_callocN(sizeof(LinkData), "DopeSheet LineStyle cache");
- link->data= linestyle;
- BLI_addtail(&linestyles, link);
- }
+ static size_t animdata_filter_dopesheet_scene (bAnimContext *ac, ListBase *anim_data, bDopeSheet *ads, Scene *sce, int filter_mode)
+ {
+ ListBase tmp_data = {NULL, NULL};
+ size_t tmp_items = 0;
+ size_t items = 0;
+
+ /* filter data contained under object first */
+ BEGIN_ANIMFILTER_SUBCHANNELS(EXPANDED_SCEC(sce))
+ {
+ bNodeTree *ntree= sce->nodetree;
+ World *wo= sce->world;
+
+ /* Action, Drivers, or NLA for Scene */
+ if ((ads->filterflag & ADS_FILTER_NOSCE) == 0) {
+ tmp_items += animdata_filter_ds_scene(ac, &tmp_data, ads, sce, filter_mode);
+ }
+
+ /* world */
+ if ((wo && wo->adt) && !(ads->filterflag & ADS_FILTER_NOWOR)) {
+ tmp_items += animdata_filter_ds_world(ac, &tmp_data, ads, sce, wo, filter_mode);
+ }
+
+ /* nodetree */
+ if ((ntree && ntree->adt) && !(ads->filterflag & ADS_FILTER_NONTREE)) {
+ tmp_items += animdata_filter_ds_nodetree(ac, &tmp_data, ads, (ID *)sce, ntree, filter_mode);
}
- if (linestyles.first) {
-
- for (link = (LinkData *)linestyles.first; link; link = link->next) {
- linestyle = (FreestyleLineStyle *)link->data;
-
- /* Action, Drivers, or NLA for line styles */
- adt= linestyle->adt;
- ANIMDATA_FILTER_CASES(linestyle,
- { /* AnimData blocks - do nothing... */ },
- { /* nla */
- /* add NLA tracks */
- items += animdata_filter_nla(ac, anim_data, ads, adt, filter_mode, linestyle, ANIMTYPE_DSLINESTYLE, (ID *)linestyle);
- },
- { /* drivers */
- /* include linestyle-expand widget? */
- if ((filter_mode & ANIMFILTER_CHANNELS) && !(filter_mode & ANIMFILTER_CURVESONLY)) {
- ale= make_new_animlistelem(linestyle, ANIMTYPE_DSLINESTYLE, sce, ANIMTYPE_SCENE, (ID *)linestyle);
- if (ale) {
- BLI_addtail(anim_data, ale);
- items++;
- }
- }
-
- /* add F-Curve channels (drivers are F-Curves) */
- if (FILTER_LS_SCED(linestyle)/*EXPANDED_DRVD(adt)*/ || !(filter_mode & ANIMFILTER_CHANNELS)) {
- // XXX owner info is messed up now...
- items += animdata_filter_fcurves(anim_data, ads, adt->drivers.first, NULL, linestyle, ANIMTYPE_DSLINESTYLE, filter_mode, (ID *)linestyle);
- }
- },
- { /* action */
- /* include nodetree-expand widget? */
- if ((filter_mode & ANIMFILTER_CHANNELS) && !(filter_mode & ANIMFILTER_CURVESONLY)) {
- ale= make_new_animlistelem(linestyle, ANIMTYPE_DSLINESTYLE, sce, ANIMTYPE_SCENE, (ID *)sce);
- if (ale) {
- BLI_addtail(anim_data, ale);
- items++;
- }
- }
-
- /* add channels */
- if (FILTER_LS_SCED(linestyle) || (filter_mode & ANIMFILTER_CURVESONLY)) {
- items += animdata_filter_action(ac, anim_data, ads, adt->action, filter_mode, linestyle, ANIMTYPE_DSLINESTYLE, (ID *)linestyle);
- }
- }
- )
+
++ /* line styles */
++ if ((ads->filterflag & ADS_FILTER_NOLINESTYLE) == 0) {
++ tmp_items += animdata_filter_ds_linestyle(ac, &tmp_data, ads, sce, filter_mode);
++ }
+
+ // TODO: one day, when sequencer becomes its own datatype, perhaps it should be included here
+ }
+ END_ANIMFILTER_SUBCHANNELS;
+
+ /* if we collected some channels, add these to the new list... */
+ if (tmp_items) {
+ /* firstly add object expander if required */
+ if (filter_mode & ANIMFILTER_LIST_CHANNELS) {
+ /* check if filtering by selection */
+ if ANIMCHANNEL_SELOK((sce->flag & SCE_DS_SELECTED)) {
+ /* NOTE: active-status doesn't matter for this! */
+ ANIMCHANNEL_NEW_CHANNEL(sce, ANIMTYPE_SCENE, sce);
}
-
- /* free cache */
- BLI_freelistN(&linestyles);
}
+
+ /* now add the list of collected channels */
+ BLI_movelisttolist(anim_data, &tmp_data);
+ BLI_assert((tmp_data.first == tmp_data.last) && (tmp_data.first == NULL));
+ items += tmp_items;
}
-
- // TODO: scene compositing nodes (these aren't standard node-trees)
- /* return the number of items added to the list */
+ /* return the number of items added */
return items;
}