]> git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - csprogs.c
fixed RF_VIEWMODEL really good this time
[xonotic/darkplaces.git] / csprogs.c
index aa438a52a89e14546d58c2ba8c41cedd49589110..bb314327f4c99975d04cade7c108e7c13e7e6f2c 100644 (file)
--- a/csprogs.c
+++ b/csprogs.c
@@ -108,21 +108,24 @@ 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)))
                        VectorCopy(cl.viewangles, val->vector);
+               if ((val = PRVM_GLOBALFIELDVALUE(prog->globaloffsets.view_punchangle)))
+                       VectorCopy(cl.punchangle, val->vector);
+               if ((val = PRVM_GLOBALFIELDVALUE(prog->globaloffsets.view_punchvector)))
+                       VectorCopy(cl.punchvector, val->vector);
                prog->globals.client->maxclients = cl.maxclients;
        CSQC_END
 }
@@ -162,7 +165,6 @@ qboolean CSQC_AddRenderEdict(prvm_edict_t *ed, int edictnum)
        prvm_eval_t *val;
        entity_render_t *entrender;
        dp_model_t *model;
-       matrix4x4_t tagmatrix, matrix2;
 
        model = CL_GetModelFromEdict(ed);
        if (!model)
@@ -206,40 +208,13 @@ qboolean CSQC_AddRenderEdict(prvm_edict_t *ed, int edictnum)
        if((val = PRVM_EDICTFIELDVALUE(ed, prog->fieldoffsets.colormod)) && VectorLength2(val->vector)) VectorCopy(val->vector, entrender->colormod);
        if((val = PRVM_EDICTFIELDVALUE(ed, prog->fieldoffsets.glowmod)) && VectorLength2(val->vector))  VectorCopy(val->vector, entrender->glowmod);
        if(ed->fields.client->effects)  entrender->effects |= (int)ed->fields.client->effects;
-       if((val = PRVM_EDICTFIELDVALUE(ed, prog->fieldoffsets.tag_entity)) && val->edict)
-       {
-               int tagentity;
-               int tagindex = 0;
-               tagentity = val->edict;
-               if((val = PRVM_EDICTFIELDVALUE(ed, prog->fieldoffsets.tag_index)) && val->_float)
-                       tagindex = (int)val->_float;
-               CL_GetTagMatrix (&tagmatrix, PRVM_PROG_TO_EDICT(tagentity), tagindex);
-       }
-       else
-               Matrix4x4_CreateIdentity(&tagmatrix);
        if (!VectorLength2(entrender->colormod))
                VectorSet(entrender->colormod, 1, 1, 1);
        if (!VectorLength2(entrender->glowmod))
                VectorSet(entrender->glowmod, 1, 1, 1);
 
-       if (renderflags & RF_USEAXIS)
-       {
-               vec3_t left;
-               VectorNegate(prog->globals.client->v_right, left);
-               Matrix4x4_FromVectors(&matrix2, prog->globals.client->v_forward, left, prog->globals.client->v_up, ed->fields.client->origin);
-               Matrix4x4_Scale(&matrix2, scale, 1);
-       }
-       else
-       {
-               vec3_t angles;
-               VectorCopy(ed->fields.client->angles, angles);
-               // if model is alias, reverse pitch direction
-               if (entrender->model->type == mod_alias)
-                       angles[0] = -angles[0];
-
-               // set up the render matrix
-               Matrix4x4_CreateFromQuakeEntity(&matrix2, ed->fields.client->origin[0], ed->fields.client->origin[1], ed->fields.client->origin[2], angles[0], angles[1], angles[2], scale);
-       }
+       // LordHavoc: use the CL_GetTagMatrix function on self to ensure consistent behavior (duplicate code would be bad)
+       CL_GetTagMatrix(&entrender->matrix, ed, 0);
 
        // set up the animation data
        VM_GenerateFrameGroupBlend(ed->priv.server->framegroupblend, ed);
@@ -247,9 +222,6 @@ qboolean CSQC_AddRenderEdict(prvm_edict_t *ed, int edictnum)
        VM_UpdateEdictSkeleton(ed, model, ed->priv.server->frameblend);
        if ((val = PRVM_EDICTFIELDVALUE(ed, prog->fieldoffsets.shadertime))) entrender->shadertime = val->_float;
 
-       // concat the matrices to make the entity relative to its tag
-       Matrix4x4_Concat(&entrender->matrix, &tagmatrix, &matrix2);
-
        // transparent offset
        if ((renderflags & RF_USETRANSPARENTOFFSET) && (val = PRVM_GLOBALFIELDVALUE(prog->globaloffsets.transparent_offset)))
                entrender->transparent_offset = val->_float;