CL_UpdateRenderEntity(flagrender);
}
-matrix4x4_t viewmodelmatrix;
+matrix4x4_t viewmodelmatrix_withbob;
+matrix4x4_t viewmodelmatrix_nobob;
static const vec3_t muzzleflashorigin = {18, 0, 0};
{
// view-relative entity (guns and such)
if (e->render.effects & EF_NOGUNBOB)
- matrix = &r_refdef.view.matrix; // really attached to view
+ matrix = &viewmodelmatrix_nobob; // really attached to view
else
- matrix = &viewmodelmatrix; // attached to gun bob matrix
+ matrix = &viewmodelmatrix_withbob; // attached to gun bob matrix
}
else
{
vec3_t csqc_viewangles;
vec3_t csqc_vieworiginfromengine;
vec3_t csqc_viewanglesfromengine;
+ matrix4x4_t csqc_viewmodelmatrixfromengine;
qboolean csqc_usecsqclistener;
matrix4x4_t csqc_listenermatrix;
char csqc_printtextbuf[MAX_INPUTLINE];
//[515]: SCENE MANAGER builtins
extern qboolean CSQC_AddRenderEdict (prvm_edict_t *ed, int edictnum);//csprogs.c
-static void CSQC_R_RecalcView (void)
+void CSQC_R_RecalcView (void)
{
- extern matrix4x4_t viewmodelmatrix;
+ extern matrix4x4_t viewmodelmatrix_nobob;
+ extern matrix4x4_t viewmodelmatrix_withbob;
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);
+ Matrix4x4_Copy(&viewmodelmatrix_nobob, &r_refdef.view.matrix);
+ Matrix4x4_ConcatScale(&viewmodelmatrix_nobob, cl_viewmodel_scale.value);
+ Matrix4x4_Concat(&viewmodelmatrix_withbob, &r_refdef.view.matrix, &cl.csqc_viewmodelmatrixfromengine);
}
void CL_RelinkLightFlashes(void);
cl.csqc_vidvars.drawworld = r_drawworld.integer != 0;
cl.csqc_vidvars.drawenginesbar = false;
cl.csqc_vidvars.drawcrosshair = false;
+ CSQC_R_RecalcView();
}
//#301 void(float mask) addentities (EXT_CSQC)
}
//[515]: set globals before calling R_UpdateView, WEIRD CRAP
+void CSQC_R_RecalcView (void);
static void CSQC_SetGlobals (void)
{
CSQC_BEGIN
VectorCopy(cl.punchangle, PRVM_clientglobalvector(view_punchangle));
VectorCopy(cl.punchvector, PRVM_clientglobalvector(view_punchvector));
prog->globals.client->maxclients = cl.maxclients;
+
+ CSQC_R_RecalcView();
CSQC_END
}
==============================================================================
*/
-extern matrix4x4_t viewmodelmatrix;
+extern matrix4x4_t viewmodelmatrix_nobob;
+extern matrix4x4_t viewmodelmatrix_withbob;
#include "cl_collision.h"
#include "csprogs.h"
entity_t *ent;
float vieworg[3], viewangles[3], smoothtime;
float gunorg[3], gunangles[3];
+ matrix4x4_t tmpmatrix;
static float viewheightavg;
float viewheight;
#endif
trace_t trace;
VectorClear(gunorg);
- viewmodelmatrix = identitymatrix;
+ viewmodelmatrix_nobob = identitymatrix;
+ viewmodelmatrix_withbob = identitymatrix;
r_refdef.view.matrix = identitymatrix;
if (cls.state == ca_connected && cls.signon == SIGNONS)
{
r_refdef.view.matrix = ent->render.matrix;
Matrix4x4_AdjustOrigin(&r_refdef.view.matrix, 0, 0, cl.stats[STAT_VIEWHEIGHT]);
}
- viewmodelmatrix = r_refdef.view.matrix;
+ Matrix4x4_Copy(&viewmodelmatrix_nobob, &r_refdef.view.matrix);
+ Matrix4x4_ConcatScale(&viewmodelmatrix_nobob, cl_viewmodel_scale.value);
+ Matrix4x4_Copy(&viewmodelmatrix_withbob, &viewmodelmatrix_nobob);
}
else
{
viewangles[2] += v_idlescale.value * sin(cl.time*v_iroll_cycle.value) * v_iroll_level.value;
}
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);
+ Matrix4x4_Copy(&viewmodelmatrix_nobob, &r_refdef.view.matrix);
+ Matrix4x4_ConcatScale(&viewmodelmatrix_nobob, cl_viewmodel_scale.value);
+
+ Matrix4x4_CreateFromQuakeEntity(&viewmodelmatrix_withbob, gunorg[0], gunorg[1], gunorg[2], gunangles[0], gunangles[1], gunangles[2], cl_viewmodel_scale.value);
VectorCopy(vieworg, cl.csqc_vieworiginfromengine);
VectorCopy(viewangles, cl.csqc_viewanglesfromengine);
+
+ Matrix4x4_Invert_Simple(&tmpmatrix, &r_refdef.view.matrix);
+ Matrix4x4_Concat(&cl.csqc_viewmodelmatrixfromengine, &tmpmatrix, &viewmodelmatrix_withbob);
}
}
}