From 7b8d809078edfa718301e0eefab8f3d7a56a1d5e Mon Sep 17 00:00:00 2001 From: maj00r Date: Sun, 4 Oct 2026 00:35:40 +0200 Subject: [PATCH] refactor(editor): drop unused editor state and vertical leftovers of the route design --- application/editormode.h | 2 -- application/editormodeinfra.cpp | 14 ++------------ application/editormodetrack.cpp | 12 +----------- editor/editorAlignment.cpp | 6 ++---- editor/editorAlignment.hpp | 4 ---- editor/editorTrack.cpp | 6 ------ editor/editorTrack.hpp | 1 - 7 files changed, 5 insertions(+), 40 deletions(-) diff --git a/application/editormode.h b/application/editormode.h index 082682e4..32a6adaa 100644 --- a/application/editormode.h +++ b/application/editormode.h @@ -472,7 +472,6 @@ class editor_mode : public application_mode void render_path_parameters(TTrack &Track); void render_straight_ui(); track_tab m_track_tab{track_tab::straights}; - int m_track_tab_request{-1}; void delete_selected_track(); void start_straight_gesture(int const Tool); void finish_straight_gesture(); @@ -575,7 +574,6 @@ class editor_mode : public application_mode std::vector m_bindings; std::vector> m_bindings_unresolved; // lines kept as they are bool m_bindings_loaded{false}; - bool m_bindings_changed{false}; std::vector m_infra_buffer; // states of the objects before the change in progress bool m_infra_suspended{false}; void infra_hooks(); diff --git a/application/editormodeinfra.cpp b/application/editormodeinfra.cpp index d81dd2f2..e950c5d7 100644 --- a/application/editormodeinfra.cpp +++ b/application/editormodeinfra.cpp @@ -374,11 +374,6 @@ bool nearest_beside(Areas_ const &Areas, glm::dvec3 const &Point, double const C return best >= 0.0; } -bool station_near(std::vector const &Areas, glm::dvec3 const &Point, double const Corridor, infra::station &Station) -{ - return nearest_beside(Areas, Point, Corridor, Station); -} - // paths of the whole scenery by cells of the plan, for the lookups reaching up to kReach from the axis class track_index { @@ -662,7 +657,6 @@ void editor_mode::infra_store() entry.second.insert(entry.second.begin(), "# objects bound to the paths in the track editor, they follow changes of the track; the simulation skips these lines"); scene::Layers.mark(entry.first, kBindingMark, std::move(entry.second)); } - m_bindings_changed = false; } std::vector editor_mode::infra_scope() const @@ -830,8 +824,6 @@ void editor_mode::infra_bind_chosen() candidate.chosen = false; ++count; } - if (count > 0) - m_bindings_changed = true; state.status = format("%d object(s) bound, they follow the changes of the track. The bindings are kept in the scenery files on save", count); } @@ -848,8 +840,6 @@ void editor_mode::infra_unbind(std::vector Indices) candidate.bound = false; m_bindings.erase(m_bindings.begin() + *index); } - if (false == Indices.empty()) - m_bindings_changed = true; } infra::object_state editor_mode::infra_state_of(infra::binding const &Binding) const @@ -973,7 +963,7 @@ void editor_mode::infra_follow(std::vector const &Tracks) // paths which took over may have been committed before the old ones were retired std::optional> everywhere; auto const take_over = [&](glm::dvec3 const &Foot, infra::station &Station) { - if (station_near(areas, Foot, 30.0, Station)) + if (nearest_beside(areas, Foot, 30.0, Station)) return true; if (false == everywhere.has_value()) { @@ -983,7 +973,7 @@ void editor_mode::infra_follow(std::vector const &Tracks) everywhere->push_back(area_of(*track)); } // only a path running where the old one did, not the one alongside - return station_near(*everywhere, Foot, 1.0, Station); + return nearest_beside(*everywhere, Foot, 1.0, Station); }; for (auto &binding : m_bindings) { diff --git a/application/editormodetrack.cpp b/application/editormodetrack.cpp index ca5f7722..8d0a2cdf 100644 --- a/application/editormodetrack.cpp +++ b/application/editormodetrack.cpp @@ -93,12 +93,10 @@ void editor_mode::select_track(scene::basic_node *Node) } else if (editor_track::is_straight(*track, m_straights.tolerance)) { - m_track_tab_request = 0; m_track_tab = track_tab::straights; } else if (std::find(m_route.chain.tracks.begin(), m_route.chain.tracks.end(), track) != m_route.chain.tracks.end() || route_from_curve(*track)) { - m_track_tab_request = 1; m_track_tab = track_tab::route; } } @@ -803,7 +801,6 @@ void editor_mode::route_recommend(alignment::vertex &Vertex) const Vertex.cant = recommended.cant; Vertex.transition_in = recommended.transition; Vertex.transition_out = recommended.transition; - Vertex.vertical_radius = 0.0; } void editor_mode::route_bind_ends() @@ -1013,13 +1010,7 @@ glm::dvec3 editor_mode::route_vertex_position(int const Vertex) const else position = design.vertices[Vertex].position; - double height; - if (Vertex < static_cast(result.vertex_elevations.size())) - height = result.vertex_elevations[Vertex]; - else if (false == design.vertices[Vertex].auto_elevation) - height = design.vertices[Vertex].elevation; - else - height = design.start.y + (design.end.y - design.start.y) * (Vertex + 1) / (count + 1.0); + auto const height{Vertex < static_cast(result.vertex_elevations.size()) ? result.vertex_elevations[Vertex] : design.start.y + (design.end.y - design.start.y) * (Vertex + 1) / (count + 1.0)}; return {position.x, height, position.y}; } @@ -2361,7 +2352,6 @@ void editor_mode::toggle_straight_set(TTrack &Track) state.set.push_back(line); m_node = &Track; ui()->set_node(m_node); - m_track_tab_request = 0; m_track_tab = track_tab::straights; } diff --git a/editor/editorAlignment.cpp b/editor/editorAlignment.cpp index bdd06cf3..29a85b01 100644 --- a/editor/editorAlignment.cpp +++ b/editor/editorAlignment.cpp @@ -245,7 +245,6 @@ recommendation recommend(double const Speed, double const Radius, limits const & auto const factor{Limits.gauge / (kGravity * 12.96)}; auto const allowance{Limits.gauge * Limits.unbalanced / kGravity}; result.radius_min = factor * Speed * Speed / (Limits.cant_max + allowance); - result.vertical_radius = std::max(Limits.vertical_min, Limits.vertical_factor * Speed * Speed); if (Radius <= 0.0) return result; result.cant_equilibrium = factor * Speed * Speed / Radius; @@ -712,12 +711,11 @@ result fit_between(design const &Design) r.vertex_chainages = vertexchainage; r.profile.push_back({0.0, Design.start.y, 0.0, 0.0}); + auto const radius{std::max(Design.norms.vertical_min, Design.norms.vertical_factor * Design.speed * Design.speed)}; for (std::size_t k = 0; k < count; ++k) { - auto const &vertex{Design.vertices[k]}; - auto const elevation{vertex.auto_elevation ? Design.start.y + (Design.end.y - Design.start.y) * vertexchainage[k] / std::max(r.length, 1e-6) : vertex.elevation}; + auto const elevation{Design.start.y + (Design.end.y - Design.start.y) * vertexchainage[k] / std::max(r.length, 1e-6)}; r.vertex_elevations.push_back(elevation); - auto const radius{vertex.vertical_radius > 0.0 ? vertex.vertical_radius : std::max(Design.norms.vertical_min, Design.norms.vertical_factor * Design.speed * Design.speed)}; if (vertexchainage[k] <= r.profile.back().chainage + 1e-3) continue; r.profile.push_back({vertexchainage[k], elevation, radius, 0.0}); diff --git a/editor/editorAlignment.hpp b/editor/editorAlignment.hpp index a3e4572f..fcf6132b 100644 --- a/editor/editorAlignment.hpp +++ b/editor/editorAlignment.hpp @@ -45,9 +45,6 @@ struct vertex double transition_in{0.0}; double transition_out{0.0}; double cant{0.0}; - bool auto_elevation{true}; - double elevation{0.0}; - double vertical_radius{0.0}; bool reverse_turn{false}; bool compound{false}; double radius2{600.0}; @@ -83,7 +80,6 @@ struct recommendation double cant{0.0}; double radius_min{0.0}; double transition{0.0}; - double vertical_radius{0.0}; }; recommendation recommend(double const Speed, double const Radius, limits const &Limits); double transition_length(double const Speed, double const Radius, double const Cant, limits const &Limits); diff --git a/editor/editorTrack.cpp b/editor/editorTrack.cpp index c40c2dcd..7d815d66 100644 --- a/editor/editorTrack.cpp +++ b/editor/editorTrack.cpp @@ -2261,12 +2261,6 @@ void editor_track::retire(TTrack &Track) on_retire(Track); } -void editor_track::revive(TTrack &Track) -{ - Track.m_editorremoved = false; - commit({&Track}); -} - void editor_track::rebuild_geometry(TTrack &Track) { auto §ion{simulation::Region->section(Track.location())}; diff --git a/editor/editorTrack.hpp b/editor/editorTrack.hpp index cc6d106c..4a80dc95 100644 --- a/editor/editorTrack.hpp +++ b/editor/editorTrack.hpp @@ -222,7 +222,6 @@ class editor_track static void move_straights(std::vector const &Lines, std::vector> const &Ends); static std::vector relay(chain const &Chain, std::vector const &Pieces); static void retire(TTrack &Track); - static void revive(TTrack &Track); static std::string material_name(material_handle const Material); static material_handle fetch_material(std::string const &Name);