Added compositing node support to the animation editors
authorMatt Ebb <matt@mke3.net>
Wed, 11 Nov 2009 05:03:49 +0000 (05:03 +0000)
committerMatt Ebb <matt@mke3.net>
Wed, 11 Nov 2009 05:03:49 +0000 (05:03 +0000)
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...

source/blender/editors/animation/anim_channels_defines.c
source/blender/editors/animation/anim_draw.c
source/blender/editors/animation/anim_filter.c
source/blender/editors/animation/keyframes_draw.c
source/blender/editors/animation/keyframes_edit.c
source/blender/editors/include/ED_anim_api.h
source/blender/editors/space_nla/nla_buttons.c
source/blender/editors/space_nla/nla_channels.c
source/blender/makesdna/DNA_action_types.h
source/blender/makesdna/DNA_node_types.h

index 7d4ad868b45c71798868afb1f5fa290e78277a94..865e89c927abef08cb2a1dd872132acd99e04b64 100644 (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 */
index aa581a7d15afeb5c0e802e4e68559c53a711418f..45512ae82fe149349f29db61347ef514608712c2 100644 (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)
index 8c4f10fb2224e57e918555973a69dd09111322ac..eab5404f10648ba4acced8607e86498944a99f21 100644 (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);
                }
index a84ca580a1560607a6f64f7aefbecf3848987b82..fb02a88ea2bc70cb6c131b03c71f67773d95dac6 100644 (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);
+               }
        }
 }
 
index d4ec78ace164b7796fd4b048952a3cf297aca209..23daa4a9034af93fb1e586b5c18a089e2a1b36a1 100644 (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;
 }
 
index f90d28cd1759f6bc38460ab0eecd29dff3803cf1..5c83d68536242ef244b08737504c5efcf7e3538d 100644 (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)
index 3d43265b862e5848e2525ad79a0d91cb5e8ad5f4..6e5da38dd1048ad882e4d391ddf62f85c55a634f 100644 (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:
index a9380c033462533d33138468c8fb2686902d8ae7..ab447dd974aed59d16af4fd13406a700d9b9605c 100644 (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:
index aed0d4e80a7bb326810ce34fdb4ee26c26108379..5f6d8ef375ad431ebf68833aaa2a362e4a488a24 100644 (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 */
index 73ff7432577b8815633dda7eb33302b10e7bea49..9d80f7f720e39a68359cbd48b8bea7efd9159868 100644 (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() */