diff --git a/language.version b/language.version index 1514075ff..a0c2afc04 100644 --- a/language.version +++ b/language.version @@ -1,3 +1,3 @@ [default] -SWWM_MODVER="\cyDEMOLITIONIST \cw1.3pre r520 \cu(Tue 27 Sep 21:46:09 CEST 2022)\c-"; -SWWM_SHORTVER="\cw1.3pre r520 \cu(2022-09-27 21:46:09)\c-"; +SWWM_MODVER="\cyDEMOLITIONIST \cw1.3pre r521 \cu(Wed 28 Sep 13:49:54 CEST 2022)\c-"; +SWWM_SHORTVER="\cw1.3pre r521 \cu(2022-09-28 13:49:54)\c-"; diff --git a/zscript/utility/swwm_utility.zsc b/zscript/utility/swwm_utility.zsc index 32ec5ddfd..de7d7424c 100644 --- a/zscript/utility/swwm_utility.zsc +++ b/zscript/utility/swwm_utility.zsc @@ -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 ) {