summaryrefslogtreecommitdiff
path: root/game/network/rail.h
diff options
context:
space:
mode:
Diffstat (limited to 'game/network/rail.h')
-rw-r--r--game/network/rail.h23
1 files changed, 17 insertions, 6 deletions
diff --git a/game/network/rail.h b/game/network/rail.h
index 7e1f5ac..3ab0c83 100644
--- a/game/network/rail.h
+++ b/game/network/rail.h
@@ -10,6 +10,7 @@
#include <glm/glm.hpp>
#include <memory>
#include <set>
+#include <utility>
#include <vector>
class Shader;
class Texture;
@@ -22,7 +23,6 @@ public:
void render(const Shader &) const override;
protected:
- RailLink();
Collection<Mesh, false> meshes;
std::vector<Vertex> vertices;
std::vector<unsigned int> indices;
@@ -30,15 +30,20 @@ protected:
class RailLinkStraight : public RailLink {
public:
- RailLinkStraight(End, End);
+ RailLinkStraight(const NodePtr &, const NodePtr &);
+
+private:
+ RailLinkStraight(NodePtr, NodePtr, const glm::vec3 & diff);
};
+using Arc = std::pair<float, float>;
class RailLinkCurve : public RailLink {
public:
- RailLinkCurve(End, End, glm::vec2);
+ RailLinkCurve(const NodePtr &, const NodePtr &, glm::vec2);
private:
- glm::vec2 centre;
+ RailLinkCurve(const NodePtr &, const NodePtr &, glm::vec3, const Arc);
+ glm::vec3 centreBase;
};
template<typename T> concept RailLinkConcept = std::is_base_of_v<RailLink, T>;
@@ -46,8 +51,14 @@ template<typename T> concept RailLinkConcept = std::is_base_of_v<RailLink, T>;
class RailLinks : public Renderable, public WorldObject {
public:
RailLinks();
- template<RailLinkConcept T> std::shared_ptr<T> addLink(glm::vec3, glm::vec3);
- template<RailLinkConcept T> std::shared_ptr<T> addLink(glm::vec3, glm::vec3, glm::vec2);
+ template<RailLinkConcept T, typename... Params>
+ std::shared_ptr<T>
+ addLink(glm::vec3 a, glm::vec3 b, Params &&... params)
+ {
+ const auto node1 = *nodes.insert(std::make_shared<Node>(a)).first;
+ const auto node2 = *nodes.insert(std::make_shared<Node>(b)).first;
+ return links.create<T>(node1, node2, std::forward<Params>(params)...);
+ }
private:
using Nodes = std::set<NodePtr, PtrSorter<NodePtr>>;