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_Reset()
9 self.iflags &~= IFLAG_INTERNALMASK;
10 self.itime1 = self.itime2 = 0;
12 void InterpolateOrigin_Note()
17 dt = time - self.itime2;
20 if(self.iflags & IFLAG_PREVALID)
21 self.iflags |= IFLAG_VALID;
23 self.iflags |= IFLAG_PREVALID;
25 self.iorigin1 = self.iorigin2;
26 self.iorigin2 = self.origin;
28 if(self.iflags & IFLAG_AUTOANGLES)
29 if(self.iorigin2 != self.iorigin1)
30 self.angles = vectoangles(self.iorigin2 - self.iorigin1);
32 if(self.iflags & IFLAG_ANGLES)
34 fixedmakevectors(self.angles);
37 self.iforward1 = self.iforward2;
38 self.iup1 = self.iup2;
42 self.iforward1 = v_forward;
45 self.iforward2 = v_forward;
49 if(self.iflags & IFLAG_VELOCITY)
51 self.ivelocity1 = self.ivelocity2;
52 self.ivelocity2 = self.velocity;
55 if(vlen(self.iorigin2 - self.iorigin1) > 1000)
57 self.itime1 = self.itime2 = time; // don't lerp
60 if((self.iflags & IFLAG_VELOCITY) && (vlen(self.ivelocity2 - self.ivelocity1) > 1000))
62 self.itime1 = self.itime2 = time; // don't lerp
67 self.itime1 = serverprevtime;
73 self.itime1 = self.itime2 = time;
76 void InterpolateOrigin_Do()
79 if(self.itime1 && self.itime2 && self.itime1 != self.itime2)
82 f = bound(0, (time - self.itime1) / (self.itime2 - self.itime1), 1);
83 self.origin = (1 - f) * self.iorigin1 + f * self.iorigin2;
84 if(self.iflags & IFLAG_ANGLES)
86 forward = (1 - f) * self.iforward1 + f * self.iforward2;
87 up = (1 - f) * self.iup1 + f * self.iup2;
88 self.angles = fixedvectoangles2(forward, up);
90 if(self.iflags & IFLAG_VELOCITY)
91 self.velocity = (1 - f) * self.ivelocity1 + f * self.ivelocity2;
94 void InterpolateOrigin_Undo()
96 self.origin = self.iorigin2;
97 if(self.iflags & IFLAG_ANGLES)
98 self.angles = fixedvectoangles2(self.iforward2, self.iup2);
99 if(self.iflags & IFLAG_VELOCITY)
100 self.velocity = self.ivelocity2;