mirror of
https://github.com/nzp-team/fteqw.git
synced 2024-11-22 03:51:32 +00:00
Move playerview weaponmodel matrix into r_refdef instead, to fix viewmodel positions in q3.
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@6211 fc73d0e0-1445-4013-8a0c-d673dee63da5
This commit is contained in:
parent
11d385ed77
commit
cb64ea30f9
10 changed files with 120 additions and 87 deletions
|
@ -449,6 +449,17 @@ static void Plug_Scene_RenderScene(plugrefdef_t *in, size_t areabytes, const qby
|
|||
VectorCopy(in->viewaxisorg[1], r_refdef.viewaxis[1]);
|
||||
VectorCopy(in->viewaxisorg[2], r_refdef.viewaxis[2]);
|
||||
VectorCopy(in->viewaxisorg[3], r_refdef.vieworg);
|
||||
|
||||
VectorSet(r_refdef.weaponmatrix[0], 1,0,0);
|
||||
VectorSet(r_refdef.weaponmatrix[1], 0,1,0);
|
||||
VectorSet(r_refdef.weaponmatrix[2], 0,0,1);
|
||||
VectorSet(r_refdef.weaponmatrix[3], 0,0,0);
|
||||
|
||||
VectorSet(r_refdef.weaponmatrix_bob[0], 1,0,0);
|
||||
VectorSet(r_refdef.weaponmatrix_bob[1], 0,1,0);
|
||||
VectorSet(r_refdef.weaponmatrix_bob[2], 0,0,1);
|
||||
VectorSet(r_refdef.weaponmatrix_bob[3], 0,0,0);
|
||||
|
||||
VectorAngles(r_refdef.viewaxis[0], r_refdef.viewaxis[2], r_refdef.viewangles, false); //do we actually still need this?
|
||||
r_refdef.flags = in->flags;
|
||||
r_refdef.fov_x = in->fov[0];
|
||||
|
|
|
@ -604,7 +604,7 @@ void VQ3_RenderView(const q3refdef_t *ref)
|
|||
VectorCopy(ref->vieworg, scene.viewaxisorg[3]);
|
||||
scene.time = ref->time/1000.0f;
|
||||
|
||||
if (ref->rdflags & 1/*RDF_NOWORLDMODEL*/)
|
||||
if (ref->rdflags & 1/*Q3RDF_NOWORLDMODEL*/)
|
||||
scene.flags |= RDF_NOWORLDMODEL;
|
||||
|
||||
scenefuncs->RenderScene(&scene, sizeof(ref->areamask), ref->areamask);
|
||||
|
|
|
@ -758,8 +758,6 @@ struct playerview_s
|
|||
vec4_t screentint;
|
||||
vec4_t bordertint; //won't contain v_cshift values, only powerup+contents+damage+bf flashes
|
||||
|
||||
vec3_t vw_axis[3]; //weapons should be positioned relative to this
|
||||
vec3_t vw_origin; //weapons should be positioned relative to this
|
||||
// entity_t viewent; // is this not utterly redundant yet?
|
||||
struct
|
||||
{
|
||||
|
|
|
@ -2395,9 +2395,10 @@ static void CLQ2_AddViewWeapon (int seat, q2player_state_t *ps, q2player_state_t
|
|||
return;
|
||||
|
||||
//generate root matrix..
|
||||
VectorCopy(pv->simorg, pv->vw_origin);
|
||||
AngleVectors(pv->simangles, pv->vw_axis[0], pv->vw_axis[1], pv->vw_axis[2]);
|
||||
VectorInverse(pv->vw_axis[1]);
|
||||
VectorCopy(pv->simorg, r_refdef.weaponmatrix[3]);
|
||||
AngleVectors(pv->simangles, r_refdef.weaponmatrix[0], r_refdef.weaponmatrix[1], r_refdef.weaponmatrix[2]);
|
||||
VectorInverse(r_refdef.weaponmatrix[1]);
|
||||
memcpy(r_refdef.weaponmatrix_bob, r_refdef.weaponmatrix, sizeof(r_refdef.weaponmatrix_bob));
|
||||
|
||||
pv->vm.oldmodel = cl.model_precache[ps->gunindex];
|
||||
if (!pv->vm.oldmodel)
|
||||
|
|
|
@ -35,7 +35,7 @@ struct texture_s;
|
|||
|
||||
static const texid_t r_nulltex = NULL;
|
||||
|
||||
//GLES2 requires GL_UNSIGNED_SHORT
|
||||
//GLES2 requires GL_UNSIGNED_SHORT (gles3 or GL_OES_element_index_uint relax this requirement)
|
||||
//geforce4 only does shorts. gffx can do ints, but with a performance hit (like most things on that gpu)
|
||||
//ati is generally more capable, but generally also has a smaller market share
|
||||
//desktop-gl will generally cope with ints, but expect a performance hit from that with old gpus (so we don't bother)
|
||||
|
@ -266,6 +266,9 @@ typedef struct refdef_s
|
|||
qboolean base_known; /*otherwise we do some fallback behaviour (ie: viewangles.0y0 and forcing input_angles)*/
|
||||
vec3_t base_angles, base_origin; /*for vr output, overrides per-eye viewangles according to that eye's matrix.*/
|
||||
|
||||
vec3_t weaponmatrix[4]; /*forward/left/up/origin*/
|
||||
vec3_t weaponmatrix_bob[4]; /*forward/left/up/origin*/
|
||||
|
||||
float fov_x, fov_y, afov;
|
||||
float fovv_x, fovv_y; //viewmodel fovs
|
||||
float mindist, maxdist; //maxdist may be 0, for 'infinite', in which case mindist probably isn't valid either.
|
||||
|
|
|
@ -1063,16 +1063,17 @@ void V_CalcGunPositionAngle (playerview_t *pv, float bob)
|
|||
vw_angles[PITCH] = r_refdef.viewangles[PITCH];
|
||||
vw_angles[ROLL] = r_refdef.viewangles[ROLL];
|
||||
|
||||
AngleVectors(vw_angles, pv->vw_axis[0], pv->vw_axis[1], pv->vw_axis[2]);
|
||||
VectorInverse(pv->vw_axis[1]);
|
||||
|
||||
AngleVectors(vw_angles, r_refdef.weaponmatrix[0], r_refdef.weaponmatrix[1], r_refdef.weaponmatrix[2]);
|
||||
VectorInverse(r_refdef.weaponmatrix[1]);
|
||||
|
||||
|
||||
VectorCopy (r_refdef.vieworg, pv->vw_origin);
|
||||
VectorCopy (r_refdef.vieworg, r_refdef.weaponmatrix[3]);
|
||||
for (i=0 ; i<3 ; i++)
|
||||
{
|
||||
pv->vw_origin[i] += pv->vw_axis[0][i]*bob*0.4;
|
||||
// pv->vw_origin[i] += pv->vw_axis[1][i]*sin(cl.time*5.5342452354235)*0.1;
|
||||
// pv->vw_origin[i] += pv->vw_axis[2][i]*bob*0.8;
|
||||
r_refdef.weaponmatrix[3][i] += r_refdef.weaponmatrix[0][i]*bob*0.4;
|
||||
// r_refdef.weaponmatrix[3][i] += r_refdef.weaponmatrix[1][i]*sin(cl.time*5.5342452354235)*0.1;
|
||||
// r_refdef.weaponmatrix[3][i] += r_refdef.weaponmatrix[2][i]*bob*0.8;
|
||||
}
|
||||
|
||||
VectorMA(pv->simvel, -DotProduct(pv->simvel, pv->gravitydir), pv->gravitydir, xyvel);
|
||||
|
@ -1082,29 +1083,31 @@ void V_CalcGunPositionAngle (playerview_t *pv, float bob)
|
|||
//FIXME: cl_followmodel should lag the viewmodel's position relative to the view
|
||||
//FIXME: cl_leanmodel should lag the viewmodel's angles relative to the view
|
||||
|
||||
if (cl_bobmodel.value)
|
||||
{ //bobmodel causes the viewmodel to bob relative to the view.
|
||||
float s = pv->bobtime * cl_bobmodel_speed.value, v;
|
||||
v = xyspeed * 0.01 * cl_bobmodel_side.value * /*cl_viewmodel_scale.value * */sin(s);
|
||||
VectorMA(pv->vw_origin, v, pv->vw_axis[1], pv->vw_origin);
|
||||
v = xyspeed * 0.01 * cl_bobmodel_up.value * /*cl_viewmodel_scale.value * */cos(2*s);
|
||||
VectorMA(pv->vw_origin, v, pv->vw_axis[2], pv->vw_origin);
|
||||
}
|
||||
|
||||
|
||||
// fudge position around to keep amount of weapon visible
|
||||
// roughly equal with different FOV
|
||||
//FIXME: should use y fov, not viewsize.
|
||||
if (r_refdef.drawsbar && v_viewmodel_quake.ival) //no sbar = no viewsize cvar.
|
||||
{
|
||||
if (scr_viewsize.value == 110)
|
||||
pv->vw_origin[2] += 1;
|
||||
r_refdef.weaponmatrix[3][2] += 1;
|
||||
else if (scr_viewsize.value == 100)
|
||||
pv->vw_origin[2] += 2;
|
||||
r_refdef.weaponmatrix[3][2] += 2;
|
||||
else if (scr_viewsize.value == 90)
|
||||
pv->vw_origin[2] += 1;
|
||||
r_refdef.weaponmatrix[3][2] += 1;
|
||||
else if (scr_viewsize.value == 80)
|
||||
pv->vw_origin[2] += 0.5;
|
||||
r_refdef.weaponmatrix[3][2] += 0.5;
|
||||
}
|
||||
|
||||
|
||||
|
||||
memcpy(r_refdef.weaponmatrix_bob, r_refdef.weaponmatrix, sizeof(r_refdef.weaponmatrix_bob));
|
||||
if (cl_bobmodel.value)
|
||||
{ //bobmodel causes the viewmodel to bob relative to the view.
|
||||
float s = pv->bobtime * cl_bobmodel_speed.value, v;
|
||||
v = xyspeed * 0.01 * cl_bobmodel_side.value * /*cl_viewmodel_scale.value * */sin(s);
|
||||
VectorMA(r_refdef.weaponmatrix_bob[3], v, r_refdef.weaponmatrix[1], r_refdef.weaponmatrix_bob[3]);
|
||||
v = xyspeed * 0.01 * cl_bobmodel_up.value * /*cl_viewmodel_scale.value * */cos(2*s);
|
||||
VectorMA(r_refdef.weaponmatrix_bob[3], v, r_refdef.weaponmatrix[2], r_refdef.weaponmatrix_bob[3]);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -2590,14 +2590,26 @@ static void R_Sprite_GenerateTrisoup(entity_t *e, int bemode)
|
|||
lightmap = 1;
|
||||
}
|
||||
|
||||
if ((e->flags & RF_WEAPONMODEL) && r_refdef.playerview->viewentity > 0)
|
||||
if (e->flags & RF_WEAPONMODELNOBOB)
|
||||
{
|
||||
sprorigin[0] = r_refdef.playerview->vw_origin[0];
|
||||
sprorigin[1] = r_refdef.playerview->vw_origin[1];
|
||||
sprorigin[2] = r_refdef.playerview->vw_origin[2];
|
||||
VectorMA(sprorigin, e->origin[0], r_refdef.playerview->vw_axis[0], sprorigin);
|
||||
VectorMA(sprorigin, e->origin[1], r_refdef.playerview->vw_axis[1], sprorigin);
|
||||
VectorMA(sprorigin, e->origin[2], r_refdef.playerview->vw_axis[2], sprorigin);
|
||||
sprorigin[0] = r_refdef.weaponmatrix[3][0];
|
||||
sprorigin[1] = r_refdef.weaponmatrix[3][1];
|
||||
sprorigin[2] = r_refdef.weaponmatrix[3][2];
|
||||
VectorMA(sprorigin, e->origin[0], r_refdef.weaponmatrix[0], sprorigin);
|
||||
VectorMA(sprorigin, e->origin[1], r_refdef.weaponmatrix[1], sprorigin);
|
||||
VectorMA(sprorigin, e->origin[2], r_refdef.weaponmatrix[2], sprorigin);
|
||||
// VectorMA(sprorigin, 12, vpn, sprorigin);
|
||||
|
||||
// batchflags |= BEF_FORCENODEPTH;
|
||||
}
|
||||
else if (e->flags & RF_WEAPONMODEL)
|
||||
{
|
||||
sprorigin[0] = r_refdef.weaponmatrix_bob[3][0];
|
||||
sprorigin[1] = r_refdef.weaponmatrix_bob[3][1];
|
||||
sprorigin[2] = r_refdef.weaponmatrix_bob[3][2];
|
||||
VectorMA(sprorigin, e->origin[0], r_refdef.weaponmatrix_bob[0], sprorigin);
|
||||
VectorMA(sprorigin, e->origin[1], r_refdef.weaponmatrix_bob[1], sprorigin);
|
||||
VectorMA(sprorigin, e->origin[2], r_refdef.weaponmatrix_bob[2], sprorigin);
|
||||
// VectorMA(sprorigin, 12, vpn, sprorigin);
|
||||
|
||||
// batchflags |= BEF_FORCENODEPTH;
|
||||
|
@ -2667,15 +2679,19 @@ static void R_Sprite_GenerateTrisoup(entity_t *e, int bemode)
|
|||
{
|
||||
case SPR_ORIENTED:
|
||||
// bullet marks on walls
|
||||
if ((e->flags & RF_WEAPONMODEL) && r_refdef.playerview->viewentity > 0)
|
||||
Matrix3_Multiply(e->axis, r_refdef.playerview->vw_axis, spraxis);
|
||||
if (e->flags & RF_WEAPONMODELNOBOB)
|
||||
Matrix3_Multiply(e->axis, r_refdef.weaponmatrix, spraxis);
|
||||
else if (e->flags & RF_WEAPONMODEL)
|
||||
Matrix3_Multiply(e->axis, r_refdef.weaponmatrix_bob, spraxis);
|
||||
else
|
||||
memcpy(spraxis, e->axis, sizeof(spraxis));
|
||||
break;
|
||||
case SPR_ORIENTED_BACKFACE:
|
||||
// bullet marks on walls, invisible to anyone in the direction that its facing...
|
||||
if ((e->flags & RF_WEAPONMODEL) && r_refdef.playerview->viewentity > 0)
|
||||
Matrix3_Multiply(e->axis, r_refdef.playerview->vw_axis, spraxis);
|
||||
if (e->flags & RF_WEAPONMODELNOBOB)
|
||||
Matrix3_Multiply(e->axis, r_refdef.weaponmatrix, spraxis);
|
||||
else if ((e->flags & RF_WEAPONMODEL) && r_refdef.playerview->viewentity > 0)
|
||||
Matrix3_Multiply(e->axis, r_refdef.weaponmatrix_bob, spraxis);
|
||||
else
|
||||
memcpy(spraxis, e->axis, sizeof(spraxis));
|
||||
VectorNegate(spraxis[1], spraxis[1]);
|
||||
|
|
|
@ -272,48 +272,48 @@ void R_RotateForEntity (float *m, float *modelview, const entity_t *e, const mod
|
|||
float em[16];
|
||||
float vm[16];
|
||||
|
||||
if ((e->flags & RF_WEAPONMODELNOBOB) || r_refdef.playerview->viewentity <= 0)
|
||||
if (e->flags & RF_WEAPONMODELNOBOB)
|
||||
{
|
||||
vm[0] = vpn[0];
|
||||
vm[1] = vpn[1];
|
||||
vm[2] = vpn[2];
|
||||
vm[0] = r_refdef.weaponmatrix[0][0];
|
||||
vm[1] = r_refdef.weaponmatrix[0][1];
|
||||
vm[2] = r_refdef.weaponmatrix[0][2];
|
||||
vm[3] = 0;
|
||||
|
||||
vm[4] = -vright[0];
|
||||
vm[5] = -vright[1];
|
||||
vm[6] = -vright[2];
|
||||
vm[4] = r_refdef.weaponmatrix[1][0];
|
||||
vm[5] = r_refdef.weaponmatrix[1][1];
|
||||
vm[6] = r_refdef.weaponmatrix[1][2];
|
||||
vm[7] = 0;
|
||||
|
||||
vm[8] = vup[0];
|
||||
vm[9] = vup[1];
|
||||
vm[10] = vup[2];
|
||||
vm[8] = r_refdef.weaponmatrix[2][0];
|
||||
vm[9] = r_refdef.weaponmatrix[2][1];
|
||||
vm[10] = r_refdef.weaponmatrix[2][2];
|
||||
vm[11] = 0;
|
||||
|
||||
vm[12] = r_refdef.vieworg[0];
|
||||
vm[13] = r_refdef.vieworg[1];
|
||||
vm[14] = r_refdef.vieworg[2];
|
||||
vm[12] = r_refdef.weaponmatrix[3][0];
|
||||
vm[13] = r_refdef.weaponmatrix[3][1];
|
||||
vm[14] = r_refdef.weaponmatrix[3][2];
|
||||
vm[15] = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
vm[0] = r_refdef.playerview->vw_axis[0][0];
|
||||
vm[1] = r_refdef.playerview->vw_axis[0][1];
|
||||
vm[2] = r_refdef.playerview->vw_axis[0][2];
|
||||
vm[0] = r_refdef.weaponmatrix_bob[0][0];
|
||||
vm[1] = r_refdef.weaponmatrix_bob[0][1];
|
||||
vm[2] = r_refdef.weaponmatrix_bob[0][2];
|
||||
vm[3] = 0;
|
||||
|
||||
vm[4] = r_refdef.playerview->vw_axis[1][0];
|
||||
vm[5] = r_refdef.playerview->vw_axis[1][1];
|
||||
vm[6] = r_refdef.playerview->vw_axis[1][2];
|
||||
vm[4] = r_refdef.weaponmatrix_bob[1][0];
|
||||
vm[5] = r_refdef.weaponmatrix_bob[1][1];
|
||||
vm[6] = r_refdef.weaponmatrix_bob[1][2];
|
||||
vm[7] = 0;
|
||||
|
||||
vm[8] = r_refdef.playerview->vw_axis[2][0];
|
||||
vm[9] = r_refdef.playerview->vw_axis[2][1];
|
||||
vm[10] = r_refdef.playerview->vw_axis[2][2];
|
||||
vm[8] = r_refdef.weaponmatrix_bob[2][0];
|
||||
vm[9] = r_refdef.weaponmatrix_bob[2][1];
|
||||
vm[10] = r_refdef.weaponmatrix_bob[2][2];
|
||||
vm[11] = 0;
|
||||
|
||||
vm[12] = r_refdef.playerview->vw_origin[0];
|
||||
vm[13] = r_refdef.playerview->vw_origin[1];
|
||||
vm[14] = r_refdef.playerview->vw_origin[2];
|
||||
vm[12] = r_refdef.weaponmatrix_bob[3][0];
|
||||
vm[13] = r_refdef.weaponmatrix_bob[3][1];
|
||||
vm[14] = r_refdef.weaponmatrix_bob[3][2];
|
||||
vm[15] = 1;
|
||||
}
|
||||
|
||||
|
|
|
@ -1893,6 +1893,7 @@ qboolean SVQ3_InitGame(server_static_t *server_state_static, server_t *server_st
|
|||
int i;
|
||||
char ssqcprogs[MAX_QPATH];
|
||||
|
||||
memset(sv3.models, 0, sizeof(sv3.models));
|
||||
sv3.server_state_static = server_state_static;
|
||||
sv3.server_state = server_state;
|
||||
sv3.world = &server_state->world;
|
||||
|
|
|
@ -3817,46 +3817,46 @@ static void BE_RotateForEntity (const entity_t *fte_restrict e, const model_t *f
|
|||
|
||||
if (e->flags & RF_WEAPONMODELNOBOB)
|
||||
{
|
||||
vm[0] = vpn[0];
|
||||
vm[1] = vpn[1];
|
||||
vm[2] = vpn[2];
|
||||
vm[0] = r_refdef.weaponmatrix[0][0];
|
||||
vm[1] = r_refdef.weaponmatrix[0][1];
|
||||
vm[2] = r_refdef.weaponmatrix[0][2];
|
||||
vm[3] = 0;
|
||||
|
||||
vm[4] = -vright[0];
|
||||
vm[5] = -vright[1];
|
||||
vm[6] = -vright[2];
|
||||
vm[4] = r_refdef.weaponmatrix[1][0];
|
||||
vm[5] = r_refdef.weaponmatrix[1][1];
|
||||
vm[6] = r_refdef.weaponmatrix[1][2];
|
||||
vm[7] = 0;
|
||||
|
||||
vm[8] = vup[0];
|
||||
vm[9] = vup[1];
|
||||
vm[10] = vup[2];
|
||||
vm[8] = r_refdef.weaponmatrix[2][0];
|
||||
vm[9] = r_refdef.weaponmatrix[2][1];
|
||||
vm[10] = r_refdef.weaponmatrix[2][2];
|
||||
vm[11] = 0;
|
||||
|
||||
vm[12] = r_refdef.vieworg[0];
|
||||
vm[13] = r_refdef.vieworg[1];
|
||||
vm[14] = r_refdef.vieworg[2];
|
||||
vm[12] = r_refdef.weaponmatrix[3][0];
|
||||
vm[13] = r_refdef.weaponmatrix[3][1];
|
||||
vm[14] = r_refdef.weaponmatrix[3][2];
|
||||
vm[15] = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
vm[0] = r_refdef.playerview->vw_axis[0][0];
|
||||
vm[1] = r_refdef.playerview->vw_axis[0][1];
|
||||
vm[2] = r_refdef.playerview->vw_axis[0][2];
|
||||
vm[0] = r_refdef.weaponmatrix_bob[0][0];
|
||||
vm[1] = r_refdef.weaponmatrix_bob[0][1];
|
||||
vm[2] = r_refdef.weaponmatrix_bob[0][2];
|
||||
vm[3] = 0;
|
||||
|
||||
vm[4] = r_refdef.playerview->vw_axis[1][0];
|
||||
vm[5] = r_refdef.playerview->vw_axis[1][1];
|
||||
vm[6] = r_refdef.playerview->vw_axis[1][2];
|
||||
vm[4] = r_refdef.weaponmatrix_bob[1][0];
|
||||
vm[5] = r_refdef.weaponmatrix_bob[1][1];
|
||||
vm[6] = r_refdef.weaponmatrix_bob[1][2];
|
||||
vm[7] = 0;
|
||||
|
||||
vm[8] = r_refdef.playerview->vw_axis[2][0];
|
||||
vm[9] = r_refdef.playerview->vw_axis[2][1];
|
||||
vm[10] = r_refdef.playerview->vw_axis[2][2];
|
||||
vm[8] = r_refdef.weaponmatrix_bob[2][0];
|
||||
vm[9] = r_refdef.weaponmatrix_bob[2][1];
|
||||
vm[10] = r_refdef.weaponmatrix_bob[2][2];
|
||||
vm[11] = 0;
|
||||
|
||||
vm[12] = r_refdef.playerview->vw_origin[0];
|
||||
vm[13] = r_refdef.playerview->vw_origin[1];
|
||||
vm[14] = r_refdef.playerview->vw_origin[2];
|
||||
vm[12] = r_refdef.weaponmatrix_bob[3][0];
|
||||
vm[13] = r_refdef.weaponmatrix_bob[3][1];
|
||||
vm[14] = r_refdef.weaponmatrix_bob[3][2];
|
||||
vm[15] = 1;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue