UI stuff and frametime

Discuss CSQC related programming.
Post Reply
Nahuel
Posts: 495
Joined: Wed Jan 12, 2011 8:42 pm
Location: mar del plata

UI stuff and frametime

Post 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
hi, I am nahuel, I love quake and qc.
Spike
Posts: 2914
Joined: Fri Nov 05, 2004 3:12 am
Location: UK
Contact:

Re: UI stuff and frametime

Post by Spike »

try the gettime builtin.
Nahuel
Posts: 495
Joined: Wed Jan 12, 2011 8:42 pm
Location: mar del plata

Re: UI stuff and frametime

Post 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
hi, I am nahuel, I love quake and qc.
Spike
Posts: 2914
Joined: Fri Nov 05, 2004 3:12 am
Location: UK
Contact:

Re: UI stuff and frametime

Post 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).
Nahuel
Posts: 495
Joined: Wed Jan 12, 2011 8:42 pm
Location: mar del plata

Re: UI stuff and frametime

Post 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,
hi, I am nahuel, I love quake and qc.
Spike
Posts: 2914
Joined: Fri Nov 05, 2004 3:12 am
Location: UK
Contact:

Re: UI stuff and frametime

Post 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.
Post Reply