[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [18924] branches/blender2.5/blender/source /blender: Keying Sets: Initial commit of skeleton code

Joshua Leung aligorith at gmail.com
Wed Feb 11 13:19:43 CET 2009


Revision: 18924
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=18924
Author:   aligorith
Date:     2009-02-11 13:19:42 +0100 (Wed, 11 Feb 2009)

Log Message:
-----------
Keying Sets: Initial commit of skeleton code

When fully implemented, these will be the clearest demonstration of 'Everything is Animateable', as they will allow users to define an arbitary group of settings through selecting items in the Datablocks (RNA-Viewer) View of the Outliner to define custom 'sets'. Such Keying Sets are known as the 'absolute' ones, which are created for a custom purpose.

Of course, 'builtin' Keying Sets will still be provided. Such built-in ones will not work on any particular paths, but will use context info to maintain the legacy method of inserting keyframes (via IKEY menu).

Currently, KeyingSets cannot be created/edited through the UI, though the backend code is in place to do this.

Modified Paths:
--------------
    branches/blender2.5/blender/source/blender/blenkernel/BKE_animsys.h
    branches/blender2.5/blender/source/blender/blenkernel/intern/anim_sys.c
    branches/blender2.5/blender/source/blender/blenkernel/intern/blender.c
    branches/blender2.5/blender/source/blender/blenkernel/intern/scene.c
    branches/blender2.5/blender/source/blender/blenloader/intern/readfile.c
    branches/blender2.5/blender/source/blender/blenloader/intern/writefile.c
    branches/blender2.5/blender/source/blender/editors/animation/keyframing.c
    branches/blender2.5/blender/source/blender/editors/include/ED_keyframing.h
    branches/blender2.5/blender/source/blender/editors/space_action/action_draw.c
    branches/blender2.5/blender/source/blender/editors/space_graph/graph_draw.c
    branches/blender2.5/blender/source/blender/editors/space_outliner/outliner.c
    branches/blender2.5/blender/source/blender/editors/space_outliner/outliner_header.c
    branches/blender2.5/blender/source/blender/editors/space_outliner/outliner_intern.h
    branches/blender2.5/blender/source/blender/editors/space_outliner/outliner_ops.c
    branches/blender2.5/blender/source/blender/editors/space_time/time_header.c
    branches/blender2.5/blender/source/blender/editors/space_view3d/view3d_buttons.c
    branches/blender2.5/blender/source/blender/makesdna/DNA_anim_types.h
    branches/blender2.5/blender/source/blender/makesdna/DNA_scene_types.h

Modified: branches/blender2.5/blender/source/blender/blenkernel/BKE_animsys.h
===================================================================
--- branches/blender2.5/blender/source/blender/blenkernel/BKE_animsys.h	2009-02-11 09:12:43 UTC (rev 18923)
+++ branches/blender2.5/blender/source/blender/blenkernel/BKE_animsys.h	2009-02-11 12:19:42 UTC (rev 18924)
@@ -9,6 +9,7 @@
 struct ListBase;
 struct Main;
 struct AnimData;
+struct KeyingSet;
 
 /* ************************************* */
 /* AnimData API */
@@ -26,6 +27,21 @@
 struct AnimData *BKE_copy_animdata(struct AnimData *adt);
 
 /* ************************************* */
+/* KeyingSets API */
+
+/* Used to create a new 'custom' KeyingSet for the user, that will be automatically added to the stack */
+struct KeyingSet *BKE_keyingset_add(struct ListBase *list, const char name[], short flag, short keyingflag);
+
+/* Add a destination to a KeyingSet */
+void BKE_keyingset_add_destination(struct KeyingSet *ks, struct ID *id, const char group_name[], const char rna_path[], int array_index, int flag);
+
+/* Free data for KeyingSet but not set itself */
+void BKE_keyingset_free(struct KeyingSet *ks);
+
+/* Free all the KeyingSets in the given list */
+void BKE_keyingsets_free(struct ListBase *list);
+
+/* ************************************* */
 // TODO: overrides, remapping, and path-finding api's
 
 /* ************************************* */

Modified: branches/blender2.5/blender/source/blender/blenkernel/intern/anim_sys.c
===================================================================
--- branches/blender2.5/blender/source/blender/blenkernel/intern/anim_sys.c	2009-02-11 09:12:43 UTC (rev 18923)
+++ branches/blender2.5/blender/source/blender/blenkernel/intern/anim_sys.c	2009-02-11 12:19:42 UTC (rev 18924)
@@ -158,7 +158,119 @@
 	return dadt;
 }
 
+/* *********************************** */ 
+/* KeyingSet API */
 
+/* NOTES:
+ * It is very likely that there will be two copies of the api - one for internal use,
+ * and one 'operator' based wrapper of the internal API, which should allow for access
+ * from Python/scripts so that riggers can automate the creation of KeyingSets for their rigs.
+ */
+
+/* Defining Tools --------------------------- */
+
+/* Used to create a new 'custom' KeyingSet for the user, that will be automatically added to the stack */
+KeyingSet *BKE_keyingset_add (ListBase *list, const char name[], short flag, short keyingflag)
+{
+	KeyingSet *ks;
+	
+	/* allocate new KeyingSet */
+	ks= MEM_callocN(sizeof(KeyingSet), "KeyingSet");
+	
+	BLI_snprintf(ks->name, 64, name);
+	
+	ks->flag= flag;
+	ks->keyingflag= keyingflag;
+	
+	/* add KeyingSet to list */
+	BLI_addtail(list, ks);
+	
+	/* return new KeyingSet for further editing */
+	return ks;
+}
+
+/* Add a destination to a KeyingSet. Nothing is returned for now...
+ * Checks are performed to ensure that destination is appropriate for the KeyingSet in question
+ */
+void BKE_keyingset_add_destination (KeyingSet *ks, ID *id, const char group_name[], const char rna_path[], int array_index, int flag)
+{
+	KS_Path *ksp;
+	
+	/* sanity checks */
+	if ELEM(NULL, ks, rna_path)
+		return;
+	
+	/* ID is optional, and should only be provided for absolute KeyingSets */
+	if (id) {
+		if ((ks->flag & KEYINGSET_ABSOLUTE) == 0)
+			return;
+	}
+	
+	/* allocate a new KeyingSet Path */
+	ksp= MEM_callocN(sizeof(KS_Path), "KeyingSet Path");
+	
+	/* just store absolute info */
+	if (ks->flag & KEYINGSET_ABSOLUTE) {
+		ksp->id= id;
+		BLI_snprintf(ksp->group, 64, group_name);
+	}
+	
+	/* just copy path info */
+	// XXX no checks are performed for templates yet
+	// should array index be checked too?
+	ksp->rna_path= BLI_strdupn(rna_path, strlen(rna_path));
+	ksp->array_index= array_index;
+	
+	/* store flags */
+	ksp->flag= flag;
+	
+	/* add KeyingSet path to KeyingSet */
+	BLI_addtail(&ks->paths, ksp);
+}	
+
+
+/* Freeing Tools --------------------------- */
+
+/* Free data for KeyingSet but not set itself */
+void BKE_keyingset_free (KeyingSet *ks)
+{
+	KS_Path *ksp, *kspn;
+	
+	/* sanity check */
+	if (ks == NULL)
+		return;
+	
+	/* free each path as we go to avoid looping twice */
+	for (ksp= ks->paths.first; ksp; ksp= kspn) {
+		kspn= ksp->next;
+		
+		/* free RNA-path info */
+		MEM_freeN(ksp->rna_path);
+		
+		/* free path itself */
+		BLI_freelinkN(&ks->paths, ks);
+	}
+}
+
+/* Free all the KeyingSets in the given list */
+void BKE_keyingsets_free (ListBase *list)
+{
+	KeyingSet *ks, *ksn;
+	
+	/* sanity check */
+	if (list == NULL)
+		return;
+	
+	/* loop over KeyingSets freeing them 
+	 * 	- BKE_keyingset_free() doesn't free the set itself, but it frees its sub-data
+	 */
+	for (ks= list->first; ks; ks= ksn) {
+		ksn= ks->next;
+		BKE_keyingset_free(ks);
+		BLI_freelinkN(list, ks);
+	}
+}
+
 /* ***************************************** */
 /* Evaluation Data-Setting Backend */
 

Modified: branches/blender2.5/blender/source/blender/blenkernel/intern/blender.c
===================================================================
--- branches/blender2.5/blender/source/blender/blenkernel/intern/blender.c	2009-02-11 09:12:43 UTC (rev 18923)
+++ branches/blender2.5/blender/source/blender/blenkernel/intern/blender.c	2009-02-11 12:19:42 UTC (rev 18924)
@@ -65,6 +65,7 @@
 #include "IMB_imbuf_types.h"
 #include "IMB_imbuf.h"
 
+#include "BKE_animsys.h"
 #include "BKE_action.h"
 #include "BKE_blender.h"
 #include "BKE_context.h"

Modified: branches/blender2.5/blender/source/blender/blenkernel/intern/scene.c
===================================================================
--- branches/blender2.5/blender/source/blender/blenkernel/intern/scene.c	2009-02-11 09:12:43 UTC (rev 18923)
+++ branches/blender2.5/blender/source/blender/blenkernel/intern/scene.c	2009-02-11 12:19:42 UTC (rev 18924)
@@ -150,6 +150,7 @@
 #endif
 
 	BKE_free_animdata((ID *)sce);
+	BKE_keyingsets_free(&sce->keyingsets);
 	
 	if (sce->r.avicodecdata) {
 		free_avicodecdata(sce->r.avicodecdata);

Modified: branches/blender2.5/blender/source/blender/blenloader/intern/readfile.c
===================================================================
--- branches/blender2.5/blender/source/blender/blenloader/intern/readfile.c	2009-02-11 09:12:43 UTC (rev 18923)
+++ branches/blender2.5/blender/source/blender/blenloader/intern/readfile.c	2009-02-11 12:19:42 UTC (rev 18924)
@@ -1929,6 +1929,39 @@
 
 /* ------- */
 
+static void lib_link_keyingsets(FileData *fd, ID *id, ListBase *list)
+{
+	KeyingSet *ks;
+	KS_Path *ksp;
+	
+	/* here, we're only interested in the ID pointer stored in some of the paths */
+	for (ks= list->first; ks; ks= ks->next) {
+		for (ksp= ks->paths.first; ksp; ksp= ksp->next) {
+			ksp->id= newlibadr(fd, id->lib, ksp->id); 
+		}
+	}
+}
+
+/* NOTE: this assumes that link_list has already been called on the list */
+static void direct_link_keyingsets(FileData *fd, ListBase *list)
+{
+	KeyingSet *ks;
+	KS_Path *ksp;
+	
+	/* link KeyingSet data to KeyingSet again (non ID-libs) */
+	for (ks= list->first; ks; ks= ks->next) {
+		/* paths */
+		link_list(fd, &ks->paths);
+		
+		for (ksp= ks->paths.first; ksp; ksp= ksp->next) {
+			/* rna path */
+			ksp->rna_path= newdataadr(fd, ksp->rna_path);
+		}
+	}
+}
+
+/* ------- */
+
 static void lib_link_animdata(FileData *fd, ID *id, AnimData *adt)
 {
 	if (adt == NULL)
@@ -3698,6 +3731,8 @@
 			if (sce->id.properties) IDP_LibLinkProperty(sce->id.properties, (fd->flags & FD_FLAGS_SWITCH_ENDIAN), fd);
 			if (sce->adt) lib_link_animdata(fd, &sce->id, sce->adt);
 			
+			lib_link_keyingsets(fd, &sce->id, &sce->keyingsets);
+			
 			sce->camera= newlibadr(fd, sce->id.lib, sce->camera);
 			sce->world= newlibadr_us(fd, sce->id.lib, sce->world);
 			sce->set= newlibadr(fd, sce->id.lib, sce->set);
@@ -3791,6 +3826,9 @@
 	sce->adt= newdataadr(fd, sce->adt);
 	direct_link_animdata(fd, sce->adt);
 	
+	link_list(fd, &sce->keyingsets);
+	direct_link_keyingsets(fd, &sce->keyingsets);
+	
 	sce->basact= newdataadr(fd, sce->basact);
 
 	sce->radio= newdataadr(fd, sce->radio);
@@ -9124,6 +9162,19 @@
 	}
 }
 
+static void expand_keyingsets(FileData *fd, Main *mainvar, ListBase *list)
+{
+	KeyingSet *ks;
+	KS_Path *ksp;
+	
+	/* expand the ID-pointers in KeyingSets's paths */
+	for (ks= list->first; ks; ks= ks->next) {
+		for (ksp= ks->paths.first; ksp; ksp= ksp->next) {
+			expand_doit(fd, mainvar, ksp->id);
+		}
+	}
+}
+
 static void expand_animdata(FileData *fd, Main *mainvar, AnimData *adt)
 {
 	FCurve *fcd;
@@ -9655,6 +9706,7 @@
 	
 	if(sce->adt)
 		expand_animdata(fd, mainvar, sce->adt);
+	expand_keyingsets(fd, mainvar, &sce->keyingsets);
 	
 	if(sce->nodetree)
 		expand_nodetree(fd, mainvar, sce->nodetree);

Modified: branches/blender2.5/blender/source/blender/blenloader/intern/writefile.c
===================================================================
--- branches/blender2.5/blender/source/blender/blenloader/intern/writefile.c	2009-02-11 09:12:43 UTC (rev 18923)
+++ branches/blender2.5/blender/source/blender/blenloader/intern/writefile.c	2009-02-11 12:19:42 UTC (rev 18924)
@@ -855,6 +855,26 @@
 	mywrite(wd, MYWRITE_FLUSH, 0);
 }
 
+static void write_keyingsets(WriteData *wd, ListBase *list)
+{
+	KeyingSet *ks;
+	KS_Path *ksp;
+	
+	for (ks= list->first; ks; ks= ks->next) {
+		/* KeyingSet */
+		writestruct(wd, DATA, "KeyingSet", 1, ks);
+		
+		/* Paths */
+		for (ksp= ks->paths.first; ksp; ksp= ksp->next) {
+			/* Path */
+			writestruct(wd, DATA, "KS_Path", 1, ksp);
+			
+			if (ksp->rna_path)
+				writedata(wd, DATA, strlen(ksp->rna_path)+1, ksp->rna_path);
+		}
+	}
+}
+
 static void write_animdata(WriteData *wd, AnimData *adt)
 {
 	AnimOverride *aor;
@@ -1533,6 +1553,7 @@
 		if (sce->id.properties) IDP_WriteProperty(sce->id.properties, wd);
 		
 		if (sce->adt) write_animdata(wd, sce->adt);
+		write_keyingsets(wd, &sce->keyingsets);
 		
 		/* direct data */
 		base= sce->base.first;
@@ -1616,9 +1637,9 @@
 				writestruct(wd, DATA, "MetaStack", 1, ms);
 			}
 		}
-
+		
 		write_scriptlink(wd, &sce->scriptlink);
-
+		
 		if (sce->r.avicodecdata) {
 			writestruct(wd, DATA, "AviCodecData", 1, sce->r.avicodecdata);
 			if (sce->r.avicodecdata->lpFormat) writedata(wd, DATA, sce->r.avicodecdata->cbFormat, sce->r.avicodecdata->lpFormat);

Modified: branches/blender2.5/blender/source/blender/editors/animation/keyframing.c
===================================================================
--- branches/blender2.5/blender/source/blender/editors/animation/keyframing.c	2009-02-11 09:12:43 UTC (rev 18923)

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list