17
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-10-17 10:59:20 +02:00

Switches: lay the pre-blade lead and the blade, not a tangent arc

A turnout's diverging track does not leave the through track tangentially. It
runs straight along the through track to the blade tip (odcinek przediglicowy),
breaks away there by the blade angle (kąt nagięcia iglicy, beta), runs straight
over the blade to its heel, and only then curves - through alfa - beta, not the
whole crossing angle - to the frog.

Give TurnoutSegment a turn_in: a signed heading break applied before the segment
is laid, which is the only way to express a track leaving by an angle rather than
a tangent. lay_turnout then places the lead, the break and the blade ahead of the
curve and hands the curve the angle that is actually left to spend; a zero blade
length keeps the break and starts the curve at the tip. Reject a blade angle that
is negative or already reaches the crossing angle.

All-zero blade figures lay exactly the old tangent arc from PR, so existing
layouts are untouched. Junction and turnout_preset carry the three new figures
through to the panel; the presets themselves still hold zeros until the Id-1
catalogue numbers are in.

Add test_turnout: the lead sits on the through track, the blade breaks by beta,
and the frog still lands on the full crossing angle and the catalogue length,
mirrored for a right-hand turnout.
This commit is contained in:
maj00r
2026-08-27 19:36:52 +02:00
parent 4ae24114ba
commit 8cd42980e6
10 changed files with 223 additions and 25 deletions

View File

@@ -2337,6 +2337,9 @@ void plan_panel::render_switches()
m_sw_crossing = preset.crossing_n;
m_sw_radius = preset.radius;
m_sw_length = preset.length;
m_sw_pre_blade = preset.pre_blade;
m_sw_blade_angle = preset.blade_angle;
m_sw_blade_length = preset.blade_length;
}
}
ImGui::EndCombo();
@@ -2559,6 +2562,10 @@ void plan_panel::add_switch_on(std::size_t const Through, double const Wx, doubl
junction.facing = true;
junction.crossing_n = m_sw_crossing;
junction.length = m_sw_length; // catalogue length from the template, 0 for a custom switch
// the blade figures come from the template too; all zero lays a tangent arc from PR
junction.pre_blade = m_sw_pre_blade;
junction.blade_angle = m_sw_blade_angle;
junction.blade_length = m_sw_blade_length;
junction.curve.mode = 1; // plain arc; the internal curve can be made compound later
junction.curve.radius = m_sw_radius;
junction.branch = static_cast<int>(m_document.niwelety.size());