diff options
author | Dan Goodliffe <dan@randomdan.homeip.net> | 2022-10-25 18:49:19 +0100 |
---|---|---|
committer | Dan Goodliffe <dan@randomdan.homeip.net> | 2022-10-28 02:10:47 +0100 |
commit | 37b135e59ba22cf9ace1141b9dd21d0819fe3d1d (patch) | |
tree | 1b24085262116f04c8869365e50f971af56f7d3d /game/network/network.cpp | |
parent | Move findDir into member function findNodeDirection (diff) | |
download | ilt-37b135e59ba22cf9ace1141b9dd21d0819fe3d1d.tar.bz2 ilt-37b135e59ba22cf9ace1141b9dd21d0819fe3d1d.tar.xz ilt-37b135e59ba22cf9ace1141b9dd21d0819fe3d1d.zip |
Implement extending a network into open space
Diffstat (limited to 'game/network/network.cpp')
-rw-r--r-- | game/network/network.cpp | 16 |
1 files changed, 16 insertions, 0 deletions
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}; +} |