[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [19634] branches/blender2.5/blender/source /blender/editors: Action Editor - Part 2 of Code Cleanups

Joshua Leung aligorith at gmail.com
Fri Apr 10 14:06:32 CEST 2009


Revision: 19634
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=19634
Author:   aligorith
Date:     2009-04-10 14:06:31 +0200 (Fri, 10 Apr 2009)

Log Message:
-----------
Action Editor - Part 2 of Code Cleanups

Nothing much to see here... there's still a few things to recode a bit nicer...

Modified Paths:
--------------
    branches/blender2.5/blender/source/blender/editors/animation/keyframes_draw.c
    branches/blender2.5/blender/source/blender/editors/animation/keyframes_edit.c
    branches/blender2.5/blender/source/blender/editors/include/ED_keyframes_edit.h
    branches/blender2.5/blender/source/blender/editors/space_action/action_select.c

Modified: branches/blender2.5/blender/source/blender/editors/animation/keyframes_draw.c
===================================================================
--- branches/blender2.5/blender/source/blender/editors/animation/keyframes_draw.c	2009-04-10 03:34:20 UTC (rev 19633)
+++ branches/blender2.5/blender/source/blender/editors/animation/keyframes_draw.c	2009-04-10 12:06:31 UTC (rev 19634)
@@ -449,8 +449,6 @@
 		/* get filterflag */
 		if (ads)
 			filterflag= ads->filterflag;
-		else if ((aki) && (aki->actmode == -1)) /* only set like this by NLA */
-			filterflag= ADS_FILTER_NLADUMMY;
 		else
 			filterflag= 0;
 		

Modified: branches/blender2.5/blender/source/blender/editors/animation/keyframes_edit.c
===================================================================
--- branches/blender2.5/blender/source/blender/editors/animation/keyframes_edit.c	2009-04-10 03:34:20 UTC (rev 19633)
+++ branches/blender2.5/blender/source/blender/editors/animation/keyframes_edit.c	2009-04-10 12:06:31 UTC (rev 19634)
@@ -36,12 +36,12 @@
 
 #include "DNA_anim_types.h"
 #include "DNA_action_types.h"
-#include "DNA_constraint_types.h"
 #include "DNA_curve_types.h"
 #include "DNA_key_types.h"
 #include "DNA_object_types.h"
 #include "DNA_space_types.h"
 #include "DNA_scene_types.h"
+#include "DNA_world_types.h"
 
 #include "BKE_action.h"
 #include "BKE_fcurve.h"
@@ -71,7 +71,7 @@
  */
 
 /* ************************************************************************** */
-/* IPO Editing Loops - Exposed API */
+/* Keyframe Editing Loops - Exposed API */
 
 /* --------------------------- Base Functions ------------------------------------ */
 
@@ -121,14 +121,14 @@
     return 0;
 }
 
-/* -------------------------------- Further Abstracted ----------------------------- */
+/* -------------------------------- Further Abstracted (Not Exposed Directly) ----------------------------- */
 
 /* This function is used to loop over the keyframe data in an Action Group */
 static short agrp_keys_bezier_loop(BeztEditData *bed, bActionGroup *agrp, BeztEditFunc bezt_ok, BeztEditFunc bezt_cb, FcuEditFunc fcu_cb)
 {
 	FCurve *fcu;
 	
-	/* only iterate over the action-channels and their sub-channels that are in this group */
+	/* only iterate over the F-Curves that are in this group */
 	for (fcu= agrp->channels.first; fcu && fcu->grp==agrp; fcu= fcu->next) {
 		if (ANIM_fcurve_keys_bezier_loop(bed, fcu, bezt_ok, bezt_cb, fcu_cb))
 			return 1;
@@ -144,17 +144,73 @@
 	
 	/* just loop through all F-Curves */
 	for (fcu= act->curves.first; fcu; fcu= fcu->next) {
-		ANIM_fcurve_keys_bezier_loop(bed, fcu, bezt_ok, bezt_cb, fcu_cb);
+		if (ANIM_fcurve_keys_bezier_loop(bed, fcu, bezt_ok, bezt_cb, fcu_cb))
+			return 1;
 	}
 	
 	return 0;
 }
 
+/* This function is used to loop over the keyframe data of an AnimData block */
+static short adt_keys_bezier_loop(BeztEditData *bed, AnimData *adt, BeztEditFunc bezt_ok, BeztEditFunc bezt_cb, FcuEditFunc fcu_cb, int filterflag)
+{
+	/* drivers or actions? */
+	if (filterflag & ADS_FILTER_ONLYDRIVERS) {
+		FCurve *fcu;
+		
+		/* just loop through all F-Curves acting as Drivers */
+		for (fcu= adt->drivers.first; fcu; fcu= fcu->next) {
+			if (ANIM_fcurve_keys_bezier_loop(bed, fcu, bezt_ok, bezt_cb, fcu_cb))
+				return 1;
+		}
+	}
+	else if (adt->action) {
+		/* call the function for actions */
+		if (act_keys_bezier_loop(bed, adt->action, bezt_ok, bezt_cb, fcu_cb))
+			return 1;
+	}
+	
+	return 0;
+}
+
+/* This function is used to loop over the keyframe data in an Object */
+static short ob_keys_bezier_loop(BeztEditData *bed, Object *ob, BeztEditFunc bezt_ok, BeztEditFunc bezt_cb, FcuEditFunc fcu_cb, int filterflag)
+{
+	Key *key= ob_get_key(ob);
+	
+	/* firstly, Object's own AnimData */
+	if (ob->adt) 
+		adt_keys_bezier_loop(bed, ob->adt, bezt_ok, bezt_cb, fcu_cb, filterflag);
+	
+	/* shapekeys */
+	if ((key && key->adt) && !(filterflag & ADS_FILTER_NOSHAPEKEYS))
+		adt_keys_bezier_loop(bed, key->adt, bezt_ok, bezt_cb, fcu_cb, filterflag);
+		
+	// FIXME: add materials, etc. (but drawing code doesn't do it yet too! :)
+	
+	return 0;
+}
+
+/* This function is used to loop over the keyframe data in a Scene */
+static short scene_keys_bezier_loop(BeztEditData *bed, Scene *sce, BeztEditFunc bezt_ok, BeztEditFunc bezt_cb, FcuEditFunc fcu_cb, int filterflag)
+{
+	World *wo= sce->world;
+	
+	/* Scene's own animation */
+	if (sce->adt)
+		adt_keys_bezier_loop(bed, sce->adt, bezt_ok, bezt_cb, fcu_cb, filterflag);
+	
+	/* World */
+	if (wo && wo->adt)
+		adt_keys_bezier_loop(bed, wo->adt, bezt_ok, bezt_cb, fcu_cb, filterflag);
+	
+	return 0;
+}
+
 /* --- */
 
-
 /* This function is used to apply operation to all keyframes, regardless of the type */
-short ANIM_animchannel_keys_bezier_loop(BeztEditData *bed, bAnimListElem *ale, BeztEditFunc bezt_ok, BeztEditFunc bezt_cb, FcuEditFunc fcu_cb)
+short ANIM_animchannel_keys_bezier_loop(BeztEditData *bed, bAnimListElem *ale, BeztEditFunc bezt_ok, BeztEditFunc bezt_cb, FcuEditFunc fcu_cb, int filterflag)
 {
 	/* sanity checks */
 	if (ale == NULL)
@@ -173,6 +229,11 @@
 			return agrp_keys_bezier_loop(bed, (bActionGroup *)ale->data, bezt_ok, bezt_cb, fcu_cb);
 		case ALE_ACT: /* action */
 			return act_keys_bezier_loop(bed, (bAction *)ale->data, bezt_ok, bezt_cb, fcu_cb);
+			
+		case ALE_OB: /* object */
+			return ob_keys_bezier_loop(bed, (Object *)ale->data, bezt_ok, bezt_cb, fcu_cb, filterflag);
+		case ALE_SCE: /* scene */
+			return scene_keys_bezier_loop(bed, (Scene *)ale->data, bezt_ok, bezt_cb, fcu_cb, filterflag);
 	}
 	
 	return 0;

Modified: branches/blender2.5/blender/source/blender/editors/include/ED_keyframes_edit.h
===================================================================
--- branches/blender2.5/blender/source/blender/editors/include/ED_keyframes_edit.h	2009-04-10 03:34:20 UTC (rev 19633)
+++ branches/blender2.5/blender/source/blender/editors/include/ED_keyframes_edit.h	2009-04-10 12:06:31 UTC (rev 19634)
@@ -30,6 +30,7 @@
 #define ED_KEYFRAMES_EDIT_H
 
 struct bAnimContext;
+struct bAnimListElem;
 struct FCurve;
 struct BezTriple;
 struct Scene;
@@ -107,8 +108,14 @@
 /* ---------------- Looping API --------------------- */
 
 /* functions for looping over keyframes */
-short ANIM_fcurve_keys_bezier_loop(BeztEditData *bed, struct FCurve *Fcu, BeztEditFunc bezt_ok, BeztEditFunc bezt_cb, FcuEditFunc fcu_cb);
+	/* function for working with F-Curve data only (i.e. when filters have been chosen to explicitly use this) */
+short ANIM_fcurve_keys_bezier_loop(BeztEditData *bed, struct FCurve *fcu, BeztEditFunc bezt_ok, BeztEditFunc bezt_cb, FcuEditFunc fcu_cb);
+	/* function for working with any type (i.e. one of the known types) of animation channel 
+	 *	- filterflag is bDopeSheet->flag (DOPESHEET_FILTERFLAG)
+	 */
+short ANIM_animchannel_keys_bezier_loop(BeztEditData *bed, struct bAnimListElem *ale, BeztEditFunc bezt_ok, BeztEditFunc bezt_cb, FcuEditFunc fcu_cb, int filterflag);
 
+
 /* functions for making sure all keyframes are in good order */
 void ANIM_editkeyframes_refresh(struct bAnimContext *ac);
 

Modified: branches/blender2.5/blender/source/blender/editors/space_action/action_select.c
===================================================================
--- branches/blender2.5/blender/source/blender/editors/space_action/action_select.c	2009-04-10 03:34:20 UTC (rev 19633)
+++ branches/blender2.5/blender/source/blender/editors/space_action/action_select.c	2009-04-10 12:06:31 UTC (rev 19634)
@@ -88,7 +88,6 @@
 /* used only by mouse_action. It is used to find the location of the nearest 
  * keyframe to where the mouse clicked, 
  */
-// XXX port this to new listview code...
 // XXX just merge this into the existing code!
 static void *get_nearest_action_key (bAnimContext *ac, int mval[2], float *selx, short *sel, short *ret_type, bActionGroup **par)
 {
@@ -129,8 +128,7 @@
 		BLI_freelistN(&anim_data);
 		return NULL;
 	}
-	
-	{
+	else {
 		/* found match - must return here... */
 		Object *nob= ANIM_nla_mapping_get(ac, ale);
 		ActKeysInc *aki= init_aki_data(ac, ale);
@@ -779,8 +777,8 @@
 	BeztEditData bed;
 	BeztEditFunc select_cb, ok_cb;
 	void *anim_channel;
-	short sel, chan_type = 0;
-	float selx = 0.0f, selxa;
+	short sel, chan_type = 0, key_type = 0;
+	float selx = 0.0f;
 	
 	/* determine what type of data we are operating on */
 	if (ac->datatype == ANIMCONT_ACTION) 
@@ -798,9 +796,11 @@
 	switch (chan_type) {
 		case ANIMTYPE_FCURVE:
 			fcu= (FCurve *)anim_channel;
+			key_type= ALE_FCURVE;
 			break;
 		case ANIMTYPE_GROUP:
 			agrp= (bActionGroup *)anim_channel;
+			key_type= ALE_GROUP;
 			break;
 #if 0 // XXX fixme
 		case ANIMTYPE_DSMAT:
@@ -821,12 +821,15 @@
 #endif // XXX fixme
 		case ANIMTYPE_FILLACTD:
 			act= (bAction *)anim_channel;
+			key_type= ALE_ACT;
 			break;
 		case ANIMTYPE_OBJECT:
 			ob= ((Base *)anim_channel)->object;
+			key_type= ALE_OB;
 			break;
 		case ANIMTYPE_SCENE:
 			sce= (Scene *)anim_channel;
+			key_type= ALE_SCE;
 			break;
 		case ANIMTYPE_GPLAYER:
 			gpl= (bGPDlayer *)anim_channel;
@@ -874,58 +877,22 @@
 	
 	/* apply selection to keyframes */
 	// XXX use more generic code looper for this stuff...
-	if (fcu)
-		ANIM_fcurve_keys_bezier_loop(&bed, fcu, ok_cb, select_cb, NULL);
-	else if (agrp) {
-		for (fcu= agrp->channels.first; fcu && fcu->grp==agrp; fcu= fcu->next)
-			ANIM_fcurve_keys_bezier_loop(&bed, fcu, ok_cb, select_cb, NULL);
+	if (gpl) {
+		/* grease pencil */
+		//select_gpencil_frame(gpl, (int)selx, selectmode);
 	}
-	else if (act) {
-		for (fcu= act->curves.first; fcu; fcu= fcu->next)
-			ANIM_fcurve_keys_bezier_loop(&bed, fcu, ok_cb, select_cb, NULL);
-	}
-	else if (ob) {
-		AnimData *adt;
+	else {
+		bAnimListElem ale = {0};
 		
-		/* Object's own animation */
-		if (ob->adt && ob->adt->action) {
-			adt= ob->adt;
-			act= adt->action;
-			
-			selxa= get_action_frame(ob, selx); // xxx
-			bed.f1= selxa;
-			
-			for (fcu= act->curves.first; fcu; fcu= fcu->next)
-				ANIM_fcurve_keys_bezier_loop(&bed, fcu, ok_cb, select_cb, NULL);
-		}
+		/* initialise just a few vars that the callback will use... */
+		// FIXME: this method is a mess anyways... it needs a recode
+		ale.datatype= key_type;
+		ale.key_data= anim_channel;
+		ale.data= anim_channel;
 		
-		/* 'Sub-Object' animation data */
-		// TODO...
+		/* loop over all the relevant channels */
+		ANIM_animchannel_keys_bezier_loop(&bed, &ale, ok_cb, select_cb, NULL, ((ads) ? (ads->filterflag) : (0)));
 	}
-	else if (sce) {
-		World *wo= sce->world;

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list