diff options
-rw-r--r-- | game/geoData.cpp | 2 | ||||
-rw-r--r-- | game/network/rail.cpp | 10 | ||||
-rw-r--r-- | lib/maths.cpp | 5 | ||||
-rw-r--r-- | lib/maths.h | 28 | ||||
-rw-r--r-- | test/Jamfile.jam | 1 |
5 files changed, 20 insertions, 26 deletions
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<const GlobalPosition3D> 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<RailLinkStraight> & instances, const Node::Ptr & a, const Node::Ptr & b) : - RailLinkStraight(instances, a, b, b->pos - a->pos) +RailLinkStraight::RailLinkStraight(NetworkLinkHolder<RailLinkStraight> & 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<RailLinkCurve> & 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<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}) { } diff --git a/lib/maths.cpp b/lib/maths.cpp index bf17204..51e27fe 100644 --- a/lib/maths.cpp +++ b/lib/maths.cpp @@ -4,6 +4,11 @@ #include <glm/gtx/rotate_vector.hpp> #include <glm/gtx/transform.hpp> +Arc::Arc(const RelativePosition2D & dir0, const RelativePosition2D & dir1) : + Arc {vector_yaw(dir0), vector_yaw(dir1)} { } + +Arc::Arc(const Angle anga, const Angle angb) : pair {anga, (angb < anga) ? angb + two_pi : angb} { } + glm::mat4 flat_orientation(const Direction3D & diff) { diff --git a/lib/maths.h b/lib/maths.h index 20a397b..656fefd 100644 --- a/lib/maths.h +++ b/lib/maths.h @@ -8,11 +8,16 @@ #include <stdexcept> #include <utility> -struct Arc : public std::pair<float, float> { - using std::pair<float, float>::pair; +struct Arc : public std::pair<Angle, Angle> { + template<glm::length_t Lc, glm::length_t Le, typename T, glm::qualifier Q> + requires(Lc >= 2, Le >= 2) + Arc(const glm::vec<Lc, T, Q> & centre, const glm::vec<Le, T, Q> & e0p, const glm::vec<Le, T, Q> & e1p) : + Arc {RelativePosition2D {e0p.xy() - centre.xy()}, RelativePosition2D {e1p.xy() - centre.xy()}} + { + } - template<typename T, glm::qualifier Q> - Arc(const glm::vec<3, T, Q> & centre3, const glm::vec<3, T, Q> & e0p, const glm::vec<3, T, Q> & e1p); + Arc(const RelativePosition2D & dir0, const RelativePosition2D & dir1); + Arc(const Angle angb, const Angle anga); auto operator[](bool i) const @@ -244,21 +249,6 @@ midpoint(const std::pair<T, T> & v) return std::midpoint(v.first, v.second); } -template<typename T, glm::qualifier Q> -Arc::Arc(const glm::vec<3, T, Q> & centre3, const glm::vec<3, T, Q> & e0p, const glm::vec<3, T, Q> & e1p) : - Arc([&]() -> Arc { - const auto diffa = e0p - centre3; - const auto diffb = e1p - centre3; - const auto anga = vector_yaw(diffa); - const auto angb = [&diffb, &anga]() { - const auto angb = vector_yaw(diffb); - return (angb < anga) ? angb + two_pi : angb; - }(); - return {anga, angb}; - }()) -{ -} - // Conversions template<typename T> inline constexpr auto diff --git a/test/Jamfile.jam b/test/Jamfile.jam index 1b07b5a..cce4513 100644 --- a/test/Jamfile.jam +++ b/test/Jamfile.jam @@ -12,6 +12,7 @@ project : requirements <define>BOOST_TEST_DYN_LINK <define>RESDIR=\\\"$(res)/\\\" <define>FIXTURESDIR=\\\"$(fixtures)/\\\" + <define>GLM_FORCE_SWIZZLE <variant>debug:<warnings>pedantic <variant>debug:<warnings-as-errors>on <variant>debug:<cflags>-Wnon-virtual-dtor |