mirror of
https://github.com/Shpoike/Quakespasm.git
synced 2024-11-10 07:21:58 +00:00
Fix chasecam to deal with the viewmodel change... Also attempt to push it away from walls in a not-so-much-of-a-wallhack kind of way.
This commit is contained in:
parent
06a1f39d43
commit
6394ea27e8
8 changed files with 26 additions and 21 deletions
|
@ -48,14 +48,25 @@ TraceLine
|
|||
TODO: impact on bmodels, monsters
|
||||
==============
|
||||
*/
|
||||
void TraceLine (vec3_t start, vec3_t end, vec3_t impact)
|
||||
void TraceLine (vec3_t start, vec3_t end, float pushoff, vec3_t impact)
|
||||
{
|
||||
trace_t trace;
|
||||
|
||||
memset (&trace, 0, sizeof(trace));
|
||||
trace.fraction = 1;
|
||||
trace.allsolid = true;
|
||||
VectorCopy (end, trace.endpos);
|
||||
SV_RecursiveHullCheck (cl.worldmodel->hulls, start, end, &trace, CONTENTMASK_ANYSOLID);
|
||||
|
||||
VectorCopy (trace.endpos, impact);
|
||||
|
||||
if (pushoff && trace.fraction < 1) //push away from the impact plane by the distance specified, so our camera's near clip plane does not intersect the wall.
|
||||
{
|
||||
vec3_t dir;
|
||||
VectorSubtract(start, end, dir);
|
||||
pushoff = pushoff / DotProduct(dir, trace.plane.normal); //distance needs to be bigger if the trace is co-planar to the surface
|
||||
VectorMA(impact, pushoff, dir, impact);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -91,28 +102,26 @@ void Chase_UpdateForDrawing (void)
|
|||
|
||||
// calc ideal camera location before checking for walls
|
||||
for (i=0 ; i<3 ; i++)
|
||||
ideal[i] = cl.viewent.origin[i]
|
||||
ideal[i] = r_refdef.vieworg[i]
|
||||
- forward[i]*chase_back.value
|
||||
+ right[i]*chase_right.value;
|
||||
//+ up[i]*chase_up.value;
|
||||
ideal[2] = cl.viewent.origin[2] + chase_up.value;
|
||||
ideal[2] = r_refdef.vieworg[2] + chase_up.value;
|
||||
|
||||
// make sure camera is not in or behind a wall
|
||||
TraceLine(r_refdef.vieworg, ideal, temp);
|
||||
if (VectorLength(temp) != 0)
|
||||
VectorCopy(temp, ideal);
|
||||
TraceLine(r_refdef.vieworg, ideal, NEARCLIP, ideal);
|
||||
|
||||
// find the spot the player is looking at
|
||||
VectorMA (r_refdef.vieworg, 1<<20, forward, temp);
|
||||
TraceLine (r_refdef.vieworg, temp, 0, crosshair);
|
||||
|
||||
// place camera
|
||||
VectorCopy (ideal, r_refdef.vieworg);
|
||||
|
||||
// find the spot the player is looking at
|
||||
VectorMA (cl.viewent.origin, 1<<20, forward, temp);
|
||||
TraceLine (cl.viewent.origin, temp, crosshair);
|
||||
|
||||
// calculate camera angles to look at the same spot
|
||||
VectorSubtract (crosshair, r_refdef.vieworg, temp);
|
||||
VectorAngles (temp, NULL, r_refdef.viewangles);
|
||||
if (r_refdef.viewangles[PITCH] == 90 || r_refdef.viewangles[PITCH] == -90)
|
||||
if (r_refdef.viewangles[PITCH] >= 89.9 || r_refdef.viewangles[PITCH] <= -89.9)
|
||||
r_refdef.viewangles[YAW] = cl.viewangles[YAW];
|
||||
}
|
||||
|
||||
|
|
|
@ -1389,7 +1389,7 @@ void CL_Tracepos_f (void)
|
|||
return;
|
||||
|
||||
VectorMA(r_refdef.vieworg, 8192.0, vpn, v);
|
||||
TraceLine(r_refdef.vieworg, v, w);
|
||||
TraceLine(r_refdef.vieworg, v, 0, w);
|
||||
|
||||
if (VectorLength(w) == 0)
|
||||
Con_Printf ("Tracepos: trace didn't hit anything\n");
|
||||
|
|
|
@ -471,7 +471,7 @@ float CL_TraceLine (vec3_t start, vec3_t end, vec3_t impact, vec3_t normal, int
|
|||
extern cvar_t chase_active;
|
||||
|
||||
void Chase_Init (void);
|
||||
void TraceLine (vec3_t start, vec3_t end, vec3_t impact);
|
||||
void TraceLine (vec3_t start, vec3_t end, float pushoff, vec3_t impact);
|
||||
void Chase_UpdateForClient (void); //johnfitz
|
||||
void Chase_UpdateForDrawing (void); //johnfitz
|
||||
|
||||
|
|
|
@ -453,7 +453,6 @@ void R_SetFrustum (float fovx, float fovy)
|
|||
GL_SetFrustum -- johnfitz -- written to replace MYgluPerspective
|
||||
=============
|
||||
*/
|
||||
#define NEARCLIP 4
|
||||
float frustum_skew = 0.0; //used by r_stereo
|
||||
/*void GL_SetFrustum(float fovx, float fovy)
|
||||
{
|
||||
|
|
|
@ -31,7 +31,6 @@ extern cvar_t r_clearcolor;
|
|||
extern cvar_t r_drawflat;
|
||||
extern cvar_t r_flatlightstyles;
|
||||
extern cvar_t gl_fullbrights;
|
||||
extern cvar_t gl_farclip;
|
||||
extern cvar_t gl_overbright;
|
||||
extern cvar_t gl_overbright_models;
|
||||
extern cvar_t r_waterwarp;
|
||||
|
|
|
@ -46,7 +46,6 @@ char skybox_name[1024]; //name of current skybox, or "" if no skybox
|
|||
gltexture_t *skybox_textures[6];
|
||||
gltexture_t *solidskytexture, *alphaskytexture;
|
||||
|
||||
extern cvar_t gl_farclip;
|
||||
cvar_t r_fastsky = {"r_fastsky", "0", CVAR_NONE};
|
||||
cvar_t r_sky_quality = {"r_sky_quality", "12", CVAR_NONE};
|
||||
cvar_t r_skyalpha = {"r_skyalpha", "1", CVAR_NONE};
|
||||
|
|
|
@ -154,6 +154,9 @@ extern refdef_t r_refdef;
|
|||
extern mleaf_t *r_viewleaf, *r_oldviewleaf;
|
||||
extern int d_lightstylevalue[MAX_LIGHTSTYLES]; // 8.8 fraction of base light value
|
||||
|
||||
extern cvar_t gl_farclip;
|
||||
#define NEARCLIP 4
|
||||
|
||||
extern cvar_t r_norefresh;
|
||||
extern cvar_t r_drawentities;
|
||||
extern cvar_t r_drawworld;
|
||||
|
|
|
@ -6945,14 +6945,10 @@ static void PF_cl_getproperty(void)
|
|||
G_FLOAT(OFS_RETURN+0) = viewprops.drawcrosshair;
|
||||
break;
|
||||
case VF_MINDIST:
|
||||
#define NEARCLIP 4
|
||||
G_FLOAT(OFS_RETURN+0) = NEARCLIP;
|
||||
break;
|
||||
case VF_MAXDIST: //maxdist
|
||||
{
|
||||
extern cvar_t gl_farclip;
|
||||
G_FLOAT(OFS_RETURN+0) = gl_farclip.value;
|
||||
}
|
||||
break;
|
||||
|
||||
case VF_CL_VIEWANGLES: //viewangles hack
|
||||
|
|
Loading…
Reference in a new issue