summaryrefslogtreecommitdiff
path: root/game/network/network.cpp
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2022-10-25 18:49:19 +0100
committerDan Goodliffe <dan@randomdan.homeip.net>2022-10-28 02:10:47 +0100
commit37b135e59ba22cf9ace1141b9dd21d0819fe3d1d (patch)
tree1b24085262116f04c8869365e50f971af56f7d3d /game/network/network.cpp
parentMove findDir into member function findNodeDirection (diff)
downloadilt-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.cpp16
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};
+}