From 31f73b6f44f3deac749af41e84435f5bc9b037f2 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Thu, 21 Mar 2024 20:09:34 +0000 Subject: Make arc_length a member function --- game/network/rail.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'game/network/rail.cpp') diff --git a/game/network/rail.cpp b/game/network/rail.cpp index 34cbceb..e342224 100644 --- a/game/network/rail.cpp +++ b/game/network/rail.cpp @@ -118,7 +118,7 @@ RailLinkCurve::RailLinkCurve( RailLinkCurve::RailLinkCurve(NetworkLinkHolder & instances, const Node::Ptr & a, const Node::Ptr & b, GlobalPosition3D c, const Arc arc) : Link({a, normalize(arc.first + half_pi)}, {b, normalize(arc.second - half_pi)}, - glm::length(RelativePosition3D(a->pos - c)) * arc_length(arc)), + glm::length(RelativePosition3D(a->pos - c)) * arc.length()), LinkCurve {c, glm::length(RelativePosition3D(ends[0].node->pos - c)), 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)} -- cgit v1.2.3 From 4571ce1b4cac2ab9bf2454ed06d0d787604d62fa Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Thu, 21 Mar 2024 20:23:44 +0000 Subject: Add helper constructors to Arc * Two angles, wraps logic ensuring b after a * Two vector directions * Centre and two endpoints, in at least 2 dimensions, uses .xy() --- game/network/rail.cpp | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'game/network/rail.cpp') diff --git a/game/network/rail.cpp b/game/network/rail.cpp index e342224..fd07ace 100644 --- a/game/network/rail.cpp +++ b/game/network/rail.cpp @@ -95,9 +95,8 @@ round_sleepers(const float v) return round_frac(v, sleepers); } -RailLinkStraight::RailLinkStraight( - NetworkLinkHolder & instances, const Node::Ptr & a, const Node::Ptr & b) : - RailLinkStraight(instances, a, b, b->pos - a->pos) +RailLinkStraight::RailLinkStraight(NetworkLinkHolder & instances, const Node::Ptr & a, + const Node::Ptr & b) : RailLinkStraight(instances, a, b, b->pos - a->pos) { } @@ -109,9 +108,8 @@ RailLinkStraight::RailLinkStraight( { } -RailLinkCurve::RailLinkCurve( - NetworkLinkHolder & instances, const Node::Ptr & a, const Node::Ptr & b, GlobalPosition2D c) : - RailLinkCurve(instances, a, b, c || a->pos.z, {c || 0, a->pos, b->pos}) +RailLinkCurve::RailLinkCurve(NetworkLinkHolder & instances, const Node::Ptr & a, const Node::Ptr & b, + GlobalPosition2D c) : RailLinkCurve(instances, a, b, c || a->pos.z, {c, a->pos, b->pos}) { } -- cgit v1.2.3