17
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-11-01 09:12:08 +01:00

refactor(track): what goes with unevenness in one place, readable

The rules stay in TrackUneven.h with no dependence on the engine, as they can
be tested. Their use on the tracks moves out of Track.cpp to TrackUneven.cpp,
split into steps: the group of switches, the values of its paths, the meeting
of two ends. One set of helpers for the paths of a track takes the place of
the same conditions written out in several places, and the value at the ends
of a switch is worked out in one place. The clatter of an axle leaves the long
Update of a vehicle. The fields in the editor say themselves when they show.

No change in behaviour.
This commit is contained in:
maj00r
2026-10-31 19:05:56 +01:00
parent 371de52342
commit 2b8d7d7cf3
10 changed files with 405 additions and 295 deletions

View File

@@ -341,6 +341,10 @@ public:
void VelocitySet(float v);
double VelocityGet();
float Friction() const;
// a switch has two paths, any other track the one
int path_count() const;
TSegment *path_segment( int const Path ) const;
TTrack *path_neighbour( int const Path, int const End ) const;
// the unevenness the track declares, on a path of a switch
track_uneven::amounts uneven_declared( int const Path = 0 ) const;
bool is_uneven() const;
@@ -402,6 +406,11 @@ private:
};
mutable switch_stray m_switchstray;
switch_stray const &switch_uneven() const;
void settle_switch_stray() const;
// the lowest value of the paths ending at the point
track_uneven::amounts switch_paths_at( glm::dvec3 const &Point ) const;
// what a plain track comes to at its end, where it meets the other one
track_uneven::amounts uneven_met( TTrack const *Other, glm::dvec3 const &Point ) const;
// the value of a switch where a track joined to it meets it
track_uneven::amounts switch_uneven_at( glm::dvec3 const &Point ) const;
static int s_layoutstamp; // bumped when tracks are joined or changed, invalidates the two above