[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [26984] trunk/blender/source/blender: Animation Editors - Texture Animation:

Joshua Leung aligorith at gmail.com
Wed Feb 17 11:21:07 CET 2010


Revision: 26984
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=26984
Author:   aligorith
Date:     2010-02-17 11:21:07 +0100 (Wed, 17 Feb 2010)

Log Message:
-----------
Animation Editors - Texture Animation:

Texture animation is now shown in the animation editors. Texture stacks are shown for each Material/Lamp/World block that uses them.

There is currently still a bit of a bug with this which means that unless the owner of the texture stack is animated too, the animation data for the textures won't show up. This will get rectified soon though.

Modified Paths:
--------------
    trunk/blender/source/blender/blenkernel/intern/texture.c
    trunk/blender/source/blender/editors/animation/anim_channels_defines.c
    trunk/blender/source/blender/editors/animation/anim_filter.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/interface/interface_templates.c
    trunk/blender/source/blender/makesdna/DNA_action_types.h
    trunk/blender/source/blender/makesdna/DNA_lamp_types.h
    trunk/blender/source/blender/makesdna/DNA_material_types.h
    trunk/blender/source/blender/makesdna/DNA_texture_types.h
    trunk/blender/source/blender/makesdna/DNA_world_types.h
    trunk/blender/source/blender/makesrna/intern/rna_action.c

Modified: trunk/blender/source/blender/blenkernel/intern/texture.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/texture.c	2010-02-17 09:33:58 UTC (rev 26983)
+++ trunk/blender/source/blender/blenkernel/intern/texture.c	2010-02-17 10:21:07 UTC (rev 26984)
@@ -420,6 +420,7 @@
 	if(tex->env) BKE_free_envmap(tex->env);
 	if(tex->pd) BKE_free_pointdensity(tex->pd);
 	if(tex->vd) BKE_free_voxeldata(tex->vd);
+	BKE_free_animdata((struct ID *)tex);
 	BKE_previewimg_free(&tex->preview);
 	BKE_icon_delete((struct ID*)tex);
 	tex->id.icon_id = 0;

Modified: trunk/blender/source/blender/editors/animation/anim_channels_defines.c
===================================================================
--- trunk/blender/source/blender/editors/animation/anim_channels_defines.c	2010-02-17 09:33:58 UTC (rev 26983)
+++ trunk/blender/source/blender/editors/animation/anim_channels_defines.c	2010-02-17 10:21:07 UTC (rev 26984)
@@ -55,6 +55,7 @@
 #include "DNA_lamp_types.h"
 #include "DNA_mesh_types.h"
 #include "DNA_material_types.h"
+#include "DNA_texture_types.h"
 #include "DNA_meta_types.h"
 #include "DNA_node_types.h"
 #include "DNA_userdef_types.h"
@@ -255,8 +256,9 @@
 	short indent= 0;
 	
 	if (ale->id) {
-		/* special exception for materials and particles */
-		if (ELEM(GS(ale->id->name),ID_MA,ID_PA))
+		/* special exception for materials, textures, and particles */
+		// xxx should tex use indention 2?
+		if (ELEM3(GS(ale->id->name),ID_MA,ID_PA,ID_TE))
 			indent++;
 	}
 	
@@ -290,8 +292,25 @@
 	short offset= acf_generic_basic_offset(ac, ale);
 	
 	if (ale->id) {
+		/* special exception for textures */
+		if (GS(ale->id->name) == ID_TE) {
+			/* minimum offset */
+			offset += 21;
+			
+			/* special offset from owner type */
+			switch (ale->ownertype) {
+				case ANIMTYPE_DSMAT:
+					offset += 21;
+					break;
+					
+				case ANIMTYPE_DSLAM:
+				case ANIMTYPE_DSWOR:
+					offset += 14;
+					break;
+			}
+		}
 		/* special exception for materials and particles */
-		if (ELEM(GS(ale->id->name),ID_MA,ID_PA)) 
+		else if (ELEM(GS(ale->id->name),ID_MA,ID_PA)) 
 			offset += 21;
 			
 		/* if not in Action Editor mode, groupings must carry some offset too... */
@@ -329,13 +348,19 @@
 static short acf_generic_dsexpand_setting_valid(bAnimContext *ac, bAnimListElem *ale, int setting)
 {
 	switch (setting) {
-		/* only expand supported */
+		/* only expand supported everywhere */
 		case ACHANNEL_SETTING_EXPAND:
 			return 1;
 			
-		 /* visible - only available in Graph Editor */
+		/* visible 
+		 * 	- only available in Graph Editor 
+		 *	- NOT available for 'filler' channels
+		 */
 		case ACHANNEL_SETTING_VISIBLE: 
-			return ((ac) && (ac->spacetype == SPACE_IPO));
+			if (ELEM3(ale->type, ANIMTYPE_FILLMATD, ANIMTYPE_FILLPARTD, ANIMTYPE_FILLTEXD))
+				return 0;
+			else
+				return ((ac) && (ac->spacetype == SPACE_IPO));
 			
 		default:
 			return 0;
@@ -1166,6 +1191,112 @@
 	acf_generic_dsexpand_setting_ptr		/* pointer for setting */
 };
 
+/* Textures Expander  ------------------------------------------- */
+
+/* offset for groups + grouped entities */
+static short acf_filltexd_offset(bAnimContext *ac, bAnimListElem *ale)
+{
+	short offset= acf_generic_basic_offset(ac, ale);
+	
+	if (ale->id) {
+		/* materials */
+		switch (GS(ale->id->name)) {
+			case ID_MA:
+				offset += 21;
+				break;
+				
+			case ID_LA:
+			case ID_WO:
+				offset += 14;
+				break;
+		}
+	}
+	
+	return offset;
+}
+
+// TODO: just get this from RNA?
+static int acf_filltexd_icon(bAnimListElem *ale)
+{
+	return ICON_TEXTURE_DATA;
+}
+
+static void acf_filltexd_name(bAnimListElem *ale, char *name)
+{
+	strcpy(name, "Textures");
+}
+
+/* get pointer to the setting (category only) */
+static void *acf_filltexd_setting_ptr(bAnimListElem *ale, int setting, short *type)
+{
+	ID *id= (ID *)ale->data;
+	
+	/* clear extra return data first */
+	*type= 0;
+	
+	switch (setting) {
+		case ACHANNEL_SETTING_EXPAND: /* expanded */
+		{
+			switch (GS(id->name)) {
+				case ID_MA:
+				{
+					Material *ma= (Material *)id;
+					GET_ACF_FLAG_PTR(ma->flag);
+				}
+				
+				case ID_LA:
+				{
+					Lamp *la= (Lamp *)id;
+					GET_ACF_FLAG_PTR(la->flag);
+				}
+					
+				case ID_WO:
+				{
+					World *wo= (World *)id;
+					GET_ACF_FLAG_PTR(wo->flag);
+				}
+			}
+		}
+		
+		default: /* unsupported */
+			return NULL;
+	}
+}
+
+/* get the appropriate flag(s) for the setting when it is valid  */
+static int acf_filltexd_setting_flag(bAnimContext *ac, int setting, short *neg)
+{
+	/* clear extra return data first */
+	*neg= 0;
+	
+	switch (setting) {
+		case ACHANNEL_SETTING_EXPAND: /* expanded */
+			/* NOTE: the exact same flag must be used for other texture stack types too! */
+			return MA_DS_SHOW_TEXS;	
+		
+		default: /* unsupported */
+			return 0;
+	}
+}
+
+/* particles expander type define */
+static bAnimChannelType ACF_FILLTEXD= 
+{
+	"Textures Filler",				/* type name */
+	
+	acf_generic_dataexpand_color,	/* backdrop color */
+	acf_generic_dataexpand_backdrop,/* backdrop */
+	acf_generic_indention_flexible,	/* indent level */
+	acf_filltexd_offset,			/* offset */
+	
+	acf_filltexd_name,				/* name */
+	acf_filltexd_icon,				/* icon */
+	
+	acf_generic_dsexpand_setting_valid,	/* has setting */	
+	acf_filltexd_setting_flag,			/* flag for setting */
+	acf_filltexd_setting_ptr			/* pointer for setting */
+};
+
 /* Material Expander  ------------------------------------------- */
 
 // TODO: just get this from RNA?
@@ -1324,6 +1455,101 @@
 	acf_dslam_setting_ptr					/* pointer for setting */
 };
 
+/* Texture Expander  ------------------------------------------- */
+
+// TODO: just get this from RNA?
+static int acf_dstex_icon(bAnimListElem *ale)
+{
+	return ICON_TEXTURE_DATA;
+}
+
+/* offset for texture expanders */
+static short acf_dstex_offset(bAnimContext *ac, bAnimListElem *ale)
+{
+	short offset = 21;
+	
+	/* special offset from owner type */
+	// FIXME: too much now!
+	switch (ale->ownertype) {
+		case ANIMTYPE_DSMAT:
+			offset += 14;
+			
+		case ANIMTYPE_DSLAM:
+		case ANIMTYPE_DSWOR:
+			offset += 7;
+	}
+	
+	return offset;
+}
+
+/* get the appropriate flag(s) for the setting when it is valid  */
+static int acf_dstex_setting_flag(bAnimContext *ac, int setting, short *neg)
+{
+	/* clear extra return data first */
+	*neg= 0;
+	
+	switch (setting) {
+		case ACHANNEL_SETTING_EXPAND: /* expanded */
+			return TEX_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_dstex_setting_ptr(bAnimListElem *ale, int setting, short *type)
+{
+	Tex *tex= (Tex *)ale->data;
+	
+	/* clear extra return data first */
+	*type= 0;
+	
+	switch (setting) {
+		case ACHANNEL_SETTING_EXPAND: /* expanded */
+			GET_ACF_FLAG_PTR(tex->flag);
+			
+		case ACHANNEL_SETTING_SELECT: /* selected */
+		case ACHANNEL_SETTING_MUTE: /* muted (for NLA only) */
+		case ACHANNEL_SETTING_VISIBLE: /* visible (for Graph Editor only) */
+			if (tex->adt)
+				GET_ACF_FLAG_PTR(tex->adt->flag)
+			else
+				return NULL;	
+		
+		default: /* unsupported */
+			return NULL;
+	}
+}
+
+/* material expander type define */
+static bAnimChannelType ACF_DSTEX= 
+{
+	"Texture Data Expander",		/* type name */
+	
+	acf_generic_channel_color,		/* backdrop color */
+	acf_generic_channel_backdrop,	/* backdrop */
+	acf_generic_indention_0,		/* indent level */
+	acf_dstex_offset,				/* offset */
+	
+	acf_generic_idblock_name,		/* name */
+	acf_dstex_icon,					/* icon */
+	
+	acf_generic_dataexpand_setting_valid,	/* has setting */
+	acf_dstex_setting_flag,					/* flag for setting */
+	acf_dstex_setting_ptr					/* pointer for setting */
+};
+
 /* Camera Expander  ------------------------------------------- */
 
 // TODO: just get this from RNA?
@@ -2260,6 +2486,7 @@
 		animchannelTypeInfo[type++]= &ACF_FILLDRIVERS; 	/* Drivers Expander */
 		animchannelTypeInfo[type++]= &ACF_FILLMATD; 	/* Materials Expander */
 		animchannelTypeInfo[type++]= &ACF_FILLPARTD; 	/* Particles Expander */
+		animchannelTypeInfo[type++]= &ACF_FILLTEXD;		/* Textures Expander */
 		
 		animchannelTypeInfo[type++]= &ACF_DSMAT;		/* Material Channel */
 		animchannelTypeInfo[type++]= &ACF_DSLAM;		/* Lamp Channel */
@@ -2272,6 +2499,7 @@
 		animchannelTypeInfo[type++]= &ACF_DSMBALL;		/* MetaBall Channel */
 		animchannelTypeInfo[type++]= &ACF_DSARM;		/* Armature Channel */
 		animchannelTypeInfo[type++]= &ACF_DSMESH;		/* Mesh Channel */
+		animchannelTypeInfo[type++]= &ACF_DSTEX;		/* Texture Channel */
 		
 		animchannelTypeInfo[type++]= &ACF_SHAPEKEY;		/* ShapeKey */
 		

Modified: trunk/blender/source/blender/editors/animation/anim_filter.c
===================================================================
--- trunk/blender/source/blender/editors/animation/anim_filter.c	2010-02-17 09:33:58 UTC (rev 26983)
+++ trunk/blender/source/blender/editors/animation/anim_filter.c	2010-02-17 10:21:07 UTC (rev 26984)
@@ -71,6 +71,7 @@
 #include "DNA_sequence_types.h"
 #include "DNA_scene_types.h"
 #include "DNA_screen_types.h"
+#include "DNA_texture_types.h"
 #include "DNA_windowmanager_types.h"
 #include "DNA_world_types.h"
 
@@ -556,6 +557,35 @@
 				ale->datatype= ALE_NONE;
 			}
 				break;
+			case ANIMTYPE_FILLTEXD:
+			{
+				ID *id= (ID *)data;
+				
+				switch (GS(id->name)) {
+					case ID_MA:
+					{
+						Material *ma= (Material *)id;
+						ale->flag= FILTER_TEX_MATC(ma);
+					}
+						break;
+					case ID_LA:
+					{
+						Lamp *la= (Lamp *)id;
+						ale->flag= FILTER_TEX_LAMC(la);
+					}
+						break;
+					case ID_WO:
+					{
+						World *wo= (World *)id;
+						ale->flag= FILTER_TEX_WORC(wo);
+					}
+						break;
+				}
+				
+				ale->key_data= NULL;
+				ale->datatype= ALE_NONE;
+			}
+				break;
 			
 			case ANIMTYPE_DSMAT:
 			{
@@ -687,7 +717,20 @@
 				ale->adt= BKE_animdata_from_id(data);
 			}
 				break;
+			case ANIMTYPE_DSTEX:
+			{
+				Tex *tex= (Tex *)data;
+				AnimData *adt= tex->adt;
 				
+				ale->flag= FILTER_TEX_DATA(tex); 
+				
+				ale->key_data= (adt) ? adt->action : NULL;
+				ale->datatype= ALE_ACT;
+				
+				ale->adt= BKE_animdata_from_id(data);
+			}
+				break;
+				
 			case ANIMTYPE_GROUP:
 			{
 				bActionGroup *agrp= (bActionGroup *)data;
@@ -1220,6 +1263,133 @@
 }
 #endif 
 

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list