summaryrefslogtreecommitdiff
path: root/game/network/rail.cpp
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2021-02-14 13:17:55 +0000
committerDan Goodliffe <dan@randomdan.homeip.net>2021-02-14 13:17:55 +0000
commitb4b52d38b63a76b3067b6b6de2b7f2dc2c8ca0f0 (patch)
tree2948ae9c038ed635e17765a85bdead48f23bb274 /game/network/rail.cpp
parentFix order of ends in test rail curves (diff)
downloadilt-b4b52d38b63a76b3067b6b6de2b7f2dc2c8ca0f0.tar.bz2
ilt-b4b52d38b63a76b3067b6b6de2b7f2dc2c8ca0f0.tar.xz
ilt-b4b52d38b63a76b3067b6b6de2b7f2dc2c8ca0f0.zip
Keep radius and arc as part of rail curve
Fixes order of mesh points oo fix culling
Diffstat (limited to 'game/network/rail.cpp')
-rw-r--r--game/network/rail.cpp9
1 files changed, 4 insertions, 5 deletions
diff --git a/game/network/rail.cpp b/game/network/rail.cpp
index a66bf65..4e09e29 100644
--- a/game/network/rail.cpp
+++ b/game/network/rail.cpp
@@ -101,22 +101,21 @@ RailLinkCurve::RailLinkCurve(const NodePtr & a, const NodePtr & b, glm::vec2 c)
}
RailLinkCurve::RailLinkCurve(const NodePtr & a, const NodePtr & b, glm::vec3 c, const Arc arc) :
- RailLink({a, normalize(arc.first - half_pi)}, {b, normalize(arc.second + half_pi)},
+ RailLink({a, normalize(arc.first + half_pi)}, {b, normalize(arc.second - half_pi)},
(glm::length(a->pos - c)) * arc_length(arc)),
- centreBase(c)
+ centreBase(c), radius {glm::length(ends[0].first->pos - centreBase)}, arc {arc}
{
const auto & e0p {ends[0].first->pos};
const auto & e1p {ends[1].first->pos};
- const auto radius = glm::length(e0p - centreBase);
const auto slength = round_sleepers(length / 2.F);
const auto segs = std::round(5.F * slength / std::pow(radius, 0.7F));
- const auto step {glm::vec3 {arc_length(arc), e1p.y - e0p.y, slength} / segs};
+ const auto step {glm::vec3 {arc_length(arc), e0p.y - e1p.y, slength} / segs};
const auto trans {glm::translate(centreBase)};
int segCount = segs;
vertices.reserve((segCount + 1) * railCrossSection.size());
indices.reserve(segCount * 2 * railCrossSection.size());
- for (glm::vec3 swing = {arc.first, 0.F, 0.F}; segCount >= 0; swing += step, --segCount) {
+ for (glm::vec3 swing = {arc.second, -e1p.y, 0.F}; segCount >= 0; swing += step, --segCount) {
const auto t {trans * glm::rotate(half_pi - swing.x, up) * glm::translate(glm::vec3 {radius, swing.y, 0.F})};
for (const auto & rcs : railCrossSection) {
const glm::vec3 m {(t * glm::vec4 {rcs.first, 1})};