From 1be5765bb2260883b43cad52d1ffce1223fc4bb7 Mon Sep 17 00:00:00 2001 From: namdre Date: Fri, 2 Mar 2018 08:06:35 +0100 Subject: [PATCH] fixing special case (was triggering assertion) refs #3861 --- src/microsim/MSLink.cpp | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/src/microsim/MSLink.cpp b/src/microsim/MSLink.cpp index ed115f3660a..9b86913cffa 100644 --- a/src/microsim/MSLink.cpp +++ b/src/microsim/MSLink.cpp @@ -220,15 +220,17 @@ MSLink::setRequestInformation(int index, bool hasFoes, bool isCont, // we want to make sure that both vehicles have the same distance to the crossing point and thus follow each other naturally std::vector distances = l.distances(s); assert(distances.size() == l.size() + s.size()); - for (int j = s.size() - 2; j >= 0; j--) { - int i = j + l.size(); - const double segLength = s[j].distanceTo2D(s[j + 1]); - if (distances[i] > minDist) { - lbcSibling += segLength; - } else { - // assume no sharp bends and just interpolate the last segment - lbcSibling += segLength - (minDist - distances[i]) * segLength / (distances[i + 1] - distances[i]); - break; + if (distances.back() > minDist) { + for (int j = s.size() - 2; j >= 0; j--) { + int i = j + l.size(); + const double segLength = s[j].distanceTo2D(s[j + 1]); + if (distances[i] > minDist) { + lbcSibling += segLength; + } else { + // assume no sharp bends and just interpolate the last segment + lbcSibling += segLength - (minDist - distances[i]) * segLength / (distances[i + 1] - distances[i]); + break; + } } } assert(lbcSibling >= -NUMERICAL_EPS);