summaryrefslogtreecommitdiff
path: root/game/network/rail.cpp
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2021-03-10 00:24:26 +0000
committerDan Goodliffe <dan@randomdan.homeip.net>2021-03-10 00:27:31 +0000
commitd00fcb72da106a55d1256d853b4742257052cdb3 (patch)
tree90e5228d7bd8c61c53c3b55a176c028f1b57a179 /game/network/rail.cpp
parentMerge nexts into ends (diff)
downloadilt-d00fcb72da106a55d1256d853b4742257052cdb3.tar.bz2
ilt-d00fcb72da106a55d1256d853b4742257052cdb3.tar.xz
ilt-d00fcb72da106a55d1256d853b4742257052cdb3.zip
Add findNodeAt to locate a node instance by position
Diffstat (limited to 'game/network/rail.cpp')
-rw-r--r--game/network/rail.cpp9
1 files changed, 9 insertions, 0 deletions
diff --git a/game/network/rail.cpp b/game/network/rail.cpp
index 25b3376..8ec6893 100644
--- a/game/network/rail.cpp
+++ b/game/network/rail.cpp
@@ -37,6 +37,15 @@ RailLinks::joinLinks(const LinkPtr & l) const
}
}
+NodePtr
+RailLinks::findNodeAt(glm::vec3 pos) const
+{
+ if (const auto n = nodes.find(std::make_shared<Node>(pos)); n != nodes.end()) {
+ return *n;
+ }
+ return {};
+}
+
std::shared_ptr<RailLink>
RailLinks::addLinksBetween(glm::vec3 start, glm::vec3 end)
{