Xonotic
interpolate.qh File Reference
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

void InterpolateOrigin_Do (entity this)
 set origin based on iorigin1 (old pos), iorigin2 (desired pos), and time More...
 
void InterpolateOrigin_Note (entity this)
 
void InterpolateOrigin_Reset (entity this)
 
void InterpolateOrigin_Undo (entity this)
 snap origin to iorigin2 (actual origin) More...
 

Variables

float autocvar_cl_lerpexcess
 
const int IFLAG_ANGLES = BIT(1)
 
const int IFLAG_AUTOANGLES = BIT(2)
 
const int IFLAG_AUTOVELOCITY = BIT(6)
 
const int IFLAG_INTERNALMASK = IFLAG_VALID | IFLAG_PREVALID
 
const int IFLAG_ORIGIN = BIT(9)
 
const int IFLAG_PREVALID = BIT(4)
 
const int IFLAG_TELEPORTED = BIT(5)
 
const int IFLAG_V_ANGLE = BIT(7)
 
const int IFLAG_V_ANGLE_X = BIT(8)
 
const int IFLAG_VALID = BIT(3)
 
const int IFLAG_VELOCITY = BIT(0)
 
int iflags
 

Function Documentation

◆ InterpolateOrigin_Do()

void InterpolateOrigin_Do ( entity  this)

set origin based on iorigin1 (old pos), iorigin2 (desired pos), and time

Definition at line 129 of file interpolate.qc.

References angles, autocvar_cl_lerpexcess, bound(), fixedvectoangles2, IFLAG_ANGLES, IFLAG_ORIGIN, IFLAG_V_ANGLE, IFLAG_V_ANGLE_X, IFLAG_VELOCITY, iflags, iforward1, iforward2, iorigin1, iorigin2, itime1, itime2, iup1, iup2, ivelocity1, ivelocity2, ivforward1, ivforward2, ivup1, ivup2, setorigin(), time, v_angle, vector(), and velocity.

Referenced by CSQCModel_Draw(), CSQCPlayer_SetCamera(), NET_HANDLE(), and Projectile_Draw().

130 {
131  if (this.itime1 && this.itime2 && this.itime1 != this.itime2)
132  {
133  float f = bound(0, (time - this.itime1) / (this.itime2 - this.itime1), 1 + autocvar_cl_lerpexcess);
134  float f_1 = 1 - f;
135  if (this.iflags & IFLAG_ORIGIN)
136  setorigin(this, f_1 * this.iorigin1 + f * this.iorigin2);
137  if (this.iflags & IFLAG_ANGLES)
138  {
139  vector forward = f_1 * this.iforward1 + f * this.iforward2;
140  vector up = f_1 * this.iup1 + f * this.iup2;
141  this.angles = fixedvectoangles2(forward, up);
142  }
143  if (this.iflags & IFLAG_V_ANGLE)
144  {
145  vector forward = f_1 * this.ivforward1 + f * this.ivforward2;
146  vector up = f_1 * this.ivup1 + f * this.ivup2;
147  this.v_angle = fixedvectoangles2(forward, up);
148  }
149  else if (this.iflags & IFLAG_V_ANGLE_X)
150  {
151  this.v_angle_x = f_1 * this.ivforward1.x + f * this.ivforward2.x;
152  }
153  if (this.iflags & IFLAG_VELOCITY)
154  this.velocity = f_1 * this.ivelocity1 + f * this.ivelocity2;
155  }
156 }
vector ivelocity2
Definition: interpolate.qc:26
int iflags
Definition: interpolate.qh:26
vector ivup1
Definition: interpolate.qc:30
float itime1
Definition: interpolate.qc:31
vector iforward1
Definition: interpolate.qc:27
vector ivforward2
Definition: interpolate.qc:29
vector v_angle
Definition: progsdefs.qc:161
const int IFLAG_V_ANGLE
Definition: interpolate.qh:34
const int IFLAG_VELOCITY
Definition: interpolate.qh:27
vector ivup2
Definition: interpolate.qc:30
float itime2
Definition: interpolate.qc:31
vector ivelocity1
Definition: interpolate.qc:26
float autocvar_cl_lerpexcess
Definition: interpolate.qh:24
vector iup1
Definition: interpolate.qc:28
vector iorigin2
Definition: interpolate.qc:25
const int IFLAG_V_ANGLE_X
Definition: interpolate.qh:35
vector iorigin1
Definition: interpolate.qc:25
vector(float skel, float bonenum) _skel_get_boneabs_hidden
const int IFLAG_ORIGIN
Definition: interpolate.qh:36
vector iup2
Definition: interpolate.qc:28
setorigin(ent, v)
vector angles
Definition: csprogsdefs.qc:104
float time
Definition: csprogsdefs.qc:16
vector iforward2
Definition: interpolate.qc:27
vector velocity
Definition: csprogsdefs.qc:103
vector ivforward1
Definition: interpolate.qc:29
const int IFLAG_ANGLES
Definition: interpolate.qh:28
#define fixedvectoangles2(a, b)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ InterpolateOrigin_Note()

void InterpolateOrigin_Note ( entity  this)

Definition at line 37 of file interpolate.qc.

References angles, FIXED_MAKE_VECTORS, IFLAG_ANGLES, IFLAG_AUTOANGLES, IFLAG_AUTOVELOCITY, IFLAG_ORIGIN, IFLAG_PREVALID, IFLAG_TELEPORTED, IFLAG_V_ANGLE, IFLAG_V_ANGLE_X, IFLAG_VALID, IFLAG_VELOCITY, iflags, iforward1, iforward2, iorigin1, iorigin2, itime1, itime2, iup1, iup2, ivelocity1, ivelocity2, ivforward1, ivforward2, ivup1, ivup2, origin, serverprevtime, time, v_angle, vdist, vectoangles(), vector(), and velocity.

Referenced by NET_HANDLE().

38 {
39  float dt = time - this.itime2;
40 
41  int f0 = this.iflags;
42  if (this.iflags & IFLAG_PREVALID) this.iflags |= IFLAG_VALID;
43  else this.iflags |= IFLAG_PREVALID;
44 
45  if (this.iflags & IFLAG_ORIGIN)
46  {
47  this.iorigin1 = this.iorigin2;
48  this.iorigin2 = this.origin;
49  }
50 
51  if ((this.iflags & IFLAG_AUTOANGLES) && this.iorigin2 != this.iorigin1)
52  this.angles = vectoangles(this.iorigin2 - this.iorigin1);
53 
54  if ((this.iflags & IFLAG_AUTOVELOCITY) && this.itime2 != this.itime1)
55  this.velocity = (this.iorigin2 - this.iorigin1) * (1.0 / (this.itime2 - this.itime1));
56 
57  if (this.iflags & IFLAG_ANGLES)
58  {
59  vector forward, right, up;
60  FIXED_MAKE_VECTORS(this.angles, forward, right, up);
61  if (f0 & IFLAG_VALID)
62  {
63  this.iforward1 = this.iforward2;
64  this.iup1 = this.iup2;
65  }
66  else
67  {
68  this.iforward1 = forward;
69  this.iup1 = up;
70  }
71  this.iforward2 = forward;
72  this.iup2 = up;
73  }
74 
75  if (this.iflags & IFLAG_V_ANGLE)
76  {
77  vector forward, right, up;
78  FIXED_MAKE_VECTORS(this.v_angle, forward, right, up);
79  if (f0 & IFLAG_VALID)
80  {
81  this.ivforward1 = this.ivforward2;
82  this.ivup1 = this.ivup2;
83  }
84  else
85  {
86  this.ivforward1 = forward;
87  this.ivup1 = up;
88  }
89  this.ivforward2 = forward;
90  this.ivup2 = up;
91  }
92  else if (this.iflags & IFLAG_V_ANGLE_X)
93  {
94  this.ivforward1_x = this.ivforward2_x;
95  this.ivforward2_x = this.v_angle.x;
96  }
97 
98  if (this.iflags & IFLAG_VELOCITY)
99  {
100  this.ivelocity1 = this.ivelocity2;
101  this.ivelocity2 = this.velocity;
102  }
103 
104  if (this.iflags & IFLAG_TELEPORTED)
105  {
106  this.iflags &= ~IFLAG_TELEPORTED;
107  this.itime1 = this.itime2 = time; // don't lerp
108  }
109  else if (vdist(this.iorigin2 - this.iorigin1, >, 1000))
110  {
111  this.itime1 = this.itime2 = time; // don't lerp
112  }
113  else if ((this.iflags & IFLAG_VELOCITY) && vdist(this.ivelocity2 - this.ivelocity1, >, 1000))
114  {
115  this.itime1 = this.itime2 = time; // don't lerp
116  }
117  else if (dt >= 0.2)
118  {
119  this.itime1 = this.itime2 = time;
120  }
121  else
122  {
123  this.itime1 = serverprevtime;
124  this.itime2 = time;
125  }
126 }
vector ivelocity2
Definition: interpolate.qc:26
int iflags
Definition: interpolate.qh:26
vector ivup1
Definition: interpolate.qc:30
float itime1
Definition: interpolate.qc:31
vector iforward1
Definition: interpolate.qc:27
const int IFLAG_VALID
Definition: interpolate.qh:30
vector ivforward2
Definition: interpolate.qc:29
vector v_angle
Definition: progsdefs.qc:161
const int IFLAG_AUTOANGLES
Definition: interpolate.qh:29
origin
Definition: ent_cs.qc:114
const int IFLAG_V_ANGLE
Definition: interpolate.qh:34
const int IFLAG_VELOCITY
Definition: interpolate.qh:27
vector ivup2
Definition: interpolate.qc:30
float itime2
Definition: interpolate.qc:31
vector ivelocity1
Definition: interpolate.qc:26
vector iup1
Definition: interpolate.qc:28
vector iorigin2
Definition: interpolate.qc:25
const int IFLAG_V_ANGLE_X
Definition: interpolate.qh:35
#define FIXED_MAKE_VECTORS
vector iorigin1
Definition: interpolate.qc:25
vector(float skel, float bonenum) _skel_get_boneabs_hidden
const int IFLAG_TELEPORTED
Definition: interpolate.qh:32
const int IFLAG_ORIGIN
Definition: interpolate.qh:36
vector iup2
Definition: interpolate.qc:28
#define vdist(v, cmp, f)
Vector distance comparison, avoids sqrt()
Definition: vector.qh:8
const int IFLAG_AUTOVELOCITY
Definition: interpolate.qh:33
vector angles
Definition: csprogsdefs.qc:104
float serverprevtime
Definition: main.qh:180
float time
Definition: csprogsdefs.qc:16
vector iforward2
Definition: interpolate.qc:27
vector velocity
Definition: csprogsdefs.qc:103
vector ivforward1
Definition: interpolate.qc:29
const int IFLAG_PREVALID
Definition: interpolate.qh:31
const int IFLAG_ANGLES
Definition: interpolate.qh:28
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ InterpolateOrigin_Reset()

void InterpolateOrigin_Reset ( entity  this)

Definition at line 32 of file interpolate.qc.

References IFLAG_INTERNALMASK, iflags, itime1, and itime2.

Referenced by NET_HANDLE().

33 {
34  this.iflags &= ~IFLAG_INTERNALMASK;
35  this.itime1 = this.itime2 = 0;
36 }
int iflags
Definition: interpolate.qh:26
float itime1
Definition: interpolate.qc:31
const int IFLAG_INTERNALMASK
Definition: interpolate.qh:37
float itime2
Definition: interpolate.qc:31
+ Here is the caller graph for this function:

◆ InterpolateOrigin_Undo()

void InterpolateOrigin_Undo ( entity  this)

snap origin to iorigin2 (actual origin)

Definition at line 159 of file interpolate.qc.

References angles, fixedvectoangles2, IFLAG_ANGLES, IFLAG_ORIGIN, IFLAG_V_ANGLE, IFLAG_V_ANGLE_X, IFLAG_VELOCITY, iflags, iforward2, iorigin2, iup2, ivelocity2, ivforward2, ivup2, setorigin(), v_angle, and velocity.

Referenced by NET_HANDLE().

160 {
161  if (this.iflags & IFLAG_ORIGIN) setorigin(this, this.iorigin2);
162  if (this.iflags & IFLAG_ANGLES) this.angles = fixedvectoangles2(this.iforward2, this.iup2);
163  if (this.iflags & IFLAG_V_ANGLE) this.v_angle = fixedvectoangles2(this.ivforward2, this.ivup2);
164  else if (this.iflags & IFLAG_V_ANGLE_X) this.v_angle_x = this.ivforward2_x;
165  if (this.iflags & IFLAG_VELOCITY) this.velocity = this.ivelocity2;
166 }
vector ivelocity2
Definition: interpolate.qc:26
int iflags
Definition: interpolate.qh:26
vector ivforward2
Definition: interpolate.qc:29
vector v_angle
Definition: progsdefs.qc:161
const int IFLAG_V_ANGLE
Definition: interpolate.qh:34
const int IFLAG_VELOCITY
Definition: interpolate.qh:27
vector ivup2
Definition: interpolate.qc:30
vector iorigin2
Definition: interpolate.qc:25
const int IFLAG_V_ANGLE_X
Definition: interpolate.qh:35
const int IFLAG_ORIGIN
Definition: interpolate.qh:36
vector iup2
Definition: interpolate.qc:28
setorigin(ent, v)
vector angles
Definition: csprogsdefs.qc:104
vector iforward2
Definition: interpolate.qc:27
vector velocity
Definition: csprogsdefs.qc:103
const int IFLAG_ANGLES
Definition: interpolate.qh:28
#define fixedvectoangles2(a, b)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Variable Documentation

◆ autocvar_cl_lerpexcess

float autocvar_cl_lerpexcess

Definition at line 24 of file interpolate.qh.

Referenced by InterpolateOrigin_Do().

◆ IFLAG_ANGLES

◆ IFLAG_AUTOANGLES

const int IFLAG_AUTOANGLES = BIT(2)

Definition at line 29 of file interpolate.qh.

Referenced by InterpolateOrigin_Note(), and NET_HANDLE().

◆ IFLAG_AUTOVELOCITY

const int IFLAG_AUTOVELOCITY = BIT(6)

Definition at line 33 of file interpolate.qh.

Referenced by InterpolateOrigin_Note(), and NET_HANDLE().

◆ IFLAG_INTERNALMASK

const int IFLAG_INTERNALMASK = IFLAG_VALID | IFLAG_PREVALID

Definition at line 37 of file interpolate.qh.

Referenced by InterpolateOrigin_Reset(), and NET_HANDLE().

◆ IFLAG_ORIGIN

const int IFLAG_ORIGIN = BIT(9)

◆ IFLAG_PREVALID

const int IFLAG_PREVALID = BIT(4)

Definition at line 31 of file interpolate.qh.

Referenced by InterpolateOrigin_Note().

◆ IFLAG_TELEPORTED

const int IFLAG_TELEPORTED = BIT(5)

Definition at line 32 of file interpolate.qh.

Referenced by InterpolateOrigin_Note(), NET_HANDLE(), and TeleportPlayer().

◆ IFLAG_V_ANGLE

const int IFLAG_V_ANGLE = BIT(7)

◆ IFLAG_V_ANGLE_X

const int IFLAG_V_ANGLE_X = BIT(8)

◆ IFLAG_VALID

const int IFLAG_VALID = BIT(3)

Definition at line 30 of file interpolate.qh.

Referenced by InterpolateOrigin_Note(), and Projectile_Draw().

◆ IFLAG_VELOCITY

const int IFLAG_VELOCITY = BIT(0)

◆ iflags