Skip to content

Use cumulative cell index for at-grade rail sleeper spacing#1016

Merged
louis-e merged 1 commit into
mainfrom
fix/at-grade-rail-sleeper-spacing
May 7, 2026
Merged

Use cumulative cell index for at-grade rail sleeper spacing#1016
louis-e merged 1 commit into
mainfrom
fix/at-grade-rail-sleeper-spacing

Conversation

@louis-e

@louis-e louis-e commented May 7, 2026

Copy link
Copy Markdown
Owner

generate_at_grade_rail keyed sleeper placement off bx % 4, which depends on world X. North-south tracks (constant bx) ended up either all sleepers or none, and east-west tracks at a different starting X had a phase shift relative to bridge tracks. Track a cumulative index (tds) across segments so spacing is orientation-independent and matches the generate_rail_bridge convention.

skip_first = 1 on segments after the first so a shared OSM-node join isn't double-counted (which would shift the sleeper phase by one cell at every node).

generate_at_grade_rail keyed sleeper placement off bx % 4, which depends
on world X. North-south tracks (constant bx) ended up either all sleepers
or none, and east-west tracks at a different starting X had a phase
shift relative to bridge tracks. Track a cumulative index (tds) across
segments so spacing is orientation-independent and matches the
generate_rail_bridge convention.

skip_first = 1 on segments after the first so a shared OSM-node join
isn't double-counted (which would shift the sleeper phase by one cell at
every node).
Copilot AI review requested due to automatic review settings May 7, 2026 18:39
@github-actions

github-actions Bot commented May 7, 2026

Copy link
Copy Markdown

⏱️ Benchmark run finished in 0m 55s
🏗️ Generation time: 28s (excl. data fetching)
🧠 Peak memory usage: 831 MB (↘ 11% less)

📈 Compared against baseline: 27s time, 935 MB memory
🧮 Delta: 28s time, -104 MB memory
🔢 Commit: 4773ed3

🟢 Generation time is unchanged.
✅ This PR drastically reduces peak memory.

📅 Last benchmark: 2026-05-07 18:42:35 UTC

You can retrigger the benchmark by commenting retrigger-benchmark.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates at-grade rail generation so sleeper placement is based on a cumulative per-cell index along the track centerline (across OSM node segments), eliminating orientation/world-X dependency and aligning spacing behavior with rail-bridge generation.

Changes:

  • Track a cumulative cell index (tds) across segments and place sleepers every 4 cells using that index.
  • Avoid double-counting the shared cell at OSM-node joins by skipping the first point of subsequent segments.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/element_processing/railways.rs
@louis-e louis-e merged commit 8571454 into main May 7, 2026
7 checks passed
@louis-e louis-e deleted the fix/at-grade-rail-sleeper-spacing branch May 7, 2026 18:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants