From c36da35e37231fffe19425d2d1587c0194383a4d Mon Sep 17 00:00:00 2001 From: Marisa the Magician Date: Sun, 30 Oct 2022 11:28:23 +0100 Subject: [PATCH] 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. --- src/playsim/p_trace.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/playsim/p_trace.cpp b/src/playsim/p_trace.cpp index 9cff0ffb2..c711b4076 100644 --- a/src/playsim/p_trace.cpp +++ b/src/playsim/p_trace.cpp @@ -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.;