From 2a768eed79e1dbccd389a31a0d593729c9aef4f8 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Sun, 11 May 2025 10:15:31 +0100 Subject: Link helper to get an End pointer based on position --- game/network/link.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'game/network/link.cpp') diff --git a/game/network/link.cpp b/game/network/link.cpp index b8ffee2..1a4bb89 100644 --- a/game/network/link.cpp +++ b/game/network/link.cpp @@ -7,6 +7,18 @@ Link::Link(End endA, End endB, float len) : ends {{std::move(endA), std::move(endB)}}, length {len} { } +const Link::End * +Link::endAt(const GlobalPosition3D & queryPos) const +{ + if (ends.front().node->pos == queryPos) { + return &ends.front(); + } + if (ends.back().node->pos == queryPos) { + return &ends.back(); + } + return nullptr; +} + LinkCurve::LinkCurve(GlobalPosition3D centre, RelativeDistance radius, Arc arc) : centreBase {centre}, radius {radius}, arc {std::move(arc)} { -- cgit v1.2.3