Rail cockpit rides: no height on an unknown floor, a standing train keeps its direction

- railHeightM is null while the train is drawn on the ellipsoid (floor
  quality 0) instead of -1.5 m, so a view waits for the surface.
- An arc step between two reports tells which way a train runs only above
  15 m, the layer's parked-train jitter (FOLLOW_MIN_MOVE_M). GPS jitter of
  a standing train no longer flips the direction through the playback
  segments, which turned a ride 180 degrees every poll.
- drawDirection, a copy of direction, becomes a directionPlayed flag.
This commit is contained in:
German Khokhlov committed 2026-11-17 19:30:47 +04:00
1 parent 134138931f
commit a7d966ae7e
4 files changed
+105 -17

No files matched your search

+15 -13
View File
@@ -47,8 +47,13 @@ export function pathWindowM(dtMs) {
return window > PATH_WINDOW_MAX_M ? NaN : window;
}
/** Arc moved between two reports before it says which way a train runs (m). */
const DIRECTION_MIN_M = 1;
/**
* Arc moved between two reports before it says which way a train runs (m).
* A standing train's GPS jitter, a few metres back and forth, stays under it
* (the same parked-train jitter as FOLLOW_MIN_MOVE_M, policy.js) and keeps
* the direction learnt.
*/
const DIRECTION_MIN_M = 15;
/** +1 or -1 for an arc step longer than DIRECTION_MIN_M, else `known`. */
function directionOf(step, known) {
@@ -65,13 +70,13 @@ function createBinding(shapeIndex, path, via, s, fix) {
/**
* Which way the drawn train runs along the shape: +1 along it, -1
* against it, 0 until two reports or a playback segment tell. Kept until
* a rebind. Once playback has placed the train, only playback changes
* it: the newest reports run ahead of the drawn train, so a reversal
* they show turns it when playback reaches it.
* a rebind, and while the train stands. Once a playback segment has told
* it (`directionPlayed`), only playback changes it: the newest reports
* run ahead of the drawn train, so a reversal they show turns it when
* playback reaches it.
*/
direction: 0,
/** The direction the last placed playback segment ran, 0 before one. */
drawDirection: 0,
directionPlayed: false,
/** Arc and time of the newest report. */
fixS: s,
fixT: fix.t,
@@ -159,7 +164,7 @@ export function followFix(binding, fix) {
pathWindowM(fix.t - binding.fixT),
);
if (!hit || hit.offsetM > PATH_OFF_TRACK_M) return false;
if (!binding.drawDirection)
if (!binding.directionPlayed)
binding.direction = directionOf(hit.s - binding.fixS, binding.direction);
binding.fixS = hit.s;
binding.fixT = fix.t;
@@ -253,11 +258,8 @@ export function placeOnPath(binding, sample, segment, out) {
cache.sTo = sTo;
cache.ok = Number.isFinite(sFrom) && Number.isFinite(sTo);
if (cache.ok) {
binding.drawDirection = directionOf(
sTo - sFrom,
binding.drawDirection || binding.direction || 0,
);
binding.direction = binding.drawDirection;
binding.direction = directionOf(sTo - sFrom, binding.direction);
if (binding.direction) binding.directionPlayed = true;
}
}
if (!cache.ok) return false;