From ca208b3ed1e40ff9c8a3c6f376e424923601ad43 Mon Sep 17 00:00:00 2001 From: maj00r Date: Thu, 8 Oct 2026 00:51:29 +0200 Subject: [PATCH] fix(editor): a long arc of a larger radius kept as a part of a compound curve, only short arcs of growing radius taken for the transition curve of an old scenery --- editor/editorTrack.cpp | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/editor/editorTrack.cpp b/editor/editorTrack.cpp index a3d4854c..11a6a1cf 100644 --- a/editor/editorTrack.cpp +++ b/editor/editorTrack.cpp @@ -1453,9 +1453,19 @@ bool editor_track::analyse_curve(std::vector> const &R Curve.cant = std::max(Curve.cant, Gauge * std::sin(std::abs(glm::radians(static_cast(roll))))); } auto const peak{*std::max_element(curvatures.begin(), curvatures.end())}; - for (std::size_t i = 0; i < run.size(); ++i) - if (curvatures[i] < 0.9 * peak) - varying[i] = true; + // old sceneries make a transition of short arcs of growing radius, a longer arc of a larger radius is a part of a compound curve + constexpr double kShortestCompoundArc{30.0}; + for (std::size_t first = 0; first < run.size();) + { + auto last{first + 1}; + while (last < run.size() && false == varying[first] && false == varying[last] && std::abs(curvatures[last] - curvatures[first]) <= 0.05 * curvatures[first]) + ++last; + auto const length{std::accumulate(lengths.begin() + first, lengths.begin() + last, 0.0)}; + if (curvatures[first] < 0.9 * peak && (varying[first] || length < kShortestCompoundArc || curvatures[first] < 0.1 * peak)) + for (auto i = first; i < last; ++i) + varying[i] = true; + first = last; + } double smallest{0.0}; for (std::size_t i = 0; i < run.size(); ++i) if (false == varying[i] && curvatures[i] > 0.0 && (smallest == 0.0 || 1.0 / curvatures[i] < smallest))