Fix inconsistent distance and hit position on traces that skip everything.

As it currently stood, only traces that never found anything in traversal had their distance and final position corrected.
Meanwhile, traces that skipped everything would return the distance and position of the last thing they crossed instead.
This change makes both cases consistent by "filling out" the remainder of the trace line for the latter.
This commit is contained in:
Marisa the Magician 2022-10-30 11:28:23 +01:00 committed by Christoph Oelckers
parent 181eda0a83
commit c36da35e37

View file

@ -894,9 +894,14 @@ bool FTraceInfo::TraceTraverse (int ptflags)
}
Results = res;
}
if (Results->HitType == TRACE_HitNone && Results->Distance == 0)
if (Results->HitType == TRACE_HitNone)
{
Results->HitPos = Start + Vec * MaxDist;
// [MK] If we didn't cross anything, it's an easy guess,
// otherwise, complete the line using the remaining distance
if (Results->Distance == 0)
Results->HitPos = Start + Vec * MaxDist;
else
Results->HitPos += Vec * (MaxDist - Results->Distance);
SetSourcePosition();
Results->Distance = MaxDist;
Results->Fraction = 1.;