Page MenuHome

Fix T102746: Jumping to next/previous (key)frame doesn't take subframes into account
ClosedPublic

Authored by Christoph Lendenfeld (ChrisLend) on Nov 30 2022, 11:58 AM.

Details

Summary

call BKE_scene_frame_set to remove duplication of frame setting logic
tiny refactor to reduce the occurence of if (next)

Diff Detail

Repository
rB Blender

Event Timeline

missed adding a fix for the SCREEN_OT_frame_offset operator. added now

source/blender/editors/screen/screen_ops.c
2954

What's the reason you need an extra delta when the subframe is not zero?

3068

This calculation shouldn't be done here. Use BKE_scene_frame_get(scene) instead.

  • use BKE_scene_frame_get
  • add comment to clarify delta
Christoph Lendenfeld (ChrisLend) added inline comments.
source/blender/editors/screen/screen_ops.c
2954

It's because if the delta is -1 as in jumping 1f to the left, it would actually do more than that, because the subframe is always zeroed.

So 1.5 would jump to 0 because "1.5 -1 = 0.5" then 0.5 -> 0.0
I added a comment to clarify that

This patch seems to be partially a refactor (duplicating some code to simplify each if (next) branch) and partially a bugfix (adjusting delta += 1). Or is the former change actually changing the behaviour, requiring the other change to become non-functional again?

the code at the bottom I needed to change because I had to split
if (scene->r.cfra != (int)ak->cfra)

into
if (cfra > ak->cfra)
and
if (cfra < ak->cfra)

so in order to keep it readable I moved if (next) out

That is clear -- I meant that this bit:

if (delta < 0 && scene->r.subframe > 0) {
  delta += 1;
}

seems to be a functional change (fixing an actual problem), whereas the other change is non-functional (fixing a code clarity issue but keeping its functionality the same).

Never mind my previous comment, this fixes the problem!

This revision is now accepted and ready to land.Jan 5 2023, 3:49 PM