]> git.rm.cloudns.org Git - xonotic/darkplaces.git/commitdiff
fixed RF_VIEWMODEL really good this time
authorhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Sun, 8 May 2011 13:49:35 +0000 (13:49 +0000)
committerhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Sun, 8 May 2011 13:49:35 +0000 (13:49 +0000)
renamed cl.csqc_origin to cl.csqc_vieworigin, cl.csqc_angles to
cl.csqc_viewangles, and added cl.csqc_vieworiginfromengine and
cl.csqc_viewanglesfromengine which are used to restore the view
parameters when R_ClearScene is used in csqc

git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@11123 d7cf8633-e32d-0410-b094-e92efae38249

client.h
clvm_cmds.c
csprogs.c
view.c

index e3715bbef23afbeeddbcc0fc04c9e8f8c58dde1b..12770afa7f8dcd3aa01737fa15c37b9450a44a29 100644 (file)
--- a/client.h
+++ b/client.h
@@ -1243,8 +1243,10 @@ typedef struct client_state_s
        // server entity number corresponding to a clientside entity
        unsigned short csqc_server2csqcentitynumber[MAX_EDICTS];
        qboolean csqc_loaded;
-       vec3_t csqc_origin;
-       vec3_t csqc_angles;
+       vec3_t csqc_vieworigin;
+       vec3_t csqc_viewangles;
+       vec3_t csqc_vieworiginfromengine;
+       vec3_t csqc_viewanglesfromengine;
        qboolean csqc_usecsqclistener;
        matrix4x4_t csqc_listenermatrix;
        char csqc_printtextbuf[MAX_INPUTLINE];
index 2d81062c8abd2aff18d1b34478d1b99dd3ff9ad2..98c342695cdfb869fae3b2712de715e3edf1782d 100644 (file)
@@ -693,8 +693,8 @@ extern qboolean CSQC_AddRenderEdict (prvm_edict_t *ed, int edictnum);//csprogs.c
 static void CSQC_R_RecalcView (void)
 {
        extern matrix4x4_t viewmodelmatrix;
-       Matrix4x4_CreateFromQuakeEntity(&r_refdef.view.matrix, cl.csqc_origin[0], cl.csqc_origin[1], cl.csqc_origin[2], cl.csqc_angles[0], cl.csqc_angles[1], cl.csqc_angles[2], 1);
-       Matrix4x4_CreateFromQuakeEntity(&viewmodelmatrix, cl.csqc_origin[0], cl.csqc_origin[1], cl.csqc_origin[2], cl.csqc_angles[0], cl.csqc_angles[1], cl.csqc_angles[2], cl_viewmodel_scale.value);
+       Matrix4x4_CreateFromQuakeEntity(&r_refdef.view.matrix, cl.csqc_vieworigin[0], cl.csqc_vieworigin[1], cl.csqc_vieworigin[2], cl.csqc_viewangles[0], cl.csqc_viewangles[1], cl.csqc_viewangles[2], 1);
+       Matrix4x4_CreateFromQuakeEntity(&viewmodelmatrix, cl.csqc_vieworigin[0], cl.csqc_vieworigin[1], cl.csqc_vieworigin[2], cl.csqc_viewangles[0], cl.csqc_viewangles[1], cl.csqc_viewangles[2], cl_viewmodel_scale.value);
 }
 
 void CL_RelinkLightFlashes(void);
@@ -722,8 +722,8 @@ void VM_CL_R_ClearScene (void)
        r_refdef.view.ortho_y = scr_fov.value * (3.0 / 4.0);
        r_refdef.view.clear = true;
        r_refdef.view.isoverlay = false;
-       // FIXME: restore cl.csqc_origin
-       // FIXME: restore cl.csqc_angles
+       VectorCopy(cl.csqc_vieworiginfromengine, cl.csqc_vieworigin);
+       VectorCopy(cl.csqc_viewanglesfromengine, cl.csqc_viewangles);
        cl.csqc_vidvars.drawworld = r_drawworld.integer != 0;
        cl.csqc_vidvars.drawenginesbar = false;
        cl.csqc_vidvars.drawcrosshair = false;
@@ -825,28 +825,28 @@ void VM_CL_R_SetView (void)
                        PRVM_G_FLOAT(OFS_RETURN) = r_refdef.view.ortho_y;
                        break;
                case VF_ORIGIN:
-                       VectorCopy(cl.csqc_origin, PRVM_G_VECTOR(OFS_RETURN));
+                       VectorCopy(cl.csqc_vieworigin, PRVM_G_VECTOR(OFS_RETURN));
                        break;
                case VF_ORIGIN_X:
-                       PRVM_G_FLOAT(OFS_RETURN) = cl.csqc_origin[0];
+                       PRVM_G_FLOAT(OFS_RETURN) = cl.csqc_vieworigin[0];
                        break;
                case VF_ORIGIN_Y:
-                       PRVM_G_FLOAT(OFS_RETURN) = cl.csqc_origin[1];
+                       PRVM_G_FLOAT(OFS_RETURN) = cl.csqc_vieworigin[1];
                        break;
                case VF_ORIGIN_Z:
-                       PRVM_G_FLOAT(OFS_RETURN) = cl.csqc_origin[2];
+                       PRVM_G_FLOAT(OFS_RETURN) = cl.csqc_vieworigin[2];
                        break;
                case VF_ANGLES:
-                       VectorCopy(cl.csqc_angles, PRVM_G_VECTOR(OFS_RETURN));
+                       VectorCopy(cl.csqc_viewangles, PRVM_G_VECTOR(OFS_RETURN));
                        break;
                case VF_ANGLES_X:
-                       PRVM_G_FLOAT(OFS_RETURN) = cl.csqc_angles[0];
+                       PRVM_G_FLOAT(OFS_RETURN) = cl.csqc_viewangles[0];
                        break;
                case VF_ANGLES_Y:
-                       PRVM_G_FLOAT(OFS_RETURN) = cl.csqc_angles[1];
+                       PRVM_G_FLOAT(OFS_RETURN) = cl.csqc_viewangles[1];
                        break;
                case VF_ANGLES_Z:
-                       PRVM_G_FLOAT(OFS_RETURN) = cl.csqc_angles[2];
+                       PRVM_G_FLOAT(OFS_RETURN) = cl.csqc_viewangles[2];
                        break;
                case VF_DRAWWORLD:
                        PRVM_G_FLOAT(OFS_RETURN) = cl.csqc_vidvars.drawworld;
@@ -932,35 +932,35 @@ void VM_CL_R_SetView (void)
                r_refdef.view.frustum_y = tan(k * M_PI / 360.0);r_refdef.view.ortho_y = k;
                break;
        case VF_ORIGIN:
-               VectorCopy(f, cl.csqc_origin);
+               VectorCopy(f, cl.csqc_vieworigin);
                CSQC_R_RecalcView();
                break;
        case VF_ORIGIN_X:
-               cl.csqc_origin[0] = k;
+               cl.csqc_vieworigin[0] = k;
                CSQC_R_RecalcView();
                break;
        case VF_ORIGIN_Y:
-               cl.csqc_origin[1] = k;
+               cl.csqc_vieworigin[1] = k;
                CSQC_R_RecalcView();
                break;
        case VF_ORIGIN_Z:
-               cl.csqc_origin[2] = k;
+               cl.csqc_vieworigin[2] = k;
                CSQC_R_RecalcView();
                break;
        case VF_ANGLES:
-               VectorCopy(f, cl.csqc_angles);
+               VectorCopy(f, cl.csqc_viewangles);
                CSQC_R_RecalcView();
                break;
        case VF_ANGLES_X:
-               cl.csqc_angles[0] = k;
+               cl.csqc_viewangles[0] = k;
                CSQC_R_RecalcView();
                break;
        case VF_ANGLES_Y:
-               cl.csqc_angles[1] = k;
+               cl.csqc_viewangles[1] = k;
                CSQC_R_RecalcView();
                break;
        case VF_ANGLES_Z:
-               cl.csqc_angles[2] = k;
+               cl.csqc_viewangles[2] = k;
                CSQC_R_RecalcView();
                break;
        case VF_DRAWWORLD:
@@ -2200,9 +2200,8 @@ void CL_GetEntityMatrix (prvm_edict_t *ent, matrix4x4_t *out, qboolean viewmatri
        if (val && val->_float != 0)
                scale = val->_float;
 
-       // TODO do we need the same weird angle inverting logic here as in the server side case?
        if(viewmatrix)
-               Matrix4x4_CreateFromQuakeEntity(out, cl.csqc_origin[0], cl.csqc_origin[1], cl.csqc_origin[2], cl.csqc_angles[0], cl.csqc_angles[1], cl.csqc_angles[2], scale * cl_viewmodel_scale.value);
+               *out = r_refdef.view.matrix;
        else if ((val = PRVM_EDICTFIELDVALUE(ent, prog->fieldoffsets.renderflags)) && ((int)val->_float & RF_USEAXIS))
        {
                vec3_t forward;
index a9f56175a0aa2ffcb04b668fb6748370c7b64f36..bb314327f4c99975d04cade7c108e7c13e7e6f2c 100644 (file)
--- a/csprogs.c
+++ b/csprogs.c
@@ -108,17 +108,16 @@ static void CSQC_SetGlobals (void)
                prog->globals.client->servercommandframe = cls.servermovesequence;
                prog->globals.client->clientcommandframe = cl.movecmd[0].sequence;
                VectorCopy(cl.viewangles, prog->globals.client->input_angles);
-               VectorCopy(cl.viewangles, cl.csqc_angles);
                // // FIXME: this actually belongs into getinputstate().. [12/17/2007 Black]
                prog->globals.client->input_buttons = cl.movecmd[0].buttons;
                VectorSet(prog->globals.client->input_movevalues, cl.movecmd[0].forwardmove, cl.movecmd[0].sidemove, cl.movecmd[0].upmove);
-               //VectorCopy(cl.movement_origin, cl.csqc_origin);
-               Matrix4x4_OriginFromMatrix(&cl.entities[cl.viewentity].render.matrix, cl.csqc_origin);
+               VectorCopy(cl.csqc_vieworiginfromengine, cl.csqc_vieworigin);
+               VectorCopy(cl.csqc_viewanglesfromengine, cl.csqc_viewangles);
 
                // LordHavoc: Spike says not to do this, but without pmove_org the
                // CSQC is useless as it can't alter the view origin without
                // completely replacing it
-               VectorCopy(cl.csqc_origin, prog->globals.client->pmove_org);
+               Matrix4x4_OriginFromMatrix(&cl.entities[cl.viewentity].render.matrix, prog->globals.client->pmove_org);
                VectorCopy(cl.movement_velocity, prog->globals.client->pmove_vel);
 
                if ((val = PRVM_GLOBALFIELDVALUE(prog->globaloffsets.view_angles)))
diff --git a/view.c b/view.c
index 86902ad883337c126061f3a221f7059b7b1d10a7..56b8ce058d77ad6d27f20a4f007736586abd156c 100644 (file)
--- a/view.c
+++ b/view.c
@@ -798,8 +798,8 @@ void V_CalcRefdef (void)
                                Matrix4x4_CreateFromQuakeEntity(&r_refdef.view.matrix, vieworg[0], vieworg[1], vieworg[2], viewangles[0], viewangles[1], viewangles[2], 1);
                        // calculate a viewmodel matrix for use in view-attached entities
                        Matrix4x4_CreateFromQuakeEntity(&viewmodelmatrix, gunorg[0], gunorg[1], gunorg[2], gunangles[0], gunangles[1], gunangles[2], cl_viewmodel_scale.value);
-                       VectorCopy(vieworg, cl.csqc_origin);
-                       VectorCopy(viewangles, cl.csqc_angles);
+                       VectorCopy(vieworg, cl.csqc_vieworiginfromengine);
+                       VectorCopy(viewangles, cl.csqc_viewanglesfromengine);
                }
        }
 }