17
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-10-31 20:29:04 +01:00

feat(editor): a slip keeps in the scenery the radius of the main track it's bent with, as a switch does, the lists of the switches telling it as Rg: switch_store::main_radius_of gives it from the first path of a switch, classify takes it from there too; a slip laid on straights keeps 0

This commit is contained in:
maj00r
2026-10-27 19:23:31 +01:00
parent 89b6ca07af
commit 1340017be3
3 changed files with 14 additions and 6 deletions

View File

@@ -451,17 +451,21 @@ void place(record &Entry, TTrack const &First)
Entry.km = alignment_store::chainage_at(Entry.start);
}
void classify(record &Entry, TTrack const &Switch)
double main_radius_of(TTrack const &Switch)
{
geometry::bezier const main{Switch.m_paths[0]};
auto const &diverging{Switch.m_paths[1]};
Entry.hand = geometry::cross(Entry.direction, geometry::plan_of(diverging.points[segment_data::point::end] - Entry.start)) > 0.0 ? 'R' : 'L';
auto const first{geometry::plan_of(main.first(0.0))};
auto const last{geometry::plan_of(main.first(1.0))};
auto const turn{glm::length(first) > 1e-12 && glm::length(last) > 1e-12 ? geometry::signed_angle(glm::normalize(first), glm::normalize(last)) : 0.0};
Entry.main_radius = std::abs(turn) > 1e-6 ? main.plan_length() / turn : 0.0;
if (std::abs(Entry.main_radius) > 20000.0)
Entry.main_radius = 0.0;
auto const radius{std::abs(turn) > 1e-6 ? main.plan_length() / turn : 0.0};
return std::abs(radius) > 20000.0 ? 0.0 : radius;
}
void classify(record &Entry, TTrack const &Switch)
{
auto const &diverging{Switch.m_paths[1]};
Entry.hand = geometry::cross(Entry.direction, geometry::plan_of(diverging.points[segment_data::point::end] - Entry.start)) > 0.0 ? 'R' : 'L';
Entry.main_radius = main_radius_of(Switch);
if (Entry.type == "Rz" || Entry.type == "Rlj" || Entry.type == "Rld")
Entry.type = Entry.main_radius == 0.0 ? "Rz" : (Entry.main_radius > 0.0) == (Entry.hand == 'R') ? "Rlj" : "Rld";
}

View File

@@ -72,6 +72,8 @@ double branch_radius(record const &Record);
void put(record Entry, scene::layer_handle const Layer);
void place(record &Entry, TTrack const &First);
void classify(record &Entry, TTrack const &Switch);
// of the first path of the switch, signed as record::main_radius: + to the right, - to the left, 0 straight
double main_radius_of(TTrack const &Switch);
void forget(std::string const &Name);
// the records follow renamed switches: their parts and the records named after them; Bases renames the records of slips and
// crossings, whose names aren't the names of their parts