mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-10-21 00:32:39 +02:00
Labels: - every button, field, tooltip and message of the editor reread for a beginner: short nouns for the fields with the sentence in the tooltip, the less used options under More settings, one glossary (field of work, template, track, grade), sides told from directions, degrees and per mille as signs, messages built from one format string - plural forms through STR_P; the last entry of a po file is read too, and the Polish plural rule is in the header - lang/editor_pl.po: the code pass entries merged, 391 entries no code uses and 3 duplicates dropped - roads: the notes and errors naming a road translated; the build options and the layout fold the texture length, kerb sizes, traffic share, roundabout part, height over the ground and junction speed limit under More settings, the lanes start folded Grade lines fitted to the terrain model (NMT), a line or the whole scenery at once: - fit_ground: a robust fit on nodes 5 m apart; the ground parting from the line (a bridge, a viaduct, a wall) is gone past rather than followed, the bends keep off the switches as far as their curves reach, a run of bends the same way is one point of intersection, a curve with no room is as sharp as the room lets it be - the ends of the line and the other paths of its switches leading into lines fitted already bound the line by what the tracks between can climb; ends meeting in the plan, laid apart in height by hand, are joined before the run - apply_profile: the paths are split where split_path takes the parameter (a straight was cut in the wrong place, into pieces of a few centimetres the game takes for zero length), no piece shorter than the margin; the paths off the ends of the route are brought to its height - Bytom: 1600 lines, grade breaks at the joints 89 -> 20; Tarnowskie Gory: 848 lines, 223 -> 3; no step over 2 cm
139 lines
4.5 KiB
C++
139 lines
4.5 KiB
C++
/*
|
|
This Source Code Form is subject to the
|
|
terms of the Mozilla Public License, v.
|
|
2.0. If a copy of the MPL was not
|
|
distributed with this file, You can
|
|
obtain one at
|
|
http://mozilla.org/MPL/2.0/.
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <array>
|
|
#include <string>
|
|
#include <map>
|
|
#include <optional>
|
|
#include <vector>
|
|
#include <glm/glm.hpp>
|
|
|
|
#include "world/Segment.h"
|
|
#include "scene/scenenode.h"
|
|
|
|
class TTrack;
|
|
|
|
// objects which belong to the railway infrastructure (signals, signs, catenary, poles, the logic placed along the
|
|
// line) bound to the paths they stand by, so they follow the changes of the track geometry
|
|
namespace infra
|
|
{
|
|
|
|
enum class kind
|
|
{
|
|
model,
|
|
include,
|
|
traction,
|
|
memcell,
|
|
launcher
|
|
};
|
|
enum class category
|
|
{
|
|
signal,
|
|
sign,
|
|
pole,
|
|
catenary,
|
|
logic,
|
|
other,
|
|
// after the others, so the numbers kept in the scenery files keep their meaning
|
|
equipment, // of the track itself, on its axis: the magnets of the train protection, the plates of a level crossing, the
|
|
// ballast and the lanterns of the switches
|
|
environment // greenery, people, small architecture: by the track, but not a part of the railway, not bound by default
|
|
};
|
|
char const *name(kind Kind);
|
|
char const *name(category Category);
|
|
// the kind of an object by the category in the description of its template, if it names one
|
|
std::optional<category> category_named(std::string const &Category);
|
|
std::vector<category> const &categories();
|
|
|
|
// point of a path, measured in the plan from the start of the path
|
|
struct station
|
|
{
|
|
TTrack *track{nullptr};
|
|
int path{0};
|
|
double s{0.0};
|
|
};
|
|
struct frame
|
|
{
|
|
glm::dvec3 point{0.0};
|
|
glm::dvec2 forward{0.0, 1.0}; // in the plan, x and z
|
|
};
|
|
|
|
double plan_length(segment_data const &Path);
|
|
// points of the path, no farther apart in the plan than about specified step; the ends included
|
|
std::vector<glm::dvec3> outline(segment_data const &Path, double Step);
|
|
frame frame_at(segment_data const &Path, double S);
|
|
frame frame_at(station const &Station);
|
|
// nearest point of specified path in the plan. returns: distance in the plan; Interior tells the nearest point
|
|
// isn't one of the ends of the path
|
|
double project(segment_data const &Path, glm::dvec3 const &Point, double &S, bool &Interior);
|
|
// nearest point among the paths of the track
|
|
double project(TTrack &Track, glm::dvec3 const &Point, station &Station, bool &Interior);
|
|
// angle around the vertical axis which turns a model to face specified direction, in degrees
|
|
double heading(glm::dvec2 const &Forward);
|
|
|
|
// location of a point relative to the rail axis: the station, a sideways offset and a height above the rail top
|
|
struct anchor
|
|
{
|
|
station at;
|
|
double offset{0.0}; // positive to the right of the direction of the path
|
|
double height{0.0};
|
|
glm::dvec3 foot{0.0}; // point of the axis the location was measured from
|
|
// ends and length of the path when the station was measured, to tell whether the path changed since
|
|
glm::dvec3 start{0.0}, end{0.0};
|
|
double length{0.0};
|
|
};
|
|
anchor make_anchor(station const &At, glm::dvec3 const &Point);
|
|
// anchor at the place of the path nearest to the point
|
|
anchor make_anchor(TTrack *Track, int const Path, glm::dvec3 const &Point);
|
|
// location for the current geometry of the path
|
|
glm::dvec3 place(anchor &Anchor);
|
|
|
|
// rules telling infrastructure apart by the names of the files and nodes
|
|
struct rule
|
|
{
|
|
category group{category::other};
|
|
std::string keywords; // separated by spaces, matched as parts of the lower case name
|
|
};
|
|
std::vector<rule> default_rules();
|
|
// first rule in the list which matches. returns: category::other if none does
|
|
category classify(std::string const &Name, std::vector<rule> const &Rules);
|
|
|
|
struct binding
|
|
{
|
|
kind type{kind::model};
|
|
category group{category::other};
|
|
scene::basic_node *node{nullptr}; // the object, unless it's an include
|
|
scene::instance_handle include{0};
|
|
std::vector<anchor> anchors; // one per point which defines the object: four for a traction piece
|
|
double yaw{0.0}; // rotation of the object relative to the direction of the path
|
|
bool turns{false}; // the object has a rotation which follows the path
|
|
std::string label;
|
|
bool lost{false}; // none of the paths around could take the object over
|
|
|
|
bool same(binding const &Other) const
|
|
{
|
|
return type == Other.type && node == Other.node && include == Other.include;
|
|
}
|
|
};
|
|
|
|
// placement of a bound object, to take a change back
|
|
struct object_state
|
|
{
|
|
binding saved;
|
|
glm::dvec3 location{0.0};
|
|
glm::vec3 angles{0.f};
|
|
std::array<glm::dvec3, 4> points{};
|
|
std::string directive;
|
|
bool moved{false}; // the object followed a change since the state was taken
|
|
};
|
|
|
|
} // namespace infra
|