mirror of
https://git.code.sf.net/p/quake/newtree
synced 2025-05-31 17:21:46 +00:00
Merged duplicate client/server functions (placed into PMOVETST.C).
PM/SV_RecursiveHullCheck -> HullCheck PM/SV_InitBoxHull -> InitBoxHull PM/SV_HullForBox -> HullForBox PM/SV_HullPointContents > HullPointContents Client now uses WORLDA.S (renamed func) pmtrace_t replaced by trace_t with ent->entnum change pmplane_t replaced by plane_t
This commit is contained in:
parent
bb39a9252b
commit
e703935e9b
3 changed files with 56 additions and 312 deletions
|
@ -54,13 +54,13 @@ vec3_t forward, right, up;
|
||||||
vec3_t player_mins = { -16, -16, -24 };
|
vec3_t player_mins = { -16, -16, -24 };
|
||||||
vec3_t player_maxs = { 16, 16, 32 };
|
vec3_t player_maxs = { 16, 16, 32 };
|
||||||
|
|
||||||
void PM_InitBoxHull (void);
|
extern void InitBoxHull (void);
|
||||||
void PM_CategorizePosition (void);
|
void PM_CategorizePosition (void);
|
||||||
|
|
||||||
void
|
void
|
||||||
Pmove_Init (void)
|
Pmove_Init (void)
|
||||||
{
|
{
|
||||||
PM_InitBoxHull ();
|
InitBoxHull ();
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -126,7 +126,7 @@ PM_FlyMove (void)
|
||||||
vec3_t planes[MAX_CLIP_PLANES];
|
vec3_t planes[MAX_CLIP_PLANES];
|
||||||
vec3_t primal_velocity, original_velocity;
|
vec3_t primal_velocity, original_velocity;
|
||||||
int i, j;
|
int i, j;
|
||||||
pmtrace_t trace;
|
trace_t trace;
|
||||||
vec3_t end;
|
vec3_t end;
|
||||||
float time_left;
|
float time_left;
|
||||||
int blocked;
|
int blocked;
|
||||||
|
@ -161,7 +161,7 @@ PM_FlyMove (void)
|
||||||
break; // moved the entire distance
|
break; // moved the entire distance
|
||||||
|
|
||||||
// save entity for contact
|
// save entity for contact
|
||||||
pmove.touchindex[pmove.numtouch] = trace.ent;
|
pmove.touchindex[pmove.numtouch] = trace.entnum;
|
||||||
pmove.numtouch++;
|
pmove.numtouch++;
|
||||||
|
|
||||||
if (trace.plane.normal[2] > 0.7) {
|
if (trace.plane.normal[2] > 0.7) {
|
||||||
|
@ -237,7 +237,7 @@ void
|
||||||
PM_FlymodeMove (void)
|
PM_FlymodeMove (void)
|
||||||
{
|
{
|
||||||
vec3_t start, dest, pmvel, pmtmp;
|
vec3_t start, dest, pmvel, pmtmp;
|
||||||
pmtrace_t trace;
|
trace_t trace;
|
||||||
float pmspeed;
|
float pmspeed;
|
||||||
|
|
||||||
pmvel[0] =
|
pmvel[0] =
|
||||||
|
@ -280,7 +280,7 @@ void
|
||||||
PM_GroundMove (void)
|
PM_GroundMove (void)
|
||||||
{
|
{
|
||||||
vec3_t start, dest;
|
vec3_t start, dest;
|
||||||
pmtrace_t trace;
|
trace_t trace;
|
||||||
vec3_t original, originalvel, down, up, downvel;
|
vec3_t original, originalvel, down, up, downvel;
|
||||||
float downdist, updist;
|
float downdist, updist;
|
||||||
|
|
||||||
|
@ -367,7 +367,7 @@ PM_Friction (void)
|
||||||
float friction;
|
float friction;
|
||||||
float drop;
|
float drop;
|
||||||
vec3_t start, stop;
|
vec3_t start, stop;
|
||||||
pmtrace_t trace;
|
trace_t trace;
|
||||||
|
|
||||||
if (pmove.waterjumptime)
|
if (pmove.waterjumptime)
|
||||||
return;
|
return;
|
||||||
|
@ -482,7 +482,7 @@ PM_WaterMove (void)
|
||||||
float wishspeed;
|
float wishspeed;
|
||||||
vec3_t wishdir;
|
vec3_t wishdir;
|
||||||
vec3_t start, dest;
|
vec3_t start, dest;
|
||||||
pmtrace_t trace;
|
trace_t trace;
|
||||||
|
|
||||||
//
|
//
|
||||||
// user intentions
|
// user intentions
|
||||||
|
@ -607,7 +607,7 @@ PM_CategorizePosition (void)
|
||||||
{
|
{
|
||||||
vec3_t point;
|
vec3_t point;
|
||||||
int cont;
|
int cont;
|
||||||
pmtrace_t tr;
|
trace_t tr;
|
||||||
|
|
||||||
// if the player hull point one unit down is solid, the player
|
// if the player hull point one unit down is solid, the player
|
||||||
// is on ground
|
// is on ground
|
||||||
|
@ -623,15 +623,16 @@ PM_CategorizePosition (void)
|
||||||
if (tr.plane.normal[2] < 0.7)
|
if (tr.plane.normal[2] < 0.7)
|
||||||
onground = -1; // too steep
|
onground = -1; // too steep
|
||||||
else
|
else
|
||||||
onground = tr.ent;
|
onground = tr.entnum;
|
||||||
if (onground != -1) {
|
if (onground != -1) {
|
||||||
pmove.waterjumptime = 0;
|
pmove.waterjumptime = 0;
|
||||||
if (!tr.startsolid && !tr.allsolid)
|
if (!tr.startsolid && !tr.allsolid)
|
||||||
VectorCopy (tr.endpos, pmove.origin);
|
VectorCopy (tr.endpos, pmove.origin);
|
||||||
}
|
}
|
||||||
// standing on an entity other than the world
|
// standing on an entity other than the world
|
||||||
if (tr.ent > 0) {
|
|
||||||
pmove.touchindex[pmove.numtouch] = tr.ent;
|
if (tr.entnum > 0) {
|
||||||
|
pmove.touchindex[pmove.numtouch] = tr.entnum;
|
||||||
pmove.numtouch++;
|
pmove.numtouch++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -49,14 +49,16 @@ static mplane_t box_planes[6];
|
||||||
extern vec3_t player_mins;
|
extern vec3_t player_mins;
|
||||||
extern vec3_t player_maxs;
|
extern vec3_t player_maxs;
|
||||||
|
|
||||||
|
int HullPointContents (hull_t *hull, int num, vec3_t p);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
PM_InitBoxHull
|
InitBoxHull
|
||||||
|
|
||||||
Set up the planes and clipnodes so that the six floats of a bounding box
|
Set up the planes and clipnodes so that the six floats of a bounding box
|
||||||
can just be stored out and get a proper hull_t structure.
|
can just be stored out and get a proper hull_t structure.
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
PM_InitBoxHull (void)
|
InitBoxHull (void)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
int side;
|
int side;
|
||||||
|
@ -85,13 +87,13 @@ PM_InitBoxHull (void)
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
PM_HullForBox
|
HullForBox
|
||||||
|
|
||||||
To keep everything totally uniform, bounding boxes are turned into small
|
To keep everything totally uniform, bounding boxes are turned into small
|
||||||
BSP trees instead of being compared directly.
|
BSP trees instead of being compared directly.
|
||||||
*/
|
*/
|
||||||
hull_t *
|
hull_t *
|
||||||
PM_HullForBox (vec3_t mins, vec3_t maxs)
|
HullForBox (vec3_t mins, vec3_t maxs)
|
||||||
{
|
{
|
||||||
box_planes[0].dist = maxs[0];
|
box_planes[0].dist = maxs[0];
|
||||||
box_planes[1].dist = mins[0];
|
box_planes[1].dist = mins[0];
|
||||||
|
@ -104,11 +106,12 @@ PM_HullForBox (vec3_t mins, vec3_t maxs)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef USE_INTEL_ASM
|
||||||
/*
|
/*
|
||||||
PM_HullPointContents
|
HullPointContents
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
PM_HullPointContents (hull_t *hull, int num, vec3_t p)
|
HullPointContents (hull_t *hull, int num, vec3_t p)
|
||||||
{
|
{
|
||||||
float d;
|
float d;
|
||||||
dclipnode_t *node;
|
dclipnode_t *node;
|
||||||
|
@ -116,7 +119,7 @@ PM_HullPointContents (hull_t *hull, int num, vec3_t p)
|
||||||
|
|
||||||
while (num >= 0) {
|
while (num >= 0) {
|
||||||
if (num < hull->firstclipnode || num > hull->lastclipnode)
|
if (num < hull->firstclipnode || num > hull->lastclipnode)
|
||||||
Sys_Error ("PM_HullPointContents: bad node number");
|
Sys_Error ("HullPointContents: bad node number");
|
||||||
|
|
||||||
node = hull->clipnodes + num;
|
node = hull->clipnodes + num;
|
||||||
plane = hull->planes + node->planenum;
|
plane = hull->planes + node->planenum;
|
||||||
|
@ -133,6 +136,7 @@ PM_HullPointContents (hull_t *hull, int num, vec3_t p)
|
||||||
|
|
||||||
return num;
|
return num;
|
||||||
}
|
}
|
||||||
|
#endif // !USE_INTEL_ASM
|
||||||
|
|
||||||
/*
|
/*
|
||||||
PM_PointContents
|
PM_PointContents
|
||||||
|
@ -140,34 +144,12 @@ PM_HullPointContents (hull_t *hull, int num, vec3_t p)
|
||||||
int
|
int
|
||||||
PM_PointContents (vec3_t p)
|
PM_PointContents (vec3_t p)
|
||||||
{
|
{
|
||||||
float d;
|
|
||||||
dclipnode_t *node;
|
|
||||||
mplane_t *plane;
|
|
||||||
hull_t *hull;
|
hull_t *hull;
|
||||||
int num;
|
int num;
|
||||||
|
|
||||||
hull = &pmove.physents[0].model->hulls[0];
|
hull = &pmove.physents[0].model->hulls[0];
|
||||||
|
|
||||||
num = hull->firstclipnode;
|
num = hull->firstclipnode;
|
||||||
|
|
||||||
while (num >= 0) {
|
return (HullPointContents (hull, num, p));
|
||||||
if (num < hull->firstclipnode || num > hull->lastclipnode)
|
|
||||||
Sys_Error ("PM_HullPointContents: bad node number");
|
|
||||||
|
|
||||||
node = hull->clipnodes + num;
|
|
||||||
plane = hull->planes + node->planenum;
|
|
||||||
|
|
||||||
if (plane->type < 3)
|
|
||||||
d = p[plane->type] - plane->dist;
|
|
||||||
else
|
|
||||||
d = DotProduct (plane->normal, p) - plane->dist;
|
|
||||||
if (d < 0)
|
|
||||||
num = node->children[1];
|
|
||||||
else
|
|
||||||
num = node->children[0];
|
|
||||||
}
|
|
||||||
|
|
||||||
return num;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -178,11 +160,11 @@ PM_PointContents (vec3_t p)
|
||||||
#define DIST_EPSILON (0.03125)
|
#define DIST_EPSILON (0.03125)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
PM_RecursiveHullCheck
|
RecursiveHullCheck
|
||||||
*/
|
*/
|
||||||
qboolean
|
qboolean
|
||||||
PM_RecursiveHullCheck (hull_t *hull, int num, float p1f, float p2f, vec3_t p1,
|
RecursiveHullCheck (hull_t *hull, int num, float p1f, float p2f, vec3_t p1,
|
||||||
vec3_t p2, pmtrace_t *trace)
|
vec3_t p2, trace_t *trace)
|
||||||
{
|
{
|
||||||
dclipnode_t *node;
|
dclipnode_t *node;
|
||||||
mplane_t *plane;
|
mplane_t *plane;
|
||||||
|
@ -209,7 +191,7 @@ PM_RecursiveHullCheck (hull_t *hull, int num, float p1f, float p2f, vec3_t p1,
|
||||||
// LordHavoc: this can be eliminated by validating in the loader... but
|
// LordHavoc: this can be eliminated by validating in the loader... but
|
||||||
// Mercury told me not to bother
|
// Mercury told me not to bother
|
||||||
if (num < hull->firstclipnode || num > hull->lastclipnode)
|
if (num < hull->firstclipnode || num > hull->lastclipnode)
|
||||||
Sys_Error ("PM_RecursiveHullCheck: bad node number");
|
Sys_Error ("RecursiveHullCheck: bad node number");
|
||||||
|
|
||||||
// find the point distances
|
// find the point distances
|
||||||
node = hull->clipnodes + num;
|
node = hull->clipnodes + num;
|
||||||
|
@ -245,22 +227,22 @@ PM_RecursiveHullCheck (hull_t *hull, int num, float p1f, float p2f, vec3_t p1,
|
||||||
mid[i] = p1[i] + frac * (p2[i] - p1[i]);
|
mid[i] = p1[i] + frac * (p2[i] - p1[i]);
|
||||||
|
|
||||||
// move up to the node
|
// move up to the node
|
||||||
if (!PM_RecursiveHullCheck (hull, node->children[side],
|
if (!RecursiveHullCheck (hull, node->children[side],
|
||||||
p1f, midf, p1, mid, trace))
|
p1f, midf, p1, mid, trace))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
#ifdef PARANOID
|
#ifdef PARANOID
|
||||||
if (PM_HullPointContents (pm_hullmodel, mid, node->children[side]) ==
|
if (HullPointContents (pm_hullmodel, mid, node->children[side]) ==
|
||||||
CONTENTS_SOLID) {
|
CONTENTS_SOLID) {
|
||||||
Con_Printf ("mid PointInHullSolid\n");
|
Con_Printf ("mid PointInHullSolid\n");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (PM_HullPointContents (hull, node->children[side ^ 1],
|
if (HullPointContents (hull, node->children[side ^ 1],
|
||||||
mid) != CONTENTS_SOLID) {
|
mid) != CONTENTS_SOLID) {
|
||||||
// go past the node
|
// go past the node
|
||||||
return PM_RecursiveHullCheck (hull, node->children[side ^ 1], midf, p2f,
|
return RecursiveHullCheck (hull, node->children[side ^ 1], midf, p2f,
|
||||||
mid, p2, trace);
|
mid, p2, trace);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -281,7 +263,7 @@ PM_RecursiveHullCheck (hull_t *hull, int num, float p1f, float p2f, vec3_t p1,
|
||||||
trace->plane.dist = -plane->dist;
|
trace->plane.dist = -plane->dist;
|
||||||
}
|
}
|
||||||
|
|
||||||
while (PM_HullPointContents (hull, hull->firstclipnode,
|
while (HullPointContents (hull, hull->firstclipnode,
|
||||||
mid) == CONTENTS_SOLID) {
|
mid) == CONTENTS_SOLID) {
|
||||||
// shouldn't really happen, but does occasionally
|
// shouldn't really happen, but does occasionally
|
||||||
frac -= 0.1;
|
frac -= 0.1;
|
||||||
|
@ -324,12 +306,12 @@ PM_TestPlayerPosition (vec3_t pos)
|
||||||
else {
|
else {
|
||||||
VectorSubtract (pe->mins, player_maxs, mins);
|
VectorSubtract (pe->mins, player_maxs, mins);
|
||||||
VectorSubtract (pe->maxs, player_mins, maxs);
|
VectorSubtract (pe->maxs, player_mins, maxs);
|
||||||
hull = PM_HullForBox (mins, maxs);
|
hull = HullForBox (mins, maxs);
|
||||||
}
|
}
|
||||||
|
|
||||||
VectorSubtract (pos, pe->origin, test);
|
VectorSubtract (pos, pe->origin, test);
|
||||||
|
|
||||||
if (PM_HullPointContents (hull, hull->firstclipnode, test) ==
|
if (HullPointContents (hull, hull->firstclipnode, test) ==
|
||||||
CONTENTS_SOLID) return false;
|
CONTENTS_SOLID) return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -339,10 +321,10 @@ PM_TestPlayerPosition (vec3_t pos)
|
||||||
/*
|
/*
|
||||||
PM_PlayerMove
|
PM_PlayerMove
|
||||||
*/
|
*/
|
||||||
pmtrace_t
|
trace_t
|
||||||
PM_PlayerMove (vec3_t start, vec3_t end)
|
PM_PlayerMove (vec3_t start, vec3_t end)
|
||||||
{
|
{
|
||||||
pmtrace_t trace, total;
|
trace_t trace, total;
|
||||||
vec3_t offset;
|
vec3_t offset;
|
||||||
vec3_t start_l, end_l;
|
vec3_t start_l, end_l;
|
||||||
hull_t *hull;
|
hull_t *hull;
|
||||||
|
@ -351,10 +333,10 @@ PM_PlayerMove (vec3_t start, vec3_t end)
|
||||||
vec3_t mins, maxs;
|
vec3_t mins, maxs;
|
||||||
|
|
||||||
// fill in a default trace
|
// fill in a default trace
|
||||||
memset (&total, 0, sizeof (pmtrace_t));
|
memset (&total, 0, sizeof (trace_t));
|
||||||
|
|
||||||
total.fraction = 1;
|
total.fraction = 1;
|
||||||
total.ent = -1;
|
total.entnum = -1;
|
||||||
VectorCopy (end, total.endpos);
|
VectorCopy (end, total.endpos);
|
||||||
|
|
||||||
for (i = 0; i < pmove.numphysent; i++) {
|
for (i = 0; i < pmove.numphysent; i++) {
|
||||||
|
@ -365,7 +347,7 @@ PM_PlayerMove (vec3_t start, vec3_t end)
|
||||||
else {
|
else {
|
||||||
VectorSubtract (pe->mins, player_maxs, mins);
|
VectorSubtract (pe->mins, player_maxs, mins);
|
||||||
VectorSubtract (pe->maxs, player_mins, maxs);
|
VectorSubtract (pe->maxs, player_mins, maxs);
|
||||||
hull = PM_HullForBox (mins, maxs);
|
hull = HullForBox (mins, maxs);
|
||||||
}
|
}
|
||||||
|
|
||||||
// PM_HullForEntity (ent, mins, maxs, offset);
|
// PM_HullForEntity (ent, mins, maxs, offset);
|
||||||
|
@ -375,7 +357,7 @@ PM_PlayerMove (vec3_t start, vec3_t end)
|
||||||
VectorSubtract (end, offset, end_l);
|
VectorSubtract (end, offset, end_l);
|
||||||
|
|
||||||
// fill in a default trace
|
// fill in a default trace
|
||||||
memset (&trace, 0, sizeof (pmtrace_t));
|
memset (&trace, 0, sizeof (trace_t));
|
||||||
|
|
||||||
trace.fraction = 1;
|
trace.fraction = 1;
|
||||||
trace.allsolid = true;
|
trace.allsolid = true;
|
||||||
|
@ -383,7 +365,7 @@ PM_PlayerMove (vec3_t start, vec3_t end)
|
||||||
VectorCopy (end, trace.endpos);
|
VectorCopy (end, trace.endpos);
|
||||||
|
|
||||||
// trace a line through the apropriate clipping hull
|
// trace a line through the apropriate clipping hull
|
||||||
PM_RecursiveHullCheck (hull, hull->firstclipnode, 0, 1, start_l, end_l,
|
RecursiveHullCheck (hull, hull->firstclipnode, 0, 1, start_l, end_l,
|
||||||
&trace);
|
&trace);
|
||||||
|
|
||||||
if (trace.allsolid)
|
if (trace.allsolid)
|
||||||
|
@ -396,7 +378,7 @@ PM_PlayerMove (vec3_t start, vec3_t end)
|
||||||
// fix trace up by the offset
|
// fix trace up by the offset
|
||||||
VectorAdd (trace.endpos, offset, trace.endpos);
|
VectorAdd (trace.endpos, offset, trace.endpos);
|
||||||
total = trace;
|
total = trace;
|
||||||
total.ent = i;
|
total.entnum = i;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
261
source/world.c
261
source/world.c
|
@ -52,7 +52,6 @@ line of sight checks trace->crosscontent, but bullets don't
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
vec3_t boxmins, boxmaxs; // enclose the test object along
|
vec3_t boxmins, boxmaxs; // enclose the test object along
|
||||||
// entire move
|
// entire move
|
||||||
|
@ -65,73 +64,14 @@ typedef struct {
|
||||||
edict_t *passedict;
|
edict_t *passedict;
|
||||||
} moveclip_t;
|
} moveclip_t;
|
||||||
|
|
||||||
|
extern qboolean RecursiveHullCheck (hull_t *hull, int num, float p1f, float p2f, vec3_t p1,
|
||||||
|
vec3_t p2, trace_t *trace);
|
||||||
|
|
||||||
int SV_HullPointContents (hull_t *hull, int num, vec3_t p);
|
extern int HullPointContents (hull_t *hull, int num, vec3_t p);
|
||||||
|
|
||||||
/*
|
|
||||||
HULL BOXES
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
static hull_t box_hull;
|
|
||||||
static dclipnode_t box_clipnodes[6];
|
|
||||||
static mplane_t box_planes[6];
|
|
||||||
|
|
||||||
/*
|
|
||||||
SV_InitBoxHull
|
|
||||||
|
|
||||||
Set up the planes and clipnodes so that the six floats of a bounding box
|
|
||||||
can just be stored out and get a proper hull_t structure.
|
|
||||||
*/
|
|
||||||
void
|
|
||||||
SV_InitBoxHull (void)
|
|
||||||
{
|
|
||||||
int i;
|
|
||||||
int side;
|
|
||||||
|
|
||||||
box_hull.clipnodes = box_clipnodes;
|
|
||||||
box_hull.planes = box_planes;
|
|
||||||
box_hull.firstclipnode = 0;
|
|
||||||
box_hull.lastclipnode = 5;
|
|
||||||
|
|
||||||
for (i = 0; i < 6; i++) {
|
|
||||||
box_clipnodes[i].planenum = i;
|
|
||||||
|
|
||||||
side = i & 1;
|
|
||||||
|
|
||||||
box_clipnodes[i].children[side] = CONTENTS_EMPTY;
|
|
||||||
if (i != 5)
|
|
||||||
box_clipnodes[i].children[side ^ 1] = i + 1;
|
|
||||||
else
|
|
||||||
box_clipnodes[i].children[side ^ 1] = CONTENTS_SOLID;
|
|
||||||
|
|
||||||
box_planes[i].type = i >> 1;
|
|
||||||
box_planes[i].normal[i >> 1] = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
SV_HullForBox
|
|
||||||
|
|
||||||
To keep everything totally uniform, bounding boxes are turned into small
|
|
||||||
BSP trees instead of being compared directly.
|
|
||||||
*/
|
|
||||||
hull_t *
|
|
||||||
SV_HullForBox (vec3_t mins, vec3_t maxs)
|
|
||||||
{
|
|
||||||
box_planes[0].dist = maxs[0];
|
|
||||||
box_planes[1].dist = mins[0];
|
|
||||||
box_planes[2].dist = maxs[1];
|
|
||||||
box_planes[3].dist = mins[1];
|
|
||||||
box_planes[4].dist = maxs[2];
|
|
||||||
box_planes[5].dist = mins[2];
|
|
||||||
|
|
||||||
return &box_hull;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
extern void InitBoxHull (void);
|
||||||
|
|
||||||
|
extern hull_t *HullForBox (vec3_t mins, vec3_t maxs);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
SV_HullForEntity
|
SV_HullForEntity
|
||||||
|
@ -176,7 +116,7 @@ SV_HullForEntity (edict_t *ent, vec3_t mins, vec3_t maxs, vec3_t offset)
|
||||||
|
|
||||||
VectorSubtract (ent->v.v.mins, maxs, hullmins);
|
VectorSubtract (ent->v.v.mins, maxs, hullmins);
|
||||||
VectorSubtract (ent->v.v.maxs, mins, hullmaxs);
|
VectorSubtract (ent->v.v.maxs, mins, hullmaxs);
|
||||||
hull = SV_HullForBox (hullmins, hullmaxs);
|
hull = HullForBox (hullmins, hullmaxs);
|
||||||
|
|
||||||
VectorCopy (ent->v.v.origin, offset);
|
VectorCopy (ent->v.v.origin, offset);
|
||||||
}
|
}
|
||||||
|
@ -241,7 +181,7 @@ SV_CreateAreaNode (int depth, vec3_t mins, vec3_t maxs)
|
||||||
void
|
void
|
||||||
SV_ClearWorld (void)
|
SV_ClearWorld (void)
|
||||||
{
|
{
|
||||||
SV_InitBoxHull ();
|
InitBoxHull ();
|
||||||
|
|
||||||
memset (sv_areanodes, 0, sizeof (sv_areanodes));
|
memset (sv_areanodes, 0, sizeof (sv_areanodes));
|
||||||
sv_numareanodes = 0;
|
sv_numareanodes = 0;
|
||||||
|
@ -425,54 +365,13 @@ SV_LinkEdict (edict_t *ent, qboolean touch_triggers)
|
||||||
SV_TouchLinks (ent, sv_areanodes);
|
SV_TouchLinks (ent, sv_areanodes);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
POINT TESTING IN HULLS
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef USE_INTEL_ASM
|
|
||||||
|
|
||||||
/*
|
|
||||||
SV_HullPointContents
|
|
||||||
*/
|
|
||||||
int
|
|
||||||
SV_HullPointContents (hull_t *hull, int num, vec3_t p)
|
|
||||||
{
|
|
||||||
float d;
|
|
||||||
dclipnode_t *node;
|
|
||||||
mplane_t *plane;
|
|
||||||
|
|
||||||
while (num >= 0) {
|
|
||||||
if (num < hull->firstclipnode || num > hull->lastclipnode)
|
|
||||||
SV_Error ("SV_HullPointContents: bad node number");
|
|
||||||
|
|
||||||
node = hull->clipnodes + num;
|
|
||||||
plane = hull->planes + node->planenum;
|
|
||||||
|
|
||||||
if (plane->type < 3)
|
|
||||||
d = p[plane->type] - plane->dist;
|
|
||||||
else
|
|
||||||
d = DotProduct (plane->normal, p) - plane->dist;
|
|
||||||
if (d < 0)
|
|
||||||
num = node->children[1];
|
|
||||||
else
|
|
||||||
num = node->children[0];
|
|
||||||
}
|
|
||||||
|
|
||||||
return num;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif // !USE_INTEL_ASM
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
SV_PointContents
|
SV_PointContents
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
SV_PointContents (vec3_t p)
|
SV_PointContents (vec3_t p)
|
||||||
{
|
{
|
||||||
return SV_HullPointContents (&sv.worldmodel->hulls[0], 0, p);
|
return HullPointContents (&sv.worldmodel->hulls[0], 0, p);
|
||||||
}
|
}
|
||||||
|
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
|
@ -498,144 +397,6 @@ SV_TestEntityPosition (edict_t *ent)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
LINE TESTING IN HULLS
|
|
||||||
*/
|
|
||||||
|
|
||||||
// 1/32 epsilon to keep floating point happy
|
|
||||||
#define DIST_EPSILON (0.03125)
|
|
||||||
|
|
||||||
/*
|
|
||||||
SV_RecursiveHullCheck
|
|
||||||
*/
|
|
||||||
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)
|
|
||||||
SV_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) {
|
|
||||||
Con_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);
|
|
||||||
Con_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;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
SV_ClipMoveToEntity
|
SV_ClipMoveToEntity
|
||||||
|
@ -666,7 +427,7 @@ SV_ClipMoveToEntity (edict_t *ent, vec3_t start, vec3_t mins, vec3_t maxs,
|
||||||
VectorSubtract (end, offset, end_l);
|
VectorSubtract (end, offset, end_l);
|
||||||
|
|
||||||
// trace a line through the apropriate clipping hull
|
// trace a line through the apropriate clipping hull
|
||||||
SV_RecursiveHullCheck (hull, hull->firstclipnode, 0, 1, start_l, end_l,
|
RecursiveHullCheck (hull, hull->firstclipnode, 0, 1, start_l, end_l,
|
||||||
&trace);
|
&trace);
|
||||||
|
|
||||||
// fix trace up by the offset
|
// fix trace up by the offset
|
||||||
|
@ -844,7 +605,7 @@ SV_TestPlayerPosition (edict_t *ent, vec3_t origin)
|
||||||
|
|
||||||
// check world first
|
// check world first
|
||||||
hull = &sv.worldmodel->hulls[1];
|
hull = &sv.worldmodel->hulls[1];
|
||||||
if (SV_HullPointContents (hull, hull->firstclipnode, origin) !=
|
if (HullPointContents (hull, hull->firstclipnode, origin) !=
|
||||||
CONTENTS_EMPTY) return sv.edicts;
|
CONTENTS_EMPTY) return sv.edicts;
|
||||||
|
|
||||||
// check all entities
|
// check all entities
|
||||||
|
@ -876,7 +637,7 @@ SV_TestPlayerPosition (edict_t *ent, vec3_t origin)
|
||||||
VectorSubtract (origin, offset, offset);
|
VectorSubtract (origin, offset, offset);
|
||||||
|
|
||||||
// test the point
|
// test the point
|
||||||
if (SV_HullPointContents (hull, hull->firstclipnode, offset) !=
|
if (HullPointContents (hull, hull->firstclipnode, offset) !=
|
||||||
CONTENTS_EMPTY) return check;
|
CONTENTS_EMPTY) return check;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue