Generalized hitnormal functions (where possible).

This commit is contained in:
Mari the Deer 2022-12-18 20:03:36 +01:00
commit b1683dae8e
24 changed files with 206 additions and 785 deletions

View file

@ -424,24 +424,9 @@ Class FancyConfetti : SWWMNonInteractiveActor
double ang = atan2(dir.y,dir.x);
double pt = asin(-dir.z);
LineTrace(ang,dist,pt,TRF_THRUACTORS|TRF_THRUHITSCAN|TRF_ABSPOSITION,newpos.z,newpos.x,newpos.y,d);
Vector3 hitnormal = -d.HitDir;
if ( d.HitType == TRACE_HitFloor )
{
if ( d.Hit3DFloor ) hitnormal = -d.Hit3DFloor.top.Normal;
else hitnormal = d.HitSector.floorplane.Normal;
}
else if ( d.HitType == TRACE_HitCeiling )
{
if ( d.Hit3DFloor ) hitnormal = -d.Hit3DFloor.bottom.Normal;
else hitnormal = d.HitSector.ceilingplane.Normal;
}
else if ( d.HitType == TRACE_HitWall )
{
hitnormal = (-d.HitLine.delta.y,d.HitLine.delta.x,0).unit();
if ( !d.LineSide ) hitnormal *= -1;
}
if ( (d.HitType != TRACE_HitNone) && (d.HitType != TRACE_HitFloor) )
{
Vector3 hitnormal = SWWMUtility.GetLineTraceHitNormal(d);
dist -= d.Distance;
// should only happen if we bounced
dir = d.HitDir-(1.2*hitnormal*(d.HitDir dot hitnormal));