diff options
author | Joshua Leung <aligorith@gmail.com> | 2010-02-12 03:44:26 +0300 |
---|---|---|
committer | Joshua Leung <aligorith@gmail.com> | 2010-02-12 03:44:26 +0300 |
commit | b482b8543eb10102c6c09756e08977a3b69ff633 (patch) | |
tree | 4532177f73045cc5cdb3582766d1e121604a53a1 /source/blender/editors/space_view3d | |
parent | f0e873cabe0797c74fba440c8b11b4e2c038f791 (diff) |
Bugfix #21051: Restored 'Playback FPS'
This commit restores the 'Playback FPS' option which showed an indicator of the frame rate of animation playback in the 3D-View.
The info for this is now stored in a temp struct in scene data, with the status info being updated by the "animation step" operator instead of relying on globals as the old code did. This seems a lot more stable than in 2.49, but the accuracy is still questionable.
Diffstat (limited to 'source/blender/editors/space_view3d')
-rw-r--r-- | source/blender/editors/space_view3d/space_view3d.c | 2 | ||||
-rw-r--r-- | source/blender/editors/space_view3d/view3d_draw.c | 59 |
2 files changed, 59 insertions, 2 deletions
diff --git a/source/blender/editors/space_view3d/space_view3d.c b/source/blender/editors/space_view3d/space_view3d.c index 97ae94cae26..594eff2c0a0 100644 --- a/source/blender/editors/space_view3d/space_view3d.c +++ b/source/blender/editors/space_view3d/space_view3d.c @@ -612,6 +612,8 @@ static void view3d_main_area_listener(ARegion *ar, wmNotifier *wmn) case NC_SCREEN: if(wmn->data == ND_GPENCIL) ED_region_tag_redraw(ar); + else if(wmn->data==ND_ANIMPLAY) + ED_region_tag_redraw(ar); break; } } diff --git a/source/blender/editors/space_view3d/view3d_draw.c b/source/blender/editors/space_view3d/view3d_draw.c index 3c5b8c0abc7..855da0eefcf 100644 --- a/source/blender/editors/space_view3d/view3d_draw.c +++ b/source/blender/editors/space_view3d/view3d_draw.c @@ -74,6 +74,7 @@ #include "BIF_glutil.h" #include "WM_api.h" +#include "WM_types.h" #include "BLF_api.h" #include "ED_armature.h" @@ -82,6 +83,7 @@ #include "ED_mesh.h" #include "ED_screen.h" #include "ED_space_api.h" +#include "ED_screen_types.h" #include "ED_util.h" #include "ED_transform.h" #include "ED_types.h" @@ -1989,6 +1991,57 @@ void ED_view3d_draw_offscreen(Scene *scene, View3D *v3d, ARegion *ar, int winx, glPopMatrix(); } +/* NOTE: the info that this uses is updated in ED_refresh_viewport_fps(), + * which currently gets called during SCREEN_OT_animation_step. + */ +static void draw_viewport_fps(Scene *scene, ARegion *ar) +{ + ScreenFrameRateInfo *fpsi= scene->fps_info; + float fps; + char printable[16]; + int i, tot; + + if (!fpsi || !fpsi->lredrawtime || !fpsi->redrawtime) + return; + + printable[0] = '\0'; + +#if 0 + /* this is too simple, better do an average */ + fps = (float)(1.0/(fpsi->lredrawtime-fpsi->redrawtime)) +#else + fpsi->redrawtimes_fps[fpsi->redrawtime_index] = (float)(1.0/(fpsi->lredrawtime-fpsi->redrawtime)); + + for (i=0, tot=0, fps=0.0f ; i < REDRAW_FRAME_AVERAGE ; i++) { + if (fpsi->redrawtimes_fps[i]) { + fps += fpsi->redrawtimes_fps[i]; + tot++; + } + } + if (tot) { + fpsi->redrawtime_index = (fpsi->redrawtime_index + 1) % REDRAW_FRAME_AVERAGE; + + //fpsi->redrawtime_index++; + //if (fpsi->redrawtime >= REDRAW_FRAME_AVERAGE) + // fpsi->redrawtime = 0; + + fps = fps / tot; + } +#endif + + /* is this more then half a frame behind? */ + if (fps+0.5 < FPS) { + UI_ThemeColor(TH_REDALERT); + sprintf(printable, "fps: %.2f", (float)fps); + } + else { + UI_ThemeColor(TH_TEXT_HI); + sprintf(printable, "fps: %i", (int)(fps+0.5)); + } + + BLF_draw_default(22, ar->winy-17, 0.0f, printable); +} + void view3d_main_area_draw(const bContext *C, ARegion *ar) { Scene *scene= CTX_data_scene(C); @@ -2176,8 +2229,10 @@ void view3d_main_area_draw(const bContext *C, ARegion *ar) else draw_view_icon(rv3d); - /* XXX removed viewport fps */ - if(U.uiflag & USER_SHOW_VIEWPORTNAME) { + if((U.uiflag & USER_SHOW_FPS) && (CTX_wm_screen(C)->animtimer)) { + draw_viewport_fps(scene, ar); + } + else if(U.uiflag & USER_SHOW_VIEWPORTNAME) { draw_viewport_name(ar, v3d); } if (grid_unit) { /* draw below the viewport name */ |