Add TraceExit. Determines trace exit point for actors.

This commit is contained in:
Mari the Deer 2022-09-28 13:49:54 +02:00
commit fbf6b3b82a
2 changed files with 18 additions and 2 deletions

View file

@ -626,6 +626,22 @@ Class SWWMUtility
return (distsq <= (radius*radius));
}
// hitscan exit point calculation given actor, entry point and direction
static clearscope Vector3 TraceExit( Actor a, Vector3 p, Vector3 d )
{
Vector3 ap = p+level.Vec3Diff(p,a.pos); // portal-relative actor position
Vector3 amin = ap+(-a.radius,-a.radius,0),
amax = ap+(a.radius,a.radius,a.height);
Vector3 tmax, div = (1./d.x,1./d.y,1./d.z);
if ( div.x < 0 ) tmax.x = (amin.x-p.x)*div.x;
else tmax.x = (amax.x-p.x)*div.x;
if ( div.y < 0 ) tmax.y = (amin.y-p.y)*div.y;
else tmax.y = (amax.y-p.y)*div.y;
if ( div.z < 0 ) tmax.z = (amin.z-p.z)*div.z;
else tmax.z = (amax.z-p.z)*div.z;
return level.Vec3Offset(p,min(min(tmax.x,tmax.y),tmax.z)*d);
}
// Liang-Barsky line clipping
static clearscope bool, Vector2, Vector2 LiangBarsky( Vector2 minclip, Vector2 maxclip, Vector2 v0, Vector2 v1 )
{