Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastian Parborg <darkdefende@gmail.com>2020-05-12 14:19:20 +0300
committerSebastian Parborg <darkdefende@gmail.com>2020-05-12 14:24:20 +0300
commit94734d64542bf7c5f8ff2b129f230173af5e1996 (patch)
tree2133859ad5adac291e43362521c7ca4fcc989f1c /source/blender/editors/screen/screen_ops.c
parent07fc240d72cdcfe3a11764a253f6ab06b0deed39 (diff)
Fix Frame Dropping not dropping the correct amount of frames
Previously the playback mode "Frame Dropping" would not drop the correct number of frames which would lead to slow playback. For example, the playback target is 60fps. However we can only muster around 32 fps. The delta frames from the last step is in this case ~1.98 or so. With the previous code, we would floor this. That would lead us to step forward one frame each time, effectively playing back the animation at half the speed as we will try to render every frame. To fix this we simply save the remaining fraction from the previous frame and use it to compute the current frame step. Reviewed By: Sybren Differential Revision: http://developer.blender.org/D7694
Diffstat (limited to 'source/blender/editors/screen/screen_ops.c')
-rw-r--r--source/blender/editors/screen/screen_ops.c29
1 files changed, 23 insertions, 6 deletions
diff --git a/source/blender/editors/screen/screen_ops.c b/source/blender/editors/screen/screen_ops.c
index cb3984aa9ad..5b808206935 100644
--- a/source/blender/editors/screen/screen_ops.c
+++ b/source/blender/editors/screen/screen_ops.c
@@ -4437,10 +4437,29 @@ static int screen_animation_step(bContext *C, wmOperator *UNUSED(op), const wmEv
}
else {
if (sync) {
- /* note: this is very simplistic,
- * its has problem that it may skip too many frames.
- * however at least this gives a less jittery playback */
- const int step = max_ii(1, floor((wt->duration - sad->last_duration) * FPS));
+ /* Try to keep the playback in realtime by dropping frames. */
+
+ /* How much time (in frames) has passed since the last frame was drawn? */
+ double delta_frames = wt->delta * FPS;
+
+ /* Add the remaining fraction from the last time step. */
+ delta_frames += sad->lagging_frame_count;
+
+ if (delta_frames < 1.0) {
+ /* We can render faster than the scene frame rate. However skipping or delaying frames
+ * here seems to in practice lead to jittery playback so just step forward a minimum of
+ * one frame. (Even though this can lead to too fast playback, the jitteryness is more
+ * annoying)
+ */
+ delta_frames = 1.0f;
+ sad->lagging_frame_count = 0;
+ }
+ else {
+ /* Extract the delta frame fractions that will be skipped when converting to int. */
+ sad->lagging_frame_count = delta_frames - (int)delta_frames;
+ }
+
+ const int step = delta_frames;
/* skip frames */
if (sad->flag & ANIMPLAY_FLAG_REVERSE) {
@@ -4461,8 +4480,6 @@ static int screen_animation_step(bContext *C, wmOperator *UNUSED(op), const wmEv
}
}
- sad->last_duration = wt->duration;
-
/* reset 'jumped' flag before checking if we need to jump... */
sad->flag &= ~ANIMPLAY_FLAG_JUMPED;