summaryrefslogtreecommitdiff
path: root/game/network/rail.cpp
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2024-12-21 03:30:18 +0000
committerDan Goodliffe <dan@randomdan.homeip.net>2024-12-21 03:30:18 +0000
commitd8ee91b44e31cf1500926d37b7391e8c94bbf14a (patch)
tree7452ba1726a623e1e03a9adec07e60aa1298d23d /game/network/rail.cpp
parentGive UI builders an interface that can be programmatically called (diff)
downloadilt-d8ee91b44e31cf1500926d37b7391e8c94bbf14a.tar.bz2
ilt-d8ee91b44e31cf1500926d37b7391e8c94bbf14a.tar.xz
ilt-d8ee91b44e31cf1500926d37b7391e8c94bbf14a.zip
Fix calculating radius and length of curved links
Diffstat (limited to 'game/network/rail.cpp')
-rw-r--r--game/network/rail.cpp11
1 files changed, 6 insertions, 5 deletions
diff --git a/game/network/rail.cpp b/game/network/rail.cpp
index 6f04070..69422aa 100644
--- a/game/network/rail.cpp
+++ b/game/network/rail.cpp
@@ -108,16 +108,17 @@ 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, {c, a->pos, b->pos})
+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::RailLinkCurve(NetworkLinkHolder<RailLinkCurve> & instances, const Node::Ptr & a, const Node::Ptr & b,
- GlobalPosition3D c, const Arc arc) :
+ GlobalPosition3D c, RelativeDistance radius, const Arc arc) :
Link({a, normalize(arc.first + half_pi)}, {b, normalize(arc.second - half_pi)},
- glm::length(RelativePosition3D(a->pos - c)) * arc.length()),
- LinkCurve {c, glm::length(RelativePosition3D(ends[0].node->pos - c)), arc},
+ glm::length(RelativePosition2D {radius * arc.length(), difference(a->pos, b->pos).z})),
+ LinkCurve {c, radius, arc},
instance {instances.vertices.acquire(ends[0].node->pos, ends[1].node->pos, c, round_sleepers(length / 2000.F),
half_pi - arc.first, half_pi - arc.second, radius)}
{