fix bug in last patch, fix RF_USEAXIS handling
authorhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Sun, 8 May 2011 13:16:54 +0000 (13:16 +0000)
committerhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Sun, 8 May 2011 13:16:54 +0000 (13:16 +0000)
git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@11122 d7cf8633-e32d-0410-b094-e92efae38249

clvm_cmds.c
csprogs.c

index ffcff83..2d81062 100644 (file)
@@ -2203,6 +2203,18 @@ void CL_GetEntityMatrix (prvm_edict_t *ent, matrix4x4_t *out, qboolean viewmatri
        // 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);
+       else if ((val = PRVM_EDICTFIELDVALUE(ent, prog->fieldoffsets.renderflags)) && ((int)val->_float & RF_USEAXIS))
+       {
+               vec3_t forward;
+               vec3_t left;
+               vec3_t up;
+               vec3_t origin;
+               VectorScale(prog->globals.client->v_forward, scale, forward);
+               VectorScale(prog->globals.client->v_right, -scale, left);
+               VectorScale(prog->globals.client->v_up, scale, up);
+               VectorCopy(ent->fields.client->origin, origin);
+               Matrix4x4_FromVectors(out, forward, left, up, origin);
+       }
        else
        {
                pitchsign = CL_GetPitchSign(ent);
index 88600c3..a9f5617 100644 (file)
--- a/csprogs.c
+++ b/csprogs.c
@@ -166,7 +166,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)
@@ -216,25 +215,7 @@ qboolean CSQC_AddRenderEdict(prvm_edict_t *ed, int edictnum)
                VectorSet(entrender->glowmod, 1, 1, 1);
 
        // LordHavoc: use the CL_GetTagMatrix function on self to ensure consistent behavior (duplicate code would be bad)
-       CL_GetTagMatrix(&tagmatrix, ed, 0);
-       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);
-       }
+       CL_GetTagMatrix(&entrender->matrix, ed, 0);
 
        // set up the animation data
        VM_GenerateFrameGroupBlend(ed->priv.server->framegroupblend, ed);
@@ -242,9 +223,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;