Changeset View
Changeset View
Standalone View
Standalone View
source/blender/windowmanager/intern/wm_operators.c
| Show First 20 Lines • Show All 3,234 Lines • ▼ Show 20 Lines | static const EnumPropertyItem redraw_timer_type_items[] = { | ||||
| {eRTAnimationStep, "ANIM_STEP", 0, "Anim Step", "Animation Steps"}, | {eRTAnimationStep, "ANIM_STEP", 0, "Anim Step", "Animation Steps"}, | ||||
| {eRTAnimationPlay, "ANIM_PLAY", 0, "Anim Play", "Animation Playback"}, | {eRTAnimationPlay, "ANIM_PLAY", 0, "Anim Play", "Animation Playback"}, | ||||
| {eRTUndo, "UNDO", 0, "Undo/Redo", "Undo/Redo"}, | {eRTUndo, "UNDO", 0, "Undo/Redo", "Undo/Redo"}, | ||||
| {0, NULL, 0, NULL, NULL} | {0, NULL, 0, NULL, NULL} | ||||
| }; | }; | ||||
| static void redraw_timer_step( | static void redraw_timer_step( | ||||
| bContext *C, Main *bmain, Scene *scene, SceneLayer *scene_layer, | bContext *C, Main *bmain, Scene *scene, ViewLayer *view_layer, | ||||
| struct Depsgraph *depsgraph, | struct Depsgraph *depsgraph, | ||||
| wmWindow *win, ScrArea *sa, ARegion *ar, | wmWindow *win, ScrArea *sa, ARegion *ar, | ||||
| const int type, const int cfra) | const int type, const int cfra) | ||||
| { | { | ||||
| if (type == eRTDrawRegion) { | if (type == eRTDrawRegion) { | ||||
| if (ar) { | if (ar) { | ||||
| ED_region_do_draw(C, ar); | ED_region_do_draw(C, ar); | ||||
| ar->do_draw = false; | ar->do_draw = false; | ||||
| Show All 31 Lines | else if (type == eRTDrawWindow) { | ||||
| CTX_wm_area_set(C, sa); | CTX_wm_area_set(C, sa); | ||||
| CTX_wm_region_set(C, ar); | CTX_wm_region_set(C, ar); | ||||
| } | } | ||||
| else if (type == eRTDrawWindowSwap) { | else if (type == eRTDrawWindowSwap) { | ||||
| redraw_timer_window_swap(C); | redraw_timer_window_swap(C); | ||||
| } | } | ||||
| else if (type == eRTAnimationStep) { | else if (type == eRTAnimationStep) { | ||||
| scene->r.cfra += (cfra == scene->r.cfra) ? 1 : -1; | scene->r.cfra += (cfra == scene->r.cfra) ? 1 : -1; | ||||
| BKE_scene_graph_update_for_newframe(bmain->eval_ctx, depsgraph, bmain, scene, scene_layer); | BKE_scene_graph_update_for_newframe(bmain->eval_ctx, depsgraph, bmain, scene, view_layer); | ||||
| } | } | ||||
| else if (type == eRTAnimationPlay) { | else if (type == eRTAnimationPlay) { | ||||
| /* play anim, return on same frame as started with */ | /* play anim, return on same frame as started with */ | ||||
| int tot = (scene->r.efra - scene->r.sfra) + 1; | int tot = (scene->r.efra - scene->r.sfra) + 1; | ||||
| while (tot--) { | while (tot--) { | ||||
| /* todo, ability to escape! */ | /* todo, ability to escape! */ | ||||
| scene->r.cfra++; | scene->r.cfra++; | ||||
| if (scene->r.cfra > scene->r.efra) | if (scene->r.cfra > scene->r.efra) | ||||
| scene->r.cfra = scene->r.sfra; | scene->r.cfra = scene->r.sfra; | ||||
| BKE_scene_graph_update_for_newframe(bmain->eval_ctx, depsgraph, bmain, scene, scene_layer); | BKE_scene_graph_update_for_newframe(bmain->eval_ctx, depsgraph, bmain, scene, view_layer); | ||||
| redraw_timer_window_swap(C); | redraw_timer_window_swap(C); | ||||
| } | } | ||||
| } | } | ||||
| else { /* eRTUndo */ | else { /* eRTUndo */ | ||||
| ED_undo_pop(C); | ED_undo_pop(C); | ||||
| ED_undo_redo(C); | ED_undo_redo(C); | ||||
| } | } | ||||
| } | } | ||||
| static int redraw_timer_exec(bContext *C, wmOperator *op) | static int redraw_timer_exec(bContext *C, wmOperator *op) | ||||
| { | { | ||||
| Main *bmain = CTX_data_main(C); | Main *bmain = CTX_data_main(C); | ||||
| Scene *scene = CTX_data_scene(C); | Scene *scene = CTX_data_scene(C); | ||||
| SceneLayer *scene_layer = CTX_data_scene_layer(C); | ViewLayer *view_layer = CTX_data_view_layer(C); | ||||
| wmWindow *win = CTX_wm_window(C); | wmWindow *win = CTX_wm_window(C); | ||||
| ScrArea *sa = CTX_wm_area(C); | ScrArea *sa = CTX_wm_area(C); | ||||
| ARegion *ar = CTX_wm_region(C); | ARegion *ar = CTX_wm_region(C); | ||||
| double time_start, time_delta; | double time_start, time_delta; | ||||
| const int type = RNA_enum_get(op->ptr, "type"); | const int type = RNA_enum_get(op->ptr, "type"); | ||||
| const int iter = RNA_int_get(op->ptr, "iterations"); | const int iter = RNA_int_get(op->ptr, "iterations"); | ||||
| const double time_limit = (double)RNA_float_get(op->ptr, "time_limit"); | const double time_limit = (double)RNA_float_get(op->ptr, "time_limit"); | ||||
| const int cfra = scene->r.cfra; | const int cfra = scene->r.cfra; | ||||
| int a, iter_steps = 0; | int a, iter_steps = 0; | ||||
| const char *infostr = ""; | const char *infostr = ""; | ||||
| struct Depsgraph *depsgraph = CTX_data_depsgraph(C); | struct Depsgraph *depsgraph = CTX_data_depsgraph(C); | ||||
| WM_cursor_wait(1); | WM_cursor_wait(1); | ||||
| time_start = PIL_check_seconds_timer(); | time_start = PIL_check_seconds_timer(); | ||||
| for (a = 0; a < iter; a++) { | for (a = 0; a < iter; a++) { | ||||
| redraw_timer_step(C, bmain, scene, scene_layer, depsgraph, win, sa, ar, type, cfra); | redraw_timer_step(C, bmain, scene, view_layer, depsgraph, win, sa, ar, type, cfra); | ||||
| iter_steps += 1; | iter_steps += 1; | ||||
| if (time_limit != 0.0) { | if (time_limit != 0.0) { | ||||
| if ((PIL_check_seconds_timer() - time_start) > time_limit) { | if ((PIL_check_seconds_timer() - time_start) > time_limit) { | ||||
| break; | break; | ||||
| } | } | ||||
| a = 0; | a = 0; | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 750 Lines • Show Last 20 Lines | |||||