summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--game/network/network.cpp6
-rw-r--r--game/network/network.h7
-rw-r--r--game/network/network.impl.h2
3 files changed, 7 insertions, 8 deletions
diff --git a/game/network/network.cpp b/game/network/network.cpp
index 775d420..0189158 100644
--- a/game/network/network.cpp
+++ b/game/network/network.cpp
@@ -35,8 +35,8 @@ Network::findNodeAt(glm::vec3 pos) const
return {};
}
-Network::IntersectRayResult
-Network::intersectRay(const Ray & ray) const
+NodePtr
+Network::intersectRayNodes(const Ray & ray) const
{
// Click within 2m of a node
if (const auto node = std::find_if(nodes.begin(), nodes.end(),
@@ -47,7 +47,7 @@ Network::intersectRay(const Ray & ray) const
node != nodes.end()) {
return *node;
}
- return intersectRayLinks(ray);
+ return {};
}
void
diff --git a/game/network/network.h b/game/network/network.h
index 64f3f91..44ad095 100644
--- a/game/network/network.h
+++ b/game/network/network.h
@@ -18,21 +18,20 @@ class Ray;
class Network {
public:
using LinkEnd = std::pair<LinkPtr, unsigned char>;
- using IntersectRayResult = std::variant<std::nullptr_t, NodePtr, LinkEnd, LinkPtr>;
explicit Network(const std::string & textureName);
virtual ~Network() = default;
[[nodiscard]] NodePtr findNodeAt(glm::vec3) const;
[[nodiscard]] NodePtr nodeAt(glm::vec3);
[[nodiscard]] std::pair<NodePtr, bool> newNodeAt(glm::vec3);
- [[nodiscard]] IntersectRayResult intersectRay(const Ray &) const;
+ [[nodiscard]] virtual LinkPtr intersectRayLinks(const Ray &) const = 0;
+ [[nodiscard]] virtual NodePtr intersectRayNodes(const Ray &) const;
[[nodiscard]] Link::Nexts routeFromTo(const Link::End &, glm::vec3) const;
[[nodiscard]] Link::Nexts routeFromTo(const Link::End &, const NodePtr &) const;
protected:
static void joinLinks(const LinkPtr & l, const LinkPtr & ol);
- [[nodiscard]] virtual IntersectRayResult intersectRayLinks(const Ray &) const = 0;
using Nodes = std::set<NodePtr, PtrSorter<NodePtr>>;
Nodes nodes;
@@ -47,7 +46,7 @@ protected:
void joinLinks(const LinkPtr &) const;
protected:
- [[nodiscard]] IntersectRayResult intersectRayLinks(const Ray &) const override;
+ [[nodiscard]] LinkPtr intersectRayLinks(const Ray &) const override;
public:
template<typename L, typename... Params>
diff --git a/game/network/network.impl.h b/game/network/network.impl.h
index afc9304..c5da3f0 100644
--- a/game/network/network.impl.h
+++ b/game/network/network.impl.h
@@ -23,7 +23,7 @@ NetworkOf<T>::joinLinks(const LinkPtr & l) const
}
template<typename T>
-Network::IntersectRayResult
+LinkPtr
NetworkOf<T>::intersectRayLinks(const Ray & ray) const
{
// Click link