diff options
author | Dan Goodliffe <dan@randomdan.homeip.net> | 2022-10-14 18:11:40 +0100 |
---|---|---|
committer | Dan Goodliffe <dan@randomdan.homeip.net> | 2022-10-14 18:11:40 +0100 |
commit | 6a347439a76e265aa66fd3bcce6ff5665b8d8662 (patch) | |
tree | 48051450d5ac78e805aadce9d102f9c11188f44e | |
parent | Fix const correctness of Texture from raw data (diff) | |
download | ilt-6a347439a76e265aa66fd3bcce6ff5665b8d8662.tar.bz2 ilt-6a347439a76e265aa66fd3bcce6ff5665b8d8662.tar.xz ilt-6a347439a76e265aa66fd3bcce6ff5665b8d8662.zip |
Network candidate links
Returns a collection of links/nodes without adding them to the network, suitable for displaying in the UI
during a design/build process
-rw-r--r-- | game/network/network.h | 19 | ||||
-rw-r--r-- | game/network/network.impl.h | 18 |
2 files changed, 31 insertions, 6 deletions
diff --git a/game/network/network.h b/game/network/network.h index 60d9a02..773426e 100644 --- a/game/network/network.h +++ b/game/network/network.h @@ -31,7 +31,9 @@ public: [[nodiscard]] Link::Nexts routeFromTo(const Link::End &, glm::vec3) const; [[nodiscard]] Link::Nexts routeFromTo(const Link::End &, const Node::Ptr &) const; - virtual Link::CPtr addStraight(glm::vec3, glm::vec3) = 0; + virtual Link::CCollection candidateStraight(glm::vec3, glm::vec3) = 0; + virtual Link::CCollection candidateJoins(glm::vec3, glm::vec3) = 0; + virtual Link::CCollection addStraight(glm::vec3, glm::vec3) = 0; virtual Link::CCollection addJoins(glm::vec3, glm::vec3) = 0; protected: @@ -55,8 +57,15 @@ protected: public: template<typename L, typename... Params> std::shared_ptr<L> - addLink(glm::vec3 a, glm::vec3 b, Params &&... params) - requires std::is_base_of_v<T, L> + candidateLink(glm::vec3 a, glm::vec3 b, Params &&... params) requires std::is_base_of_v<T, L> + { + const auto node1 = candidateNodeAt(a).first, node2 = candidateNodeAt(b).first; + return std::make_shared<L>(node1, node2, std::forward<Params>(params)...); + } + + template<typename L, typename... Params> + std::shared_ptr<L> + addLink(glm::vec3 a, glm::vec3 b, Params &&... params) requires std::is_base_of_v<T, L> { const auto node1 = nodeAt(a), node2 = nodeAt(b); auto l {links.template create<L>(node1, node2, std::forward<Params>(params)...)}; @@ -64,7 +73,9 @@ public: return l; } - Link::CPtr addStraight(glm::vec3 n1, glm::vec3 n2) override; + Link::CCollection candidateStraight(glm::vec3 n1, glm::vec3 n2) override; + Link::CCollection candidateJoins(glm::vec3, glm::vec3) override; + Link::CCollection addStraight(glm::vec3 n1, glm::vec3 n2) override; Link::CCollection addJoins(glm::vec3, glm::vec3) override; void render(const Shader &) const override; diff --git a/game/network/network.impl.h b/game/network/network.impl.h index 68da5d9..6769320 100644 --- a/game/network/network.impl.h +++ b/game/network/network.impl.h @@ -38,10 +38,24 @@ NetworkOf<T>::intersectRayLinks(const Ray & ray) const } template<typename T> -Link::CPtr +Link::CCollection +NetworkOf<T>::candidateStraight(glm::vec3 n1, glm::vec3 n2) +{ + return {candidateLink<typename T::StraightLink>(n1, n2)}; +} + +template<typename T> +Link::CCollection +NetworkOf<T>::candidateJoins(glm::vec3 n1, glm::vec3 n2) +{ + return {candidateLink<typename T::StraightLink>(n1, n2)}; +} + +template<typename T> +Link::CCollection NetworkOf<T>::addStraight(glm::vec3 n1, glm::vec3 n2) { - return addLink<typename T::StraightLink>(n1, n2); + return {addLink<typename T::StraightLink>(n1, n2)}; } template<typename T> |