diff options
author | Dan Goodliffe <dan@randomdan.homeip.net> | 2025-01-13 01:45:43 +0000 |
---|---|---|
committer | Dan Goodliffe <dan@randomdan.homeip.net> | 2025-01-21 20:58:55 +0000 |
commit | 1aba027462a861f2c1155672792dbbe555d7dc0a (patch) | |
tree | f406c86cc0c610c05da63fc508d8963f0cb61ba4 /game/network/rail.cpp | |
parent | Add default Q = glm::defaultp to maths functions (diff) | |
download | ilt-1aba027462a861f2c1155672792dbbe555d7dc0a.tar.bz2 ilt-1aba027462a861f2c1155672792dbbe555d7dc0a.tar.xz ilt-1aba027462a861f2c1155672792dbbe555d7dc0a.zip |
Add distance helperterrain-for-networks
Works with integer positions, first template param allows forcing to N dimensions
Diffstat (limited to 'game/network/rail.cpp')
-rw-r--r-- | game/network/rail.cpp | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/game/network/rail.cpp b/game/network/rail.cpp index 2820cca..d7de231 100644 --- a/game/network/rail.cpp +++ b/game/network/rail.cpp @@ -40,8 +40,8 @@ RailLinks::addLinksBetween(GlobalPosition3D start, GlobalPosition3D end) const auto flatStart {start.xy()}, flatEnd {end.xy()}; if (node2ins.second == NodeIs::InNetwork) { auto midheight = [&](auto mid) { - const auto sm = glm::length(RelativePosition2D(flatStart - mid)), - em = glm::length(RelativePosition2D(flatEnd - mid)); + const auto sm = ::distance<2>(flatStart, mid); + const auto em = ::distance<2>(flatEnd, mid); return start.z + GlobalDistance(RelativeDistance(end.z - start.z) * (sm / (sm + em))); }; const float dir2 = pi + findNodeDirection(node2ins.first); @@ -117,7 +117,7 @@ RailLinkStraight::RailLinkStraight( RailLinkCurve::RailLinkCurve( NetworkLinkHolder<RailLinkCurve> & instances, const Node::Ptr & a, const Node::Ptr & b, GlobalPosition2D c) : - RailLinkCurve(instances, a, b, c || a->pos.z, glm::length(difference(a->pos.xy(), c)), {c, a->pos, b->pos}) + RailLinkCurve(instances, a, b, c || a->pos.z, ::distance<2>(a->pos.xy(), c), {c, a->pos, b->pos}) { } |