[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [37838] branches/soc-2011-pepper/source/ blender/editors: AnimChannelFiltering - Material Nodes support

Joshua Leung aligorith at gmail.com
Mon Jun 27 05:54:33 CEST 2011


Revision: 37838
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=37838
Author:   aligorith
Date:     2011-06-27 03:54:33 +0000 (Mon, 27 Jun 2011)
Log Message:
-----------
AnimChannelFiltering - Material Nodes support

Animation for Material nodes is now shown in Animation Editors :)

Modified Paths:
--------------
    branches/soc-2011-pepper/source/blender/editors/animation/anim_channels_defines.c
    branches/soc-2011-pepper/source/blender/editors/animation/anim_filter.c
    branches/soc-2011-pepper/source/blender/editors/include/ED_anim_api.h
    branches/soc-2011-pepper/source/blender/editors/space_nla/nla_draw.c

Modified: branches/soc-2011-pepper/source/blender/editors/animation/anim_channels_defines.c
===================================================================
--- branches/soc-2011-pepper/source/blender/editors/animation/anim_channels_defines.c	2011-06-27 03:54:22 UTC (rev 37837)
+++ branches/soc-2011-pepper/source/blender/editors/animation/anim_channels_defines.c	2011-06-27 03:54:33 UTC (rev 37838)
@@ -259,23 +259,53 @@
 		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 @@
 	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 @@
 	
 	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 */

Modified: branches/soc-2011-pepper/source/blender/editors/animation/anim_filter.c
===================================================================
--- branches/soc-2011-pepper/source/blender/editors/animation/anim_filter.c	2011-06-27 03:54:22 UTC (rev 37837)
+++ branches/soc-2011-pepper/source/blender/editors/animation/anim_filter.c	2011-06-27 03:54:33 UTC (rev 37838)
@@ -672,7 +672,7 @@
 				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_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 @@
 			/* 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;
 		

Modified: branches/soc-2011-pepper/source/blender/editors/include/ED_anim_api.h
===================================================================
--- branches/soc-2011-pepper/source/blender/editors/include/ED_anim_api.h	2011-06-27 03:54:22 UTC (rev 37837)
+++ branches/soc-2011-pepper/source/blender/editors/include/ED_anim_api.h	2011-06-27 03:54:33 UTC (rev 37838)
@@ -230,7 +230,6 @@
 #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,15 +244,17 @@
 #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 */
 #define EDITABLE_AGRP(agrp) ((agrp->flag & AGRP_PROTECTED)==0)

Modified: branches/soc-2011-pepper/source/blender/editors/space_nla/nla_draw.c
===================================================================
--- branches/soc-2011-pepper/source/blender/editors/space_nla/nla_draw.c	2011-06-27 03:54:22 UTC (rev 37837)
+++ branches/soc-2011-pepper/source/blender/editors/space_nla/nla_draw.c	2011-06-27 03:54:33 UTC (rev 37838)
@@ -38,6 +38,7 @@
 #include <float.h>
 
 #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 @@
 					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 @@
 					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;
 					}




More information about the Bf-blender-cvs mailing list