summaryrefslogtreecommitdiff
path: root/game/network/rail.cpp
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2025-06-13 21:53:32 +0100
committerDan Goodliffe <dan@randomdan.homeip.net>2025-06-13 21:53:32 +0100
commit1e7a924874050674a103f6927f4a3c5ef6459222 (patch)
tree68f8f4b5dd34ff19b8a7cb6778a556775ed45b83 /game/network/rail.cpp
parentHandle edge cases (diff)
downloadilt-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.cpp16
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;
+}