Added compositing node support to the animation editors

Now when nodes are keyed, they will show up in the dopesheet/graph editor/etc in a new 'Nodetree' category.

Still a major problem left, nodes need unique names in order for the rna paths to hold animation data properly...
This commit is contained in:
Matt Ebb
2009-11-11 05:03:49 +00:00
parent 792c4d602d
commit bf50cc8b39
10 changed files with 193 additions and 3 deletions

View File

@@ -55,6 +55,7 @@
#include "DNA_lamp_types.h"
#include "DNA_material_types.h"
#include "DNA_meta_types.h"
#include "DNA_node_types.h"
#include "DNA_userdef_types.h"
#include "DNA_gpencil_types.h"
#include "DNA_windowmanager_types.h"
@@ -1735,6 +1736,79 @@ static bAnimChannelType ACF_DSARM=
acf_dsarm_setting_ptr /* pointer for setting */
};
/* NodeTree Expander ------------------------------------------- */
// TODO: just get this from RNA?
static int acf_dsntree_icon(bAnimListElem *ale)
{
return ICON_NODETREE;
}
/* get the appropriate flag(s) for the setting when it is valid */
static int acf_dsntree_setting_flag(int setting, short *neg)
{
/* clear extra return data first */
*neg= 0;
switch (setting) {
case ACHANNEL_SETTING_EXPAND: /* expanded */
return NTREE_DS_EXPAND;
case ACHANNEL_SETTING_MUTE: /* mute (only in NLA) */
return ADT_NLA_EVAL_OFF;
case ACHANNEL_SETTING_VISIBLE: /* visible (only in Graph Editor) */
*neg= 1;
return ADT_CURVES_NOT_VISIBLE;
case ACHANNEL_SETTING_SELECT: /* selected */
return ADT_UI_SELECTED;
default: /* unsupported */
return 0;
}
}
/* get pointer to the setting */
static void *acf_dsntree_setting_ptr(bAnimListElem *ale, int setting, short *type)
{
bNodeTree *ntree= (bNodeTree *)ale->data;
/* clear extra return data first */
*type= 0;
switch (setting) {
case ACHANNEL_SETTING_EXPAND: /* expanded */
GET_ACF_FLAG_PTR(ntree->flag);
case ACHANNEL_SETTING_SELECT: /* selected */
case ACHANNEL_SETTING_MUTE: /* muted (for NLA only) */
case ACHANNEL_SETTING_VISIBLE: /* visible (for Graph Editor only) */
if (ntree->adt)
GET_ACF_FLAG_PTR(ntree->adt->flag)
else
return NULL;
default: /* unsupported */
return NULL;
}
}
/* metaball expander type define */
static bAnimChannelType ACF_DSNTREE=
{
acf_generic_dataexpand_backdrop,/* backdrop */
acf_generic_indention_1, /* indent level */
acf_generic_basic_offset, /* offset */
acf_generic_idblock_name, /* name */
acf_dsntree_icon, /* icon */
acf_generic_dataexpand_setting_valid, /* has setting */
acf_dsntree_setting_flag, /* flag for setting */
acf_dsntree_setting_ptr /* pointer for setting */
};
/* ShapeKey Entry ------------------------------------------- */
@@ -1982,6 +2056,7 @@ void ANIM_init_channel_typeinfo_data (void)
animchannelTypeInfo[type++]= &ACF_DSCUR; /* Curve Channel */
animchannelTypeInfo[type++]= &ACF_DSSKEY; /* ShapeKey Channel */
animchannelTypeInfo[type++]= &ACF_DSWOR; /* World Channel */
animchannelTypeInfo[type++]= &ACF_DSNTREE; /* NodeTree Channel */
animchannelTypeInfo[type++]= &ACF_DSPART; /* Particle Channel */
animchannelTypeInfo[type++]= &ACF_DSMBALL; /* MetaBall Channel */
animchannelTypeInfo[type++]= &ACF_DSARM; /* Armature Channel */

View File

@@ -343,6 +343,7 @@ short ANIM_headerUI_standard_buttons (const bContext *C, bDopeSheet *ads, uiBloc
uiBlockBeginAlign(block);
uiDefIconButBitI(block, TOGN, ADS_FILTER_NOSCE, B_REDR, ICON_SCENE_DATA, (short)(xco+=XIC),yco,XIC,YIC, &(ads->filterflag), 0, 0, 0, 0, "Display Scene Animation");
uiDefIconButBitI(block, TOGN, ADS_FILTER_NOWOR, B_REDR, ICON_WORLD_DATA, (short)(xco+=XIC),yco,XIC,YIC, &(ads->filterflag), 0, 0, 0, 0, "Display World Animation");
uiDefIconButBitI(block, TOGN, ADS_FILTER_NONTREE, B_REDR, ICON_NODETREE, (short)(xco+=XIC),yco,XIC,YIC, &(ads->filterflag), 0, 0, 0, 0, "Display Node Tree Animation");
if (mainptr && mainptr->key.first)
uiDefIconButBitI(block, TOGN, ADS_FILTER_NOSHAPEKEYS, B_REDR, ICON_SHAPEKEY_DATA, (short)(xco+=XIC),yco,XIC,YIC, &(ads->filterflag), 0, 0, 0, 0, "Display ShapeKeys");
if (mainptr && mainptr->mat.first)

View File

@@ -64,6 +64,7 @@
#include "DNA_material_types.h"
#include "DNA_mesh_types.h"
#include "DNA_meta_types.h"
#include "DNA_node_types.h"
#include "DNA_object_types.h"
#include "DNA_particle_types.h"
#include "DNA_space_types.h"
@@ -596,6 +597,19 @@ bAnimListElem *make_new_animlistelem (void *data, short datatype, void *owner, s
ale->key_data= (adt) ? adt->action : NULL;
ale->datatype= ALE_ACT;
ale->adt= BKE_animdata_from_id(data);
}
break;
case ANIMTYPE_DSARM:
{
bArmature *arm= (bArmature *)data;
AnimData *adt= arm->adt;
ale->flag= FILTER_ARM_OBJD(arm);
ale->key_data= (adt) ? adt->action : NULL;
ale->datatype= ALE_ACT;
ale->adt= BKE_animdata_from_id(data);
}
break;
@@ -622,6 +636,19 @@ bAnimListElem *make_new_animlistelem (void *data, short datatype, void *owner, s
ale->key_data= (adt) ? adt->action : NULL;
ale->datatype= ALE_ACT;
ale->adt= BKE_animdata_from_id(data);
}
break;
case ANIMTYPE_DSNTREE:
{
bNodeTree *ntree= (bNodeTree *)data;
AnimData *adt= ntree->adt;
ale->flag= FILTER_NTREE_SCED(ntree);
ale->key_data= (adt) ? adt->action : NULL;
ale->datatype= ALE_ACT;
ale->adt= BKE_animdata_from_id(data);
}
break;
@@ -1485,6 +1512,7 @@ static int animdata_filter_dopesheet_ob (ListBase *anim_data, bDopeSheet *ads, B
static int animdata_filter_dopesheet_scene (ListBase *anim_data, bDopeSheet *ads, Scene *sce, int filter_mode)
{
World *wo= sce->world;
bNodeTree *ntree= sce->nodetree;
AnimData *adt= NULL;
bAnimListElem *ale;
int items = 0;
@@ -1590,6 +1618,50 @@ static int animdata_filter_dopesheet_scene (ListBase *anim_data, bDopeSheet *ads
}
)
}
/* 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(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(anim_data, ads, adt->action, filter_mode, ntree, ANIMTYPE_DSNTREE, (ID *)ntree);
}
}
)
}
// TODO: scene compositing nodes (these aren't standard node-trees)
@@ -1616,7 +1688,7 @@ static int animdata_filter_dopesheet (ListBase *anim_data, bAnimContext *ac, bDo
/* scene-linked animation */
// TODO: sequencer, composite nodes - are we to include those here too?
{
short sceOk= 0, worOk= 0;
short sceOk= 0, worOk= 0, nodeOk=0;
/* check filtering-flags if ok */
ANIMDATA_FILTER_CASES(sce,
@@ -1643,17 +1715,30 @@ static int animdata_filter_dopesheet (ListBase *anim_data, bAnimContext *ac, bDo
worOk= !(ads->filterflag & ADS_FILTER_NOWOR);,
worOk= !(ads->filterflag & ADS_FILTER_NOWOR);)
}
if (sce->nodetree) {
ANIMDATA_FILTER_CASES(sce->nodetree,
{
/* for the special AnimData blocks only case, we only need to add
* the block if it is valid... then other cases just get skipped (hence ok=0)
*/
ANIMDATA_ADD_ANIMDATA(sce->nodetree);
nodeOk=0;
},
nodeOk= !(ads->filterflag & ADS_FILTER_NONTREE);,
nodeOk= !(ads->filterflag & ADS_FILTER_NONTREE);,
nodeOk= !(ads->filterflag & ADS_FILTER_NONTREE);)
}
/* if only F-Curves with visible flags set can be shown, check that
* datablocks haven't been set to invisible
*/
if (filter_mode & ANIMFILTER_CURVEVISIBLE) {
if ((sce->adt) && (sce->adt->flag & ADT_CURVES_NOT_VISIBLE))
sceOk= worOk= 0;
sceOk= worOk= nodeOk= 0;
}
/* check if not all bad (i.e. so there is something to show) */
if ( !(!sceOk && !worOk) ) {
if ( !(!sceOk && !worOk && !nodeOk) ) {
/* add scene data to the list of filtered channels */
items += animdata_filter_dopesheet_scene(anim_data, ads, sce, filter_mode);
}

View File

@@ -58,6 +58,7 @@
#include "DNA_lamp_types.h"
#include "DNA_material_types.h"
#include "DNA_meta_types.h"
#include "DNA_node_types.h"
#include "DNA_particle_types.h"
#include "DNA_userdef_types.h"
#include "DNA_gpencil_types.h"
@@ -688,6 +689,15 @@ void scene_to_keylist(bDopeSheet *ads, Scene *sce, DLRBT_Tree *keys, DLRBT_Tree
if (adt->action)
action_to_keylist(adt, adt->action, keys, blocks);
}
/* nodetree animdata */
if ((sce->nodetree) && (sce->nodetree->adt) && !(filterflag & ADS_FILTER_NONTREE)) {
adt= sce->nodetree->adt;
// TODO: when we adapt NLA system, this needs to be the NLA-scaled version
if (adt->action)
action_to_keylist(adt, adt->action, keys, blocks);
}
}
}

View File

@@ -44,6 +44,7 @@
#include "DNA_material_types.h"
#include "DNA_object_types.h"
#include "DNA_meta_types.h"
#include "DNA_node_types.h"
#include "DNA_particle_types.h"
#include "DNA_space_types.h"
#include "DNA_scene_types.h"
@@ -304,6 +305,7 @@ static short ob_keys_bezier_loop(BeztEditData *bed, Object *ob, BeztEditFunc bez
static short scene_keys_bezier_loop(BeztEditData *bed, Scene *sce, BeztEditFunc bezt_ok, BeztEditFunc bezt_cb, FcuEditFunc fcu_cb, int filterflag)
{
World *wo= (sce) ? sce->world : NULL;
bNodeTree *ntree= (sce) ? sce->nodetree : NULL;
/* sanity check */
if (sce == NULL)
@@ -321,6 +323,13 @@ static short scene_keys_bezier_loop(BeztEditData *bed, Scene *sce, BeztEditFunc
return 1;
}
/* NodeTree */
if (ntree && ntree->adt) {
if (adt_keys_bezier_loop(bed, ntree->adt, bezt_ok, bezt_cb, fcu_cb, filterflag))
return 1;
}
return 0;
}

View File

@@ -140,6 +140,7 @@ typedef enum eAnim_ChannelType {
ANIMTYPE_DSCUR,
ANIMTYPE_DSSKEY,
ANIMTYPE_DSWOR,
ANIMTYPE_DSNTREE,
ANIMTYPE_DSPART,
ANIMTYPE_DSMBALL,
ANIMTYPE_DSARM,
@@ -202,6 +203,7 @@ typedef enum eAnimFilter_Flags {
#define EXPANDED_SCEC(sce) ((sce->flag & SCE_DS_COLLAPSED)==0)
/* 'Sub-Scene' channels (flags stored in Data block) */
#define FILTER_WOR_SCED(wo) ((wo->flag & WO_DS_EXPAND))
#define FILTER_NTREE_SCED(ntree) ((ntree->flag & NTREE_DS_EXPAND))
/* 'Object' channels */
#define SEL_OBJC(base) ((base->flag & SELECT))
#define EXPANDED_OBJC(ob) ((ob->nlaflag & OB_ADS_COLLAPSED)==0)

View File

@@ -155,6 +155,7 @@ static int nla_panel_context(const bContext *C, PointerRNA *adt_ptr, PointerRNA
case ANIMTYPE_DSCUR:
case ANIMTYPE_DSSKEY:
case ANIMTYPE_DSWOR:
case ANIMTYPE_DSNTREE:
case ANIMTYPE_DSPART:
case ANIMTYPE_DSMBALL:
case ANIMTYPE_DSARM:

View File

@@ -189,6 +189,7 @@ static int mouse_nla_channels (bAnimContext *ac, float x, int channel_index, sho
case ANIMTYPE_DSCUR:
case ANIMTYPE_DSSKEY:
case ANIMTYPE_DSWOR:
case ANIMTYPE_DSNTREE:
case ANIMTYPE_DSPART:
case ANIMTYPE_DSMBALL:
case ANIMTYPE_DSARM:

View File

@@ -446,6 +446,7 @@ typedef enum DOPESHEET_FILTERFLAG {
ADS_FILTER_NOPART = (1<<16),
ADS_FILTER_NOMBA = (1<<17),
ADS_FILTER_NOARM = (1<<18),
ADS_FILTER_NONTREE = (1<<19),
/* NLA-specific filters */
ADS_FILTER_NLA_NOACT = (1<<20), /* if the AnimData block has no NLA data, don't include to just show Action-line */

View File

@@ -177,6 +177,8 @@ typedef struct bNodeTree {
int stacksize; /* amount of elements in stack */
int cur_index; /* sockets in groups have unique identifiers, adding new sockets always
will increase this counter */
int flag, pad;
ListBase alltypes; /* type definitions */
struct bNodeType *owntype; /* for groups or dynamic trees, no read/write */
@@ -201,6 +203,9 @@ typedef struct bNodeTree {
#define NTREE_TYPE_INIT 1
#define NTREE_EXEC_INIT 2
/* ntree->flag */
#define NTREE_DS_EXPAND 1 /* for animation editors */
/* data structs, for node->storage */
/* this one has been replaced with ImageUser, keep it for do_versions() */