Forgot to actually check the hitcontents.

This commit is contained in:
Shpoike 2021-03-06 06:04:42 +00:00
parent 58261f7580
commit e0cc588ca3
2 changed files with 21 additions and 23 deletions

View file

@ -624,6 +624,7 @@ enum
}; };
struct rhtctx_s struct rhtctx_s
{ {
unsigned int hitcontents;
vec3_t start, end; vec3_t start, end;
mclipnode_t *clipnodes; mclipnode_t *clipnodes;
mplane_t *planes; mplane_t *planes;
@ -661,7 +662,7 @@ reenter:
{ {
/*hit a leaf*/ /*hit a leaf*/
trace->contents = num; trace->contents = num;
if (num == CONTENTS_SOLID) if (ctx->hitcontents & CONTENTMASK_FROMQ1(num))
{ {
if (trace->allsolid) if (trace->allsolid)
trace->startsolid = true; trace->startsolid = true;
@ -672,7 +673,7 @@ reenter:
trace->allsolid = false; trace->allsolid = false;
if (num == CONTENTS_EMPTY) if (num == CONTENTS_EMPTY)
trace->inopen = true; trace->inopen = true;
else else if (num != CONTENTS_SOLID)
trace->inwater = true; trace->inwater = true;
return rht_empty; return rht_empty;
} }
@ -768,26 +769,22 @@ SV_RecursiveHullCheck
Decides if its a simple point test, or does a slightly more expensive check. Decides if its a simple point test, or does a slightly more expensive check.
================== ==================
*/ */
qboolean SV_RecursiveHullCheck (hull_t *hull, int num, float p1f, float p2f, vec3_t p1, vec3_t p2, trace_t *trace) qboolean SV_RecursiveHullCheck (hull_t *hull, vec3_t p1, vec3_t p2, trace_t *trace, unsigned int hitcontents)
{ {
if (p1[0]==p2[0] && p1[1]==p2[1] && p1[2]==p2[2]) if (p1[0]==p2[0] && p1[1]==p2[1] && p1[2]==p2[2])
{ {
/*points cannot cross planes, so do it faster*/ /*points cannot cross planes, so do it faster*/
int c = SV_HullPointContents(hull, num, p1); int c = SV_HullPointContents(hull, hull->firstclipnode, p1);
trace->contents = c; trace->contents = c;
switch(c) if (hitcontents & CONTENTMASK_FROMQ1(c))
{
case CONTENTS_SOLID:
trace->startsolid = true; trace->startsolid = true;
break; else
case CONTENTS_EMPTY: {
trace->allsolid = false; trace->allsolid = false;
if (c == CONTENTS_EMPTY)
trace->inopen = true; trace->inopen = true;
break; else if (c != CONTENTS_SOLID)
default:
trace->allsolid = false;
trace->inwater = true; trace->inwater = true;
break;
} }
return true; return true;
} }
@ -798,7 +795,8 @@ qboolean SV_RecursiveHullCheck (hull_t *hull, int num, float p1f, float p2f, vec
VectorCopy(p2, ctx.end); VectorCopy(p2, ctx.end);
ctx.clipnodes = hull->clipnodes; ctx.clipnodes = hull->clipnodes;
ctx.planes = hull->planes; ctx.planes = hull->planes;
return Q1BSP_RecursiveHullTrace(&ctx, num, p1f, p2f, p1, p2, trace) != rht_impact; ctx.hitcontents = hitcontents;
return Q1BSP_RecursiveHullTrace(&ctx, hull->firstclipnode, 0, 1, p1, p2, trace) != rht_impact;
} }
} }
@ -842,7 +840,7 @@ trace_t SV_ClipMoveToEntity (edict_t *ent, vec3_t start, vec3_t mins, vec3_t max
end_r[0] = DotProduct(end_l, axis[0]); end_r[0] = DotProduct(end_l, axis[0]);
end_r[1] = DotProduct(end_l, axis[1]); end_r[1] = DotProduct(end_l, axis[1]);
end_r[2] = DotProduct(end_l, axis[2]); end_r[2] = DotProduct(end_l, axis[2]);
SV_RecursiveHullCheck (hull, hull->firstclipnode, 0, 1, start_r, end_r, &trace); SV_RecursiveHullCheck (hull, start_r, end_r, &trace, hitcontents);
VectorCopy(trace.endpos, tmp); VectorCopy(trace.endpos, tmp);
trace.endpos[0] = DotProductTranspose(tmp,axis,0); trace.endpos[0] = DotProductTranspose(tmp,axis,0);
trace.endpos[1] = DotProductTranspose(tmp,axis,1); trace.endpos[1] = DotProductTranspose(tmp,axis,1);
@ -853,7 +851,7 @@ trace_t SV_ClipMoveToEntity (edict_t *ent, vec3_t start, vec3_t mins, vec3_t max
trace.plane.normal[2] = DotProductTranspose(tmp,axis,2); trace.plane.normal[2] = DotProductTranspose(tmp,axis,2);
} }
else else
SV_RecursiveHullCheck (hull, hull->firstclipnode, 0, 1, start_l, end_l, &trace); SV_RecursiveHullCheck (hull, start_l, end_l, &trace, hitcontents);
// fix trace up by the offset // fix trace up by the offset
if (trace.fraction != 1) if (trace.fraction != 1)
@ -1077,7 +1075,7 @@ static void World_ClipToNetwork ( moveclip_t *clip )
end_r[0] = DotProduct(end_l, axis[0]); end_r[0] = DotProduct(end_l, axis[0]);
end_r[1] = DotProduct(end_l, axis[1]); end_r[1] = DotProduct(end_l, axis[1]);
end_r[2] = DotProduct(end_l, axis[2]); end_r[2] = DotProduct(end_l, axis[2]);
SV_RecursiveHullCheck (hull, hull->firstclipnode, 0, 1, start_r, end_r, &trace); SV_RecursiveHullCheck (hull, start_r, end_r, &trace, clip->hitcontents);
VectorCopy(trace.endpos, tmp); VectorCopy(trace.endpos, tmp);
trace.endpos[0] = DotProductTranspose(tmp,axis,0); trace.endpos[0] = DotProductTranspose(tmp,axis,0);
trace.endpos[1] = DotProductTranspose(tmp,axis,1); trace.endpos[1] = DotProductTranspose(tmp,axis,1);
@ -1088,7 +1086,7 @@ static void World_ClipToNetwork ( moveclip_t *clip )
trace.plane.normal[2] = DotProductTranspose(tmp,axis,2); trace.plane.normal[2] = DotProductTranspose(tmp,axis,2);
} }
else else
SV_RecursiveHullCheck (hull, hull->firstclipnode, 0, 1, start_l, end_l, &trace); SV_RecursiveHullCheck (hull, start_l, end_l, &trace, clip->hitcontents);
// fix trace up by the offset // fix trace up by the offset
if (trace.fraction != 1) if (trace.fraction != 1)

View file

@ -73,8 +73,8 @@ int SV_TruePointContents (vec3_t p);
edict_t *SV_TestEntityPosition (edict_t *ent); edict_t *SV_TestEntityPosition (edict_t *ent);
#define CONTENTMASK(c) (1u<<(-CONTENTS_##c)) #define CONTENTMASK_FROMQ1(c) (1u<<(-c))
#define CONTENTMASK_ANYSOLID (CONTENTMASK(SOLID) | CONTENTMASK(CLIP)) #define CONTENTMASK_ANYSOLID (CONTENTMASK_FROMQ1(CONTENTS_SOLID) | CONTENTMASK_FROMQ1(CONTENTS_CLIP))
trace_t SV_ClipMoveToEntity (edict_t *ent, vec3_t start, vec3_t mins, vec3_t maxs, vec3_t end, unsigned int hitcontents); trace_t SV_ClipMoveToEntity (edict_t *ent, vec3_t start, vec3_t mins, vec3_t maxs, vec3_t end, unsigned int hitcontents);
trace_t SV_Move (vec3_t start, vec3_t mins, vec3_t maxs, vec3_t end, int type, edict_t *passedict); trace_t SV_Move (vec3_t start, vec3_t mins, vec3_t maxs, vec3_t end, int type, edict_t *passedict);
// mins and maxs are reletive // mins and maxs are reletive
@ -89,7 +89,7 @@ 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) // passedict is explicitly excluded from clipping checks (normally NULL)
qboolean SV_RecursiveHullCheck (hull_t *hull, int num, float p1f, float p2f, vec3_t p1, vec3_t p2, trace_t *trace); qboolean SV_RecursiveHullCheck (hull_t *hull, vec3_t p1, vec3_t p2, trace_t *trace, unsigned int hitcontents);
qmodel_t *PR_CSQC_GetModel(int idx); qmodel_t *PR_CSQC_GetModel(int idx);
#endif /* _QUAKE_WORLD_H */ #endif /* _QUAKE_WORLD_H */