summaryrefslogtreecommitdiff
path: root/game/network
diff options
context:
space:
mode:
Diffstat (limited to 'game/network')
-rw-r--r--game/network/network.cpp9
-rw-r--r--game/network/network.h1
2 files changed, 10 insertions, 0 deletions
diff --git a/game/network/network.cpp b/game/network/network.cpp
index 0189158..aff1aa4 100644
--- a/game/network/network.cpp
+++ b/game/network/network.cpp
@@ -35,6 +35,15 @@ Network::findNodeAt(glm::vec3 pos) const
return {};
}
+std::pair<NodePtr, bool>
+Network::candidateNodeAt(glm::vec3 pos) const
+{
+ if (const auto n = nodes.find(std::make_shared<Node>(pos)); n != nodes.end()) {
+ return {*n, true};
+ }
+ return {std::make_shared<Node>(pos), false};
+}
+
NodePtr
Network::intersectRayNodes(const Ray & ray) const
{
diff --git a/game/network/network.h b/game/network/network.h
index d561e55..79a4a2b 100644
--- a/game/network/network.h
+++ b/game/network/network.h
@@ -24,6 +24,7 @@ public:
[[nodiscard]] NodePtr findNodeAt(glm::vec3) const;
[[nodiscard]] NodePtr nodeAt(glm::vec3);
[[nodiscard]] std::pair<NodePtr, bool> newNodeAt(glm::vec3);
+ [[nodiscard]] std::pair<NodePtr, bool> candidateNodeAt(glm::vec3) const;
[[nodiscard]] virtual LinkPtr intersectRayLinks(const Ray &) const = 0;
[[nodiscard]] virtual NodePtr intersectRayNodes(const Ray &) const;