From 1e7a924874050674a103f6927f4a3c5ef6459222 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Fri, 13 Jun 2025 21:53:32 +0100 Subject: Create a list of snap points for the existing network These form key positions in the world to ease neat creation. --- game/network/rail.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'game/network/rail.cpp') 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; +} -- cgit v1.2.3