mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2025-01-18 15:01:41 +00:00
nuke SV_RecursiveHullCheck from cl_cam.c and use PM_RecursiveHullCheck
instead. Also add prototype for PM_RecursiveHullCheck to pmove.h
This commit is contained in:
parent
f505e8630c
commit
e9c420c749
2 changed files with 4 additions and 132 deletions
|
@ -119,5 +119,7 @@ int PM_HullPointContents (hull_t *hull, int num, vec3_t p);
|
|||
int PM_PointContents (vec3_t point);
|
||||
qboolean PM_TestPlayerPosition (vec3_t point);
|
||||
pmtrace_t PM_PlayerMove (vec3_t start, vec3_t stop);
|
||||
qboolean PM_RecursiveHullCheck (hull_t *hull, int num, float p1f, float p2f,
|
||||
vec3_t p1, vec3_t p2, pmtrace_t *trace);
|
||||
|
||||
#endif // _PMOVE_H
|
||||
|
|
|
@ -80,9 +80,6 @@ extern kbutton_t in_lookup, in_lookdown;
|
|||
extern kbutton_t in_moveleft, in_moveright;
|
||||
extern kbutton_t in_strafe, in_speed;
|
||||
|
||||
qboolean SV_RecursiveHullCheck (hull_t *hull, int num, float p1f, float p2f,
|
||||
vec3_t p1, vec3_t p2, trace_t *trace);
|
||||
|
||||
cvar_t *chase_back;
|
||||
cvar_t *chase_up;
|
||||
cvar_t *chase_right;
|
||||
|
@ -658,140 +655,13 @@ CL_Cam_Init_Cvars (void)
|
|||
chase_active = Cvar_Get ("chase_active", "0", CVAR_NONE, NULL, "None");
|
||||
}
|
||||
|
||||
// 1/32 epsilon to keep floating point happy
|
||||
#define DIST_EPSILON (0.03125)
|
||||
|
||||
qboolean
|
||||
SV_RecursiveHullCheck (hull_t *hull, int num, float p1f, float p2f, vec3_t p1,
|
||||
vec3_t p2, trace_t *trace)
|
||||
{
|
||||
dclipnode_t *node;
|
||||
mplane_t *plane;
|
||||
float t1, t2;
|
||||
float frac;
|
||||
int i;
|
||||
vec3_t mid;
|
||||
int side;
|
||||
float midf;
|
||||
|
||||
// check for empty
|
||||
if (num < 0) {
|
||||
if (num != CONTENTS_SOLID) {
|
||||
trace->allsolid = false;
|
||||
if (num == CONTENTS_EMPTY)
|
||||
trace->inopen = true;
|
||||
else
|
||||
trace->inwater = true;
|
||||
} else
|
||||
trace->startsolid = true;
|
||||
return true; // empty
|
||||
}
|
||||
|
||||
if (num < hull->firstclipnode || num > hull->lastclipnode)
|
||||
Sys_Error ("SV_RecursiveHullCheck: bad node number");
|
||||
|
||||
// find the point distances
|
||||
node = hull->clipnodes + num;
|
||||
plane = hull->planes + node->planenum;
|
||||
|
||||
if (plane->type < 3) {
|
||||
t1 = p1[plane->type] - plane->dist;
|
||||
t2 = p2[plane->type] - plane->dist;
|
||||
} else {
|
||||
t1 = DotProduct (plane->normal, p1) - plane->dist;
|
||||
t2 = DotProduct (plane->normal, p2) - plane->dist;
|
||||
}
|
||||
|
||||
#if 1
|
||||
if (t1 >= 0 && t2 >= 0)
|
||||
return SV_RecursiveHullCheck (hull, node->children[0], p1f, p2f, p1,
|
||||
p2, trace);
|
||||
if (t1 < 0 && t2 < 0)
|
||||
return SV_RecursiveHullCheck (hull, node->children[1], p1f, p2f, p1,
|
||||
p2, trace);
|
||||
#else
|
||||
if ((t1 >= DIST_EPSILON && t2 >= DIST_EPSILON) || (t2 > t1 && t1 >= 0))
|
||||
return SV_RecursiveHullCheck (hull, node->children[0], p1f, p2f, p1,
|
||||
p2, trace);
|
||||
if ((t1 <= -DIST_EPSILON && t2 <= -DIST_EPSILON) || (t2 < t1 && t1 <= 0))
|
||||
return SV_RecursiveHullCheck (hull, node->children[1], p1f, p2f, p1,
|
||||
p2, trace);
|
||||
#endif
|
||||
|
||||
// put the crosspoint DIST_EPSILON pixels on the near side
|
||||
if (t1 < 0)
|
||||
frac = (t1 + DIST_EPSILON) / (t1 - t2);
|
||||
else
|
||||
frac = (t1 - DIST_EPSILON) / (t1 - t2);
|
||||
if (frac < 0)
|
||||
frac = 0;
|
||||
if (frac > 1)
|
||||
frac = 1;
|
||||
|
||||
midf = p1f + (p2f - p1f) * frac;
|
||||
for (i = 0; i < 3; i++)
|
||||
mid[i] = p1[i] + frac * (p2[i] - p1[i]);
|
||||
|
||||
side = (t1 < 0);
|
||||
|
||||
// move up to the node
|
||||
if (!SV_RecursiveHullCheck
|
||||
(hull, node->children[side], p1f, midf, p1, mid, trace)) return false;
|
||||
|
||||
#ifdef PARANOID
|
||||
if (SV_HullPointContents (sv_hullmodel, mid, node->children[side])
|
||||
== CONTENTS_SOLID) {
|
||||
Sys_Printf ("mid PointInHullSolid\n");
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (SV_HullPointContents (hull, node->children[side ^ 1], mid)
|
||||
!= CONTENTS_SOLID)
|
||||
// go past the node
|
||||
return SV_RecursiveHullCheck (hull, node->children[side ^ 1], midf,
|
||||
p2f, mid, p2, trace);
|
||||
|
||||
if (trace->allsolid)
|
||||
return false; // never got out of the solid area
|
||||
|
||||
// the other side of the node is solid, this is the impact point
|
||||
if (!side) {
|
||||
VectorCopy (plane->normal, trace->plane.normal);
|
||||
trace->plane.dist = plane->dist;
|
||||
} else {
|
||||
VectorSubtract (vec3_origin, plane->normal, trace->plane.normal);
|
||||
trace->plane.dist = -plane->dist;
|
||||
}
|
||||
|
||||
while (SV_HullPointContents (hull, hull->firstclipnode, mid)
|
||||
== CONTENTS_SOLID) { // shouldn't really happen, but does
|
||||
// occasionally
|
||||
frac -= 0.1;
|
||||
if (frac < 0) {
|
||||
trace->fraction = midf;
|
||||
VectorCopy (mid, trace->endpos);
|
||||
Sys_Printf ("backup past 0\n");
|
||||
return false;
|
||||
}
|
||||
midf = p1f + (p2f - p1f) * frac;
|
||||
for (i = 0; i < 3; i++)
|
||||
mid[i] = p1[i] + frac * (p2[i] - p1[i]);
|
||||
}
|
||||
|
||||
trace->fraction = midf;
|
||||
VectorCopy (mid, trace->endpos);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void
|
||||
TraceLine (vec3_t start, vec3_t end, vec3_t impact)
|
||||
{
|
||||
trace_t trace;
|
||||
pmtrace_t trace;
|
||||
|
||||
memset (&trace, 0, sizeof (trace));
|
||||
SV_RecursiveHullCheck (cl.worldmodel->hulls, 0, 0, 1, start, end, &trace);
|
||||
PM_RecursiveHullCheck (cl.worldmodel->hulls, 0, 0, 1, start, end, &trace);
|
||||
|
||||
VectorCopy (trace.endpos, impact);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue