From 0af9cf1a9e956711edbee4b8710a458dc532985b Mon Sep 17 00:00:00 2001 From: lordhavoc Date: Fri, 15 Feb 2002 21:25:43 +0000 Subject: [PATCH] double precision RecursiveHullCheck git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@1517 d7cf8633-e32d-0410-b094-e92efae38249 --- sv_main.c | 9 ++++++--- sv_move.c | 17 +++++++++-------- world.h | 45 +++++++++++++++++++++++++++------------------ 3 files changed, 42 insertions(+), 29 deletions(-) diff --git a/sv_main.c b/sv_main.c index ff6f0fa5..34ac5460 100644 --- a/sv_main.c +++ b/sv_main.c @@ -503,18 +503,21 @@ void SV_WriteEntitiesToClient (client_t *client, edict_t *clent, sizebuf_t *msg) int e, clentnum, bits, alpha, glowcolor, glowsize, scale, effects; int culled_pvs, culled_portal, culled_trace, visibleentities, totalentities; byte *pvs; - vec3_t org, origin, angles, entmins, entmaxs, testorigin; + vec3_t org, origin, angles, entmins, entmaxs; float nextfullupdate; edict_t *ent; eval_t *val; entity_state_t *baseline; // LordHavoc: delta or startup baseline trace_t trace; model_t *model; + double testeye[3]; + double testorigin[3]; Mod_CheckLoaded(sv.worldmodel); // find the client's PVS VectorAdd (clent->v.origin, clent->v.view_ofs, org); + VectorCopy (org, testeye); pvs = SV_FatPVS (org); /* // dp protocol @@ -660,10 +663,10 @@ void SV_WriteEntitiesToClient (client_t *client, edict_t *clent, sizebuf_t *msg) VectorCopy(testorigin, trace.endpos); VectorCopy(org, RecursiveHullCheckInfo.start); - VectorSubtract(testorigin, org, RecursiveHullCheckInfo.dist); + VectorSubtract(testorigin, testeye, RecursiveHullCheckInfo.dist); RecursiveHullCheckInfo.hull = sv.worldmodel->hulls; RecursiveHullCheckInfo.trace = &trace; - SV_RecursiveHullCheck (sv.worldmodel->hulls->firstclipnode, 0, 1, org, testorigin); + SV_RecursiveHullCheck (sv.worldmodel->hulls->firstclipnode, 0, 1, testeye, testorigin); if (trace.fraction == 1) client->lastvisible[e] = realtime; diff --git a/sv_move.c b/sv_move.c index 382c9a08..4462519b 100644 --- a/sv_move.c +++ b/sv_move.c @@ -110,12 +110,12 @@ pr_global_struct->trace_normal is set to the normal of the blocking wall qboolean SV_movestep (edict_t *ent, vec3_t move, qboolean relink) { float dz; - vec3_t oldorg, neworg, end; + vec3_t oldorg, neworg, end, traceendpos; trace_t trace; int i; edict_t *enemy; -// try the move +// try the move VectorCopy (ent->v.origin, oldorg); VectorAdd (ent->v.origin, move, neworg); @@ -136,22 +136,23 @@ qboolean SV_movestep (edict_t *ent, vec3_t move, qboolean relink) neworg[2] += 8; } trace = SV_Move (ent->v.origin, ent->v.mins, ent->v.maxs, neworg, MOVE_NORMAL, ent); - + if (trace.fraction == 1) { - if ( ((int)ent->v.flags & FL_SWIM) && SV_PointContents(trace.endpos) == CONTENTS_EMPTY ) + VectorCopy(trace.endpos, traceendpos); + if ( ((int)ent->v.flags & FL_SWIM) && SV_PointContents(traceendpos) == CONTENTS_EMPTY ) return false; // swim monster left water - - VectorCopy (trace.endpos, ent->v.origin); + + VectorCopy (traceendpos, ent->v.origin); if (relink) SV_LinkEdict (ent, true); return true; } - + if (enemy == sv.edicts) break; } - + return false; } diff --git a/world.h b/world.h index 55838dca..db8b5ca8 100644 --- a/world.h +++ b/world.h @@ -27,17 +27,30 @@ typedef struct typedef struct { - qboolean allsolid; // if true, plane is not valid - qboolean startsolid; // if true, the initial point was in a solid area - qboolean inopen, inwater; - float fraction; // time completed, 1.0 = didn't hit anything - vec3_t endpos; // final position - plane_t plane; // surface normal at impact - edict_t *ent; // entity the surface is on - int startcontents; // if not zero, treats this value as empty, and - // all others as solid (impact on content change) - int endcontents; // set to the contents that was hit at the end point -} trace_t; + // if true, the entire trace was in solid + qboolean allsolid; + // if true, the initial point was in solid + qboolean startsolid; + // if true, the trace passed through empty somewhere + qboolean inopen; + // if true, the trace passed through water somewhere + qboolean inwater; + // fraction of the total distance that was traveled before impact + // (1.0 = did not hit anything) + double fraction; + // final position + double endpos[3]; + // surface normal at impact + plane_t plane; + // entity the surface is on + edict_t *ent; + // if not zero, treats this value as empty, and all others as solid (impact + // on content change) + int startcontents; + // the contents that was hit at the end or impact point + int endcontents; +} +trace_t; #define MOVE_NORMAL 0 @@ -82,21 +95,17 @@ trace_t SV_Move (vec3_t start, vec3_t mins, vec3_t maxs, vec3_t end, int type, e // passedict is explicitly excluded from clipping checks (normally NULL) -int SV_RecursiveHullCheck (int num, float p1f, float p2f, vec3_t p1, vec3_t p2); +int SV_RecursiveHullCheck (int num, double p1f, double p2f, double p1[3], double p2[3]); typedef struct { hull_t *hull; trace_t *trace; - vec3_t start; - vec3_t dist; + double start[3]; + double dist[3]; } RecursiveHullCheckTraceInfo_t; // LordHavoc: FIXME: this is not thread safe, if threading matters here, pass // this as a struct to RecursiveHullCheck, RecursiveHullCheck_Impact, etc... extern RecursiveHullCheckTraceInfo_t RecursiveHullCheckInfo; - -// optimized variant of RecursiveHullCheck that only returns success/failure -// FIXME: broken, fix it -//extern qboolean SV_TestLine (hull_t *hull, int num, vec3_t p1, vec3_t p2); -- 2.39.2