diff options
| author | Dan Goodliffe <dan@randomdan.homeip.net> | 2025-06-13 21:53:32 +0100 |
|---|---|---|
| committer | Dan Goodliffe <dan@randomdan.homeip.net> | 2025-06-13 21:53:32 +0100 |
| commit | 1e7a924874050674a103f6927f4a3c5ef6459222 (patch) | |
| tree | 68f8f4b5dd34ff19b8a7cb6778a556775ed45b83 /game/network/rail.cpp | |
| parent | Handle edge cases (diff) | |
| download | ilt-1e7a924874050674a103f6927f4a3c5ef6459222.tar.bz2 ilt-1e7a924874050674a103f6927f4a3c5ef6459222.tar.xz ilt-1e7a924874050674a103f6927f4a3c5ef6459222.zip | |
Create a list of snap points for the existing networkbetter-network
These form key positions in the world to ease neat creation.
Diffstat (limited to 'game/network/rail.cpp')
| -rw-r--r-- | game/network/rail.cpp | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/game/network/rail.cpp b/game/network/rail.cpp index 342a2ad..45d55d6 100644 --- a/game/network/rail.cpp +++ b/game/network/rail.cpp @@ -137,3 +137,19 @@ RailLinks::getBaseWidth() const static constexpr auto BASE_WIDTH = 5'700; return BASE_WIDTH; } + +SnapPoints +RailLinks::getSnapPoints() const +{ + static constexpr auto EXTENSION_SNAP_DIST = 1'200.F; + SnapPoints out; + for (const auto & link : links) { + for (const auto & end : link->ends) { + // Link end node; directionless, suitable crossings + out.emplace_back(end.node->pos, end.node->pos, std::nullopt); + // Link end; with direction, suitable for continuing/joining + out.emplace_back(end.node->pos - ((sincos(end.dir) * EXTENSION_SNAP_DIST) || 0.F), end.node->pos, end.dir); + } + } + return out; +} |
