diff options
author | Dan Goodliffe <dan@randomdan.homeip.net> | 2024-10-20 16:24:14 +0100 |
---|---|---|
committer | Dan Goodliffe <dan@randomdan.homeip.net> | 2024-10-20 16:24:14 +0100 |
commit | 5b6a6f3b241fea6d19521ddbb705e27d5e4c0268 (patch) | |
tree | 2c7fd705a6cff4be087f62b9ce940b413f8942b4 /game/network | |
parent | Misc readability fixes (diff) | |
download | ilt-5b6a6f3b241fea6d19521ddbb705e27d5e4c0268.tar.bz2 ilt-5b6a6f3b241fea6d19521ddbb705e27d5e4c0268.tar.xz ilt-5b6a6f3b241fea6d19521ddbb705e27d5e4c0268.zip |
Move lots of maths helpers to inline, constexpr, templates
Always for working with different dimensions/types
Diffstat (limited to 'game/network')
-rw-r--r-- | game/network/link.cpp | 2 | ||||
-rw-r--r-- | game/network/network.cpp | 2 | ||||
-rw-r--r-- | game/network/rail.cpp | 4 |
3 files changed, 4 insertions, 4 deletions
diff --git a/game/network/link.cpp b/game/network/link.cpp index 248fe7d..745896c 100644 --- a/game/network/link.cpp +++ b/game/network/link.cpp @@ -51,7 +51,7 @@ LinkCurve::positionAt(float dist, unsigned char start) const + RelativePosition3D {0, 0, static_cast<RelativeDistance>(es.first->pos.z - centreBase.z) + (static_cast<RelativeDistance>(es.second->pos.z - es.first->pos.z) * frac)}}; - const auto pitch {vector_pitch({0, 0, static_cast<RelativeDistance>(es.second->pos.z - es.first->pos.z) / length})}; + const auto pitch {vector_pitch(difference(es.second->pos, es.first->pos) / length)}; return Location {GlobalPosition3D(relPos + relClimb) + centreBase, {pitch, normalize(ang + dirOffset[start]), 0}}; } diff --git a/game/network/network.cpp b/game/network/network.cpp index 65b2a62..fa86cb5 100644 --- a/game/network/network.cpp +++ b/game/network/network.cpp @@ -95,7 +95,7 @@ Network::routeFromTo(const Link::End & end, const Node::Ptr & dest) const GenCurveDef Network::genCurveDef(const GlobalPosition3D & start, const GlobalPosition3D & end, float startDir) { - const auto diff {end - start}; + const auto diff = difference(end, start); const auto vy {vector_yaw(diff)}; const auto dir = pi + startDir; const auto flatStart {start.xy()}, flatEnd {end.xy()}; diff --git a/game/network/rail.cpp b/game/network/rail.cpp index fd07ace..c29217a 100644 --- a/game/network/rail.cpp +++ b/game/network/rail.cpp @@ -32,7 +32,7 @@ RailLinks::addLinksBetween(GlobalPosition3D start, GlobalPosition3D end) } // Find start link/end - opposite entry dir to existing link; so pi +... const Angle dir = pi + findNodeDirection(node1ins.first); - if (dir == vector_yaw(end - start)) { + if (dir == vector_yaw(difference(end, start))) { return addLink<RailLinkStraight>(start, end); } const auto flatStart {start.xy()}, flatEnd {end.xy()}; @@ -62,7 +62,7 @@ RailLinks::addLinksBetween(GlobalPosition3D start, GlobalPosition3D end) return addLink<RailLinkCurve>(midh, end, c2); } } - const auto diff {end - start}; + const auto diff = difference(end, start); const auto vy {vector_yaw(diff)}; const auto n2ed {(vy * 2) - dir - pi}; const auto centre {find_arc_centre(flatStart, dir, flatEnd, n2ed)}; |