Page 1 of 1

UI stuff and frametime

Posted: Sat Jan 26, 2019 6:01 pm
by Nahuel
Well, i need to animate smoothly UI stuff in darkplaces, and i am using frametime. I know that can cause problems and Spike suggest use cltime + clframetime for that (instead frametime and time), the problem is: i dont find cltime or clframetime extensions in darkplaces defs. Is there any way to recreate these extensions using qc? maybe cltime or clframetime have a different name in darkplaces? I searched for them without success :( thank you very much

Re: UI stuff and frametime

Posted: Sun Jan 27, 2019 4:22 am
by Spike
try the gettime builtin.

Re: UI stuff and frametime

Posted: Sun Jan 27, 2019 3:50 pm
by Nahuel

Code: Select all

float GETTIME_FRAMESTART = 0; // time of start of frame
float GETTIME_REALTIME = 1; // current time (may be OS specific)
float GETTIME_HIRES = 2; // like REALTIME, but may reset between QC invocations and thus can be higher precision
float GETTIME_UPTIME = 3; // time since start of the engine
//builtin definitions:
float(float tmr) gettime = #519;
well to be hoinest i dont understand at all that time stuff so i did display onscreen all these gettime values and frametime aswell . GETTIME_HIRES displays a number very similar to frametime , but it doesnt stop in pause.
" but may reset between QC invocations and thus can be higher precision" i donot understant this.
:) I guess gettime(GETTIME_HIRES); is not clframetime, but i can use it as is? sorry i dont understand the gettime stuff at all , (GETTIME_HIRES works very fine anyway)
ty

Re: UI stuff and frametime

Posted: Sun Jan 27, 2019 11:17 pm
by Spike

Code: Select all

if (runningindp)
{
  static float oldtime;
  cltime = gettime(GETTIME_FRAMESTART);
  clframetime = oldtime?cltime - oldtime:0.1;
  oldtime = cltime;
}
shove that at the start of your CSQC_UpdateView.


HIRES is time-since-frame-start (read: high res only because the float value is centered around 0), REALTIME also continuously changes for each call. uptime==framestart (read: map changes will not restore lost precision, so restart the client at least once a day).
none of theses are subject to latency or drift, so they'll stay smooth (precision-willing - doubles are fine, but floats are only okay for inter-frame deltas but when they're used for time-since-foo they'll suffer noticeable precision loss after about a day).

Re: UI stuff and frametime

Posted: Mon Jan 28, 2019 2:43 pm
by Nahuel

Code: Select all

static float 
i didn't even know about static floats :O :lol: thats awesome, can static floats be used in ssqc ?

Code: Select all

  clframetime = oldtime?cltime - oldtime:0.1;
i dont understand this part, what the "?" is doing here?
map changes will not restore lost precision, so restart the client at least once a day.
they'll suffer noticeable precision loss after about a day
well i guess i should add a extreme-clock-timer to send a "restart" command in csqc after 20 hours (72000 seconds), maybe the best option in this EXTREME case is to use a quicksav and load it ? it restarts when player load saved games?
i dont know exactly why "changemap" command doesnt restore lost precisiĆ³n . "map" command do it? TY in advance,

Re: UI stuff and frametime

Posted: Mon Jan 28, 2019 9:14 pm
by Spike
static works at both global scope and local scope, equivalent to C.
(static locals are also visible to nested functions where regular locals are not)

r = (a?b:c)
is equivalent to
if (a) r=b; else r=c;


recovering lost precision requires rebasing the float timer back to 0. double(float)s have more than enough precision, but (single)floats do not, hence why the engine is okay, but qc will have issues before that.
join some unpopular nq server some time. one that has a map uptime of 4+ days. you'll see how it can't even hold time differences of 0.1. You need much more precision than that for smooth animations.