[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [14642] trunk/blender/source/blender/src/ drawview.c: [#8397] "playback fps' jumps all over the map

Campbell Barton ideasman42 at gmail.com
Thu May 1 16:51:09 CEST 2008


Revision: 14642
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=14642
Author:   campbellbarton
Date:     2008-05-01 16:51:06 +0200 (Thu, 01 May 2008)

Log Message:
-----------
[#8397] "playback fps' jumps all over the map
average over the last 8 times to reduce flickering. ideally this would show how many frames were drawn in the last second. but I think this is good enough just to get an idea how fast the animation is playing without annoying flicker.

Modified Paths:
--------------
    trunk/blender/source/blender/src/drawview.c

Modified: trunk/blender/source/blender/src/drawview.c
===================================================================
--- trunk/blender/source/blender/src/drawview.c	2008-05-01 14:22:21 UTC (rev 14641)
+++ trunk/blender/source/blender/src/drawview.c	2008-05-01 14:51:06 UTC (rev 14642)
@@ -3394,9 +3394,13 @@
 static int curmode;
 
 /* used for fps display */
+#define REDRAW_FRAME_AVERAGE 8
 static double redrawtime;
 static double lredrawtime;
+static float redrawtimes_fps[REDRAW_FRAME_AVERAGE];
+static short redrawtime_index;
 
+
 int update_time(void)
 {
 	static double ltime;
@@ -3418,14 +3422,33 @@
 {
 	float fps;
 	char printable[16];
-
+	int i, tot;
 	
 	if (lredrawtime == redrawtime)
 		return;
 	
 	printable[0] = '\0';
-	fps = (float)(1.0/(lredrawtime-redrawtime));
 	
+#if 0
+	/* this is too simple, better do an average */
+	fps = (float)(1.0/(lredrawtime-redrawtime))
+#else
+	redrawtimes_fps[redrawtime_index] = (float)(1.0/(lredrawtime-redrawtime));
+	
+	for (i=0, tot=0, fps=0.0f ; i < REDRAW_FRAME_AVERAGE ; i++) {
+		if (redrawtimes_fps[i]) {
+			fps += redrawtimes_fps[i];
+			tot++;
+		}
+	}
+	
+	redrawtime_index++;
+	if (redrawtime_index >= REDRAW_FRAME_AVERAGE)
+		redrawtime_index = 0;
+	
+	fps = fps / tot;
+#endif
+	
 	/* is this more then half a frame behind? */
 	if (fps+0.5 < FPS) {
 		BIF_ThemeColor(TH_REDALERT);
@@ -3549,6 +3572,12 @@
 		cached = cached_dynamics(PSFRA,PEFRA);
 		
 		redrawtime = 1.0/FPS;
+		
+		redrawtime_index = REDRAW_FRAME_AVERAGE;
+		while(redrawtime_index--) {
+			redrawtimes_fps[redrawtime_index] = 0.0;
+		}
+		
 		lredrawtime = 0.0;
 		return;
 	}





More information about the Bf-blender-cvs mailing list