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/geoData.cpp | 2 +- game/network/rail.cpp | 10 ++++------ 2 files changed, 5 insertions(+), 7 deletions(-) (limited to 'game') diff --git a/game/geoData.cpp b/game/geoData.cpp index f4d9f65..aaa2548 100644 --- a/game/geoData.cpp +++ b/game/geoData.cpp @@ -453,7 +453,7 @@ GeoData::setHeights(const std::span triangleStrip) return extrusionDir; }; // Previous half edge end to current half end start arc tangents - const Arc arc {p1, p1 + (e0 || 0.F), p1 + (e1 || 0.F)}; + const Arc arc {e0, e1}; const auto limit = std::floor((arc.second - arc.first) * 5.F / pi); const auto inc = (arc.second - arc.first) / limit; for (float step = 1; step < limit; step += 1.F) { 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