From: Rudolf Polzer Date: Tue, 15 Nov 2011 11:51:06 +0000 (+0100) Subject: move interpolation to the csqcmodel directory X-Git-Tag: xonotic-v0.6.0~74^2~100^2~55 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=c47815ed835b7dc4eae92d3f2a0e6e5896169be7;p=xonotic%2Fxonotic-data.pk3dir.git move interpolation to the csqcmodel directory --- diff --git a/qcsrc/client/interpolate.qc b/qcsrc/client/interpolate.qc deleted file mode 100644 index a3140c8e7..000000000 --- a/qcsrc/client/interpolate.qc +++ /dev/null @@ -1,104 +0,0 @@ -// FIXME make this generic code, to be used for other entities too? -.vector iorigin1, iorigin2; -.vector ivelocity1, ivelocity2; -.vector iforward1, iforward2; -.vector iup1, iup2; -.float itime1, itime2; -void InterpolateOrigin_Reset() -{ - self.iflags &~= IFLAG_INTERNALMASK; - self.itime1 = self.itime2 = 0; -} -void InterpolateOrigin_Note() -{ - float dt; - float f0; - - dt = time - self.itime2; - - f0 = self.iflags; - if(self.iflags & IFLAG_PREVALID) - self.iflags |= IFLAG_VALID; - else - self.iflags |= IFLAG_PREVALID; - - self.iorigin1 = self.iorigin2; - self.iorigin2 = self.origin; - - if(self.iflags & IFLAG_AUTOANGLES) - if(self.iorigin2 != self.iorigin1) - self.angles = vectoangles(self.iorigin2 - self.iorigin1); - - if(self.iflags & IFLAG_ANGLES) - { - fixedmakevectors(self.angles); - if(f0 & IFLAG_VALID) - { - self.iforward1 = self.iforward2; - self.iup1 = self.iup2; - } - else - { - self.iforward1 = v_forward; - self.iup1 = v_up; - } - self.iforward2 = v_forward; - self.iup2 = v_up; - } - - if(self.iflags & IFLAG_VELOCITY) - { - self.ivelocity1 = self.ivelocity2; - self.ivelocity2 = self.velocity; - } - - if(self.iflags & IFLAG_TELEPORTED) - { - self.iflags &~= IFLAG_TELEPORTED; - self.itime1 = self.itime2 = time; // don't lerp - } - else if(vlen(self.iorigin2 - self.iorigin1) > 1000) - { - self.itime1 = self.itime2 = time; // don't lerp - } - else if((self.iflags & IFLAG_VELOCITY) && (vlen(self.ivelocity2 - self.ivelocity1) > 1000)) - { - self.itime1 = self.itime2 = time; // don't lerp - } - else if(dt >= 0.2) - { - self.itime1 = self.itime2 = time; - } - else - { - self.itime1 = serverprevtime; - self.itime2 = time; - } -} -void InterpolateOrigin_Do() -{ - vector forward, up; - if(self.itime1 && self.itime2 && self.itime1 != self.itime2) - { - float f; - f = bound(0, (time - self.itime1) / (self.itime2 - self.itime1), 1 + autocvar_cl_lerpexcess); - self.origin = (1 - f) * self.iorigin1 + f * self.iorigin2; - if(self.iflags & IFLAG_ANGLES) - { - forward = (1 - f) * self.iforward1 + f * self.iforward2; - up = (1 - f) * self.iup1 + f * self.iup2; - self.angles = fixedvectoangles2(forward, up); - } - if(self.iflags & IFLAG_VELOCITY) - self.velocity = (1 - f) * self.ivelocity1 + f * self.ivelocity2; - } -} -void InterpolateOrigin_Undo() -{ - self.origin = self.iorigin2; - if(self.iflags & IFLAG_ANGLES) - self.angles = fixedvectoangles2(self.iforward2, self.iup2); - if(self.iflags & IFLAG_VELOCITY) - self.velocity = self.ivelocity2; -} - diff --git a/qcsrc/client/interpolate.qh b/qcsrc/client/interpolate.qh deleted file mode 100644 index 1035c99f9..000000000 --- a/qcsrc/client/interpolate.qh +++ /dev/null @@ -1,20 +0,0 @@ -.float iflags; -#define IFLAG_VELOCITY 1 -#define IFLAG_ANGLES 2 -#define IFLAG_AUTOANGLES 4 -#define IFLAG_VALID 8 -#define IFLAG_PREVALID 16 -#define IFLAG_TELEPORTED 32 -#define IFLAG_INTERNALMASK (IFLAG_VALID | IFLAG_PREVALID) - -// call this BEFORE reading an entity update -void InterpolateOrigin_Undo(); - -// call this AFTER receiving an entity update -void InterpolateOrigin_Note(); - -// call this when the entity got teleported, before InterpolateOrigin_Note -void InterpolateOrigin_Reset(); - -// call this BEFORE drawing -void InterpolateOrigin_Do(); diff --git a/qcsrc/client/progs.src b/qcsrc/client/progs.src index 6ed7321a7..e3dc63501 100644 --- a/qcsrc/client/progs.src +++ b/qcsrc/client/progs.src @@ -20,7 +20,7 @@ csqc_builtins.qc autocvars.qh -interpolate.qh +../csqcmodel/interpolate.qh teamradar.qh hud.qh scoreboard.qh @@ -76,7 +76,7 @@ shownames.qc announcer.qc Main.qc View.qc -interpolate.qc +../csqcmodel/interpolate.qc waypointsprites.qc movetypes.qc prandom.qc diff --git a/qcsrc/csqcmodel/interpolate.qc b/qcsrc/csqcmodel/interpolate.qc new file mode 100644 index 000000000..a3140c8e7 --- /dev/null +++ b/qcsrc/csqcmodel/interpolate.qc @@ -0,0 +1,104 @@ +// FIXME make this generic code, to be used for other entities too? +.vector iorigin1, iorigin2; +.vector ivelocity1, ivelocity2; +.vector iforward1, iforward2; +.vector iup1, iup2; +.float itime1, itime2; +void InterpolateOrigin_Reset() +{ + self.iflags &~= IFLAG_INTERNALMASK; + self.itime1 = self.itime2 = 0; +} +void InterpolateOrigin_Note() +{ + float dt; + float f0; + + dt = time - self.itime2; + + f0 = self.iflags; + if(self.iflags & IFLAG_PREVALID) + self.iflags |= IFLAG_VALID; + else + self.iflags |= IFLAG_PREVALID; + + self.iorigin1 = self.iorigin2; + self.iorigin2 = self.origin; + + if(self.iflags & IFLAG_AUTOANGLES) + if(self.iorigin2 != self.iorigin1) + self.angles = vectoangles(self.iorigin2 - self.iorigin1); + + if(self.iflags & IFLAG_ANGLES) + { + fixedmakevectors(self.angles); + if(f0 & IFLAG_VALID) + { + self.iforward1 = self.iforward2; + self.iup1 = self.iup2; + } + else + { + self.iforward1 = v_forward; + self.iup1 = v_up; + } + self.iforward2 = v_forward; + self.iup2 = v_up; + } + + if(self.iflags & IFLAG_VELOCITY) + { + self.ivelocity1 = self.ivelocity2; + self.ivelocity2 = self.velocity; + } + + if(self.iflags & IFLAG_TELEPORTED) + { + self.iflags &~= IFLAG_TELEPORTED; + self.itime1 = self.itime2 = time; // don't lerp + } + else if(vlen(self.iorigin2 - self.iorigin1) > 1000) + { + self.itime1 = self.itime2 = time; // don't lerp + } + else if((self.iflags & IFLAG_VELOCITY) && (vlen(self.ivelocity2 - self.ivelocity1) > 1000)) + { + self.itime1 = self.itime2 = time; // don't lerp + } + else if(dt >= 0.2) + { + self.itime1 = self.itime2 = time; + } + else + { + self.itime1 = serverprevtime; + self.itime2 = time; + } +} +void InterpolateOrigin_Do() +{ + vector forward, up; + if(self.itime1 && self.itime2 && self.itime1 != self.itime2) + { + float f; + f = bound(0, (time - self.itime1) / (self.itime2 - self.itime1), 1 + autocvar_cl_lerpexcess); + self.origin = (1 - f) * self.iorigin1 + f * self.iorigin2; + if(self.iflags & IFLAG_ANGLES) + { + forward = (1 - f) * self.iforward1 + f * self.iforward2; + up = (1 - f) * self.iup1 + f * self.iup2; + self.angles = fixedvectoangles2(forward, up); + } + if(self.iflags & IFLAG_VELOCITY) + self.velocity = (1 - f) * self.ivelocity1 + f * self.ivelocity2; + } +} +void InterpolateOrigin_Undo() +{ + self.origin = self.iorigin2; + if(self.iflags & IFLAG_ANGLES) + self.angles = fixedvectoangles2(self.iforward2, self.iup2); + if(self.iflags & IFLAG_VELOCITY) + self.velocity = self.ivelocity2; +} + diff --git a/qcsrc/csqcmodel/interpolate.qh b/qcsrc/csqcmodel/interpolate.qh new file mode 100644 index 000000000..1035c99f9 --- /dev/null +++ b/qcsrc/csqcmodel/interpolate.qh @@ -0,0 +1,20 @@ +.float iflags; +#define IFLAG_VELOCITY 1 +#define IFLAG_ANGLES 2 +#define IFLAG_AUTOANGLES 4 +#define IFLAG_VALID 8 +#define IFLAG_PREVALID 16 +#define IFLAG_TELEPORTED 32 +#define IFLAG_INTERNALMASK (IFLAG_VALID | IFLAG_PREVALID) + +// call this BEFORE reading an entity update +void InterpolateOrigin_Undo(); + +// call this AFTER receiving an entity update +void InterpolateOrigin_Note(); + +// call this when the entity got teleported, before InterpolateOrigin_Note +void InterpolateOrigin_Reset(); + +// call this BEFORE drawing +void InterpolateOrigin_Do();