Changeset View
Changeset View
Standalone View
Standalone View
source/blender/windowmanager/intern/wm_operators.c
| Show First 20 Lines • Show All 3,145 Lines • ▼ Show 20 Lines | static const EnumPropertyItem redraw_timer_type_items[] = { | ||||
| {eRTDrawWindowSwap, "DRAW_WIN_SWAP", 0, "Draw Window + Swap", "Draw Window and Swap"}, | {eRTDrawWindowSwap, "DRAW_WIN_SWAP", 0, "Draw Window + Swap", "Draw Window and Swap"}, | ||||
| {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(bContext *C, | static void redraw_timer_step(bContext *C, | ||||
| Main *bmain, | |||||
| Scene *scene, | Scene *scene, | ||||
| struct Depsgraph *depsgraph, | struct Depsgraph *depsgraph, | ||||
| wmWindow *win, | wmWindow *win, | ||||
| ScrArea *area, | ScrArea *area, | ||||
| ARegion *region, | ARegion *region, | ||||
| const int type, | const int type, | ||||
| const int cfra) | const int cfra) | ||||
| { | { | ||||
| Show All 34 Lines | else if (type == eRTDrawWindow) { | ||||
| CTX_wm_area_set(C, area); | CTX_wm_area_set(C, area); | ||||
| CTX_wm_region_set(C, region); | CTX_wm_region_set(C, region); | ||||
| } | } | ||||
| 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(depsgraph, bmain); | BKE_scene_graph_update_for_newframe(depsgraph); | ||||
| } | } | ||||
| 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(depsgraph, bmain); | BKE_scene_graph_update_for_newframe(depsgraph); | ||||
| redraw_timer_window_swap(C); | redraw_timer_window_swap(C); | ||||
| } | } | ||||
| } | } | ||||
| else { /* eRTUndo */ | else { /* eRTUndo */ | ||||
| /* Undo and redo, including depsgraph update since that can be a | /* Undo and redo, including depsgraph update since that can be a | ||||
| * significant part of the cost. */ | * significant part of the cost. */ | ||||
| ED_undo_pop(C); | ED_undo_pop(C); | ||||
| wm_event_do_refresh_wm_and_depsgraph(C); | wm_event_do_refresh_wm_and_depsgraph(C); | ||||
| ED_undo_redo(C); | ED_undo_redo(C); | ||||
| wm_event_do_refresh_wm_and_depsgraph(C); | wm_event_do_refresh_wm_and_depsgraph(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); | |||||
| Scene *scene = CTX_data_scene(C); | Scene *scene = CTX_data_scene(C); | ||||
| wmWindow *win = CTX_wm_window(C); | wmWindow *win = CTX_wm_window(C); | ||||
| ScrArea *area = CTX_wm_area(C); | ScrArea *area = CTX_wm_area(C); | ||||
| ARegion *region = CTX_wm_region(C); | ARegion *region = CTX_wm_region(C); | ||||
| wmWindowManager *wm = CTX_wm_manager(C); | wmWindowManager *wm = CTX_wm_manager(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 = ""; | ||||
| /* NOTE: Depsgraph is used to update scene for a new state, so no need to ensure evaluation here. | /* NOTE: Depsgraph is used to update scene for a new state, so no need to ensure evaluation here. | ||||
| */ | */ | ||||
| struct Depsgraph *depsgraph = CTX_data_depsgraph_pointer(C); | struct Depsgraph *depsgraph = CTX_data_depsgraph_pointer(C); | ||||
| WM_cursor_wait(1); | WM_cursor_wait(1); | ||||
| time_start = PIL_check_seconds_timer(); | time_start = PIL_check_seconds_timer(); | ||||
| wm_window_make_drawable(wm, win); | wm_window_make_drawable(wm, win); | ||||
| for (a = 0; a < iter; a++) { | for (a = 0; a < iter; a++) { | ||||
| redraw_timer_step(C, bmain, scene, depsgraph, win, area, region, type, cfra); | redraw_timer_step(C, scene, depsgraph, win, area, region, 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 856 Lines • Show Last 20 Lines | |||||