[Bf-blender-cvs] [7706260] alembic_basic_io: Support animation of CacheFile properties.

Kévin Dietrich noreply at git.blender.org
Fri Jun 24 22:29:30 CEST 2016


Commit: 77062602d120d7e21364a70a8bb7e7c349c5315b
Author: Kévin Dietrich
Date:   Fri Jun 24 21:11:46 2016 +0200
Branches: alembic_basic_io
https://developer.blender.org/rB77062602d120d7e21364a70a8bb7e7c349c5315b

Support animation of CacheFile properties.

===================================================================

M	source/blender/blenkernel/intern/anim_sys.c
M	source/blender/blenkernel/intern/cachefile.c
M	source/blender/blenloader/intern/readfile.c
M	source/blender/blenloader/intern/writefile.c
M	source/blender/editors/animation/anim_channels_defines.c
M	source/blender/editors/animation/anim_channels_edit.c
M	source/blender/editors/animation/anim_filter.c
M	source/blender/editors/animation/keyframes_draw.c
M	source/blender/editors/include/ED_anim_api.h
M	source/blender/editors/include/ED_keyframes_draw.h
M	source/blender/editors/interface/interface_icons.c
M	source/blender/editors/space_nla/nla_buttons.c
M	source/blender/editors/space_nla/nla_channels.c
M	source/blender/editors/space_outliner/outliner_tree.c
M	source/blender/editors/space_time/space_time.c
M	source/blender/makesdna/DNA_action_types.h
M	source/blender/makesdna/DNA_cachefile_types.h
M	source/blender/makesrna/intern/rna_cachefile.c
M	source/blender/makesrna/intern/rna_space.c

===================================================================

diff --git a/source/blender/blenkernel/intern/anim_sys.c b/source/blender/blenkernel/intern/anim_sys.c
index 91b33f3..8b7681c 100644
--- a/source/blender/blenkernel/intern/anim_sys.c
+++ b/source/blender/blenkernel/intern/anim_sys.c
@@ -101,6 +101,7 @@ bool id_type_can_have_animdata(ID *id)
 		case ID_MC:
 		case ID_MSK:
 		case ID_GD:
+		case ID_CF:
 		{
 			return true;
 		}
@@ -1158,6 +1159,9 @@ void BKE_animdata_main_cb(Main *mainptr, ID_AnimData_Edit_Callback func, void *u
 	
 	/* grease pencil */
 	ANIMDATA_IDS_CB(mainptr->gpencil.first);
+
+	/* cache files */
+	ANIMDATA_IDS_CB(mainptr->cachefiles.first);
 }
 
 /* Fix all RNA-Paths throughout the database (directly access the Global.main version)
@@ -1248,6 +1252,9 @@ void BKE_animdata_fix_paths_rename_all(ID *ref_id, const char *prefix, const cha
 	
 	/* grease pencil */
 	RENAMEFIX_ANIM_IDS(mainptr->gpencil.first);
+
+	/* cache files */
+	RENAMEFIX_ANIM_IDS(mainptr->cachefiles.first);
 	
 	/* scenes */
 	RENAMEFIX_ANIM_NODETREE_IDS(mainptr->scene.first, Scene);
@@ -2825,6 +2832,9 @@ void BKE_animsys_evaluate_all_animation(Main *main, Scene *scene, float ctime)
 	
 	/* grease pencil */
 	EVAL_ANIM_IDS(main->gpencil.first, ADT_RECALC_ANIM);
+
+	/* cache files */
+	EVAL_ANIM_IDS(main->cachefiles.first, ADT_RECALC_ANIM);
 	
 	/* objects */
 	/* ADT_RECALC_ANIM doesn't need to be supplied here, since object AnimData gets
diff --git a/source/blender/blenkernel/intern/cachefile.c b/source/blender/blenkernel/intern/cachefile.c
index 334de78..621957a 100644
--- a/source/blender/blenkernel/intern/cachefile.c
+++ b/source/blender/blenkernel/intern/cachefile.c
@@ -35,6 +35,7 @@
 #include "BLI_string.h"
 #include "BLI_utildefines.h"
 
+#include "BKE_animsys.h"
 #include "BKE_cachefile.h"
 #include "BKE_global.h"
 #include "BKE_library.h"
@@ -67,12 +68,13 @@ void *BKE_cachefile_add(Main *bmain, const char *name)
 	return cache_file;
 }
 
+/** Free (or release) any data used by this cachefile (does not free the cachefile itself). */
 void BKE_cachefile_free(CacheFile *cache_file)
 {
+	BKE_animdata_free((ID *)cache_file, false);
+
 #ifdef WITH_ALEMBIC
 	ABC_free_handle(cache_file->handle);
-#else
-	UNUSED_VARS(cache_file);
 #endif
 }
 
diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c
index 8cd7fde..dc2ec1f 100644
--- a/source/blender/blenloader/intern/readfile.c
+++ b/source/blender/blenloader/intern/readfile.c
@@ -2263,28 +2263,6 @@ static PackedFile *direct_link_packedfile(FileData *fd, PackedFile *oldpf)
 	return pf;
 }
 
-/* ************ READ CACHEFILES *************** */
-
-static void lib_link_cachefiles(FileData *fd, Main *main)
-{
-	CacheFile *cache_file;
-
-	/* only link ID pointers */
-	for (cache_file = main->cachefiles.first; cache_file; cache_file = cache_file->id.next) {
-		if (cache_file->id.tag & LIB_TAG_NEED_LINK) {
-			cache_file->id.tag &= ~LIB_TAG_NEED_LINK;
-
-			BKE_cachefile_load(cache_file, fd->relabase);
-		}
-	}
-}
-
-static void direct_link_cachefile(FileData *fd, CacheFile *cache_file)
-{
-	cache_file->handle = NULL;
-	UNUSED_VARS(fd);
-}
-
 /* ************ READ ANIMATION STUFF ***************** */
 
 /* Legacy Data Support (for Version Patching) ----------------------------- */
@@ -2710,6 +2688,35 @@ static void direct_link_animdata(FileData *fd, AnimData *adt)
 	adt->actstrip = newdataadr(fd, adt->actstrip);
 }	
 
+/* ************ READ CACHEFILES *************** */
+
+static void lib_link_cachefiles(FileData *fd, Main *main)
+{
+	CacheFile *cache_file;
+
+	/* only link ID pointers */
+	for (cache_file = main->cachefiles.first; cache_file; cache_file = cache_file->id.next) {
+		if (cache_file->id.tag & LIB_TAG_NEED_LINK) {
+			cache_file->id.tag &= ~LIB_TAG_NEED_LINK;
+		}
+
+		BKE_cachefile_load(cache_file, fd->relabase);
+
+		if (cache_file->adt) {
+			lib_link_animdata(fd, &cache_file->id, cache_file->adt);
+		}
+	}
+}
+
+static void direct_link_cachefile(FileData *fd, CacheFile *cache_file)
+{
+	cache_file->handle = NULL;
+
+	/* relink animdata */
+	cache_file->adt = newdataadr(fd, cache_file->adt);
+	direct_link_animdata(fd, cache_file->adt);
+}
+
 /* ************ READ MOTION PATHS *************** */
 
 /* direct data for cache */
@@ -9437,6 +9444,13 @@ static void expand_camera(FileData *fd, Main *mainvar, Camera *ca)
 		expand_animdata(fd, mainvar, ca->adt);
 }
 
+static void expand_cachefile(FileData *fd, Main *mainvar, CacheFile *cache_file)
+{
+	if (cache_file->adt) {
+		expand_animdata(fd, mainvar, cache_file->adt);
+	}
+}
+
 static void expand_speaker(FileData *fd, Main *mainvar, Speaker *spk)
 {
 	expand_doit(fd, mainvar, spk->sound);
@@ -9632,6 +9646,9 @@ void BLO_expand_main(void *fdhandle, Main *mainvar)
 					case ID_GD:
 						expand_gpencil(fd, mainvar, (bGPdata *)id);
 						break;
+					case ID_CF:
+						expand_cachefile(fd, mainvar, (CacheFile *)id);
+						break;
 					}
 					
 					do_it = true;
diff --git a/source/blender/blenloader/intern/writefile.c b/source/blender/blenloader/intern/writefile.c
index f6b7a42..0d5b67d 100644
--- a/source/blender/blenloader/intern/writefile.c
+++ b/source/blender/blenloader/intern/writefile.c
@@ -3577,6 +3577,10 @@ static void write_cachefiles(WriteData *wd, ListBase *idbase)
 	for (cache_file = idbase->first; cache_file; cache_file = cache_file->id.next) {
 		if (cache_file->id.us > 0 || wd->current) {
 			writestruct(wd, ID_CF, "CacheFile", 1, cache_file);
+
+			if (cache_file->adt) {
+				write_animdata(wd, cache_file->adt);
+			}
 		}
 	}
 }
diff --git a/source/blender/editors/animation/anim_channels_defines.c b/source/blender/editors/animation/anim_channels_defines.c
index ea2f7fc..dcd3157 100644
--- a/source/blender/editors/animation/anim_channels_defines.c
+++ b/source/blender/editors/animation/anim_channels_defines.c
@@ -40,6 +40,7 @@
 
 #include "DNA_anim_types.h"
 #include "DNA_armature_types.h"
+#include "DNA_cachefile_types.h"
 #include "DNA_camera_types.h"
 #include "DNA_object_types.h"
 #include "DNA_particle_types.h"
@@ -1578,6 +1579,88 @@ static bAnimChannelType ACF_DSTEX =
 /* Camera Expander  ------------------------------------------- */
 
 // TODO: just get this from RNA?
+static int acf_dscachefile_icon(bAnimListElem *ale)
+{
+	UNUSED_VARS(ale);
+	return ICON_FILE;
+}
+
+/* get the appropriate flag(s) for the setting when it is valid  */
+static int acf_dscachefile_setting_flag(bAnimContext *ac, eAnimChannel_Settings setting, bool *neg)
+{
+	/* clear extra return data first */
+	*neg = false;
+
+	switch (setting) {
+		case ACHANNEL_SETTING_EXPAND: /* expanded */
+			return CACHEFILE_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 = true;
+			return ADT_CURVES_NOT_VISIBLE;
+
+		case ACHANNEL_SETTING_SELECT: /* selected */
+			return ADT_UI_SELECTED;
+
+		default: /* unsupported */
+			return 0;
+	}
+
+	UNUSED_VARS(ac);
+}
+
+/* get pointer to the setting */
+static void *acf_dscachefile_setting_ptr(bAnimListElem *ale, eAnimChannel_Settings setting, short *type)
+{
+	CacheFile *cache_file = (CacheFile *)ale->data;
+
+	/* clear extra return data first */
+	*type = 0;
+
+	switch (setting) {
+		case ACHANNEL_SETTING_EXPAND: /* expanded */
+			return GET_ACF_FLAG_PTR(cache_file->flag, type);
+
+		case ACHANNEL_SETTING_SELECT: /* selected */
+		case ACHANNEL_SETTING_MUTE: /* muted (for NLA only) */
+		case ACHANNEL_SETTING_VISIBLE: /* visible (for Graph Editor only) */
+			if (cache_file->adt) {
+				return GET_ACF_FLAG_PTR(cache_file->adt->flag, type);
+			}
+
+			return NULL;
+
+		default: /* unsupported */
+			return NULL;
+	}
+}
+
+/* CacheFile expander type define. */
+static bAnimChannelType ACF_DSCACHEFILE =
+{
+	"Cache File Expander",          /* type name */
+	ACHANNEL_ROLE_EXPANDER,         /* role */
+
+	acf_generic_dataexpand_color,   /* backdrop color */
+	acf_generic_dataexpand_backdrop, /* backdrop */
+	acf_generic_indention_1,        /* indent level */
+	acf_generic_basic_offset,       /* offset */
+
+	acf_generic_idblock_name,       /* name */
+	acf_generic_idfill_name_prop,   /* name prop */
+	acf_dscachefile_icon,           /* icon */
+
+	acf_generic_dataexpand_setting_valid,   /* has setting */
+	acf_dscachefile_setting_flag,           /* flag for setting */
+	acf_dscachefile_setting_ptr             /* pointer for setting */
+};
+
+/* Camera Expander  ------------------------------------------- */
+
+// TODO: just get this from RNA?
 static int acf_dscam_icon(bAnimListElem *UNUSED(ale))
 {
 	return ICON_CAMERA_DATA;
@@ -3388,6 +3471,7 @@ static void ANIM_init_channel_typeinfo_data(void)
 		animchannelTypeInfo[type++] = &ACF_DSMAT;        /* Material Channel */
 		animchannelTypeInfo[type++] = &ACF_DSLAM;        /* Lamp Channel */
 		animchannelTypeInfo[type++] = &ACF_DSCAM;        /* Camera Channel */
+		animchannelTypeInfo[type++] = &ACF_DSCACHEFILE;  /* CacheFile Channel */
 		animchannelTypeInfo[type++] = &ACF_DSCUR;        /* Curve Channel */
 		animchannelTypeInfo[type++] = &ACF_DSSKEY;       /* ShapeKey Channel */
 		animchannelTypeInfo[type++] = &ACF_DSWOR;        /* World Channel */
diff --git a/source/blender/editors/animation/anim_channels_edit.c b/source/blender/editors/animation/anim_channels_edit.c
index c98470f..0fadc58 100644
--- a/source/blender/editors/animation/anim_channels_edit.c
+++ b/source/blender/editors/animation/anim_channels_edit.c
@@ -120,6 +120,7 @@ void ANIM_set_active_channel(bAnimContext *ac, void *data, eAnimCont_Types datat
 			case ANIMTYPE_DSMAT:    /* Datablock AnimData Expanders */
 			case ANIMTYPE_DSLAM:
 			case ANIMTYPE_DSCAM:
+			case ANIMTYPE_DSCACHEFILE:
 			case ANIMTYPE_DSCUR:
 			case ANIMTYPE_DSSKEY:
 			case ANIMTYPE_DSWOR:
@@ -175,6 +176,7 @@ void ANIM_set_active_channel(bAnimContext *ac, void *data, eAnimCont_Types datat
 			case ANIMTYPE_DSMAT:    /* Datablock AnimData Expanders */
 			case ANIMTYPE_DSLAM:
 			case ANIMTYPE_DSCAM:
+			case ANIMTYPE_DSCACHEFILE:
 			case ANIMTYPE_DSCUR:
 			case ANIMTYPE_DSSKEY:
 			case ANIMTYPE_DSWOR:
@@ -275,6 +277,7 @@ void ANIM_deselect_anim_channels(bAnimContext *ac, void *data, eAnimCont_Types d
 				case 

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list