Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/screen/screen_ops.c
| Show First 20 Lines • Show All 992 Lines • ▼ Show 20 Lines | |||||
| /* function to be called outside UI context, or for redo */ | /* function to be called outside UI context, or for redo */ | ||||
| static int frame_offset_exec(bContext *C, wmOperator *op) | static int frame_offset_exec(bContext *C, wmOperator *op) | ||||
| { | { | ||||
| Scene *scene = CTX_data_scene(C); | Scene *scene = CTX_data_scene(C); | ||||
| int delta = RNA_int_get(op->ptr, "delta"); | int delta = RNA_int_get(op->ptr, "delta"); | ||||
| if (delta < 0 && scene->r.subframe > 0) { | |||||
sybren: What's the reason you need an extra `delta` when the subframe is not zero? | |||||
ChrisLendAuthorUnsubmitted Done Inline ActionsIt'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 ChrisLend: It's because if the delta is -1 as in jumping 1f to the left, it would actually do more than… | |||||
| delta += 1; | |||||
| } | |||||
| scene->r.cfra += delta; | scene->r.cfra += delta; | ||||
| FRAMENUMBER_MIN_CLAMP(scene->r.cfra); | FRAMENUMBER_MIN_CLAMP(scene->r.cfra); | ||||
| scene->r.subframe = 0.0f; | scene->r.subframe = 0.0f; | ||||
| areas_do_frame_follow(C, false); | areas_do_frame_follow(C, false); | ||||
| DEG_id_tag_update(&scene->id, ID_RECALC_FRAME_CHANGE); | DEG_id_tag_update(&scene->id, ID_RECALC_FRAME_CHANGE); | ||||
| ▲ Show 20 Lines • Show All 95 Lines • ▼ Show 20 Lines | |||||
| const bool next = RNA_boolean_get(op->ptr, "next"); | const bool next = RNA_boolean_get(op->ptr, "next"); | ||||
| bool done = false; | bool done = false; | ||||
| /* sanity checks */ | /* sanity checks */ | ||||
| if (scene == NULL) { | if (scene == NULL) { | ||||
| return OPERATOR_CANCELLED; | return OPERATOR_CANCELLED; | ||||
| } | } | ||||
| float cfra = (float)(scene->r.cfra); | const float cfra = (float)(scene->r.cfra) + scene->r.subframe; | ||||
sybrenUnsubmitted Done Inline ActionsThis calculation shouldn't be done here. Use BKE_scene_frame_get(scene) instead. sybren: This calculation shouldn't be done here. Use `BKE_scene_frame_get(scene)` instead. | |||||
| /* Initialize binary-tree-list for getting keyframes. */ | /* Initialize binary-tree-list for getting keyframes. */ | ||||
| struct AnimKeylist *keylist = ED_keylist_create(); | struct AnimKeylist *keylist = ED_keylist_create(); | ||||
| /* Speed up dummy dope-sheet context with flags to perform necessary filtering. */ | /* Speed up dummy dope-sheet context with flags to perform necessary filtering. */ | ||||
| if ((scene->flag & SCE_KEYS_NO_SELONLY) == 0) { | if ((scene->flag & SCE_KEYS_NO_SELONLY) == 0) { | ||||
| /* Only selected channels are included. */ | /* Only selected channels are included. */ | ||||
| ads.filterflag |= ADS_FILTER_ONLYSEL; | ads.filterflag |= ADS_FILTER_ONLYSEL; | ||||
| Show All 17 Lines | |||||
| MaskLayer *masklay = BKE_mask_layer_active(mask); | MaskLayer *masklay = BKE_mask_layer_active(mask); | ||||
| mask_to_keylist(&ads, masklay, keylist); | mask_to_keylist(&ads, masklay, keylist); | ||||
| } | } | ||||
| } | } | ||||
| ED_keylist_prepare_for_direct_access(keylist); | ED_keylist_prepare_for_direct_access(keylist); | ||||
| /* find matching keyframe in the right direction */ | /* find matching keyframe in the right direction */ | ||||
| const ActKeyColumn *ak; | const ActKeyColumn *ak; | ||||
| if (next) { | if (next) { | ||||
| ak = ED_keylist_find_next(keylist, cfra); | ak = ED_keylist_find_next(keylist, cfra); | ||||
| while ((ak != NULL) && (done == false)) { | |||||
| if (cfra < ak->cfra) { | |||||
| BKE_scene_frame_set(scene, ak->cfra); | |||||
| done = true; | |||||
| } | |||||
| else { | |||||
| ak = ak->next; | |||||
| } | |||||
| } | |||||
| } | } | ||||
| else { | else { | ||||
| ak = ED_keylist_find_prev(keylist, cfra); | ak = ED_keylist_find_prev(keylist, cfra); | ||||
| } | while ((ak != NULL) && (done == false)) { | ||||
| if (cfra > ak->cfra) { | |||||
| while ((ak != NULL) && (done == false)) { | BKE_scene_frame_set(scene, ak->cfra); | ||||
| if (scene->r.cfra != (int)ak->cfra) { | done = true; | ||||
| /* 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 { | else { | ||||
| ak = ak->prev; | ak = ak->prev; | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| /* free temp stuff */ | /* free temp stuff */ | ||||
| ▲ Show 20 Lines • Show All 992 Lines • Show Last 20 Lines | |||||
What's the reason you need an extra delta when the subframe is not zero?