From f99c6c8785088d039c73d41012b93e7f06c68136 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 1 Sep 2023 11:39:35 +1000 Subject: [PATCH] Cleanup: rename wmTimer struct members for clarity --- .../editors/interface/interface_handlers.cc | 4 +- .../blender/editors/interface/view2d_ops.cc | 2 +- source/blender/editors/screen/screen_ops.cc | 10 ++--- source/blender/editors/space_info/info_ops.cc | 6 +-- .../editors/space_node/node_relationships.cc | 4 +- .../view3d_navigate_smoothview.cc | 2 +- source/blender/makesrna/intern/rna_wm.cc | 6 +-- source/blender/windowmanager/WM_types.hh | 12 +++--- .../blender/windowmanager/intern/wm_jobs.cc | 16 +++---- .../windowmanager/intern/wm_playanim.cc | 6 +-- .../blender/windowmanager/intern/wm_window.cc | 42 +++++++++---------- 11 files changed, 55 insertions(+), 55 deletions(-) diff --git a/source/blender/editors/interface/interface_handlers.cc b/source/blender/editors/interface/interface_handlers.cc index 55af67a722a..e9d9797b61a 100644 --- a/source/blender/editors/interface/interface_handlers.cc +++ b/source/blender/editors/interface/interface_handlers.cc @@ -11051,10 +11051,10 @@ static int ui_pie_handler(bContext *C, const wmEvent *event, uiPopupBlockHandle if (menu->scrolltimer == nullptr) { menu->scrolltimer = WM_event_timer_add( CTX_wm_manager(C), CTX_wm_window(C), TIMER, PIE_MENU_INTERVAL); - menu->scrolltimer->duration = 0.0; + menu->scrolltimer->time_duration = 0.0; } - const double duration = menu->scrolltimer->duration; + const double duration = menu->scrolltimer->time_duration; float event_xy[2] = {float(event->xy[0]), float(event->xy[1])}; diff --git a/source/blender/editors/interface/view2d_ops.cc b/source/blender/editors/interface/view2d_ops.cc index 7f8e861ef9b..889daeb2780 100644 --- a/source/blender/editors/interface/view2d_ops.cc +++ b/source/blender/editors/interface/view2d_ops.cc @@ -1701,7 +1701,7 @@ static int view2d_smoothview_invoke(bContext *C, wmOperator * /*op*/, const wmEv float step; if (sms->time_allowed != 0.0) { - step = float((v2d->smooth_timer->duration) / sms->time_allowed); + step = float((v2d->smooth_timer->time_duration) / sms->time_allowed); } else { step = 1.0f; diff --git a/source/blender/editors/screen/screen_ops.cc b/source/blender/editors/screen/screen_ops.cc index 4f96883b97c..a082ba86415 100644 --- a/source/blender/editors/screen/screen_ops.cc +++ b/source/blender/editors/screen/screen_ops.cc @@ -4751,7 +4751,7 @@ static int screen_animation_step_invoke(bContext *C, wmOperator * /*op*/, const /* Try to keep the playback in realtime by dropping frames. */ /* How much time (in frames) has passed since the last frame was drawn? */ - double delta_frames = wt->delta * FPS; + double delta_frames = wt->time_delta * FPS; /* Add the remaining fraction from the last time step. */ delta_frames += sad->lagging_frame_count; @@ -4873,7 +4873,7 @@ static int screen_animation_step_invoke(bContext *C, wmOperator * /*op*/, const /* Update frame rate info too. * NOTE: this may not be accurate enough, since we might need this after modifiers/etc. * have been calculated instead of just before updates have been done? */ - ED_scene_fps_average_accumulate(scene, U.playback_fps_samples, wt->ltime); + ED_scene_fps_average_accumulate(scene, U.playback_fps_samples, wt->time_last); } /* Recalculate the time-step for the timer now that we've finished calculating this, @@ -4881,7 +4881,7 @@ static int screen_animation_step_invoke(bContext *C, wmOperator * /*op*/, const */ /* TODO: this may make evaluation a bit slower if the value doesn't change... * any way to avoid this? */ - wt->timestep = (1.0 / FPS); + wt->time_step = (1.0 / FPS); return OPERATOR_FINISHED; } @@ -5481,7 +5481,7 @@ float ED_region_blend_alpha(ARegion *region) RegionAlphaInfo *rgi = static_cast(region->regiontimer->customdata); float alpha; - alpha = float(region->regiontimer->duration) / TIMEOUT; + alpha = float(region->regiontimer->time_duration) / TIMEOUT; /* makes sure the blend out works 100% - without area redraws */ if (rgi->hidden) { alpha = 0.9f - TIMESTEP - alpha; @@ -5577,7 +5577,7 @@ static int region_blend_invoke(bContext *C, wmOperator * /*op*/, const wmEvent * } /* end timer? */ - if (rgi->region->regiontimer->duration > double(TIMEOUT)) { + if (rgi->region->regiontimer->time_duration > double(TIMEOUT)) { region_blend_end(C, rgi->region, false); return (OPERATOR_FINISHED | OPERATOR_PASS_THROUGH); } diff --git a/source/blender/editors/space_info/info_ops.cc b/source/blender/editors/space_info/info_ops.cc index 6fec7d59c64..41d43c9cd2f 100644 --- a/source/blender/editors/space_info/info_ops.cc +++ b/source/blender/editors/space_info/info_ops.cc @@ -599,7 +599,7 @@ static int update_reports_display_invoke(bContext *C, wmOperator * /*op*/, const timeout = (report->type & RPT_ERROR_ALL) ? ERROR_TIMEOUT : INFO_TIMEOUT; /* clear the report display after timeout */ - if (float(reports->reporttimer->duration) > timeout) { + if (float(reports->reporttimer->time_duration) > timeout) { WM_event_timer_remove(wm, nullptr, reports->reporttimer); reports->reporttimer = nullptr; @@ -624,8 +624,8 @@ static int update_reports_display_invoke(bContext *C, wmOperator * /*op*/, const rti->widthfac = 1.0f; } - progress = powf(float(reports->reporttimer->duration) / timeout, 2.0f); - flash_progress = powf(float(reports->reporttimer->duration) / flash_timeout, 2.0); + progress = powf(float(reports->reporttimer->time_duration) / timeout, 2.0f); + flash_progress = powf(float(reports->reporttimer->time_duration) / flash_timeout, 2.0); /* save us from too many draws */ if (flash_progress <= 1.0f) { diff --git a/source/blender/editors/space_node/node_relationships.cc b/source/blender/editors/space_node/node_relationships.cc index b90bef7fbdb..be6113bd322 100644 --- a/source/blender/editors/space_node/node_relationships.cc +++ b/source/blender/editors/space_node/node_relationships.cc @@ -2547,13 +2547,13 @@ static int node_insert_offset_modal(bContext *C, wmOperator *op, const wmEvent * return OPERATOR_PASS_THROUGH; } - const float duration = float(iofsd->anim_timer->duration); + const float duration = float(iofsd->anim_timer->time_duration); /* handle animation - do this before possibly aborting due to duration, since * main thread might be so busy that node hasn't reached final position yet */ for (bNode *node : snode->edittree->all_nodes()) { if (UNLIKELY(node->runtime->anim_ofsx)) { - const float prev_duration = duration - float(iofsd->anim_timer->delta); + const float prev_duration = duration - float(iofsd->anim_timer->time_delta); /* Clamp duration to not overshoot. */ const float clamped_duration = math::min(duration, NODE_INSOFS_ANIM_DURATION); if (prev_duration < clamped_duration) { diff --git a/source/blender/editors/space_view3d/view3d_navigate_smoothview.cc b/source/blender/editors/space_view3d/view3d_navigate_smoothview.cc index 3b4583e5638..002480d763c 100644 --- a/source/blender/editors/space_view3d/view3d_navigate_smoothview.cc +++ b/source/blender/editors/space_view3d/view3d_navigate_smoothview.cc @@ -480,7 +480,7 @@ static void view3d_smoothview_apply_from_timer(bContext *C, View3D *v3d, ARegion float factor; if (sms->time_allowed != 0.0) { - factor = float(rv3d->smooth_timer->duration / sms->time_allowed); + factor = float(rv3d->smooth_timer->time_duration / sms->time_allowed); } else { factor = 1.0f; diff --git a/source/blender/makesrna/intern/rna_wm.cc b/source/blender/makesrna/intern/rna_wm.cc index b12bd90dd33..cf1bae24d99 100644 --- a/source/blender/makesrna/intern/rna_wm.cc +++ b/source/blender/makesrna/intern/rna_wm.cc @@ -2311,17 +2311,17 @@ static void rna_def_timer(BlenderRNA *brna) /* could wrap more, for now this is enough */ prop = RNA_def_property(srna, "time_step", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, nullptr, "timestep"); + RNA_def_property_float_sdna(prop, nullptr, "time_step"); RNA_def_property_clear_flag(prop, PROP_EDITABLE); RNA_def_property_ui_text(prop, "Time Step", ""); prop = RNA_def_property(srna, "time_delta", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, nullptr, "delta"); + RNA_def_property_float_sdna(prop, nullptr, "time_delta"); RNA_def_property_clear_flag(prop, PROP_EDITABLE); RNA_def_property_ui_text(prop, "Delta", "Time since last step in seconds"); prop = RNA_def_property(srna, "time_duration", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, nullptr, "duration"); + RNA_def_property_float_sdna(prop, nullptr, "time_duration"); RNA_def_property_clear_flag(prop, PROP_EDITABLE); RNA_def_property_ui_text(prop, "Delta", "Time since the timer started seconds"); diff --git a/source/blender/windowmanager/WM_types.hh b/source/blender/windowmanager/WM_types.hh index 35bf72cedb5..6e4bb2fa818 100644 --- a/source/blender/windowmanager/WM_types.hh +++ b/source/blender/windowmanager/WM_types.hh @@ -892,7 +892,7 @@ struct wmTimer { wmWindow *win; /** Set by timer user. */ - double timestep; + double time_step; /** Set by timer user, goes to event system. */ int event_type; /** Various flags controlling timer options, see below. */ @@ -901,16 +901,16 @@ struct wmTimer { void *customdata; /** Total running time in seconds. */ - double duration; + double time_duration; /** Time since previous step in seconds. */ - double delta; + double time_delta; /** Internal, last time timer was activated. */ - double ltime; + double time_last; /** Internal, next time we want to activate the timer. */ - double ntime; + double time_next; /** Internal, when the timer started. */ - double stime; + double time_start; /** Internal, put timers to sleep when needed. */ bool sleep; }; diff --git a/source/blender/windowmanager/intern/wm_jobs.cc b/source/blender/windowmanager/intern/wm_jobs.cc index 6f4aadda4b1..9bc32d325e6 100644 --- a/source/blender/windowmanager/intern/wm_jobs.cc +++ b/source/blender/windowmanager/intern/wm_jobs.cc @@ -100,7 +100,7 @@ struct wmJob { void (*canceled)(void *); /** Running jobs each have own timer */ - double timestep; + double time_step; wmTimer *wt; /** Only start job after specified time delay */ double start_delay_time; @@ -343,9 +343,9 @@ void WM_jobs_customdata_set(wmJob *wm_job, void *customdata, void (*free)(void * } } -void WM_jobs_timer(wmJob *wm_job, double timestep, uint note, uint endnote) +void WM_jobs_timer(wmJob *wm_job, double time_step, uint note, uint endnote) { - wm_job->timestep = timestep; + wm_job->time_step = time_step; wm_job->note = note; wm_job->endnote = endnote; } @@ -451,8 +451,8 @@ void WM_jobs_start(wmWindowManager *wm, wmJob *wm_job) else { if (wm_job->customdata && wm_job->startjob) { - const double timestep = (wm_job->start_delay_time > 0.0) ? wm_job->start_delay_time : - wm_job->timestep; + const double time_step = (wm_job->start_delay_time > 0.0) ? wm_job->start_delay_time : + wm_job->time_step; wm_jobs_test_suspend_stop(wm, wm_job); @@ -479,12 +479,12 @@ void WM_jobs_start(wmWindowManager *wm, wmJob *wm_job) } /* restarted job has timer already */ - if (wm_job->wt && (wm_job->wt->timestep > timestep)) { + if (wm_job->wt && (wm_job->wt->time_step > time_step)) { WM_event_timer_remove(wm, wm_job->win, wm_job->wt); - wm_job->wt = WM_event_timer_add(wm, wm_job->win, TIMERJOBS, timestep); + wm_job->wt = WM_event_timer_add(wm, wm_job->win, TIMERJOBS, time_step); } if (wm_job->wt == nullptr) { - wm_job->wt = WM_event_timer_add(wm, wm_job->win, TIMERJOBS, timestep); + wm_job->wt = WM_event_timer_add(wm, wm_job->win, TIMERJOBS, time_step); } wm_job->start_time = PIL_check_seconds_timer(); diff --git a/source/blender/windowmanager/intern/wm_playanim.cc b/source/blender/windowmanager/intern/wm_playanim.cc index 5d24bda6eb5..7cb3610b908 100644 --- a/source/blender/windowmanager/intern/wm_playanim.cc +++ b/source/blender/windowmanager/intern/wm_playanim.cc @@ -448,12 +448,12 @@ static PlayAnimPict *playanim_step(PlayAnimPict *playanim, int step) static int pupdate_time() { - static double ltime; + static double time_last; double time = PIL_check_seconds_timer(); - ptottime += (time - ltime); - ltime = time; + ptottime += (time - time_last); + time_last = time; return (ptottime < 0); } diff --git a/source/blender/windowmanager/intern/wm_window.cc b/source/blender/windowmanager/intern/wm_window.cc index e807d7f06f9..4a62a91790a 100644 --- a/source/blender/windowmanager/intern/wm_window.cc +++ b/source/blender/windowmanager/intern/wm_window.cc @@ -1614,23 +1614,23 @@ static bool wm_window_timers_process(const bContext *C, int *sleep_us_p) } /* Future timer, update nearest time & skip. */ - if (wt->ntime >= time) { + if (wt->time_next >= time) { if ((has_event == false) && (sleep_us != 0)) { /* The timer is not ready to run but may run shortly. */ - if (wt->ntime < ntime_min) { - ntime_min = wt->ntime; + if (wt->time_next < ntime_min) { + ntime_min = wt->time_next; } } continue; } - wt->delta = time - wt->ltime; - wt->duration += wt->delta; - wt->ltime = time; + wt->time_delta = time - wt->time_last; + wt->time_duration += wt->time_delta; + wt->time_last = time; - wt->ntime = wt->stime; - if (wt->timestep != 0.0f) { - wt->ntime += wt->timestep * ceil(wt->duration / wt->timestep); + wt->time_next = wt->time_start; + if (wt->time_step != 0.0f) { + wt->time_next += wt->time_step * ceil(wt->time_duration / wt->time_step); } if (wt->event_type == TIMERJOBS) { @@ -1961,16 +1961,16 @@ void WM_event_timer_sleep(wmWindowManager *wm, wmWindow * /*win*/, wmTimer *time timer->sleep = do_sleep; } -wmTimer *WM_event_timer_add(wmWindowManager *wm, wmWindow *win, int event_type, double timestep) +wmTimer *WM_event_timer_add(wmWindowManager *wm, wmWindow *win, int event_type, double time_step) { wmTimer *wt = static_cast(MEM_callocN(sizeof(wmTimer), "window timer")); - BLI_assert(timestep >= 0.0f); + BLI_assert(time_step >= 0.0f); wt->event_type = event_type; - wt->ltime = PIL_check_seconds_timer(); - wt->ntime = wt->ltime + timestep; - wt->stime = wt->ltime; - wt->timestep = timestep; + wt->time_last = PIL_check_seconds_timer(); + wt->time_next = wt->time_last + time_step; + wt->time_start = wt->time_last; + wt->time_step = time_step; wt->win = win; BLI_addtail(&wm->timers, wt); @@ -1981,16 +1981,16 @@ wmTimer *WM_event_timer_add(wmWindowManager *wm, wmWindow *win, int event_type, wmTimer *WM_event_timer_add_notifier(wmWindowManager *wm, wmWindow *win, uint type, - double timestep) + double time_step) { wmTimer *wt = static_cast(MEM_callocN(sizeof(wmTimer), "window timer")); - BLI_assert(timestep >= 0.0f); + BLI_assert(time_step >= 0.0f); wt->event_type = TIMERNOTIFIER; - wt->ltime = PIL_check_seconds_timer(); - wt->ntime = wt->ltime + timestep; - wt->stime = wt->ltime; - wt->timestep = timestep; + wt->time_last = PIL_check_seconds_timer(); + wt->time_next = wt->time_last + time_step; + wt->time_start = wt->time_last; + wt->time_step = time_step; wt->win = win; wt->customdata = POINTER_FROM_UINT(type); wt->flags |= WM_TIMER_NO_FREE_CUSTOM_DATA;