From 19b7364bcaed390063da2181ac4ce1ecd39bacf0 Mon Sep 17 00:00:00 2001 From: maj00r Date: Wed, 21 Oct 2026 11:09:16 +0200 Subject: [PATCH] fix(editor): the cant of a path is typed in millimetres The inspector took the cant as the roll angle in degrees while every readout shows it in millimetres of one rail over the other. --- application/editormodetrack.cpp | 10 ++++++---- lang/editor_pl.po | 6 ++++++ 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/application/editormodetrack.cpp b/application/editormodetrack.cpp index 2b80b872..0b6237e4 100644 --- a/application/editormodetrack.cpp +++ b/application/editormodetrack.cpp @@ -1462,10 +1462,12 @@ void editor_mode::render_path_ui() { if (begin_fields("##cantradius", 0.3f)) { - field_row("Roll (deg)"); - if (auto rolls{path.rolls}; ImGui::DragFloat2("##roll", rolls.data(), 0.01f, -15.0f, 15.0f, "%.2f") && std::isfinite(rolls[0]) && std::isfinite(rolls[1])) - path.rolls = rolls; - item_tooltip("Cant at the start and at the end as the roll angle of the track"); + field_row("Cant (mm)"); + auto const lift = [](float const Roll) { return static_cast(1500.0 * std::sin(glm::radians(static_cast(Roll)))); }; + auto const roll = [](float const Lift) { return static_cast(glm::degrees(std::asin(std::clamp(static_cast(Lift) / 1500.0, -1.0, 1.0)))); }; + if (std::array cants{lift(path.rolls[0]), lift(path.rolls[1])}; ImGui::DragFloat2("##roll", cants.data(), 0.5f, -388.0f, 388.0f, "%.0f") && std::isfinite(cants[0]) && std::isfinite(cants[1])) + path.rolls = {roll(cants[0]), roll(cants[1])}; + item_tooltip("Cant at the start and at the end: how much higher one rail is, + raises the left rail looking along the path"); finish_edit(rebuild::geometry); field_row("Radius"); if (auto radius{path.radius}; ImGui::InputFloat("##radius", &radius, 0.0f, 0.0f, "%.1f") && std::isfinite(radius)) diff --git a/lang/editor_pl.po b/lang/editor_pl.po index f71b08db..8d7a78fa 100644 --- a/lang/editor_pl.po +++ b/lang/editor_pl.po @@ -9991,3 +9991,9 @@ msgstr "na drugą stronę" msgid "type the radius of the curve" msgstr "wpisz promień łuku" + +msgid "Cant (mm)" +msgstr "Przechyłka (mm)" + +msgid "Cant at the start and at the end: how much higher one rail is, + raises the left rail looking along the path" +msgstr "Przechyłka na początku i na końcu: o ile jedna szyna jest wyżej, + podnosi lewą szynę patrząc wzdłuż toru"