[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [13418] trunk/blender/source/blender: == Action Editor Drawing - Optimisations (Part 2 out of ?) ==

Joshua Leung aligorith at gmail.com
Sun Jan 27 04:21:26 CET 2008


Revision: 13418
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=13418
Author:   aligorith
Date:     2008-01-27 04:21:24 +0100 (Sun, 27 Jan 2008)

Log Message:
-----------
== Action Editor Drawing - Optimisations (Part 2 out of ?) ==

Keyframes are now checked for whether they are visible or not before they are prepared for drawing. This should provide some improvements for large data-sets... 

In general there don't appear to be any major issues, although in a few situations, long-keyframes may end up appearing/disappearing. 

Modified Paths:
--------------
    trunk/blender/source/blender/include/BDR_drawaction.h
    trunk/blender/source/blender/src/drawaction.c
    trunk/blender/source/blender/src/drawarmature.c
    trunk/blender/source/blender/src/editaction.c
    trunk/blender/source/blender/src/poselib.c
    trunk/blender/source/blender/src/transform_conversions.c

Modified: trunk/blender/source/blender/include/BDR_drawaction.h
===================================================================
--- trunk/blender/source/blender/include/BDR_drawaction.h	2008-01-26 22:39:07 UTC (rev 13417)
+++ trunk/blender/source/blender/include/BDR_drawaction.h	2008-01-27 03:21:24 UTC (rev 13418)
@@ -68,6 +68,12 @@
 } ActKeyBlock;
 
 
+/* Inclusion-Range Limiting Struct (optional) */
+typedef struct ActKeysInc {
+	struct Object *ob;				/* if present, used to find action-scaled time */
+	float start, end;				/* frames (global-time) to only consider keys between */
+} ActKeysInc;
+
 /* ******************************* Methods ****************************** */
 
 /* Action Generics */
@@ -81,11 +87,11 @@
 void draw_object_channel(struct gla2DDrawInfo *di, struct Object *ob, float ypos);
 
 /* Keydata Generation */
-void icu_to_keylist(struct IpoCurve *icu, ListBase *keys, ListBase *blocks);
-void ipo_to_keylist(struct Ipo *ipo, ListBase *keys, ListBase *blocks);
-void agroup_to_keylist(struct bActionGroup *agrp, ListBase *keys, ListBase *blocks);
-void action_to_keylist(struct bAction *act, ListBase *keys, ListBase *blocks);
-void ob_to_keylist(struct Object *ob, ListBase *keys, ListBase *blocks);
+void icu_to_keylist(struct IpoCurve *icu, ListBase *keys, ListBase *blocks, ActKeysInc *aki);
+void ipo_to_keylist(struct Ipo *ipo, ListBase *keys, ListBase *blocks, ActKeysInc *aki);
+void agroup_to_keylist(struct bActionGroup *agrp, ListBase *keys, ListBase *blocks, ActKeysInc *aki);
+void action_to_keylist(struct bAction *act, ListBase *keys, ListBase *blocks, ActKeysInc *aki);
+void ob_to_keylist(struct Object *ob, ListBase *keys, ListBase *blocks, ActKeysInc *aki);
 
 #endif  /*  BDR_DRAWACTION_H */
 

Modified: trunk/blender/source/blender/src/drawaction.c
===================================================================
--- trunk/blender/source/blender/src/drawaction.c	2008-01-26 22:39:07 UTC (rev 13417)
+++ trunk/blender/source/blender/src/drawaction.c	2008-01-27 03:21:24 UTC (rev 13418)
@@ -816,8 +816,7 @@
 	/* Draw keyframes 
 	 *	1) Only channels that are visible in the Action Editor get drawn/evaluated.
 	 *	   This is to try to optimise this for heavier data sets
-	 *	2) Keyframes which are out of view horizontally could be disregarded (probably as
-	 *	   option - 'drop-frames' or so). Todo...
+	 *	2) Keyframes which are out of view horizontally are disregarded 
 	 */
 	y = 0.0;
 	for (ale= act_data.first; ale; ale= ale->next) {
@@ -1241,12 +1240,15 @@
 	glDisable(GL_BLEND);
 }
 
+#define INIT_AKI_DATA {((G.saction && NLA_ACTION_SCALED)? OBACT : NULL), G.v2d->cur.xmin - 10, G.v2d->cur.xmax + 10}
+
 void draw_object_channel(gla2DDrawInfo *di, Object *ob, float ypos)
 {
 	ListBase keys = {0, 0};
 	ListBase blocks = {0, 0};
+	ActKeysInc aki = INIT_AKI_DATA;
 
-	ob_to_keylist(ob, &keys, &blocks);
+	ob_to_keylist(ob, &keys, &blocks, &aki);
 	draw_keylist(di, &keys, &blocks, ypos);
 	
 	BLI_freelistN(&keys);
@@ -1257,8 +1259,9 @@
 {
 	ListBase keys = {0, 0};
 	ListBase blocks = {0, 0};
+	ActKeysInc aki = INIT_AKI_DATA;
 
-	ipo_to_keylist(ipo, &keys, &blocks);
+	ipo_to_keylist(ipo, &keys, &blocks, &aki);
 	draw_keylist(di, &keys, &blocks, ypos);
 	
 	BLI_freelistN(&keys);
@@ -1269,8 +1272,9 @@
 {
 	ListBase keys = {0, 0};
 	ListBase blocks = {0, 0};
+	ActKeysInc aki = INIT_AKI_DATA;
 
-	icu_to_keylist(icu, &keys, &blocks);
+	icu_to_keylist(icu, &keys, &blocks, &aki);
 	draw_keylist(di, &keys, &blocks, ypos);
 	
 	BLI_freelistN(&keys);
@@ -1281,8 +1285,9 @@
 {
 	ListBase keys = {0, 0};
 	ListBase blocks = {0, 0};
+	ActKeysInc aki = INIT_AKI_DATA;
 
-	agroup_to_keylist(agrp, &keys, &blocks);
+	agroup_to_keylist(agrp, &keys, &blocks, &aki);
 	draw_keylist(di, &keys, &blocks, ypos);
 	BLI_freelistN(&keys);
 	BLI_freelistN(&blocks);
@@ -1291,27 +1296,28 @@
 void draw_action_channel(gla2DDrawInfo *di, bAction *act, float ypos)
 {
 	ListBase keys = {0, 0};
+	ActKeysInc aki = INIT_AKI_DATA;
 
-	action_to_keylist(act, &keys, NULL);
+	action_to_keylist(act, &keys, NULL, &aki);
 	draw_keylist(di, &keys, NULL, ypos);
 	BLI_freelistN(&keys);
 }
 
 /* --------------- Conversion: data -> keyframe list ------------------ */
 
-void ob_to_keylist(Object *ob, ListBase *keys, ListBase *blocks)
+void ob_to_keylist(Object *ob, ListBase *keys, ListBase *blocks, ActKeysInc *aki)
 {
 	bConstraintChannel *conchan;
 
 	if (ob) {
 		/* Add object keyframes */
 		if (ob->ipo)
-			ipo_to_keylist(ob->ipo, keys, blocks);
+			ipo_to_keylist(ob->ipo, keys, blocks, aki);
 		
 		/* Add constraint keyframes */
-		for (conchan=ob->constraintChannels.first; conchan; conchan=conchan->next){
+		for (conchan=ob->constraintChannels.first; conchan; conchan=conchan->next) {
 			if(conchan->ipo)
-				ipo_to_keylist(conchan->ipo, keys, blocks);		
+				ipo_to_keylist(conchan->ipo, keys, blocks, aki);		
 		}
 			
 		/* Add object data keyframes */
@@ -1319,8 +1325,25 @@
 	}
 }
 
-void icu_to_keylist(IpoCurve *icu, ListBase *keys, ListBase *blocks)
+static short bezt_in_aki_range (ActKeysInc *aki, BezTriple *bezt)
 {
+	/* when aki == NULL, we don't care about range */
+	if (aki == NULL) 
+		return 1;
+		
+	/* if nla-scaling is in effect, apply appropriate scaling adjustments */
+	if (aki->ob) {
+		float frame= get_action_frame_inv(aki->ob, bezt->vec[1][0]);
+		return IN_RANGE(frame, aki->start, aki->end);
+	}
+	else {
+		/* check if in range */
+		return IN_RANGE(bezt->vec[1][0], aki->start, aki->end);
+	}
+}
+
+void icu_to_keylist(IpoCurve *icu, ListBase *keys, ListBase *blocks, ActKeysInc *aki)
+{
 	BezTriple *bezt;
 	ActKeyColumn *ak;
 	ActKeyBlock *ab;
@@ -1331,8 +1354,11 @@
 		bezt= icu->bezt;
 		
 		for (v=0; v<icu->totvert; v++, bezt++) {
-			add_bezt_to_keycolumnslist(keys, bezt);
-			if (blocks) add_bezt_to_keyblockslist(blocks, icu, v);
+			/* only if keyframe is in range (optimisation) */
+			if (bezt_in_aki_range(aki, bezt)) {
+				add_bezt_to_keycolumnslist(keys, bezt);
+				if (blocks) add_bezt_to_keyblockslist(blocks, icu, v);
+			}
 		}
 		
 		/* update the number of curves that elements have appeared in  */
@@ -1355,17 +1381,17 @@
 	}
 }
 
-void ipo_to_keylist(Ipo *ipo, ListBase *keys, ListBase *blocks)
+void ipo_to_keylist(Ipo *ipo, ListBase *keys, ListBase *blocks, ActKeysInc *aki)
 {
 	IpoCurve *icu;
 	
 	if (ipo) {
 		for (icu= ipo->curve.first; icu; icu= icu->next)
-			icu_to_keylist(icu, keys, blocks);
+			icu_to_keylist(icu, keys, blocks, aki);
 	}
 }
 
-void agroup_to_keylist(bActionGroup *agrp, ListBase *keys, ListBase *blocks)
+void agroup_to_keylist(bActionGroup *agrp, ListBase *keys, ListBase *blocks, ActKeysInc *aki)
 {
 	bActionChannel *achan;
 	bConstraintChannel *conchan;
@@ -1375,18 +1401,18 @@
 		for (achan= agrp->channels.first; achan && achan!=agrp->channels.last; achan= achan->next) {
 			/* firstly, add keys from action channel's ipo block */
 			if (achan->ipo)
-				ipo_to_keylist(achan->ipo, keys, blocks);
+				ipo_to_keylist(achan->ipo, keys, blocks, aki);
 			
 			/* then, add keys from constraint channels */
 			for (conchan= achan->constraintChannels.first; conchan; conchan= conchan->next) {
 				if (conchan->ipo)
-					ipo_to_keylist(conchan->ipo, keys, blocks);
+					ipo_to_keylist(conchan->ipo, keys, blocks, aki);
 			}
 		}
 	}
 }
 
-void action_to_keylist(bAction *act, ListBase *keys, ListBase *blocks)
+void action_to_keylist(bAction *act, ListBase *keys, ListBase *blocks, ActKeysInc *aki)
 {
 	bActionChannel *achan;
 	bConstraintChannel *conchan;
@@ -1396,12 +1422,12 @@
 		for (achan= act->chanbase.first; achan; achan= achan->next) {
 			/* firstly, add keys from action channel's ipo block */
 			if (achan->ipo)
-				ipo_to_keylist(achan->ipo, keys, blocks);
+				ipo_to_keylist(achan->ipo, keys, blocks, aki);
 			
 			/* then, add keys from constraint channels */
 			for (conchan= achan->constraintChannels.first; conchan; conchan= conchan->next) {
 				if (conchan->ipo)
-					ipo_to_keylist(conchan->ipo, keys, blocks);
+					ipo_to_keylist(conchan->ipo, keys, blocks, aki);
 			}
 		}
 	}

Modified: trunk/blender/source/blender/src/drawarmature.c
===================================================================
--- trunk/blender/source/blender/src/drawarmature.c	2008-01-26 22:39:07 UTC (rev 13417)
+++ trunk/blender/source/blender/src/drawarmature.c	2008-01-27 03:21:24 UTC (rev 13418)
@@ -2111,7 +2111,7 @@
 					if (act) {
 						achan= get_action_channel(act, pchan->name);
 						if (achan) 
-							ipo_to_keylist(achan->ipo, &keys, NULL);
+							ipo_to_keylist(achan->ipo, &keys, NULL, NULL);
 					}
 					
 					/* Draw slightly-larger yellow dots at each keyframe */
@@ -2257,17 +2257,18 @@
 	bArmature *arm= ob->data;
 	bPose *posen, *poseo;
 	ListBase keys= {NULL, NULL};
+	ActKeysInc aki = {0, 0, 0};
 	ActKeyColumn *ak, *akn;
 	float start, end, range, colfac, i;
 	int cfrao, flago, ipoflago;
 	
-	start = arm->ghostsf;
-	end = arm->ghostef;
+	aki.start= start = arm->ghostsf;
+	aki.end= end = arm->ghostef;
 	if (end <= start)
 		return;
 	
 	/* get keyframes - then clip to only within range */
-	action_to_keylist(act, &keys, NULL);
+	action_to_keylist(act, &keys, NULL, &aki);
 	range= 0;
 	for (ak= keys.first; ak; ak= akn) {
 		akn= ak->next;

Modified: trunk/blender/source/blender/src/editaction.c
===================================================================
--- trunk/blender/source/blender/src/editaction.c	2008-01-26 22:39:07 UTC (rev 13417)
+++ trunk/blender/source/blender/src/editaction.c	2008-01-27 03:21:24 UTC (rev 13418)
@@ -682,20 +682,20 @@
 					case ALE_IPO:
 					{
 						Ipo *ipo= (Ipo *)ale->key_data;
-						ipo_to_keylist(ipo, &act_keys, NULL);
+						ipo_to_keylist(ipo, &act_keys, NULL, NULL);
 					}
 						break;
 					case ALE_ICU:
 					{
 						IpoCurve *icu= (IpoCurve *)ale->key_data;
-						icu_to_keylist(icu, &act_keys, NULL);
+						icu_to_keylist(icu, &act_keys, NULL, NULL);
 					}
 						break;
 				}
 			}
 			else if (ale->type == ACTTYPE_GROUP) {
 				bActionGroup *agrp= (bActionGroup *)ale->data;
-				agroup_to_keylist(agrp, &act_keys, NULL);
+				agroup_to_keylist(agrp, &act_keys, NULL, NULL);
 			}
 			
 			/* loop through keyframes, finding one that was clicked on */

Modified: trunk/blender/source/blender/src/poselib.c
===================================================================
--- trunk/blender/source/blender/src/poselib.c	2008-01-26 22:39:07 UTC (rev 13417)
+++ trunk/blender/source/blender/src/poselib.c	2008-01-27 03:21:24 UTC (rev 13418)
@@ -218,7 +218,7 @@
 	}
 	

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list