From 30e3c9625856c24fa88ec148da6865657414c77d Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Sun, 7 Feb 2021 11:32:15 +0000 Subject: Links have length, ends have entry direction --- game/network/rail.h | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) (limited to 'game/network/rail.h') 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 #include #include +#include #include class Shader; class Texture; @@ -22,7 +23,6 @@ public: void render(const Shader &) const override; protected: - RailLink(); Collection meshes; std::vector vertices; std::vector 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; 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 concept RailLinkConcept = std::is_base_of_v; @@ -46,8 +51,14 @@ template concept RailLinkConcept = std::is_base_of_v; class RailLinks : public Renderable, public WorldObject { public: RailLinks(); - template std::shared_ptr addLink(glm::vec3, glm::vec3); - template std::shared_ptr addLink(glm::vec3, glm::vec3, glm::vec2); + template + std::shared_ptr + addLink(glm::vec3 a, glm::vec3 b, Params &&... params) + { + const auto node1 = *nodes.insert(std::make_shared(a)).first; + const auto node2 = *nodes.insert(std::make_shared(b)).first; + return links.create(node1, node2, std::forward(params)...); + } private: using Nodes = std::set>; -- cgit v1.2.3