Cleanup: rename wmTimer struct members for clarity
This commit is contained in:
parent
18280b9a75
commit
f99c6c8785
|
@ -11051,10 +11051,10 @@ static int ui_pie_handler(bContext *C, const wmEvent *event, uiPopupBlockHandle
|
||||||
if (menu->scrolltimer == nullptr) {
|
if (menu->scrolltimer == nullptr) {
|
||||||
menu->scrolltimer = WM_event_timer_add(
|
menu->scrolltimer = WM_event_timer_add(
|
||||||
CTX_wm_manager(C), CTX_wm_window(C), TIMER, PIE_MENU_INTERVAL);
|
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])};
|
float event_xy[2] = {float(event->xy[0]), float(event->xy[1])};
|
||||||
|
|
||||||
|
|
|
@ -1701,7 +1701,7 @@ static int view2d_smoothview_invoke(bContext *C, wmOperator * /*op*/, const wmEv
|
||||||
|
|
||||||
float step;
|
float step;
|
||||||
if (sms->time_allowed != 0.0) {
|
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 {
|
else {
|
||||||
step = 1.0f;
|
step = 1.0f;
|
||||||
|
|
|
@ -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. */
|
/* Try to keep the playback in realtime by dropping frames. */
|
||||||
|
|
||||||
/* How much time (in frames) has passed since the last frame was drawn? */
|
/* 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. */
|
/* Add the remaining fraction from the last time step. */
|
||||||
delta_frames += sad->lagging_frame_count;
|
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.
|
/* Update frame rate info too.
|
||||||
* NOTE: this may not be accurate enough, since we might need this after modifiers/etc.
|
* 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? */
|
* 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,
|
/* 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...
|
/* TODO: this may make evaluation a bit slower if the value doesn't change...
|
||||||
* any way to avoid this? */
|
* any way to avoid this? */
|
||||||
wt->timestep = (1.0 / FPS);
|
wt->time_step = (1.0 / FPS);
|
||||||
|
|
||||||
return OPERATOR_FINISHED;
|
return OPERATOR_FINISHED;
|
||||||
}
|
}
|
||||||
|
@ -5481,7 +5481,7 @@ float ED_region_blend_alpha(ARegion *region)
|
||||||
RegionAlphaInfo *rgi = static_cast<RegionAlphaInfo *>(region->regiontimer->customdata);
|
RegionAlphaInfo *rgi = static_cast<RegionAlphaInfo *>(region->regiontimer->customdata);
|
||||||
float alpha;
|
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 */
|
/* makes sure the blend out works 100% - without area redraws */
|
||||||
if (rgi->hidden) {
|
if (rgi->hidden) {
|
||||||
alpha = 0.9f - TIMESTEP - alpha;
|
alpha = 0.9f - TIMESTEP - alpha;
|
||||||
|
@ -5577,7 +5577,7 @@ static int region_blend_invoke(bContext *C, wmOperator * /*op*/, const wmEvent *
|
||||||
}
|
}
|
||||||
|
|
||||||
/* end timer? */
|
/* end timer? */
|
||||||
if (rgi->region->regiontimer->duration > double(TIMEOUT)) {
|
if (rgi->region->regiontimer->time_duration > double(TIMEOUT)) {
|
||||||
region_blend_end(C, rgi->region, false);
|
region_blend_end(C, rgi->region, false);
|
||||||
return (OPERATOR_FINISHED | OPERATOR_PASS_THROUGH);
|
return (OPERATOR_FINISHED | OPERATOR_PASS_THROUGH);
|
||||||
}
|
}
|
||||||
|
|
|
@ -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;
|
timeout = (report->type & RPT_ERROR_ALL) ? ERROR_TIMEOUT : INFO_TIMEOUT;
|
||||||
|
|
||||||
/* clear the report display after 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);
|
WM_event_timer_remove(wm, nullptr, reports->reporttimer);
|
||||||
reports->reporttimer = nullptr;
|
reports->reporttimer = nullptr;
|
||||||
|
|
||||||
|
@ -624,8 +624,8 @@ static int update_reports_display_invoke(bContext *C, wmOperator * /*op*/, const
|
||||||
rti->widthfac = 1.0f;
|
rti->widthfac = 1.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
progress = powf(float(reports->reporttimer->duration) / timeout, 2.0f);
|
progress = powf(float(reports->reporttimer->time_duration) / timeout, 2.0f);
|
||||||
flash_progress = powf(float(reports->reporttimer->duration) / flash_timeout, 2.0);
|
flash_progress = powf(float(reports->reporttimer->time_duration) / flash_timeout, 2.0);
|
||||||
|
|
||||||
/* save us from too many draws */
|
/* save us from too many draws */
|
||||||
if (flash_progress <= 1.0f) {
|
if (flash_progress <= 1.0f) {
|
||||||
|
|
|
@ -2547,13 +2547,13 @@ static int node_insert_offset_modal(bContext *C, wmOperator *op, const wmEvent *
|
||||||
return OPERATOR_PASS_THROUGH;
|
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
|
/* 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 */
|
* main thread might be so busy that node hasn't reached final position yet */
|
||||||
for (bNode *node : snode->edittree->all_nodes()) {
|
for (bNode *node : snode->edittree->all_nodes()) {
|
||||||
if (UNLIKELY(node->runtime->anim_ofsx)) {
|
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. */
|
/* Clamp duration to not overshoot. */
|
||||||
const float clamped_duration = math::min(duration, NODE_INSOFS_ANIM_DURATION);
|
const float clamped_duration = math::min(duration, NODE_INSOFS_ANIM_DURATION);
|
||||||
if (prev_duration < clamped_duration) {
|
if (prev_duration < clamped_duration) {
|
||||||
|
|
|
@ -480,7 +480,7 @@ static void view3d_smoothview_apply_from_timer(bContext *C, View3D *v3d, ARegion
|
||||||
float factor;
|
float factor;
|
||||||
|
|
||||||
if (sms->time_allowed != 0.0) {
|
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 {
|
else {
|
||||||
factor = 1.0f;
|
factor = 1.0f;
|
||||||
|
|
|
@ -2311,17 +2311,17 @@ static void rna_def_timer(BlenderRNA *brna)
|
||||||
|
|
||||||
/* could wrap more, for now this is enough */
|
/* could wrap more, for now this is enough */
|
||||||
prop = RNA_def_property(srna, "time_step", PROP_FLOAT, PROP_NONE);
|
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_clear_flag(prop, PROP_EDITABLE);
|
||||||
RNA_def_property_ui_text(prop, "Time Step", "");
|
RNA_def_property_ui_text(prop, "Time Step", "");
|
||||||
|
|
||||||
prop = RNA_def_property(srna, "time_delta", PROP_FLOAT, PROP_NONE);
|
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_clear_flag(prop, PROP_EDITABLE);
|
||||||
RNA_def_property_ui_text(prop, "Delta", "Time since last step in seconds");
|
RNA_def_property_ui_text(prop, "Delta", "Time since last step in seconds");
|
||||||
|
|
||||||
prop = RNA_def_property(srna, "time_duration", PROP_FLOAT, PROP_NONE);
|
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_clear_flag(prop, PROP_EDITABLE);
|
||||||
RNA_def_property_ui_text(prop, "Delta", "Time since the timer started seconds");
|
RNA_def_property_ui_text(prop, "Delta", "Time since the timer started seconds");
|
||||||
|
|
||||||
|
|
|
@ -892,7 +892,7 @@ struct wmTimer {
|
||||||
wmWindow *win;
|
wmWindow *win;
|
||||||
|
|
||||||
/** Set by timer user. */
|
/** Set by timer user. */
|
||||||
double timestep;
|
double time_step;
|
||||||
/** Set by timer user, goes to event system. */
|
/** Set by timer user, goes to event system. */
|
||||||
int event_type;
|
int event_type;
|
||||||
/** Various flags controlling timer options, see below. */
|
/** Various flags controlling timer options, see below. */
|
||||||
|
@ -901,16 +901,16 @@ struct wmTimer {
|
||||||
void *customdata;
|
void *customdata;
|
||||||
|
|
||||||
/** Total running time in seconds. */
|
/** Total running time in seconds. */
|
||||||
double duration;
|
double time_duration;
|
||||||
/** Time since previous step in seconds. */
|
/** Time since previous step in seconds. */
|
||||||
double delta;
|
double time_delta;
|
||||||
|
|
||||||
/** Internal, last time timer was activated. */
|
/** Internal, last time timer was activated. */
|
||||||
double ltime;
|
double time_last;
|
||||||
/** Internal, next time we want to activate the timer. */
|
/** Internal, next time we want to activate the timer. */
|
||||||
double ntime;
|
double time_next;
|
||||||
/** Internal, when the timer started. */
|
/** Internal, when the timer started. */
|
||||||
double stime;
|
double time_start;
|
||||||
/** Internal, put timers to sleep when needed. */
|
/** Internal, put timers to sleep when needed. */
|
||||||
bool sleep;
|
bool sleep;
|
||||||
};
|
};
|
||||||
|
|
|
@ -100,7 +100,7 @@ struct wmJob {
|
||||||
void (*canceled)(void *);
|
void (*canceled)(void *);
|
||||||
|
|
||||||
/** Running jobs each have own timer */
|
/** Running jobs each have own timer */
|
||||||
double timestep;
|
double time_step;
|
||||||
wmTimer *wt;
|
wmTimer *wt;
|
||||||
/** Only start job after specified time delay */
|
/** Only start job after specified time delay */
|
||||||
double start_delay_time;
|
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->note = note;
|
||||||
wm_job->endnote = endnote;
|
wm_job->endnote = endnote;
|
||||||
}
|
}
|
||||||
|
@ -451,8 +451,8 @@ void WM_jobs_start(wmWindowManager *wm, wmJob *wm_job)
|
||||||
else {
|
else {
|
||||||
|
|
||||||
if (wm_job->customdata && wm_job->startjob) {
|
if (wm_job->customdata && wm_job->startjob) {
|
||||||
const double timestep = (wm_job->start_delay_time > 0.0) ? wm_job->start_delay_time :
|
const double time_step = (wm_job->start_delay_time > 0.0) ? wm_job->start_delay_time :
|
||||||
wm_job->timestep;
|
wm_job->time_step;
|
||||||
|
|
||||||
wm_jobs_test_suspend_stop(wm, wm_job);
|
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 */
|
/* 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_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) {
|
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();
|
wm_job->start_time = PIL_check_seconds_timer();
|
||||||
|
|
|
@ -448,12 +448,12 @@ static PlayAnimPict *playanim_step(PlayAnimPict *playanim, int step)
|
||||||
|
|
||||||
static int pupdate_time()
|
static int pupdate_time()
|
||||||
{
|
{
|
||||||
static double ltime;
|
static double time_last;
|
||||||
|
|
||||||
double time = PIL_check_seconds_timer();
|
double time = PIL_check_seconds_timer();
|
||||||
|
|
||||||
ptottime += (time - ltime);
|
ptottime += (time - time_last);
|
||||||
ltime = time;
|
time_last = time;
|
||||||
return (ptottime < 0);
|
return (ptottime < 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1614,23 +1614,23 @@ static bool wm_window_timers_process(const bContext *C, int *sleep_us_p)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Future timer, update nearest time & skip. */
|
/* Future timer, update nearest time & skip. */
|
||||||
if (wt->ntime >= time) {
|
if (wt->time_next >= time) {
|
||||||
if ((has_event == false) && (sleep_us != 0)) {
|
if ((has_event == false) && (sleep_us != 0)) {
|
||||||
/* The timer is not ready to run but may run shortly. */
|
/* The timer is not ready to run but may run shortly. */
|
||||||
if (wt->ntime < ntime_min) {
|
if (wt->time_next < ntime_min) {
|
||||||
ntime_min = wt->ntime;
|
ntime_min = wt->time_next;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
wt->delta = time - wt->ltime;
|
wt->time_delta = time - wt->time_last;
|
||||||
wt->duration += wt->delta;
|
wt->time_duration += wt->time_delta;
|
||||||
wt->ltime = time;
|
wt->time_last = time;
|
||||||
|
|
||||||
wt->ntime = wt->stime;
|
wt->time_next = wt->time_start;
|
||||||
if (wt->timestep != 0.0f) {
|
if (wt->time_step != 0.0f) {
|
||||||
wt->ntime += wt->timestep * ceil(wt->duration / wt->timestep);
|
wt->time_next += wt->time_step * ceil(wt->time_duration / wt->time_step);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (wt->event_type == TIMERJOBS) {
|
if (wt->event_type == TIMERJOBS) {
|
||||||
|
@ -1961,16 +1961,16 @@ void WM_event_timer_sleep(wmWindowManager *wm, wmWindow * /*win*/, wmTimer *time
|
||||||
timer->sleep = do_sleep;
|
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<wmTimer *>(MEM_callocN(sizeof(wmTimer), "window timer"));
|
wmTimer *wt = static_cast<wmTimer *>(MEM_callocN(sizeof(wmTimer), "window timer"));
|
||||||
BLI_assert(timestep >= 0.0f);
|
BLI_assert(time_step >= 0.0f);
|
||||||
|
|
||||||
wt->event_type = event_type;
|
wt->event_type = event_type;
|
||||||
wt->ltime = PIL_check_seconds_timer();
|
wt->time_last = PIL_check_seconds_timer();
|
||||||
wt->ntime = wt->ltime + timestep;
|
wt->time_next = wt->time_last + time_step;
|
||||||
wt->stime = wt->ltime;
|
wt->time_start = wt->time_last;
|
||||||
wt->timestep = timestep;
|
wt->time_step = time_step;
|
||||||
wt->win = win;
|
wt->win = win;
|
||||||
|
|
||||||
BLI_addtail(&wm->timers, wt);
|
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,
|
wmTimer *WM_event_timer_add_notifier(wmWindowManager *wm,
|
||||||
wmWindow *win,
|
wmWindow *win,
|
||||||
uint type,
|
uint type,
|
||||||
double timestep)
|
double time_step)
|
||||||
{
|
{
|
||||||
wmTimer *wt = static_cast<wmTimer *>(MEM_callocN(sizeof(wmTimer), "window timer"));
|
wmTimer *wt = static_cast<wmTimer *>(MEM_callocN(sizeof(wmTimer), "window timer"));
|
||||||
BLI_assert(timestep >= 0.0f);
|
BLI_assert(time_step >= 0.0f);
|
||||||
|
|
||||||
wt->event_type = TIMERNOTIFIER;
|
wt->event_type = TIMERNOTIFIER;
|
||||||
wt->ltime = PIL_check_seconds_timer();
|
wt->time_last = PIL_check_seconds_timer();
|
||||||
wt->ntime = wt->ltime + timestep;
|
wt->time_next = wt->time_last + time_step;
|
||||||
wt->stime = wt->ltime;
|
wt->time_start = wt->time_last;
|
||||||
wt->timestep = timestep;
|
wt->time_step = time_step;
|
||||||
wt->win = win;
|
wt->win = win;
|
||||||
wt->customdata = POINTER_FROM_UINT(type);
|
wt->customdata = POINTER_FROM_UINT(type);
|
||||||
wt->flags |= WM_TIMER_NO_FREE_CUSTOM_DATA;
|
wt->flags |= WM_TIMER_NO_FREE_CUSTOM_DATA;
|
||||||
|
|
Loading…
Reference in New Issue