Fix for [#30495] Framerate goes crazy after changing Sync mode from "Frame Dropping...
authorJoerg Mueller <nexyon@gmail.com>
Sun, 18 Mar 2012 22:21:29 +0000 (22:21 +0000)
committerJoerg Mueller <nexyon@gmail.com>
Sun, 18 Mar 2012 22:21:29 +0000 (22:21 +0000)
source/blender/editors/include/ED_screen_types.h
source/blender/editors/screen/screen_ops.c

index 51699d095ae0aef0e712bae4dc91288c8f8e1d79..6f7d0c55b9a64ae245e5703f5db1c6ea87e20968 100644 (file)
@@ -41,6 +41,7 @@ typedef struct ScreenAnimData {
        short flag;                     /* flags for playback */
        int sfra;                       /* frame that playback was started from */
        int nextfra;            /* next frame to go to (when ANIMPLAY_FLAG_USE_NEXT_FRAME is set) */
+       double last_duration;   /* used for frame dropping */
 } ScreenAnimData;
 
 /* for animplayer */
index b1d718f08b5778e026a6f6dc11061a9b97c367dc..697f40a507a12dda0bd9bc8ac573f45fe6d94c91 100644 (file)
@@ -2915,13 +2915,12 @@ static int screen_animation_step(bContext *C, wmOperator *UNUSED(op), wmEvent *e
                }
                else {
                        if (sync) {
-                               int step = floor(wt->duration * FPS);
+                               int step = floor((wt->duration - sad->last_duration) * FPS);
                                /* skip frames */
                                if (sad->flag & ANIMPLAY_FLAG_REVERSE)
                                        scene->r.cfra -= step;
                                else
                                        scene->r.cfra += step;
-                               wt->duration -= ((double)step)/FPS;
                        }
                        else {
                                /* one frame +/- */
@@ -2932,6 +2931,8 @@ static int screen_animation_step(bContext *C, wmOperator *UNUSED(op), wmEvent *e
                        }
                }
                
+               sad->last_duration = wt->duration;
+
                /* reset 'jumped' flag before checking if we need to jump... */
                sad->flag &= ~ANIMPLAY_FLAG_JUMPED;