From d240fc840ebe35499e09c48960d4d89ce25c2824 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Wed, 10 Mar 2021 01:20:08 +0000 Subject: Add some more helpers to Network --- game/network/rail.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'game/network/rail.cpp') diff --git a/game/network/rail.cpp b/game/network/rail.cpp index c84f97f..7cc6284 100644 --- a/game/network/rail.cpp +++ b/game/network/rail.cpp @@ -42,8 +42,7 @@ RailLinks::joinLinks(const LinkPtr & l) const std::shared_ptr RailLinks::addLinksBetween(glm::vec3 start, glm::vec3 end) { - auto node1ins = nodes.insert(std::make_shared(start)); - auto node2ins = nodes.insert(std::make_shared(end)); + auto node1ins = newNodeAt(start), node2ins = newNodeAt(end); if (node1ins.second && node2ins.second) { // Both nodes are new, direct link, easy return addLink(start, end); @@ -65,14 +64,14 @@ RailLinks::addLinksBetween(glm::vec3 start, glm::vec3 end) } throw std::runtime_error("Node exists but couldn't find it"); }; - float dir = pi + findDir(*node1ins.first); + float dir = pi + findDir(node1ins.first); const glm::vec2 flatStart {!start}, flatEnd {!end}; if (!node2ins.second) { auto midheight = [&](auto mid) { const auto sm = glm::distance(flatStart, mid), em = glm::distance(flatEnd, mid); return start.y + ((end.y - start.y) * (sm / (sm + em))); }; - float dir2 = pi + findDir(*node2ins.first); + float dir2 = pi + findDir(node2ins.first); if (const auto radii = find_arcs_radius(flatStart, dir, flatEnd, dir2); radii.first < radii.second) { const auto radius {radii.first}; const auto c1 = flatStart + sincosf(dir + half_pi) * radius; -- cgit v1.2.3