From 0274730929c3c06d40a0bd18a7d2ea3af7ab5f4d Mon Sep 17 00:00:00 2001 From: havoc Date: Mon, 19 Feb 2007 05:53:32 +0000 Subject: [PATCH] fix broken SOLID_CORPSE collisions git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@6866 d7cf8633-e32d-0410-b094-e92efae38249 --- cl_collision.c | 14 +++++++++----- sv_phys.c | 20 +++++++++++++------- 2 files changed, 22 insertions(+), 12 deletions(-) diff --git a/cl_collision.c b/cl_collision.c index 82aa3cec..0dae92c9 100644 --- a/cl_collision.c +++ b/cl_collision.c @@ -156,7 +156,7 @@ extern cvar_t sv_debugmove; trace_t CL_Move(const vec3_t start, const vec3_t mins, const vec3_t maxs, const vec3_t end, int type, prvm_edict_t *passedict, int hitsupercontentsmask, qboolean hitnetworkbrushmodels, qboolean hitnetworkplayers, int *hitnetworkentity, qboolean hitcsqcentities) { vec3_t hullmins, hullmaxs; - int i; + int i, bodysupercontents; int passedictprog; qboolean pointtrace; prvm_edict_t *traceowner, *touch; @@ -325,6 +325,8 @@ trace_t CL_Move(const vec3_t start, const vec3_t mins, const vec3_t maxs, const continue; } + bodysupercontents = touch->fields.client->solid == SOLID_CORPSE ? SUPERCONTENTS_CORPSE : SUPERCONTENTS_BODY; + // might interact, so do an exact clip model = NULL; if ((int) touch->fields.client->solid == SOLID_BSP || type == MOVE_HITMODEL) @@ -332,16 +334,18 @@ trace_t CL_Move(const vec3_t start, const vec3_t mins, const vec3_t maxs, const unsigned int modelindex = (unsigned int)touch->fields.client->modelindex; // if the modelindex is 0, it shouldn't be SOLID_BSP! if (modelindex > 0 && modelindex < MAX_MODELS) - model = CL_GetModelByIndex((int)touch->fields.client->modelindex); - Matrix4x4_CreateFromQuakeEntity(&matrix, touch->fields.client->origin[0], touch->fields.client->origin[1], touch->fields.client->origin[2], touch->fields.client->angles[0], touch->fields.client->angles[1], touch->fields.client->angles[2], 1); + model = sv.models[(int)touch->fields.client->modelindex]; } + if (model) + Matrix4x4_CreateFromQuakeEntity(&matrix, touch->fields.client->origin[0], touch->fields.client->origin[1], touch->fields.client->origin[2], touch->fields.client->angles[0], touch->fields.client->angles[1], touch->fields.client->angles[2], 1); else Matrix4x4_CreateTranslate(&matrix, touch->fields.client->origin[0], touch->fields.client->origin[1], touch->fields.client->origin[2]); Matrix4x4_Invert_Simple(&imatrix, &matrix); if ((int)touch->fields.client->flags & FL_MONSTER) - Collision_ClipToGenericEntity(&trace, model, touch->fields.client->frame, touch->fields.client->mins, touch->fields.client->maxs, SUPERCONTENTS_BODY, &matrix, &imatrix, clipstart, clipmins2, clipmaxs2, clipend, hitsupercontentsmask); + Collision_ClipToGenericEntity(&trace, model, touch->fields.client->frame, touch->fields.client->mins, touch->fields.client->maxs, bodysupercontents, &matrix, &imatrix, clipstart, clipmins2, clipmaxs2, clipend, hitsupercontentsmask); else - Collision_ClipToGenericEntity(&trace, model, touch->fields.client->frame, touch->fields.client->mins, touch->fields.client->maxs, SUPERCONTENTS_BODY, &matrix, &imatrix, clipstart, clipmins, clipmaxs, clipend, hitsupercontentsmask); + Collision_ClipToGenericEntity(&trace, model, touch->fields.client->frame, touch->fields.client->mins, touch->fields.client->maxs, bodysupercontents, &matrix, &imatrix, clipstart, clipmins, clipmaxs, clipend, hitsupercontentsmask); + if (cliptrace.realfraction > trace.realfraction && hitnetworkentity) *hitnetworkentity = 0; Collision_CombineTraces(&cliptrace, &trace, (void *)touch, touch->fields.client->solid == SOLID_BSP); diff --git a/sv_phys.c b/sv_phys.c index f85429b4..3a02f1e4 100644 --- a/sv_phys.c +++ b/sv_phys.c @@ -121,7 +121,7 @@ trace_t SV_Move(const vec3_t start, const vec3_t mins, const vec3_t maxs, const #endif { vec3_t hullmins, hullmaxs; - int i; + int i, bodysupercontents; int passedictprog; qboolean pointtrace; prvm_edict_t *traceowner, *touch; @@ -240,6 +240,8 @@ trace_t SV_Move(const vec3_t start, const vec3_t mins, const vec3_t maxs, const continue; } + bodysupercontents = touch->fields.server->solid == SOLID_CORPSE ? SUPERCONTENTS_CORPSE : SUPERCONTENTS_BODY; + // might interact, so do an exact clip model = NULL; if ((int) touch->fields.server->solid == SOLID_BSP || type == MOVE_HITMODEL) @@ -248,15 +250,17 @@ trace_t SV_Move(const vec3_t start, const vec3_t mins, const vec3_t maxs, const // if the modelindex is 0, it shouldn't be SOLID_BSP! if (modelindex > 0 && modelindex < MAX_MODELS) model = sv.models[(int)touch->fields.server->modelindex]; - Matrix4x4_CreateFromQuakeEntity(&matrix, touch->fields.server->origin[0], touch->fields.server->origin[1], touch->fields.server->origin[2], touch->fields.server->angles[0], touch->fields.server->angles[1], touch->fields.server->angles[2], 1); } + if (model) + Matrix4x4_CreateFromQuakeEntity(&matrix, touch->fields.server->origin[0], touch->fields.server->origin[1], touch->fields.server->origin[2], touch->fields.server->angles[0], touch->fields.server->angles[1], touch->fields.server->angles[2], 1); else Matrix4x4_CreateTranslate(&matrix, touch->fields.server->origin[0], touch->fields.server->origin[1], touch->fields.server->origin[2]); Matrix4x4_Invert_Simple(&imatrix, &matrix); if ((int)touch->fields.server->flags & FL_MONSTER) - Collision_ClipToGenericEntity(&trace, model, touch->fields.server->frame, touch->fields.server->mins, touch->fields.server->maxs, SUPERCONTENTS_BODY, &matrix, &imatrix, clipstart, clipmins2, clipmaxs2, clipend, hitsupercontentsmask); + Collision_ClipToGenericEntity(&trace, model, touch->fields.server->frame, touch->fields.server->mins, touch->fields.server->maxs, bodysupercontents, &matrix, &imatrix, clipstart, clipmins2, clipmaxs2, clipend, hitsupercontentsmask); else - Collision_ClipToGenericEntity(&trace, model, touch->fields.server->frame, touch->fields.server->mins, touch->fields.server->maxs, SUPERCONTENTS_BODY, &matrix, &imatrix, clipstart, clipmins, clipmaxs, clipend, hitsupercontentsmask); + Collision_ClipToGenericEntity(&trace, model, touch->fields.server->frame, touch->fields.server->mins, touch->fields.server->maxs, bodysupercontents, &matrix, &imatrix, clipstart, clipmins, clipmaxs, clipend, hitsupercontentsmask); + Collision_CombineTraces(&cliptrace, &trace, (void *)touch, touch->fields.server->solid == SOLID_BSP); } @@ -1527,7 +1531,7 @@ Only used by players */ void SV_WalkMove (prvm_edict_t *ent) { - int clip, oldonground, originalmove_clip, originalmove_flags, originalmove_groundentity; + int clip, oldonground, originalmove_clip, originalmove_flags, originalmove_groundentity, hitsupercontentsmask; vec3_t upmove, downmove, start_origin, start_velocity, stepnormal, originalmove_origin, originalmove_velocity; trace_t downtrace; @@ -1536,6 +1540,8 @@ void SV_WalkMove (prvm_edict_t *ent) if (sv.frametime <= 0) return; + hitsupercontentsmask = SV_GenericHitSuperContentsMask(ent); + SV_CheckVelocity(ent); // do a regular slide move unless it looks like you ran into a step @@ -1545,7 +1551,7 @@ void SV_WalkMove (prvm_edict_t *ent) VectorCopy (ent->fields.server->origin, start_origin); VectorCopy (ent->fields.server->velocity, start_velocity); - clip = SV_FlyMove (ent, sv.frametime, NULL, SV_GenericHitSuperContentsMask(ent)); + clip = SV_FlyMove (ent, sv.frametime, NULL, hitsupercontentsmask); SV_CheckVelocity(ent); @@ -1593,7 +1599,7 @@ void SV_WalkMove (prvm_edict_t *ent) // move forward ent->fields.server->velocity[2] = 0; - clip = SV_FlyMove (ent, sv.frametime, stepnormal, SV_GenericHitSuperContentsMask(ent)); + clip = SV_FlyMove (ent, sv.frametime, stepnormal, hitsupercontentsmask); ent->fields.server->velocity[2] += start_velocity[2]; SV_CheckVelocity(ent); -- 2.39.2