diff options
author | Dan Goodliffe <dan@randomdan.homeip.net> | 2021-02-14 14:16:17 +0000 |
---|---|---|
committer | Dan Goodliffe <dan@randomdan.homeip.net> | 2021-02-14 14:18:36 +0000 |
commit | fcfc640551ae27043fdb9ec8132670f5effd67fa (patch) | |
tree | fec5ea14f981cae8f766b81bbd7420c35896954f /game | |
parent | Swap application of rotX and rotY (diff) | |
download | ilt-fcfc640551ae27043fdb9ec8132670f5effd67fa.tar.bz2 ilt-fcfc640551ae27043fdb9ec8132670f5effd67fa.tar.xz ilt-fcfc640551ae27043fdb9ec8132670f5effd67fa.zip |
Apply pitch to vehicles on a link
Diffstat (limited to 'game')
-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 3b31204..56feec0 100644 --- a/game/network/rail.cpp +++ b/game/network/rail.cpp @@ -102,7 +102,7 @@ RailLinkStraight::positionAt(float dist, unsigned char start) const const auto es {std::make_pair(ends[start].first.get(), ends[1 - start].first.get())}; const auto diff {es.second->pos - es.first->pos}; const auto dir {glm::normalize(diff)}; - return Transform {es.first->pos + dir * dist, {0, vector_yaw(diff) /*, std::atan2(diff.x, -diff.z)*/, 0}}; + return Transform {es.first->pos + dir * dist, {-vector_pitch(dir), vector_yaw(dir), 0}}; } RailLinkCurve::RailLinkCurve(const NodePtr & a, const NodePtr & b, glm::vec2 c) : @@ -147,6 +147,6 @@ RailLinkCurve::positionAt(float dist, unsigned char start) const const auto relPos {glm::vec3 {std::cos(angArc), 0, -std::sin(angArc)} * radius}; const auto relClimb { glm::vec3 {0, -centreBase.y + es.first->pos.y + ((es.second->pos.y - es.first->pos.y) * frac), 0}}; - - return Transform {relPos + relClimb + centreBase, {0, normalize(ang + dirOffset[start]), 0}}; + const auto pitch {vector_pitch({0, (es.first->pos.y - es.second->pos.y) / length, 0})}; + return Transform {relPos + relClimb + centreBase, {pitch, normalize(ang + dirOffset[start]), 0}}; } |