]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
smooth up/down aiming
authorRudolf Polzer <divverent@xonotic.org>
Tue, 12 Feb 2013 16:50:39 +0000 (17:50 +0100)
committerRudolf Polzer <divverent@xonotic.org>
Tue, 12 Feb 2013 16:50:39 +0000 (17:50 +0100)
13 files changed:
qcsrc/client/Main.qc
qcsrc/client/csqcmodel_hooks.qc
qcsrc/client/hook.qc
qcsrc/client/laser.qc
qcsrc/client/projectile.qc
qcsrc/client/teamradar.qc
qcsrc/client/wall.qc
qcsrc/client/waypointsprites.qc
qcsrc/common/csqcmodel_settings.qh
qcsrc/csqcmodellib/cl_model.qc
qcsrc/csqcmodellib/cl_player.qc
qcsrc/csqcmodellib/interpolate.qc
qcsrc/csqcmodellib/interpolate.qh

index 47d0e37d6a903f78268480795a1d1579d7fbe471..d7f65c6ecdc4369988dbca5f08c08618362f0859 100644 (file)
@@ -445,6 +445,7 @@ void Ent_ReadEntCS()
 
        entcs_receiver[self.sv_entnum] = self;
        self.entremove = Ent_RemoveEntCS;
+       self.iflags |= IFLAG_ORIGIN;
 
        InterpolateOrigin_Note();
 }
index 3b4c95c1620da79c509552d6e06bcf37e0729775..9639ea8ef553475670171069d969b7e648321eab 100644 (file)
@@ -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)
index 641d50d634fee10abbb0abacbef4d30943df4eb0..1c2894afa2bf1e00bd548260b33f6534729985a8 100644 (file)
@@ -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();
 
index c5475d7a63a3cb738f1cb387930169794f233a6f..03ea99303297efc1605599b11fe622017fe60334 100644 (file)
@@ -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)
        {
index 25032806eb9df5029a3066f69eb5b4aacf643cde..fb4fdd5ef24e1fd245486a58d3a69ecf5fae33a8 100644 (file)
@@ -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;
 
index e5dcc00f2c911ffe2d650ed83007d309aa0f6f22..335db28a9d026bb1089e52c26253a811693ca87e 100644 (file)
@@ -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)
index 3d5aa138ffb07f0689dd544db9919f1a9e092301..211af4cb0889593380acdfa9785149ae76a5d52d 100644 (file)
@@ -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;
index 39b60a66b0c767d1342bec2dcb5e8645d6cd332a..7e9b91d6b81d65daa657a544410ce25fb87e97f9 100644 (file)
@@ -656,6 +656,7 @@ void Ent_WaypointSprite()
        self.draw2d = Draw_WaypointSprite;
 
        InterpolateOrigin_Undo();
+       self.iflags |= IFLAG_ORIGIN;
 
        if(sendflags & 0x80)
        {
index b21737f9ec196d02c88c26fe8e9defdae964f49f..a9ed986deef9e774a4a3c38b0eaaf50a30dfce82 100644 (file)
@@ -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) \
index 85e2f15ee99ca82f51732b0ff8ca4faaaf09d61b..c4882d8d20c0c4da5a28e87a02adf6e22d7db6c7 100644 (file)
@@ -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
 
index f77f9512623e099cea3f7f4fecff98e762e5019c..2711867dbc445cb68f9930c4a81600d9d3601d14 100644 (file)
@@ -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;
index 2ed78fbd8c3b92247ecae15a36525358e9a2f7f7..c1626f816e3b395cb70fa9da1c0e07737ccb1ae0 100644 (file)
@@ -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;
 }
index c69c90dde9f53f9dcd1eea3587c463a59baf8eab..66bf491e57dd745378e9d939bf65b80e88d4d80e 100644 (file)
@@ -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;