From: Rudolf Polzer Date: Tue, 12 Feb 2013 16:50:39 +0000 (+0100) Subject: smooth up/down aiming X-Git-Tag: xonotic-v0.7.0~87 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=d82b2d32a258461cb8416e16f87dcb41a5a98fff;p=xonotic%2Fxonotic-data.pk3dir.git smooth up/down aiming --- diff --git a/qcsrc/client/Main.qc b/qcsrc/client/Main.qc index 47d0e37d6..d7f65c6ec 100644 --- a/qcsrc/client/Main.qc +++ b/qcsrc/client/Main.qc @@ -445,6 +445,7 @@ void Ent_ReadEntCS() entcs_receiver[self.sv_entnum] = self; self.entremove = Ent_RemoveEntCS; + self.iflags |= IFLAG_ORIGIN; InterpolateOrigin_Note(); } diff --git a/qcsrc/client/csqcmodel_hooks.qc b/qcsrc/client/csqcmodel_hooks.qc index 3b4c95c16..9639ea8ef 100644 --- a/qcsrc/client/csqcmodel_hooks.qc +++ b/qcsrc/client/csqcmodel_hooks.qc @@ -671,6 +671,8 @@ void CSQCModel_Hook_PreDraw(float isplayer) void CSQCModel_Hook_PreUpdate(float isnew, float isplayer, float islocalplayer) { + // interpolate v_angle + self.iflags |= IFLAG_V_ANGLE_X; // revert to values from server CSQCModel_Effects_PreUpdate(); if(self.isplayermodel) diff --git a/qcsrc/client/hook.qc b/qcsrc/client/hook.qc index 641d50d63..1c2894afa 100644 --- a/qcsrc/client/hook.qc +++ b/qcsrc/client/hook.qc @@ -226,7 +226,7 @@ void Ent_ReadHook(float bIsNew, float type) sf = ReadByte(); self.HookSilent = (sf & 0x80); - self.iflags = IFLAG_VELOCITY; + self.iflags = IFLAG_VELOCITY | IFLAG_ORIGIN; InterpolateOrigin_Undo(); diff --git a/qcsrc/client/laser.qc b/qcsrc/client/laser.qc index c5475d7a6..03ea99303 100644 --- a/qcsrc/client/laser.qc +++ b/qcsrc/client/laser.qc @@ -76,9 +76,9 @@ void Ent_Laser() self.count = (f & 0xF0); if(self.count & 0x80) - self.iflags = IFLAG_VELOCITY; + self.iflags = IFLAG_VELOCITY | IFLAG_ORIGIN; else - self.iflags = IFLAG_ANGLES; + self.iflags = IFLAG_ANGLES | IFLAG_ORIGIN; if(f & 1) { diff --git a/qcsrc/client/projectile.qc b/qcsrc/client/projectile.qc index 25032806e..fb4fdd5ef 100644 --- a/qcsrc/client/projectile.qc +++ b/qcsrc/client/projectile.qc @@ -192,7 +192,7 @@ void Ent_Projectile() f = ReadByte(); self.count = (f & 0x80); - self.iflags = (self.iflags & IFLAG_INTERNALMASK) | IFLAG_AUTOANGLES | IFLAG_ANGLES; + self.iflags = (self.iflags & IFLAG_INTERNALMASK) | IFLAG_AUTOANGLES | IFLAG_ANGLES | IFLAG_ORIGIN; self.solid = SOLID_TRIGGER; //self.effects = EF_NOMODELFLAGS; diff --git a/qcsrc/client/teamradar.qc b/qcsrc/client/teamradar.qc index e5dcc00f2..335db28a9 100644 --- a/qcsrc/client/teamradar.qc +++ b/qcsrc/client/teamradar.qc @@ -203,7 +203,7 @@ void Ent_RadarLink() InterpolateOrigin_Undo(); - self.iflags = IFLAG_VELOCITY; + self.iflags = IFLAG_VELOCITY | IFLAG_ORIGIN; self.classname = "radarlink"; if(sendflags & 1) diff --git a/qcsrc/client/wall.qc b/qcsrc/client/wall.qc index 3d5aa138f..211af4cb0 100644 --- a/qcsrc/client/wall.qc +++ b/qcsrc/client/wall.qc @@ -75,7 +75,7 @@ void Ent_Wall() var .vector fld; InterpolateOrigin_Undo(); - self.iflags = IFLAG_ANGLES; + self.iflags = IFLAG_ANGLES | IFLAG_ORIGIN; if(self.bgmscriptangular) fld = angles; diff --git a/qcsrc/client/waypointsprites.qc b/qcsrc/client/waypointsprites.qc index 39b60a66b..7e9b91d6b 100644 --- a/qcsrc/client/waypointsprites.qc +++ b/qcsrc/client/waypointsprites.qc @@ -656,6 +656,7 @@ void Ent_WaypointSprite() self.draw2d = Draw_WaypointSprite; InterpolateOrigin_Undo(); + self.iflags |= IFLAG_ORIGIN; if(sendflags & 0x80) { diff --git a/qcsrc/common/csqcmodel_settings.qh b/qcsrc/common/csqcmodel_settings.qh index b21737f9e..a9ed986de 100644 --- a/qcsrc/common/csqcmodel_settings.qh +++ b/qcsrc/common/csqcmodel_settings.qh @@ -17,6 +17,9 @@ # define TAG_ENTITY_TYPE entity #endif +// new fields +.vector v_angle; + // add properties you want networked to CSQC here #define CSQCMODEL_EXTRAPROPERTIES \ CSQCMODEL_PROPERTY(1, float, ReadShort, WriteShort, colormap) \ diff --git a/qcsrc/csqcmodellib/cl_model.qc b/qcsrc/csqcmodellib/cl_model.qc index 85e2f15ee..c4882d8d2 100644 --- a/qcsrc/csqcmodellib/cl_model.qc +++ b/qcsrc/csqcmodellib/cl_model.qc @@ -182,7 +182,6 @@ void CSQCModel_Draw() if(!CSQCPlayer_IsLocalPlayer()) InterpolateOrigin_Do(); - // TODO csqcplayers: run prediction here too CSQCModel_InterpolateAnimation_Do(); { CSQCMODEL_HOOK_PREDRAW } @@ -212,6 +211,7 @@ void CSQCModel_Read(float isnew) local noref float isnolocalplayer = (isplayer && (self.entnum != player_localnum + 1)); self.classname = "csqcmodel"; + self.iflags |= IFLAG_ORIGIN; // interpolate origin too self.iflags |= IFLAG_ANGLES; // interpolate angles too self.iflags |= IFLAG_VELOCITY | IFLAG_AUTOVELOCITY; // let's calculate velocity automatically diff --git a/qcsrc/csqcmodellib/cl_player.qc b/qcsrc/csqcmodellib/cl_player.qc index f77f95126..2711867db 100644 --- a/qcsrc/csqcmodellib/cl_player.qc +++ b/qcsrc/csqcmodellib/cl_player.qc @@ -213,6 +213,11 @@ void CSQCPlayer_SetCamera() } else { + float flg = self.iflags; + self.iflags &~= IFLAG_ORIGIN | IFLAG_ANGLES; + InterpolateOrigin_Do(); + self.iflags = flg; + if(csqcplayer_status == CSQCPLAYERSTATUS_FROMSERVER) { vector o, v; diff --git a/qcsrc/csqcmodellib/interpolate.qc b/qcsrc/csqcmodellib/interpolate.qc index 2ed78fbd8..c1626f816 100644 --- a/qcsrc/csqcmodellib/interpolate.qc +++ b/qcsrc/csqcmodellib/interpolate.qc @@ -24,6 +24,8 @@ .vector ivelocity1, ivelocity2; .vector iforward1, iforward2; .vector iup1, iup2; +.vector ivforward1, ivforward2; +.vector ivup1, ivup2; .float itime1, itime2; void InterpolateOrigin_Reset() { @@ -43,8 +45,11 @@ void InterpolateOrigin_Note() else self.iflags |= IFLAG_PREVALID; - self.iorigin1 = self.iorigin2; - self.iorigin2 = self.origin; + if(self.iflags & IFLAG_ORIGIN) + { + self.iorigin1 = self.iorigin2; + self.iorigin2 = self.origin; + } if(self.iflags & IFLAG_AUTOANGLES) if(self.iorigin2 != self.iorigin1) @@ -71,6 +76,28 @@ void InterpolateOrigin_Note() self.iup2 = v_up; } + if(self.iflags & IFLAG_V_ANGLE) + { + fixedmakevectors(self.v_angle); + if(f0 & IFLAG_VALID) + { + self.ivforward1 = self.ivforward2; + self.ivup1 = self.ivup2; + } + else + { + self.ivforward1 = v_forward; + self.ivup1 = v_up; + } + self.ivforward2 = v_forward; + self.ivup2 = v_up; + } + else if(self.iflags & IFLAG_V_ANGLE_X) + { + self.ivforward1_x = self.ivforward2_x; + self.ivforward2_x = self.v_angle_x; + } + if(self.iflags & IFLAG_VELOCITY) { self.ivelocity1 = self.ivelocity2; @@ -107,22 +134,36 @@ void InterpolateOrigin_Do() { 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_ORIGIN) + setorigin(self, (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_V_ANGLE) + { + forward = (1 - f) * self.ivforward1 + f * self.ivforward2; + up = (1 - f) * self.ivup1 + f * self.ivup2; + self.v_angle = fixedvectoangles2(forward, up); + } + else if(self.iflags & IFLAG_V_ANGLE_X) + self.v_angle_x = (1 - f) * self.ivforward1_x + f * self.ivforward2_x; if(self.iflags & IFLAG_VELOCITY) self.velocity = (1 - f) * self.ivelocity1 + f * self.ivelocity2; } } void InterpolateOrigin_Undo() { - setorigin(self, self.iorigin2); + if(self.iflags & IFLAG_ORIGIN) + setorigin(self, self.iorigin2); if(self.iflags & IFLAG_ANGLES) self.angles = fixedvectoangles2(self.iforward2, self.iup2); + if(self.iflags & IFLAG_V_ANGLE) + self.v_angle = fixedvectoangles2(self.ivforward2, self.ivup2); + else if(self.iflags & IFLAG_V_ANGLE_X) + self.v_angle_x = self.ivforward2_x; if(self.iflags & IFLAG_VELOCITY) self.velocity = self.ivelocity2; } diff --git a/qcsrc/csqcmodellib/interpolate.qh b/qcsrc/csqcmodellib/interpolate.qh index c69c90dde..66bf491e5 100644 --- a/qcsrc/csqcmodellib/interpolate.qh +++ b/qcsrc/csqcmodellib/interpolate.qh @@ -28,6 +28,9 @@ #define IFLAG_PREVALID 16 #define IFLAG_TELEPORTED 32 #define IFLAG_AUTOVELOCITY 64 +#define IFLAG_V_ANGLE 128 +#define IFLAG_V_ANGLE_X 256 +#define IFLAG_ORIGIN 512 #define IFLAG_INTERNALMASK (IFLAG_VALID | IFLAG_PREVALID) // call this BEFORE reading an entity update @@ -41,3 +44,6 @@ void InterpolateOrigin_Reset(); // call this BEFORE drawing void InterpolateOrigin_Do(); + +// in case we interpolate that: +.vector v_angle;