From 37b135e59ba22cf9ace1141b9dd21d0819fe3d1d Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Tue, 25 Oct 2022 18:49:19 +0100 Subject: Implement extending a network into open space --- game/network/network.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'game/network/network.cpp') diff --git a/game/network/network.cpp b/game/network/network.cpp index ad501b5..7724c20 100644 --- a/game/network/network.cpp +++ b/game/network/network.cpp @@ -93,3 +93,19 @@ Network::routeFromTo(const Link::End & end, const Node::Ptr & dest) const { return RouteWalker().findRouteTo(end, dest); } + +GenCurveDef +Network::genCurveDef(const glm::vec3 & start, const glm::vec3 & end, float startDir) +{ + const auto diff {end - start}; + const auto vy {vector_yaw(diff)}; + const auto dir = pi + startDir; + const auto flatStart {!start}, flatEnd {!end}; + const auto n2ed {(vy * 2) - dir - pi}; + const auto centre {find_arc_centre(flatStart, dir, flatEnd, n2ed)}; + + if (centre.second) { // right hand arc + return {end, start, centre.first}; + } + return {start, end, centre.first}; +} -- cgit v1.2.3