Fix T102746: Jumping to next/previous (key)frame doesn't take subframes into account
Previously when on frame 2.5 and trying to jump to a keyframe that was on frame 2, it would instead jump past it. Now it properly respects the subframes for that. Reviewed by: Sybren A. Stüvel Differential Revision: https://developer.blender.org/D16651 Ref: D16651
This commit is contained in:
parent
825f01b7b5
commit
5eab813fc0
Notes:
blender-bot
2023-02-13 13:57:25 +01:00
Referenced by issue #102746, Jumping to next/previous (key)frame doesn't take subframes into account
|
@ -2951,6 +2951,11 @@ static int frame_offset_exec(bContext *C, wmOperator *op)
|
|||
|
||||
int delta = RNA_int_get(op->ptr, "delta");
|
||||
|
||||
/* In order to jump from e.g. 1.5 to 1 the delta needs to be incremented by 1 since the subframe
|
||||
* is always zeroed. Otherwise it would jump to 0.*/
|
||||
if (delta < 0 && scene->r.subframe > 0) {
|
||||
delta += 1;
|
||||
}
|
||||
scene->r.cfra += delta;
|
||||
FRAMENUMBER_MIN_CLAMP(scene->r.cfra);
|
||||
scene->r.subframe = 0.0f;
|
||||
|
@ -3062,7 +3067,7 @@ static int keyframe_jump_exec(bContext *C, wmOperator *op)
|
|||
return OPERATOR_CANCELLED;
|
||||
}
|
||||
|
||||
float cfra = (float)(scene->r.cfra);
|
||||
const float cfra = BKE_scene_frame_get(scene);
|
||||
|
||||
/* Initialize binary-tree-list for getting keyframes. */
|
||||
struct AnimKeylist *keylist = ED_keylist_create();
|
||||
|
@ -3096,25 +3101,26 @@ static int keyframe_jump_exec(bContext *C, wmOperator *op)
|
|||
|
||||
/* find matching keyframe in the right direction */
|
||||
const ActKeyColumn *ak;
|
||||
|
||||
if (next) {
|
||||
ak = ED_keylist_find_next(keylist, cfra);
|
||||
}
|
||||
else {
|
||||
ak = ED_keylist_find_prev(keylist, cfra);
|
||||
while ((ak != NULL) && (done == false)) {
|
||||
if (cfra < ak->cfra) {
|
||||
BKE_scene_frame_set(scene, ak->cfra);
|
||||
done = true;
|
||||
}
|
||||
else {
|
||||
ak = ak->next;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
while ((ak != NULL) && (done == false)) {
|
||||
if (scene->r.cfra != (int)ak->cfra) {
|
||||
/* this changes the frame, so set the frame and we're done */
|
||||
const int whole_frame = (int)ak->cfra;
|
||||
scene->r.cfra = whole_frame;
|
||||
scene->r.subframe = ak->cfra - whole_frame;
|
||||
done = true;
|
||||
}
|
||||
else {
|
||||
/* take another step... */
|
||||
if (next) {
|
||||
ak = ak->next;
|
||||
else {
|
||||
ak = ED_keylist_find_prev(keylist, cfra);
|
||||
while ((ak != NULL) && (done == false)) {
|
||||
if (cfra > ak->cfra) {
|
||||
BKE_scene_frame_set(scene, ak->cfra);
|
||||
done = true;
|
||||
}
|
||||
else {
|
||||
ak = ak->prev;
|
||||
|
|
Loading…
Reference in New Issue