[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [37983] branches/soc-2011-pepper/source/ blender/editors: Animation Channels Filtering Refactor - Part 5

Joshua Leung aligorith at gmail.com
Thu Jun 30 15:56:48 CEST 2011


Revision: 37983
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=37983
Author:   aligorith
Date:     2011-06-30 13:56:47 +0000 (Thu, 30 Jun 2011)
Log Message:
-----------
Animation Channels Filtering Refactor - Part 5

Channels can now be used as "animation containers" to be filtered
further to obtain a set of subsidiary channels (i.e. F-Curves
associated with some summary channel).

The main use of this is that object and scene summary channels can now
be defined without defining the filtering logic in three different
places - once for channel filtering, once for drawing keyframes in
action editor, and once for editing these keyframes.

An indirect consequence of this, is that the "Only selected channels"
option in Timeline will now result in only the keyframes for a
selected bones getting shown (when enabled), instead of all keyframes
for the active object. This was requested by Lee during Durian, and is
something which has only become possible as a result of this commit.

Modified Paths:
--------------
    branches/soc-2011-pepper/source/blender/editors/animation/anim_channels_edit.c
    branches/soc-2011-pepper/source/blender/editors/animation/anim_filter.c
    branches/soc-2011-pepper/source/blender/editors/animation/keyframes_draw.c
    branches/soc-2011-pepper/source/blender/editors/animation/keyframes_edit.c
    branches/soc-2011-pepper/source/blender/editors/armature/poselib.c
    branches/soc-2011-pepper/source/blender/editors/include/ED_anim_api.h
    branches/soc-2011-pepper/source/blender/editors/include/ED_keyframes_edit.h
    branches/soc-2011-pepper/source/blender/editors/space_action/action_select.c
    branches/soc-2011-pepper/source/blender/editors/space_nla/nla_edit.c
    branches/soc-2011-pepper/source/blender/editors/space_time/space_time.c

Modified: branches/soc-2011-pepper/source/blender/editors/animation/anim_channels_edit.c
===================================================================
--- branches/soc-2011-pepper/source/blender/editors/animation/anim_channels_edit.c	2011-06-30 13:27:36 UTC (rev 37982)
+++ branches/soc-2011-pepper/source/blender/editors/animation/anim_channels_edit.c	2011-06-30 13:56:47 UTC (rev 37983)
@@ -1405,10 +1405,6 @@
 
 /* ------------------- */
 
-/* macro to be used in setflag_anim_channels */
-#define ASUBCHANNEL_SEL_OK(ale) ( (onlysel == 0) || \
-		((ale->id) && (GS(ale->id->name)==ID_OB) && (((Object *)ale->id)->flag & SELECT)) ) 
-
 /* Set/clear a particular flag (setting) for all selected + visible channels 
  *	setting: the setting to modify
  *	mode: eAnimChannels_SetFlag

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-30 13:27:36 UTC (rev 37982)
+++ branches/soc-2011-pepper/source/blender/editors/animation/anim_filter.c	2011-06-30 13:56:47 UTC (rev 37983)
@@ -127,6 +127,9 @@
 /* Get data being edited in Action Editor (depending on current 'mode') */
 static short actedit_get_context (bAnimContext *ac, SpaceAction *saction)
 {
+	/* get dopesheet */
+	ac->ads = &saction->ads;
+	
 	/* sync settings with current view status, then return appropriate data */
 	switch (saction->mode) {
 		case SACTCONT_ACTION: /* 'Action Editor' */
@@ -190,6 +193,7 @@
 		sipo->ads= MEM_callocN(sizeof(bDopeSheet), "GraphEdit DopeSheet");
 		sipo->ads->source= (ID *)ac->scene;
 	}
+	ac->ads = sipo->ads;
 	
 	/* set settings for Graph Editor - "Selected = Editable" */
 	if (sipo->flag & SIPO_SELCUVERTSONLY)
@@ -238,6 +242,7 @@
 	/* init dopesheet data if non-existant (i.e. for old files) */
 	if (snla->ads == NULL)
 		snla->ads= MEM_callocN(sizeof(bDopeSheet), "NlaEdit DopeSheet");
+	ac->ads = snla->ads;
 	
 	/* sync settings with current view status, then return appropriate data */
 	/* update scene-pointer (no need to check for pinning yet, as not implemented) */
@@ -2038,6 +2043,32 @@
 	return 1;
 }  
 
+/* ......................... */
+
+/* filter data associated with a channel - usually for handling summary-channels in DopeSheet */
+static size_t animdata_filter_animchan (bAnimContext *ac, ListBase *anim_data, bDopeSheet *ads, bAnimListElem *channel, int filter_mode)
+{
+	size_t items = 0;
+	
+	/* data to filter depends on channel type */
+	// XXX: only common channel-types have been handled for now
+	switch (channel->type) {
+		case ANIMTYPE_SUMMARY:
+			items += animdata_filter_dopesheet(ac, anim_data, ads, filter_mode);
+			break;
+			
+		case ANIMTYPE_SCENE:
+			items += animdata_filter_dopesheet_scene(ac, anim_data, ads, channel->data, filter_mode);
+			break;
+		
+		case ANIMTYPE_OBJECT:
+			items += animdata_filter_dopesheet_ob(ac, anim_data, ads, channel->data, filter_mode);
+			break;
+	}
+	
+	return items;
+}
+
 /* ----------- Cleanup API --------------- */
 
 /* Remove entries with invalid types in animation channel list */
@@ -2157,6 +2188,15 @@
 				items = animdata_filter_dopesheet(ac, anim_data, data, filter_mode);
 			}
 				break;
+			
+			case ANIMCONT_CHANNEL: /* animation channel */
+			{
+				bDopeSheet *ads = ac->ads;
+				
+				/* based on the channel type, filter relevant data for this */
+				items = animdata_filter_animchan(ac, anim_data, ads, data, filter_mode);
+			}
+				break;
 		}
 			
 		/* remove any 'weedy' entries */

Modified: branches/soc-2011-pepper/source/blender/editors/animation/keyframes_draw.c
===================================================================
--- branches/soc-2011-pepper/source/blender/editors/animation/keyframes_draw.c	2011-06-30 13:27:36 UTC (rev 37982)
+++ branches/soc-2011-pepper/source/blender/editors/animation/keyframes_draw.c	2011-06-30 13:56:47 UTC (rev 37983)
@@ -786,150 +786,71 @@
 
 void scene_to_keylist(bDopeSheet *ads, Scene *sce, DLRBT_Tree *keys, DLRBT_Tree *blocks)
 {
-	if (sce) {
-		AnimData *adt;
-		int filterflag;
-		
-		/* get filterflag */
-		if (ads)
-			filterflag= ads->filterflag;
-		else
-			filterflag= 0;
-			
-		/* scene animdata */
-		if ((sce->adt) && !(filterflag & ADS_FILTER_NOSCE)) {
-			adt= sce->adt;
-			
-			if (adt->action) 
-				action_to_keylist(adt, adt->action, keys, blocks);
-		}
-		
-		/* world animdata */
-		if ((sce->world) && (sce->world->adt) && !(filterflag & ADS_FILTER_NOWOR)) {
-			adt= sce->world->adt;
-			
-			if (adt->action) 
-				action_to_keylist(adt, adt->action, keys, blocks);
-		}
-		
-		/* nodetree animdata */
-		if ((sce->nodetree) && (sce->nodetree->adt) && !(filterflag & ADS_FILTER_NONTREE)) {
-			adt= sce->nodetree->adt;
-			
-			if (adt->action) 
-				action_to_keylist(adt, adt->action, keys, blocks);
-		}
-	}
+	bAnimContext ac = {NULL};
+	ListBase anim_data = {NULL, NULL};
+	bAnimListElem *ale;
+	int filter;
+	
+	bAnimListElem dummychan = {0};
+	
+	if (sce == NULL)
+		return;
+	
+	/* create a dummy wrapper data to work with */
+	dummychan.type = ANIMTYPE_SCENE;
+	dummychan.data = sce;
+	dummychan.id = &sce->id;
+	dummychan.adt = sce->adt;
+	
+	ac.ads = ads;
+	ac.data = &dummychan;
+	ac.datatype = ANIMCONT_CHANNEL;
+	
+	/* get F-Curves to take keyframes from */
+	filter= ANIMFILTER_DATA_VISIBLE; // curves only
+	ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype);
+	
+	/* loop through each F-Curve, grabbing the keyframes */
+	for (ale= anim_data.first; ale; ale= ale->next)
+		fcurve_to_keylist(ale->adt, ale->data, keys, blocks);
+	
+	BLI_freelistN(&anim_data);
 }
 
 void ob_to_keylist(bDopeSheet *ads, Object *ob, DLRBT_Tree *keys, DLRBT_Tree *blocks)
-{
-	Key *key= ob_get_key(ob);
-	int filterflag= (ads)? ads->filterflag : 0;
+{	
+	bAnimContext ac = {NULL};
+	ListBase anim_data = {NULL, NULL};
+	bAnimListElem *ale;
+	int filter;
 	
-	/* sanity check */
+	bAnimListElem dummychan = {0};
+	Base dummybase = {0};
+	
 	if (ob == NULL)
 		return;
-		
-	/* Add action keyframes */
-	if (ob->adt && ob->adt->action)
-		action_to_keylist(ob->adt, ob->adt->action, keys, blocks);
 	
-	/* Add shapekey keyframes (only if dopesheet allows, if it is available) */
-	if ((key && key->adt && key->adt->action) && !(filterflag & ADS_FILTER_NOSHAPEKEYS))
-		action_to_keylist(key->adt, key->adt->action, keys, blocks);
+	/* create a dummy wrapper data to work with */
+	dummybase.object = ob;
 	
-	/* Add material keyframes */
-	if ((ob->totcol) && !(filterflag & ADS_FILTER_NOMAT)) {
-		int a;
-		
-		for (a=1; a <= ob->totcol; a++) {
-			Material *ma= give_current_material(ob, a);
-			
-			/* there might not be a material */
-			if (ELEM(NULL, ma, ma->adt)) 
-				continue;
-			
-			/* add material's data */
-			action_to_keylist(ma->adt, ma->adt->action, keys, blocks);
-			
-			// TODO: textures...
-		}
-	}
+	dummychan.type = ANIMTYPE_OBJECT;
+	dummychan.data = &dummybase;
+	dummychan.id = &ob->id;
+	dummychan.adt = ob->adt;
 	
-	/* Add object data keyframes */
-	switch (ob->type) {
-		case OB_CAMERA: /* ------- Camera ------------ */
-		{
-			Camera *ca= (Camera *)ob->data;
-			
-			if ((ca->adt) && !(filterflag & ADS_FILTER_NOCAM)) 
-				action_to_keylist(ca->adt, ca->adt->action, keys, blocks);
-		}
-			break;
-		case OB_LAMP: /* ---------- Lamp ----------- */
-		{
-			Lamp *la= (Lamp *)ob->data;
-			
-			if ((la->adt) && !(filterflag & ADS_FILTER_NOLAM)) 
-				action_to_keylist(la->adt, la->adt->action, keys, blocks);
-		}
-			break;
-		case OB_CURVE: /* ------- Curve ---------- */
-		case OB_SURF: /* ------- Nurbs Surface ---------- */
-		case OB_FONT: /* ------- Text Curve ---------- */
-		{
-			Curve *cu= (Curve *)ob->data;
-			
-			if ((cu->adt) && !(filterflag & ADS_FILTER_NOCUR)) 
-				action_to_keylist(cu->adt, cu->adt->action, keys, blocks);
-		}
-			break;
-		case OB_MBALL: /* ------- MetaBall ---------- */
-		{
-			MetaBall *mb= (MetaBall *)ob->data;
-			
-			if ((mb->adt) && !(filterflag & ADS_FILTER_NOMBA)) 
-				action_to_keylist(mb->adt, mb->adt->action, keys, blocks);
-		}
-			break;
-		case OB_ARMATURE: /* ------- Armature ---------- */
-		{
-			bArmature *arm= (bArmature *)ob->data;
-			
-			if ((arm->adt) && !(filterflag & ADS_FILTER_NOARM)) 
-				action_to_keylist(arm->adt, arm->adt->action, keys, blocks);
-		}
-			break;
-		case OB_MESH: /* ------- Mesh ---------- */
-		{
-			Mesh *me= (Mesh *)ob->data;
-			
-			if ((me->adt) && !(filterflag & ADS_FILTER_NOMESH)) 
-				action_to_keylist(me->adt, me->adt->action, keys, blocks);
-		}
-			break;
-		case OB_LATTICE: /* ------- Lattice ---------- */
-		{
-			Lattice *lt= (Lattice *)ob->data;
-			
-			if ((lt->adt) && !(filterflag & ADS_FILTER_NOLAT)) 
-				action_to_keylist(lt->adt, lt->adt->action, keys, blocks);
-		}
-			break;
-	}
+	ac.ads = ads;
+	ac.data = &dummychan;
+	ac.datatype = ANIMCONT_CHANNEL;
 	
-	/* Add Particle System Keyframes */
-	if ((ob->particlesystem.first) && !(filterflag & ADS_FILTER_NOPART)) {
-		ParticleSystem *psys = ob->particlesystem.first;
-		
-		for(; psys; psys=psys->next) {
-			if (ELEM(NULL, psys->part, psys->part->adt))
-				continue;
-			else
-				action_to_keylist(psys->part->adt, psys->part->adt->action, keys, blocks);
-		}
-	}
+	/* get F-Curves to take keyframes from */
+	filter= ANIMFILTER_DATA_VISIBLE; // curves only
+	ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype);
+	
+	/* loop through each F-Curve, grabbing the keyframes */
+	for (ale= anim_data.first; ale; ale= ale->next)
+		fcurve_to_keylist(ale->adt, ale->data, keys, blocks);
+	
+	BLI_freelistN(&anim_data);
 }
 
 void fcurve_to_keylist(AnimData *adt, FCurve *fcu, DLRBT_Tree *keys, DLRBT_Tree *blocks)

Modified: branches/soc-2011-pepper/source/blender/editors/animation/keyframes_edit.c
===================================================================
--- branches/soc-2011-pepper/source/blender/editors/animation/keyframes_edit.c	2011-06-30 13:27:36 UTC (rev 37982)
+++ branches/soc-2011-pepper/source/blender/editors/animation/keyframes_edit.c	2011-06-30 13:56:47 UTC (rev 37983)
@@ -224,169 +224,94 @@
 }
 
 /* This function is used to loop over the keyframe data in an Object */
-static short ob_keyframes_loop(KeyframeEditData *ked, Object *ob, KeyframeEditFunc key_ok, KeyframeEditFunc key_cb, FcuEditFunc fcu_cb, int filterflag)
+static short ob_keyframes_loop(KeyframeEditData *ked, bDopeSheet *ads, Object *ob, KeyframeEditFunc key_ok, KeyframeEditFunc key_cb, FcuEditFunc fcu_cb)
 {

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list