summaryrefslogtreecommitdiff
path: root/game/network/network.cpp
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2021-03-13 14:42:37 +0000
committerDan Goodliffe <dan@randomdan.homeip.net>2021-03-13 14:42:37 +0000
commit56782dbb368117faaddda0a45ca2ecb753af90d7 (patch)
treeb80b09f507fe3932c0404474743c43a0126b88eb /game/network/network.cpp
parentOnly attempt to render renderable networks (diff)
downloadilt-56782dbb368117faaddda0a45ca2ecb753af90d7.tar.bz2
ilt-56782dbb368117faaddda0a45ca2ecb753af90d7.tar.xz
ilt-56782dbb368117faaddda0a45ca2ecb753af90d7.zip
Initial commit of the route finder
Diffstat (limited to 'game/network/network.cpp')
-rw-r--r--game/network/network.cpp18
1 files changed, 18 insertions, 0 deletions
diff --git a/game/network/network.cpp b/game/network/network.cpp
index fd61764..7349ff0 100644
--- a/game/network/network.cpp
+++ b/game/network/network.cpp
@@ -1,9 +1,11 @@
#include "network.h"
+#include "routeWalker.h"
#include <array>
#include <cache.h>
#include <game/network/link.h>
#include <gfx/models/texture.h>
#include <initializer_list>
+#include <stdexcept>
#include <utility>
Network::Network(const std::string & tn) : texture {Texture::cachedTexture.get(tn)} { }
@@ -44,3 +46,19 @@ Network::joinLinks(const LinkPtr & l, const LinkPtr & ol)
}
}
}
+
+std::vector<LinkWPtr>
+Network::routeFromTo(const Link::End & start, glm::vec3 dest) const
+{
+ auto destNode {findNodeAt(dest)};
+ if (!destNode) {
+ throw std::out_of_range("Node does not exist in network");
+ }
+ return routeFromTo(start, destNode);
+}
+
+std::vector<LinkWPtr>
+Network::routeFromTo(const Link::End & end, const NodePtr & dest) const
+{
+ return RouteWalker().findRouteTo(end, dest);
+}