1 // FIXME make this generic code, to be used for other entities too?
2 .vector iorigin1, iorigin2;
3 .vector ivelocity1, ivelocity2;
4 .vector iforward1, iforward2;
7 void InterpolateOrigin_Note()
11 dt = time - self.itime2;
13 if(self.iflags & IFLAG_PREVALID)
14 self.iflags |= IFLAG_VALID;
16 self.iflags |= IFLAG_PREVALID;
18 self.iorigin1 = self.iorigin2;
19 self.iorigin2 = self.origin;
21 if(self.iflags & IFLAG_AUTOANGLES)
22 self.angles = vectoangles(self.iorigin2 - self.iorigin1);
24 if(self.iflags & IFLAG_ANGLES)
26 fixedmakevectors(self.angles);
27 self.iforward1 = self.iforward2;
28 self.iup1 = self.iup2;
29 self.iforward2 = v_forward;
33 if(self.iflags & IFLAG_VELOCITY)
35 self.ivelocity1 = self.ivelocity2;
36 self.ivelocity2 = self.velocity;
39 if(vlen(self.iorigin2 - self.iorigin1) > 1000)
41 self.itime1 = self.itime2 = time; // don't lerp
44 if((self.iflags & IFLAG_VELOCITY) && (vlen(self.ivelocity2 - self.ivelocity1) > 1000))
46 self.itime1 = self.itime2 = time; // don't lerp
51 self.itime1 = serverprevtime;
57 self.itime1 = self.itime2 = time;
60 void InterpolateOrigin_Do()
63 if(self.itime1 && self.itime2 && self.itime1 != self.itime2)
66 f = bound(0, (time - self.itime1) / (self.itime2 - self.itime1), 1);
67 self.origin = (1 - f) * self.iorigin1 + f * self.iorigin2;
68 if(self.iflags & IFLAG_ANGLES)
70 forward = (1 - f) * self.iforward1 + f * self.iforward2;
71 up = (1 - f) * self.iup1 + f * self.iup2;
72 self.angles = fixedvectoangles2(forward, up);
74 if(self.iflags & IFLAG_VELOCITY)
75 self.velocity = (1 - f) * self.ivelocity1 + f * self.ivelocity2;
78 void InterpolateOrigin_Undo()
80 self.origin = self.iorigin2;
81 if(self.iflags & IFLAG_ANGLES)
82 self.angles = fixedvectoangles2(self.iforward2, self.iup2);
83 if(self.iflags & IFLAG_VELOCITY)
84 self.velocity = self.ivelocity2;