Revision: 24474
          
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=24474
Author:   broken
Date:     2009-11-11 06:03:49 +0100 (Wed, 11 Nov 2009)

Log Message:
-----------
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...

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

Modified: trunk/blender/source/blender/editors/animation/anim_channels_defines.c
===================================================================
--- trunk/blender/source/blender/editors/animation/anim_channels_defines.c      
2009-11-11 04:38:37 UTC (rev 24473)
+++ trunk/blender/source/blender/editors/animation/anim_channels_defines.c      
2009-11-11 05:03:49 UTC (rev 24474)
@@ -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,7 +1736,80 @@
        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  ------------------------------------------- */
 
 /* name for ShapeKey */
@@ -1982,6 +2056,7 @@
                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 */

Modified: trunk/blender/source/blender/editors/animation/anim_draw.c
===================================================================
--- trunk/blender/source/blender/editors/animation/anim_draw.c  2009-11-11 
04:38:37 UTC (rev 24473)
+++ trunk/blender/source/blender/editors/animation/anim_draw.c  2009-11-11 
05:03:49 UTC (rev 24474)
@@ -343,6 +343,7 @@
                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)

Modified: trunk/blender/source/blender/editors/animation/anim_filter.c
===================================================================
--- trunk/blender/source/blender/editors/animation/anim_filter.c        
2009-11-11 04:38:37 UTC (rev 24473)
+++ trunk/blender/source/blender/editors/animation/anim_filter.c        
2009-11-11 05:03:49 UTC (rev 24474)
@@ -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"
@@ -599,6 +600,19 @@
                                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;
                        case ANIMTYPE_DSSKEY:
                        {
                                Key *key= (Key *)data;
@@ -625,6 +639,19 @@
                                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;
                        case ANIMTYPE_DSPART:
                        {
                                ParticleSettings *part= 
(ParticleSettings*)ale->data;
@@ -1485,6 +1512,7 @@
 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 @@
                        }
                )
        }
+       /* 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 @@
        /* 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 @@
                                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);
                }

Modified: trunk/blender/source/blender/editors/animation/keyframes_draw.c
===================================================================
--- trunk/blender/source/blender/editors/animation/keyframes_draw.c     
2009-11-11 04:38:37 UTC (rev 24473)
+++ trunk/blender/source/blender/editors/animation/keyframes_draw.c     
2009-11-11 05:03:49 UTC (rev 24474)
@@ -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 @@
                        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);
+               }
        }
 }
 

Modified: trunk/blender/source/blender/editors/animation/keyframes_edit.c
===================================================================

@@ Diff output truncated at 10240 characters. @@

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to