summaryrefslogtreecommitdiff
path: root/game/network/link.h
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2021-02-05 00:30:13 +0000
committerDan Goodliffe <dan@randomdan.homeip.net>2021-02-05 00:30:13 +0000
commitc1ea14d1c96de18448c0c3779d30b7e1e4451f61 (patch)
treeb97edc04e70495caf49545dc30ed9936d1986d07 /game/network/link.h
parentCreate terrain as collection of meshes (diff)
downloadilt-c1ea14d1c96de18448c0c3779d30b7e1e4451f61.tar.bz2
ilt-c1ea14d1c96de18448c0c3779d30b7e1e4451f61.tar.xz
ilt-c1ea14d1c96de18448c0c3779d30b7e1e4451f61.zip
Initial commit generating some basic rail network
Diffstat (limited to 'game/network/link.h')
-rw-r--r--game/network/link.h51
1 files changed, 51 insertions, 0 deletions
diff --git a/game/network/link.h b/game/network/link.h
new file mode 100644
index 0000000..0da413c
--- /dev/null
+++ b/game/network/link.h
@@ -0,0 +1,51 @@
+#ifndef LINK_H
+#define LINK_H
+
+#include <array>
+#include <glm/glm.hpp>
+#include <memory>
+#include <special_members.hpp>
+#include <utility>
+
+// Generic network node
+// something that can be travelled to
+// it has location
+class Node {
+public:
+ explicit Node(glm::vec3 p) noexcept : pos(p) {};
+ virtual ~Node() noexcept = default;
+ NO_COPY(Node);
+ NO_MOVE(Node);
+
+ glm::vec3 pos;
+};
+using NodePtr = std::shared_ptr<Node>;
+
+// Generic network link
+// something that can be travelled along
+// it joins 2 nodes
+class Link {
+public:
+ // side determines which edges can be moved to next, must alternate
+ using End = std::pair<NodePtr, bool /*side*/>;
+
+ Link(End, End);
+ virtual ~Link() = default;
+ NO_COPY(Link);
+ NO_MOVE(Link);
+
+ std::array<End, 2> ends;
+};
+
+template<typename T> struct PtrSorter {
+ bool
+ operator()(const T & a, const T & b) const
+ {
+ return *a < *b;
+ }
+};
+
+bool operator<(const glm::vec3 & a, const glm::vec3 & b);
+bool operator<(const Node & a, const Node & b);
+
+#endif