mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-11-04 14:55:52 +01:00
refactor(editor): drop unused editor state and vertical leftovers of the route design
This commit is contained in:
@@ -472,7 +472,6 @@ class editor_mode : public application_mode
|
|||||||
void render_path_parameters(TTrack &Track);
|
void render_path_parameters(TTrack &Track);
|
||||||
void render_straight_ui();
|
void render_straight_ui();
|
||||||
track_tab m_track_tab{track_tab::straights};
|
track_tab m_track_tab{track_tab::straights};
|
||||||
int m_track_tab_request{-1};
|
|
||||||
void delete_selected_track();
|
void delete_selected_track();
|
||||||
void start_straight_gesture(int const Tool);
|
void start_straight_gesture(int const Tool);
|
||||||
void finish_straight_gesture();
|
void finish_straight_gesture();
|
||||||
@@ -575,7 +574,6 @@ class editor_mode : public application_mode
|
|||||||
std::vector<infra::binding> m_bindings;
|
std::vector<infra::binding> m_bindings;
|
||||||
std::vector<std::pair<scene::layer_handle, std::string>> m_bindings_unresolved; // lines kept as they are
|
std::vector<std::pair<scene::layer_handle, std::string>> m_bindings_unresolved; // lines kept as they are
|
||||||
bool m_bindings_loaded{false};
|
bool m_bindings_loaded{false};
|
||||||
bool m_bindings_changed{false};
|
|
||||||
std::vector<infra::object_state> m_infra_buffer; // states of the objects before the change in progress
|
std::vector<infra::object_state> m_infra_buffer; // states of the objects before the change in progress
|
||||||
bool m_infra_suspended{false};
|
bool m_infra_suspended{false};
|
||||||
void infra_hooks();
|
void infra_hooks();
|
||||||
|
|||||||
@@ -374,11 +374,6 @@ bool nearest_beside(Areas_ const &Areas, glm::dvec3 const &Point, double const C
|
|||||||
return best >= 0.0;
|
return best >= 0.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool station_near(std::vector<track_area> 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
|
// paths of the whole scenery by cells of the plan, for the lookups reaching up to kReach from the axis
|
||||||
class track_index
|
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");
|
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));
|
scene::Layers.mark(entry.first, kBindingMark, std::move(entry.second));
|
||||||
}
|
}
|
||||||
m_bindings_changed = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<TTrack *> editor_mode::infra_scope() const
|
std::vector<TTrack *> editor_mode::infra_scope() const
|
||||||
@@ -830,8 +824,6 @@ void editor_mode::infra_bind_chosen()
|
|||||||
candidate.chosen = false;
|
candidate.chosen = false;
|
||||||
++count;
|
++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);
|
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<std::size_t> Indices)
|
|||||||
candidate.bound = false;
|
candidate.bound = false;
|
||||||
m_bindings.erase(m_bindings.begin() + *index);
|
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
|
infra::object_state editor_mode::infra_state_of(infra::binding const &Binding) const
|
||||||
@@ -973,7 +963,7 @@ void editor_mode::infra_follow(std::vector<TTrack *> const &Tracks)
|
|||||||
// paths which took over may have been committed before the old ones were retired
|
// paths which took over may have been committed before the old ones were retired
|
||||||
std::optional<std::vector<track_area>> everywhere;
|
std::optional<std::vector<track_area>> everywhere;
|
||||||
auto const take_over = [&](glm::dvec3 const &Foot, infra::station &Station) {
|
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;
|
return true;
|
||||||
if (false == everywhere.has_value())
|
if (false == everywhere.has_value())
|
||||||
{
|
{
|
||||||
@@ -983,7 +973,7 @@ void editor_mode::infra_follow(std::vector<TTrack *> const &Tracks)
|
|||||||
everywhere->push_back(area_of(*track));
|
everywhere->push_back(area_of(*track));
|
||||||
}
|
}
|
||||||
// only a path running where the old one did, not the one alongside
|
// 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)
|
for (auto &binding : m_bindings)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -93,12 +93,10 @@ void editor_mode::select_track(scene::basic_node *Node)
|
|||||||
}
|
}
|
||||||
else if (editor_track::is_straight(*track, m_straights.tolerance))
|
else if (editor_track::is_straight(*track, m_straights.tolerance))
|
||||||
{
|
{
|
||||||
m_track_tab_request = 0;
|
|
||||||
m_track_tab = track_tab::straights;
|
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))
|
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;
|
m_track_tab = track_tab::route;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -803,7 +801,6 @@ void editor_mode::route_recommend(alignment::vertex &Vertex) const
|
|||||||
Vertex.cant = recommended.cant;
|
Vertex.cant = recommended.cant;
|
||||||
Vertex.transition_in = recommended.transition;
|
Vertex.transition_in = recommended.transition;
|
||||||
Vertex.transition_out = recommended.transition;
|
Vertex.transition_out = recommended.transition;
|
||||||
Vertex.vertical_radius = 0.0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void editor_mode::route_bind_ends()
|
void editor_mode::route_bind_ends()
|
||||||
@@ -1013,13 +1010,7 @@ glm::dvec3 editor_mode::route_vertex_position(int const Vertex) const
|
|||||||
else
|
else
|
||||||
position = design.vertices[Vertex].position;
|
position = design.vertices[Vertex].position;
|
||||||
|
|
||||||
double height;
|
auto const height{Vertex < static_cast<int>(result.vertex_elevations.size()) ? result.vertex_elevations[Vertex] : design.start.y + (design.end.y - design.start.y) * (Vertex + 1) / (count + 1.0)};
|
||||||
if (Vertex < static_cast<int>(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);
|
|
||||||
return {position.x, height, position.y};
|
return {position.x, height, position.y};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2361,7 +2352,6 @@ void editor_mode::toggle_straight_set(TTrack &Track)
|
|||||||
state.set.push_back(line);
|
state.set.push_back(line);
|
||||||
m_node = &Track;
|
m_node = &Track;
|
||||||
ui()->set_node(m_node);
|
ui()->set_node(m_node);
|
||||||
m_track_tab_request = 0;
|
|
||||||
m_track_tab = track_tab::straights;
|
m_track_tab = track_tab::straights;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -245,7 +245,6 @@ recommendation recommend(double const Speed, double const Radius, limits const &
|
|||||||
auto const factor{Limits.gauge / (kGravity * 12.96)};
|
auto const factor{Limits.gauge / (kGravity * 12.96)};
|
||||||
auto const allowance{Limits.gauge * Limits.unbalanced / kGravity};
|
auto const allowance{Limits.gauge * Limits.unbalanced / kGravity};
|
||||||
result.radius_min = factor * Speed * Speed / (Limits.cant_max + allowance);
|
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)
|
if (Radius <= 0.0)
|
||||||
return result;
|
return result;
|
||||||
result.cant_equilibrium = factor * Speed * Speed / Radius;
|
result.cant_equilibrium = factor * Speed * Speed / Radius;
|
||||||
@@ -712,12 +711,11 @@ result fit_between(design const &Design)
|
|||||||
|
|
||||||
r.vertex_chainages = vertexchainage;
|
r.vertex_chainages = vertexchainage;
|
||||||
r.profile.push_back({0.0, Design.start.y, 0.0, 0.0});
|
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)
|
for (std::size_t k = 0; k < count; ++k)
|
||||||
{
|
{
|
||||||
auto const &vertex{Design.vertices[k]};
|
auto const elevation{Design.start.y + (Design.end.y - Design.start.y) * vertexchainage[k] / std::max(r.length, 1e-6)};
|
||||||
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};
|
|
||||||
r.vertex_elevations.push_back(elevation);
|
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)
|
if (vertexchainage[k] <= r.profile.back().chainage + 1e-3)
|
||||||
continue;
|
continue;
|
||||||
r.profile.push_back({vertexchainage[k], elevation, radius, 0.0});
|
r.profile.push_back({vertexchainage[k], elevation, radius, 0.0});
|
||||||
|
|||||||
@@ -45,9 +45,6 @@ struct vertex
|
|||||||
double transition_in{0.0};
|
double transition_in{0.0};
|
||||||
double transition_out{0.0};
|
double transition_out{0.0};
|
||||||
double cant{0.0};
|
double cant{0.0};
|
||||||
bool auto_elevation{true};
|
|
||||||
double elevation{0.0};
|
|
||||||
double vertical_radius{0.0};
|
|
||||||
bool reverse_turn{false};
|
bool reverse_turn{false};
|
||||||
bool compound{false};
|
bool compound{false};
|
||||||
double radius2{600.0};
|
double radius2{600.0};
|
||||||
@@ -83,7 +80,6 @@ struct recommendation
|
|||||||
double cant{0.0};
|
double cant{0.0};
|
||||||
double radius_min{0.0};
|
double radius_min{0.0};
|
||||||
double transition{0.0};
|
double transition{0.0};
|
||||||
double vertical_radius{0.0};
|
|
||||||
};
|
};
|
||||||
recommendation recommend(double const Speed, double const Radius, limits const &Limits);
|
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);
|
double transition_length(double const Speed, double const Radius, double const Cant, limits const &Limits);
|
||||||
|
|||||||
@@ -2261,12 +2261,6 @@ void editor_track::retire(TTrack &Track)
|
|||||||
on_retire(Track);
|
on_retire(Track);
|
||||||
}
|
}
|
||||||
|
|
||||||
void editor_track::revive(TTrack &Track)
|
|
||||||
{
|
|
||||||
Track.m_editorremoved = false;
|
|
||||||
commit({&Track});
|
|
||||||
}
|
|
||||||
|
|
||||||
void editor_track::rebuild_geometry(TTrack &Track)
|
void editor_track::rebuild_geometry(TTrack &Track)
|
||||||
{
|
{
|
||||||
auto §ion{simulation::Region->section(Track.location())};
|
auto §ion{simulation::Region->section(Track.location())};
|
||||||
|
|||||||
@@ -222,7 +222,6 @@ class editor_track
|
|||||||
static void move_straights(std::vector<straight> const &Lines, std::vector<std::pair<glm::dvec3, glm::dvec3>> const &Ends);
|
static void move_straights(std::vector<straight> const &Lines, std::vector<std::pair<glm::dvec3, glm::dvec3>> const &Ends);
|
||||||
static std::vector<TTrack *> relay(chain const &Chain, std::vector<segment_data> const &Pieces);
|
static std::vector<TTrack *> relay(chain const &Chain, std::vector<segment_data> const &Pieces);
|
||||||
static void retire(TTrack &Track);
|
static void retire(TTrack &Track);
|
||||||
static void revive(TTrack &Track);
|
|
||||||
|
|
||||||
static std::string material_name(material_handle const Material);
|
static std::string material_name(material_handle const Material);
|
||||||
static material_handle fetch_material(std::string const &Name);
|
static material_handle fetch_material(std::string const &Name);
|
||||||
|
|||||||
Reference in New Issue
Block a user