diff --git a/src/am_map.cpp b/src/am_map.cpp index d6916b27d5d..9caac9b1b0c 100644 --- a/src/am_map.cpp +++ b/src/am_map.cpp @@ -1846,9 +1846,10 @@ void DAutomap::collectPath () constexpr int MIN_DISTANCE_BETWEEN_POINTS = 32; if (abs(last_line.b.x - pos.X) >= MIN_DISTANCE_BETWEEN_POINTS || abs(last_line.b.y - pos.Y) >= MIN_DISTANCE_BETWEEN_POINTS) { - // If the distance between two points is very high, the player has likely teleported so no path should be drawn between the points. - constexpr int MAX_DISTANCE_BETWEEN_TICKS = 100; - if (abs(last_line.b.x - pos.X) >= MAX_DISTANCE_BETWEEN_TICKS || abs(last_line.b.y - pos.Y) >= MAX_DISTANCE_BETWEEN_TICKS) + // If the player's velocity is lower than the distance between the last two ticks (with some tolerance), + // the player has likely teleported so no path should be drawn between the points. + constexpr float EPSILON = 10.0; + if ((pos - last_tick_pos).Length() > (players[consoleplayer].camera->VelXYToSpeed() + EPSILON)) { ml.a.x = pos.X; ml.a.y = pos.Y; @@ -1862,7 +1863,7 @@ void DAutomap::collectPath () ml.b.x = pos.X; ml.b.y = pos.Y; - if (path_history.Size() > am_pathlength) + if (path_history.Size() > uint32_t(am_pathlength)) { // Path is too long; remove the oldest lines. path_history.Delete(0); @@ -1879,6 +1880,8 @@ void DAutomap::collectPath () ml.b.y = pos.Y; path_history.Push(ml); } + + last_tick_pos = players[consoleplayer].camera->InterpolatedPosition(r_viewpoint.TicFrac); } //============================================================================= diff --git a/src/am_map.h b/src/am_map.h index 3665e443831..306e19611b1 100644 --- a/src/am_map.h +++ b/src/am_map.h @@ -44,6 +44,9 @@ class DAutomapBase : public DObject // called instead of view drawer if automap active. virtual void Drawer(int bottom) = 0; + // Used for am_path drawing to calculate distance between ticks. + DVector2 last_tick_pos; + virtual void NewResolution() = 0; virtual void LevelInit() = 0; virtual void UpdateShowAllLines() = 0;