From b6bc47eb098261189c63b3aecb806960db6235e1 Mon Sep 17 00:00:00 2001 From: Joshua Leung Date: Mon, 27 Jun 2011 03:54:33 +0000 Subject: AnimChannelFiltering - Material Nodes support Animation for Material nodes is now shown in Animation Editors :) --- .../editors/animation/anim_channels_defines.c | 51 +++++++++++++++++++--- source/blender/editors/animation/anim_filter.c | 23 +++------- source/blender/editors/include/ED_anim_api.h | 7 +-- source/blender/editors/space_nla/nla_draw.c | 43 +++++++++++++++++- 4 files changed, 98 insertions(+), 26 deletions(-) (limited to 'source/blender/editors') diff --git a/source/blender/editors/animation/anim_channels_defines.c b/source/blender/editors/animation/anim_channels_defines.c index c3e79d787e1..c4246ab534c 100644 --- a/source/blender/editors/animation/anim_channels_defines.c +++ b/source/blender/editors/animation/anim_channels_defines.c @@ -259,23 +259,53 @@ static short acf_generic_basic_offset(bAnimContext *ac, bAnimListElem *ale) return 0; } +/* offset based on nodetree type */ +static short acf_nodetree_rootType_offset(bNodeTree *ntree) +{ + if (ntree) { + switch (ntree->type) { + case NTREE_SHADER: + /* 1 additional level (i.e. is indented one level in from material, + * so shift all right by one step) + */ + return INDENT_STEP_SIZE; + + case NTREE_COMPOSIT: + /* no additional levels needed */ + return 0; + + case NTREE_TEXTURE: + /* 2 additional levels */ + return INDENT_STEP_SIZE*2; + } + } + + // unknown + return 0; +} + /* offset for groups + grouped entities */ static short acf_generic_group_offset(bAnimContext *ac, bAnimListElem *ale) { short offset= acf_generic_basic_offset(ac, ale); if (ale->id) { - /* special exception for textures */ + /* texture animdata */ if (GS(ale->id->name) == ID_TE) { offset += 21; } - /* special exception for materials and particles */ + /* materials and particles animdata */ else if (ELEM(GS(ale->id->name),ID_MA,ID_PA)) offset += 14; - /* if not in Action Editor mode, groupings must carry some offset too... */ + /* if not in Action Editor mode, action-groups (and their children) must carry some offset too... */ else if (ac->datatype != ANIMCONT_ACTION) offset += 14; + + /* nodetree animdata */ + if (GS(ale->id->name) == ID_NT) { + offset += acf_nodetree_rootType_offset((bNodeTree*)ale->id); + } } /* offset is just the normal type - i.e. based on indention */ @@ -1827,6 +1857,17 @@ static int acf_dsntree_icon(bAnimListElem *UNUSED(ale)) return ICON_NODETREE; } +/* offset for nodetree expanders */ +static short acf_dsntree_offset(bAnimContext *ac, bAnimListElem *ale) +{ + bNodeTree *ntree = (bNodeTree *)ale->data; + short offset= acf_generic_basic_offset(ac, ale); + + offset += acf_nodetree_rootType_offset(ntree); + + return offset; +} + /* get the appropriate flag(s) for the setting when it is valid */ static int acf_dsntree_setting_flag(bAnimContext *UNUSED(ac), int setting, short *neg) { @@ -1884,8 +1925,8 @@ static bAnimChannelType ACF_DSNTREE= acf_generic_dataexpand_color, /* backdrop color */ acf_generic_dataexpand_backdrop,/* backdrop */ - acf_generic_indention_1, /* indent level */ // XXX this only works for compositing - acf_generic_basic_offset, /* offset */ + acf_generic_indention_1, /* indent level */ + acf_dsntree_offset, /* offset */ acf_generic_idblock_name, /* name */ acf_dsntree_icon, /* icon */ diff --git a/source/blender/editors/animation/anim_filter.c b/source/blender/editors/animation/anim_filter.c index ca300892636..e2c902d6131 100644 --- a/source/blender/editors/animation/anim_filter.c +++ b/source/blender/editors/animation/anim_filter.c @@ -672,7 +672,7 @@ static bAnimListElem *make_new_animlistelem (void *data, short datatype, ID *own bNodeTree *ntree= (bNodeTree *)data; AnimData *adt= ntree->adt; - ale->flag= FILTER_NTREE_SCED(ntree); + ale->flag= FILTER_NTREE_DATA(ntree); ale->key_data= (adt) ? adt->action : NULL; ale->datatype= ALE_ACT; @@ -1282,25 +1282,11 @@ static size_t animdata_filter_gpencil (ListBase *anim_data, void *UNUSED(data), 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}; - short expanded = 0; size_t tmp_items = 0; size_t items = 0; - /* get datatype specific data first */ - if (owner_id == NULL) - return 0; - - switch (GS(owner_id->name)) { - case ID_SCE: /* compositing nodes */ - { - //Scene *scene = (Scene *)owner_id; - expanded = FILTER_NTREE_SCED(ntree); // XXX: this macro needs renaming... doesn't only do this for scene ones! - } - break; - } - /* add nodetree animation channels */ - BEGIN_ANIMFILTER_SUBCHANNELS(expanded) + BEGIN_ANIMFILTER_SUBCHANNELS(FILTER_NTREE_DATA(ntree)) { /* animation data filtering */ tmp_items += animfilter_block_data(ac, &tmp_data, ads, (ID *)ntree, filter_mode); @@ -1427,6 +1413,11 @@ static size_t animdata_filter_ds_materials (bAnimContext *ac, ListBase *anim_dat /* textures */ if (!(ads->filterflag & ADS_FILTER_NOTEX)) tmp_items += animdata_filter_ds_textures(ac, &tmp_data, ads, (ID *)ma, filter_mode); + + /* nodes */ + if ((ma->nodetree) && !(ads->filterflag & ADS_FILTER_NONTREE)) { + tmp_items += animdata_filter_ds_nodetree(ac, &tmp_data, ads, (ID *)ma, ma->nodetree, filter_mode); + } } END_ANIMFILTER_SUBCHANNELS; diff --git a/source/blender/editors/include/ED_anim_api.h b/source/blender/editors/include/ED_anim_api.h index 7853bd0b5c2..7c23389ed6f 100644 --- a/source/blender/editors/include/ED_anim_api.h +++ b/source/blender/editors/include/ED_anim_api.h @@ -230,7 +230,6 @@ 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) @@ -245,14 +244,16 @@ typedef enum eAnimFilter_Flags { #define FILTER_ARM_OBJD(arm) ((arm->flag & ARM_DS_EXPAND)) #define FILTER_MESH_OBJD(me) ((me->flag & ME_DS_EXPAND)) #define FILTER_LATTICE_OBJD(lt) ((lt->flag & LT_DS_EXPAND)) + /* Variable use expanders */ +#define FILTER_NTREE_DATA(ntree) ((ntree->flag & NTREE_DS_EXPAND)) +#define FILTER_TEX_DATA(tex) ((tex->flag & TEX_DS_EXPAND)) /* 'Sub-object/Action' channels (flags stored in Action) */ #define SEL_ACTC(actc) ((actc->flag & ACT_SELECTED)) #define EXPANDED_ACTC(actc) ((actc->flag & ACT_COLLAPSED)==0) /* 'Sub-AnimData' channels */ #define EXPANDED_DRVD(adt) ((adt->flag & ADT_DRIVERS_COLLAPSED)==0) - /* Texture expanders */ -#define FILTER_TEX_DATA(tex) ((tex->flag & TEX_DS_EXPAND)) + /* Actions (also used for Dopesheet) */ /* Action Channel Group */ diff --git a/source/blender/editors/space_nla/nla_draw.c b/source/blender/editors/space_nla/nla_draw.c index dc9594c6e4c..5138569539e 100644 --- a/source/blender/editors/space_nla/nla_draw.c +++ b/source/blender/editors/space_nla/nla_draw.c @@ -38,6 +38,7 @@ #include #include "DNA_anim_types.h" +#include "DNA_node_types.h" #include "DNA_screen_types.h" #include "DNA_space_types.h" #include "DNA_windowmanager_types.h" @@ -608,9 +609,28 @@ static void draw_nla_channel_list_gl (bAnimContext *ac, ListBase *anim_data, Vie if (ale->id) { /* special exception for textures */ if (GS(ale->id->name) == ID_TE) { - offset= 21; + offset= 14; indent= 1; } + /* special exception for nodetrees */ + else if (GS(ale->id->name) == ID_NT) { + bNodeTree *ntree = (bNodeTree *)ale->id; + + switch (ntree->type) { + case NTREE_SHADER: + { + /* same as for textures */ + offset= 14; + indent= 1; + } + break; + + default: + /* normal will do */ + offset= 14; + break; + } + } else offset= 14; } @@ -656,9 +676,28 @@ static void draw_nla_channel_list_gl (bAnimContext *ac, ListBase *anim_data, Vie if (ale->id) { /* special exception for textures */ if (GS(ale->id->name) == ID_TE) { - offset= 21; + offset= 14; indent= 1; } + /* special exception for nodetrees */ + else if (GS(ale->id->name) == ID_NT) { + bNodeTree *ntree = (bNodeTree *)ale->id; + + switch (ntree->type) { + case NTREE_SHADER: + { + /* same as for textures */ + offset= 14; + indent= 1; + } + break; + + default: + /* normal will do */ + offset= 14; + break; + } + } else offset= 14; } -- cgit v1.2.3