From 6f53a7389f176401a73b425e366498ea6a22f9fd Mon Sep 17 00:00:00 2001 From: havoc Date: Sun, 28 Dec 2003 01:05:40 +0000 Subject: [PATCH] fixed fiends jumping through player bug, huge thanks to Tomaz for days of help tracking down this longstanding bug! (it supported rotated collisions with bbox entities - not good!) refined the COLLISIONPARANOID checks (now centralized in SV_Move) git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@3758 d7cf8633-e32d-0410-b094-e92efae38249 --- sv_move.c | 17 ----------------- sv_phys.c | 36 +----------------------------------- todo | 3 ++- world.c | 50 +++++++++++++++++++++++++++++++++++++------------- 4 files changed, 40 insertions(+), 66 deletions(-) diff --git a/sv_move.c b/sv_move.c index c7053c22..9fc5b31d 100644 --- a/sv_move.c +++ b/sv_move.c @@ -134,23 +134,6 @@ 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 COLLISIONPARANOID >= 1 - { - int endstuck; - vec3_t temp; - VectorCopy(trace.endpos, temp); - endstuck = SV_Move(temp, ent->v->mins, ent->v->maxs, temp, MOVE_WORLDONLY, ent).startsolid; -#if COLLISIONPARANOID < 2 - if (trace.startsolid || endstuck) -#endif - { - Con_Printf("%s{e%i:%f %f %f:%f %f %f:%f:%f %f %f%s%s}\n", (trace.startsolid || endstuck) ? "\002" : "", ent - sv.edicts, ent->v->origin[0], ent->v->origin[1], ent->v->origin[2], neworg[0] - ent->v->origin[0], neworg[1] - ent->v->origin[1], neworg[2] - ent->v->origin[2], trace.fraction, trace.endpos[0] - ent->v->origin[0], trace.endpos[1] - ent->v->origin[1], trace.endpos[2] - ent->v->origin[2], trace.startsolid ? " startstuck" : "", endstuck ? " endstuck" : ""); - //Con_Printf("trace %f %f %f : %f : %f %f %f\n", trace.endpos[0], trace.endpos[1], trace.endpos[2], trace.fraction, trace.plane.normal[0], trace.plane.normal[1], trace.plane.normal[2]); - if (endstuck) - Cbuf_AddText("disconnect\n"); - } - } -#endif if (trace.fraction == 1) { diff --git a/sv_phys.c b/sv_phys.c index a69f2783..4de751be 100644 --- a/sv_phys.c +++ b/sv_phys.c @@ -247,23 +247,6 @@ int SV_FlyMove (edict_t *ent, float time, float *stepnormal) VectorMA(ent->v->origin, time, ent->v->velocity, end); trace = SV_Move (ent->v->origin, ent->v->mins, ent->v->maxs, end, MOVE_NORMAL, ent); //Con_Printf("trace %f %f %f : %f : %f %f %f\n", trace.endpos[0], trace.endpos[1], trace.endpos[2], trace.fraction, trace.plane.normal[0], trace.plane.normal[1], trace.plane.normal[2]); -#if COLLISIONPARANOID >= 1 - { - int endstuck; - vec3_t temp; - VectorCopy(trace.endpos, temp); - endstuck = SV_Move(temp, ent->v->mins, ent->v->maxs, temp, MOVE_WORLDONLY, ent).startsolid; -#if COLLISIONPARANOID < 2 - if (trace.startsolid || endstuck) -#endif - { - Con_Printf("%s{e%i:%i:%f %f %f:%f %f %f:%f:%f %f %f%s%s}\n", (trace.startsolid || endstuck) ? "\002" : "", ent - sv.edicts, bumpcount, ent->v->origin[0], ent->v->origin[1], ent->v->origin[2], end[0] - ent->v->origin[0], end[1] - ent->v->origin[1], end[2] - ent->v->origin[2], trace.fraction, trace.endpos[0] - ent->v->origin[0], trace.endpos[1] - ent->v->origin[1], trace.endpos[2] - ent->v->origin[2], trace.startsolid ? " startstuck" : "", endstuck ? " endstuck" : ""); - //Con_Printf("trace %f %f %f : %f : %f %f %f\n", trace.endpos[0], trace.endpos[1], trace.endpos[2], trace.fraction, trace.plane.normal[0], trace.plane.normal[1], trace.plane.normal[2]); - if (endstuck) - Cbuf_AddText("disconnect\n"); - } - } -#endif /* if (trace.startsolid) @@ -536,30 +519,13 @@ trace_t SV_PushEntity (edict_t *ent, vec3_t push, vec3_t pushangles) trace = SV_Move (ent->v->origin, ent->v->mins, ent->v->maxs, end, MOVE_NOMONSTERS, ent); else trace = SV_Move (ent->v->origin, ent->v->mins, ent->v->maxs, end, MOVE_NORMAL, ent); -#if COLLISIONPARANOID >= 1 - { - int endstuck; - vec3_t temp; - VectorCopy(trace.endpos, temp); - endstuck = SV_Move(temp, ent->v->mins, ent->v->maxs, temp, MOVE_WORLDONLY, ent).startsolid; -#if COLLISIONPARANOID < 2 - if (trace.startsolid || endstuck) -#endif - { - Con_Printf("%s{e%i:%f %f %f:%f %f %f:%f:%f %f %f%s%s}\n", (trace.startsolid || endstuck) ? "\002" : "", ent - sv.edicts, ent->v->origin[0], ent->v->origin[1], ent->v->origin[2], end[0] - ent->v->origin[0], end[1] - ent->v->origin[1], end[2] - ent->v->origin[2], trace.fraction, trace.endpos[0] - ent->v->origin[0], trace.endpos[1] - ent->v->origin[1], trace.endpos[2] - ent->v->origin[2], trace.startsolid ? " startstuck" : "", endstuck ? " endstuck" : ""); - //Con_Printf("trace %f %f %f : %f : %f %f %f\n", trace.endpos[0], trace.endpos[1], trace.endpos[2], trace.fraction, trace.plane.normal[0], trace.plane.normal[1], trace.plane.normal[2]); - if (endstuck) - Cbuf_AddText("disconnect\n"); - } - } -#endif VectorCopy (trace.endpos, ent->v->origin); // FIXME: turn players specially ent->v->angles[1] += trace.fraction * pushangles[1]; SV_LinkEdict (ent, true); - if (trace.fraction < 1 && trace.ent && (!((int)ent->v->flags & FL_ONGROUND) || ent->v->groundentity != EDICT_TO_PROG(trace.ent))) + if (trace.ent && (!((int)ent->v->flags & FL_ONGROUND) || ent->v->groundentity != EDICT_TO_PROG(trace.ent))) SV_Impact (ent, trace.ent); return trace; } diff --git a/todo b/todo index af48400d..06748d5f 100644 --- a/todo +++ b/todo @@ -35,6 +35,7 @@ -n darkplaces: server is starting before the "port" cvar is set by commandline and scripts? (yummyluv) -n darkplaces: typing ip in join game menu should show 'trying' and 'no response' after a while, or 'no network' if networking is not initialized (yummyluv) -n dpmod: make grapple off-hand (joe hill) +0 darkplaces: mini scoreboard (the deathmatch overlay) shows player names multiple times in some cases? 4 darkplaces: add qw protocol support (making darkplaces work as a qwcl client) (tell Fuh) 0 darkplaces: add some cl_explosions_ cvars to control settings - start alpha, end alpha, start size, end size, life time (Supajoe, Mercury) 0 darkplaces: "edict -1" and other invalid numbers cause an error, should just complain (Supajoe) @@ -42,7 +43,7 @@ 0 darkplaces: change sky handling to draw sky even if fog is on (Deej, C0burn) 3 darkplaces: redesign startup script handling to simply stop execution until video inits, when it encounters certain commands (instead of delaying those commands) d darkplaces: physics bug: rotating bmodels stop when the player blocks them instead of pushing the player -0 darkplaces: physics bug: fiends can leap through the player +d darkplaces: physics bug: fiends can leap through the player (thanks to Tomaz for massive assistance in tracking down this longstanding bug) -n darkplaces: physics bug: bmodels (doors, etc) hurt player if player pushes against it, and sometimes gets stuck for a frame when falling onto it (Andrew A. Gilevsky) 0 darkplaces: add gl_polyblend cvar to control amount of viewblend effect (Andrew A. Gilevsky) 0 darkplaces: add r_waterwarp cvar to control amount of viewwarping underwater (Andrew A. Gilevsky) diff --git a/world.c b/world.c index 074590c7..a8885886 100644 --- a/world.c +++ b/world.c @@ -478,9 +478,11 @@ trace_t SV_ClipMoveToEntity(edict_t *ent, const vec3_t start, const vec3_t mins, if (ent->v->movetype != MOVETYPE_PUSH) Host_Error("SV_ClipMoveToEntity: SOLID_BSP without MOVETYPE_PUSH"); } + Matrix4x4_CreateFromQuakeEntity(&matrix, ent->v->origin[0], ent->v->origin[1], ent->v->origin[2], ent->v->angles[0], ent->v->angles[1], ent->v->angles[2], 1); } + else + Matrix4x4_CreateTranslate(&matrix, ent->v->origin[0], ent->v->origin[1], ent->v->origin[2]); - Matrix4x4_CreateFromQuakeEntity(&matrix, ent->v->origin[0], ent->v->origin[1], ent->v->origin[2], ent->v->angles[0], ent->v->angles[1], ent->v->angles[2], 1); Matrix4x4_Invert_Simple(&imatrix, &matrix); Matrix4x4_Transform(&imatrix, start, starttransformed); Matrix4x4_Transform(&imatrix, end, endtransformed); @@ -502,9 +504,8 @@ trace_t SV_ClipMoveToEntity(edict_t *ent, const vec3_t start, const vec3_t mins, else Collision_ClipTrace_Box(&trace, ent->v->mins, ent->v->maxs, starttransformed, mins, maxs, endtransformed, SUPERCONTENTS_SOLID, SUPERCONTENTS_SOLID); - if (trace.fraction < 1 || trace.startsolid) + if (trace.fraction < 1) { - trace.ent = ent; VectorLerp(start, trace.fraction, end, trace.endpos); VectorCopy(trace.plane.normal, tempnormal); Matrix4x4_Transform3x3(&matrix, tempnormal, trace.plane.normal); @@ -534,6 +535,8 @@ void SV_ClipToNode(moveclip_t *clip, link_t *list) touch->e->areagridmarknumber = sv_areagrid_marknumber; sv_areagrid_stats_entitychecks++; + // LordHavoc: this box comparison isn't much use with the high resolution areagrid + /* if (clip->boxmins[0] > touch->v->absmax[0] || clip->boxmaxs[0] < touch->v->absmin[0] || clip->boxmins[1] > touch->v->absmax[1] @@ -541,6 +544,7 @@ void SV_ClipToNode(moveclip_t *clip, link_t *list) || clip->boxmins[2] > touch->v->absmax[2] || clip->boxmaxs[2] < touch->v->absmin[2]) continue; + */ if (clip->type == MOVE_NOMONSTERS && touch->v->solid != SOLID_BSP) continue; @@ -550,6 +554,8 @@ void SV_ClipToNode(moveclip_t *clip, link_t *list) if (clip->passedict) { + if (touch == clip->passedict) + continue; if (!clip->passedict->v->size[0] && !touch->v->size[0]) continue; // points never interact if (PROG_TO_EDICT(touch->v->owner) == clip->passedict) @@ -563,8 +569,6 @@ void SV_ClipToNode(moveclip_t *clip, link_t *list) continue; } - if (touch == clip->passedict) - continue; if (touch->v->solid == SOLID_TRIGGER) { ED_Print(touch); @@ -572,9 +576,7 @@ void SV_ClipToNode(moveclip_t *clip, link_t *list) } // might interact, so do an exact clip - if (touch->v->solid == SOLID_BSP) - trace = SV_ClipMoveToEntity(touch, clip->start, clip->mins, clip->maxs, clip->end, clip->type); - else if ((int)touch->v->flags & FL_MONSTER) + if ((int)touch->v->flags & FL_MONSTER) trace = SV_ClipMoveToEntity(touch, clip->start, clip->mins2, clip->maxs2, clip->end, clip->type); else trace = SV_ClipMoveToEntity(touch, clip->start, clip->mins, clip->maxs, clip->end, clip->type); @@ -584,8 +586,8 @@ void SV_ClipToNode(moveclip_t *clip, link_t *list) if (trace.startsolid) { clip->trace.startsolid = true; - //if (!clip->trace.ent) - // clip->trace.ent = trace.ent; + if (clip->trace.fraction == 1) + clip->trace.ent = touch; } if (trace.inopen) clip->trace.inopen = true; @@ -599,8 +601,6 @@ void SV_ClipToNode(moveclip_t *clip, link_t *list) clip->trace.ent = touch; } clip->trace.startsupercontents |= trace.startsupercontents; - //if (clip->trace.allsolid) - // return; } } @@ -609,7 +609,11 @@ void SV_ClipToNode(moveclip_t *clip, link_t *list) SV_Move ================== */ +#if COLLISIONPARANOID >= 1 +trace_t SV_Move_(const vec3_t start, const vec3_t mins, const vec3_t maxs, const vec3_t end, int type, edict_t *passedict) +#else trace_t SV_Move(const vec3_t start, const vec3_t mins, const vec3_t maxs, const vec3_t end, int type, edict_t *passedict) +#endif { moveclip_t clip; vec3_t hullmins, hullmaxs; @@ -632,8 +636,8 @@ trace_t SV_Move(const vec3_t start, const vec3_t mins, const vec3_t maxs, const // clip to world clip.trace = SV_ClipMoveToEntity(sv.edicts, clip.start, clip.mins, clip.maxs, clip.end, clip.type); + clip.trace.ent = sv.edicts; if (clip.type == MOVE_WORLDONLY) - //if (clip.trace.allsolid) return clip.trace; if (clip.type == MOVE_MISSILE) @@ -696,6 +700,26 @@ trace_t SV_Move(const vec3_t start, const vec3_t mins, const vec3_t maxs, const return clip.trace; } +#if COLLISIONPARANOID >= 1 +trace_t SV_Move(const vec3_t start, const vec3_t mins, const vec3_t maxs, const vec3_t end, int type, edict_t *passedict) +{ + int endstuck; + trace_t trace; + vec3_t temp; + trace = SV_Move_(start, mins, maxs, end, type, passedict); + if (passedict) + { + VectorCopy(trace.endpos, temp); + endstuck = SV_Move_(temp, mins, maxs, temp, type, passedict).startsolid; +#if COLLISIONPARANOID < 3 + if (trace.startsolid || endstuck) +#endif + Con_Printf("%s{e%i:%f %f %f:%f %f %f:%f:%f %f %f%s%s}\n", (trace.startsolid || endstuck) ? "\002" : "", passedict ? passedict - sv.edicts : -1, passedict->v->origin[0], passedict->v->origin[1], passedict->v->origin[2], end[0] - passedict->v->origin[0], end[1] - passedict->v->origin[1], end[2] - passedict->v->origin[2], trace.fraction, trace.endpos[0] - passedict->v->origin[0], trace.endpos[1] - passedict->v->origin[1], trace.endpos[2] - passedict->v->origin[2], trace.startsolid ? " startstuck" : "", endstuck ? " endstuck" : ""); + } + return trace; +} +#endif + int SV_PointSuperContents(const vec3_t point) { return SV_Move(point, vec3_origin, vec3_origin, point, MOVE_NOMONSTERS, NULL).startsupercontents; -- 2.39.2