]> git.xonotic.org Git - xonotic/darkplaces.git/commitdiff
now lerps punchangle and punchvector
authorhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Fri, 4 Feb 2005 11:50:50 +0000 (11:50 +0000)
committerhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Fri, 4 Feb 2005 11:50:50 +0000 (11:50 +0000)
git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@5001 d7cf8633-e32d-0410-b094-e92efae38249

cl_main.c
cl_parse.c
client.h

index 19d058e3d8ecbc08264698d778328488cfa05b1a..387dd63377e4c0f2de70910d2750fef2d9432ccf 100644 (file)
--- a/cl_main.c
+++ b/cl_main.c
@@ -112,7 +112,7 @@ void CL_ClearState(void)
 // wipe the entire cl structure
        memset (&cl, 0, sizeof(cl));
        // reset the view zoom interpolation
-       cl.viewzoomold = cl.viewzoomnew = 1;
+       cl.mviewzoom[0] = cl.mviewzoom[1] = 1;
 
        SZ_Clear (&cls.message);
 
@@ -233,7 +233,7 @@ void CL_EstablishConnection(const char *host)
        CL_Disconnect();
        NetConn_ClientFrame();
        NetConn_ServerFrame();
-       
+
        if (LHNETADDRESS_FromString(&cls.connect_address, host, 26000) && (cls.connect_mysocket = NetConn_ChooseClientSocketForAddress(&cls.connect_address)))
        {
                cls.connect_trying = true;
@@ -1146,10 +1146,13 @@ void CL_LerpPlayer(float frac)
        int i;
        float d;
 
-       cl.viewzoom = cl.viewzoomold + frac * (cl.viewzoomnew - cl.viewzoomold);
-
+       cl.viewzoom = cl.mviewzoom[1] + frac * (cl.mviewzoom[0] - cl.mviewzoom[1]);
        for (i = 0;i < 3;i++)
+       {
+               cl.punchangle[i] = cl.mpunchangle[1][i] + frac * (cl.mpunchangle[0][i] - cl.mpunchangle[1][i]);
+               cl.punchvector[i] = cl.mpunchvector[1][i] + frac * (cl.mpunchvector[0][i] - cl.mpunchvector[1][i]);
                cl.velocity[i] = cl.mvelocity[1][i] + frac * (cl.mvelocity[0][i] - cl.mvelocity[1][i]);
+       }
 
        if (cls.demoplayback)
        {
index 271d29af0a25d22901f272fd6285ebeb854b8431..d7432e0c772d56c74c4d967dab562b6c4c629418 100644 (file)
@@ -441,7 +441,7 @@ void CL_ParseServerInfo (void)
        {
                CL_KeepaliveMessage();
 
-               // Don't lock the sfx here, S_ServerSounds already did that 
+               // Don't lock the sfx here, S_ServerSounds already did that
                cl.sound_precache[i] = S_PrecacheSound (parse_sound_precache[i], true, false);
        }
 
@@ -607,7 +607,10 @@ void CL_ParseClientdata (int bits)
 {
        int i, j;
 
+       VectorCopy (cl.mpunchangle[0], cl.mpunchangle[1]);
+       VectorCopy (cl.mpunchvector[0], cl.mpunchvector[1]);
        VectorCopy (cl.mvelocity[0], cl.mvelocity[1]);
+       cl.mviewzoom[1] = cl.mviewzoom[0];
 
        if (cl.protocol != PROTOCOL_DARKPLACES6)
        {
@@ -616,15 +619,16 @@ void CL_ParseClientdata (int bits)
                cl.stats[STAT_VIEWZOOM] = 255;
        }
        cl.idealpitch = 0;
-       cl.punchangle[0] = 0;
-       cl.punchangle[1] = 0;
-       cl.punchangle[2] = 0;
-       cl.punchvector[0] = 0;
-       cl.punchvector[1] = 0;
-       cl.punchvector[2] = 0;
+       cl.mpunchangle[0][0] = 0;
+       cl.mpunchangle[0][1] = 0;
+       cl.mpunchangle[0][2] = 0;
+       cl.mpunchvector[0][0] = 0;
+       cl.mpunchvector[0][1] = 0;
+       cl.mpunchvector[0][2] = 0;
        cl.mvelocity[0][0] = 0;
        cl.mvelocity[0][1] = 0;
        cl.mvelocity[0][2] = 0;
+       cl.mviewzoom[0] = 1;
 
        bits &= 0xFFFF;
        if (bits & SU_EXTEND1)
@@ -643,18 +647,18 @@ void CL_ParseClientdata (int bits)
                if (bits & (SU_PUNCH1<<i) )
                {
                        if (cl.protocol == PROTOCOL_DARKPLACES1 || cl.protocol == PROTOCOL_DARKPLACES2 || cl.protocol == PROTOCOL_DARKPLACES3 || cl.protocol == PROTOCOL_DARKPLACES4 || cl.protocol == PROTOCOL_DARKPLACES5 || cl.protocol == PROTOCOL_DARKPLACES6)
-                               cl.punchangle[i] = MSG_ReadAngle16i();
+                               cl.mpunchangle[0][i] = MSG_ReadAngle16i();
                        else if (cl.protocol == PROTOCOL_QUAKE || cl.protocol == PROTOCOL_NEHAHRAMOVIE)
-                               cl.punchangle[i] = MSG_ReadChar();
+                               cl.mpunchangle[0][i] = MSG_ReadChar();
                        else
                                Host_Error("CL_ParseClientData: unknown cl.protocol %i\n", cl.protocol);
                }
                if (bits & (SU_PUNCHVEC1<<i))
                {
                        if (cl.protocol == PROTOCOL_DARKPLACES1 || cl.protocol == PROTOCOL_DARKPLACES2 || cl.protocol == PROTOCOL_DARKPLACES3 || cl.protocol == PROTOCOL_DARKPLACES4)
-                               cl.punchvector[i] = MSG_ReadCoord16i();
+                               cl.mpunchvector[0][i] = MSG_ReadCoord16i();
                        else if (cl.protocol == PROTOCOL_DARKPLACES5 || cl.protocol == PROTOCOL_DARKPLACES6)
-                               cl.punchvector[i] = MSG_ReadCoord32f();
+                               cl.mpunchvector[0][i] = MSG_ReadCoord32f();
                        else
                                Host_Error("CL_ParseClientData: unknown cl.protocol %i\n", cl.protocol);
                }
@@ -731,8 +735,7 @@ void CL_ParseClientdata (int bits)
        cl.activeweapon = cl.stats[STAT_ACTIVEWEAPON];
 
        // viewzoom interpolation
-       cl.viewzoomold = cl.viewzoomnew;
-       cl.viewzoomnew = (float) max(cl.stats[STAT_VIEWZOOM], 2) * (1.0f / 255.0f);
+       cl.mviewzoom[0] = (float) max(cl.stats[STAT_VIEWZOOM], 2) * (1.0f / 255.0f);
 }
 
 /*
@@ -1156,7 +1159,7 @@ void CL_ParseTempEntity(void)
                color[0] = MSG_ReadCoord(cl.protocol) * (2.0f / 1.0f);
                color[1] = MSG_ReadCoord(cl.protocol) * (2.0f / 1.0f);
                color[2] = MSG_ReadCoord(cl.protocol) * (2.0f / 1.0f);
-               CL_AllocDlight(NULL, &tempmatrix, 350, color[0], color[1], color[2], 700, 0.5, 0, -1, true, 1, 0.25, 0.25, 1, 1, LIGHTFLAG_NORMALMODE | LIGHTFLAG_REALTIMEMODE);        
+               CL_AllocDlight(NULL, &tempmatrix, 350, color[0], color[1], color[2], 700, 0.5, 0, -1, true, 1, 0.25, 0.25, 1, 1, LIGHTFLAG_NORMALMODE | LIGHTFLAG_REALTIMEMODE);
                S_StartSound(-1, 0, cl_sfx_r_exp3, pos, 1, 1);
                break;
 
index f634a223c81c292031df08293c84db613997b1be..d592f9d4dc27f45ea55c84e7c07923510656b591 100644 (file)
--- a/client.h
+++ b/client.h
@@ -76,7 +76,7 @@ beam_t;
 
 typedef struct rtlight_s
 {
-       // shadow volumes are done entirely in model space, so there are no matrices for dealing with them...  they just use the origin 
+       // shadow volumes are done entirely in model space, so there are no matrices for dealing with them...  they just use the origin
 
        // note that the world to light matrices are inversely scaled (divided) by lightradius
 
@@ -110,7 +110,7 @@ typedef struct rtlight_s
        vec_t specularscale;
        // LIGHTFLAG_* flags
        int flags;
-       
+
        // generated properties
        // used only for shadow volumes
        vec3_t shadoworigin;
@@ -213,7 +213,7 @@ typedef struct dlight_s
        // (worldlight only)
        struct dlight_s *next;
        // embedded rtlight struct for renderer
-       // (renderer only)      
+       // (renderer only)
        rtlight_t rtlight;
 }
 dlight_t;
@@ -494,20 +494,17 @@ typedef struct
 // the view is temporarily offset, and an angle reset commands at the start
 // of each level and after teleporting.
 
-       // during demo playback viewangles is lerped between these
-       vec3_t mviewangles[2];
-       // either client controlled, or lerped from demo mviewangles
-       vec3_t viewangles;
-
+       // mviewangles is read from demo
+       // viewangles is either client controlled or lerped from mviewangles
+       vec3_t mviewangles[2], viewangles;
+       // update by server, used by qc to do weapon recoil
+       vec3_t mpunchangle[2], punchangle;
+       // update by server, can be used by mods to kick view around
+       vec3_t mpunchvector[2], punchvector;
        // update by server, used for lean+bob (0 is newest)
-       vec3_t mvelocity[2];
-       // lerped between mvelocity[0] and [1]
-       vec3_t velocity;
-
-       // temporary offset
-       vec3_t punchangle;
-       // LordHavoc: origin view kick
-       vec3_t punchvector;
+       vec3_t mvelocity[2], velocity;
+       // update by server, can be used by mods for zooming
+       vec_t mviewzoom[2], viewzoom;
 
 // pitch drifting vars
        float idealpitch;
@@ -572,11 +569,6 @@ typedef struct
        // [cl.maxclients]
        scoreboard_t *scores;
 
-       // LordHavoc: sniping zoom, QC controlled
-       float viewzoom;
-       // for interpolation
-       float viewzoomold, viewzoomnew;
-
        // protocol version of the server we're connected to
        int protocol;