From d8f85267ad65c89d00d2fe229ca680d6e2589beb Mon Sep 17 00:00:00 2001 From: "auria.mg" Date: Wed, 10 Oct 2018 19:53:07 -0400 Subject: [PATCH] Another attempt to fix #3462, this one works much better --- src/tracks/check_lap.cpp | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/tracks/check_lap.cpp b/src/tracks/check_lap.cpp index 9b2c9394d..b228bcd8b 100644 --- a/src/tracks/check_lap.cpp +++ b/src/tracks/check_lap.cpp @@ -70,13 +70,9 @@ bool CheckLap::isTriggered(const Vec3 &old_pos, const Vec3 &new_pos, if(!lin_world) return false; - // Cannot cross lap when off-road, since we are not sure where the kart is - if (!lin_world->isOnRoad(kart_index)) - return false; - float current_distance = lin_world->getDistanceDownTrackForKart(kart_index, false); - bool result = (m_previous_distance[kart_index]>0.95f*track_length && - current_distance<7.0f); + float threshold = 0.33f * track_length; + bool result = current_distance < threshold && lin_world->isOnRoad(kart_index); if (UserConfigParams::m_check_debug && result) { @@ -85,7 +81,9 @@ bool CheckLap::isTriggered(const Vec3 &old_pos, const Vec3 &new_pos, m_previous_distance[kart_index], current_distance); } - m_previous_distance[kart_index] = current_distance; + // Cannot cross lap when off-road, since we are not sure where the kart is + if (lin_world->isOnRoad(kart_index)) + m_previous_distance[kart_index] = current_distance; if (result) lin_world->setLastTriggeredCheckline(kart_index, m_index);