From 2f8d7643d03f39fa848576692264d0fe3a37ed91 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Mon, 6 Nov 2023 20:48:33 +0000 Subject: Reformat with new clang-format --- game/network/rail.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'game/network/rail.cpp') diff --git a/game/network/rail.cpp b/game/network/rail.cpp index bd24a2b..5a4f1e1 100644 --- a/game/network/rail.cpp +++ b/game/network/rail.cpp @@ -21,6 +21,7 @@ constexpr auto RAIL_CROSSSECTION_VERTICES {5U}; constexpr glm::vec3 RAIL_HEIGHT {0, 0, .25F}; RailLinks::RailLinks() : NetworkOf {"rails.jpg"} { } + void RailLinks::tick(TickDuration) { -- cgit v1.2.3 From 9c2c3f71065c94a18c02440111b6ff8ca977b90e Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Thu, 9 Nov 2023 00:40:40 +0000 Subject: WIP typedefing all the things - sources --- game/network/rail.cpp | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) (limited to 'game/network/rail.cpp') diff --git a/game/network/rail.cpp b/game/network/rail.cpp index 5a4f1e1..f46504b 100644 --- a/game/network/rail.cpp +++ b/game/network/rail.cpp @@ -18,7 +18,7 @@ template class NetworkOf; constexpr auto RAIL_CROSSSECTION_VERTICES {5U}; -constexpr glm::vec3 RAIL_HEIGHT {0, 0, .25F}; +constexpr Size3D RAIL_HEIGHT {0, 0, .25F}; RailLinks::RailLinks() : NetworkOf {"rails.jpg"} { } @@ -28,7 +28,7 @@ RailLinks::tick(TickDuration) } std::shared_ptr -RailLinks::addLinksBetween(glm::vec3 start, glm::vec3 end) +RailLinks::addLinksBetween(Position3D start, Position3D end) { auto node1ins = newNodeAt(start), node2ins = newNodeAt(end); if (node1ins.second == NodeIs::NotInNetwork && node2ins.second == NodeIs::NotInNetwork) { @@ -45,7 +45,7 @@ RailLinks::addLinksBetween(glm::vec3 start, glm::vec3 end) if (dir == vector_yaw(end - start)) { return addLink(start, end); } - const glm::vec2 flatStart {!start}, flatEnd {!end}; + const Position2D flatStart {!start}, flatEnd {!end}; if (node2ins.second == NodeIs::InNetwork) { auto midheight = [&](auto mid) { const auto sm = glm::distance(flatStart, mid), em = glm::distance(flatEnd, mid); @@ -100,7 +100,7 @@ RailLink::render(const SceneShader &) const mesh->Draw(); } -constexpr const std::array, RAIL_CROSSSECTION_VERTICES> railCrossSection {{ +constexpr const std::array, RAIL_CROSSSECTION_VERTICES> railCrossSection {{ // ___________ // _/ \_ // left to right @@ -122,7 +122,7 @@ RailLinkStraight::RailLinkStraight(const Node::Ptr & a, const Node::Ptr & b) : R { } -RailLinkStraight::RailLinkStraight(Node::Ptr a, Node::Ptr b, const glm::vec3 & diff) : +RailLinkStraight::RailLinkStraight(Node::Ptr a, Node::Ptr b, const Position3D & diff) : Link({std::move(a), vector_yaw(diff)}, {std::move(b), vector_yaw(-diff)}, glm::length(diff)) { if (glGenVertexArrays) { @@ -133,20 +133,20 @@ RailLinkStraight::RailLinkStraight(Node::Ptr a, Node::Ptr b, const glm::vec3 & d for (auto ei : {1U, 0U}) { const auto trans {glm::translate(ends[ei].node->pos) * e}; for (const auto & rcs : railCrossSection) { - const glm::vec3 m {(trans * glm::vec4 {rcs.first, 1})}; - vertices.emplace_back(m, glm::vec2 {rcs.second, len * static_cast(ei)}, up); + const Position3D m {(trans * glm::vec4 {rcs.first, 1})}; + vertices.emplace_back(m, Position2D {rcs.second, len * static_cast(ei)}, up); } } mesh = defaultMesh(vertices); } } -RailLinkCurve::RailLinkCurve(const Node::Ptr & a, const Node::Ptr & b, glm::vec2 c) : +RailLinkCurve::RailLinkCurve(const Node::Ptr & a, const Node::Ptr & b, Position2D c) : RailLinkCurve(a, b, c ^ a->pos.z, {!c, a->pos, b->pos}) { } -RailLinkCurve::RailLinkCurve(const Node::Ptr & a, const Node::Ptr & b, glm::vec3 c, const Arc arc) : +RailLinkCurve::RailLinkCurve(const Node::Ptr & a, const Node::Ptr & b, Position3D c, const Arc arc) : Link({a, normalize(arc.first + half_pi)}, {b, normalize(arc.second - half_pi)}, (glm::length(a->pos - c)) * arc_length(arc)), LinkCurve {c, glm::length(ends[0].node->pos - c), arc} @@ -156,25 +156,25 @@ RailLinkCurve::RailLinkCurve(const Node::Ptr & a, const Node::Ptr & b, glm::vec3 const auto & e1p {ends[1].node->pos}; const auto slength = round_sleepers(length / 2.F); const auto segs = std::round(15.F * slength / std::pow(radius, 0.7F)); - const auto step {glm::vec3 {arc_length(arc), e1p.z - e0p.z, slength} / segs}; + const auto step {Position3D {arc_length(arc), e1p.z - e0p.z, slength} / segs}; const auto trans {glm::translate(centreBase)}; auto segCount = static_cast(std::lround(segs)) + 1; std::vector vertices; vertices.reserve(segCount * railCrossSection.size()); - for (glm::vec3 swing = {arc.first, centreBase.z - e0p.z, 0.F}; segCount; swing += step, --segCount) { + for (Position3D swing = {arc.first, centreBase.z - e0p.z, 0.F}; segCount; swing += step, --segCount) { const auto t { - trans * glm::rotate(half_pi - swing.x, up) * glm::translate(glm::vec3 {radius, 0.F, swing.y})}; + trans * glm::rotate(half_pi - swing.x, up) * glm::translate(Position3D {radius, 0.F, swing.y})}; for (const auto & rcs : railCrossSection) { - const glm::vec3 m {(t * glm::vec4 {rcs.first, 1})}; - vertices.emplace_back(m, glm::vec2 {rcs.second, swing.z}, up); + const Position3D m {(t * glm::vec4 {rcs.first, 1})}; + vertices.emplace_back(m, Position2D {rcs.second, swing.z}, up); } } mesh = defaultMesh(vertices); } } -glm::vec3 +Position3D RailLink::vehiclePositionOffset() const { return RAIL_HEIGHT; -- cgit v1.2.3 From d771fbda2c171cfbc36cc0eb3122c1a02ffbb081 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Thu, 9 Nov 2023 01:57:27 +0000 Subject: WIP typedefing just about everything else --- game/network/rail.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'game/network/rail.cpp') diff --git a/game/network/rail.cpp b/game/network/rail.cpp index f46504b..cc61db9 100644 --- a/game/network/rail.cpp +++ b/game/network/rail.cpp @@ -133,7 +133,7 @@ RailLinkStraight::RailLinkStraight(Node::Ptr a, Node::Ptr b, const Position3D & for (auto ei : {1U, 0U}) { const auto trans {glm::translate(ends[ei].node->pos) * e}; for (const auto & rcs : railCrossSection) { - const Position3D m {(trans * glm::vec4 {rcs.first, 1})}; + const Position3D m {(trans * (rcs.first ^ 1))}; vertices.emplace_back(m, Position2D {rcs.second, len * static_cast(ei)}, up); } } @@ -166,7 +166,7 @@ RailLinkCurve::RailLinkCurve(const Node::Ptr & a, const Node::Ptr & b, Position3 const auto t { trans * glm::rotate(half_pi - swing.x, up) * glm::translate(Position3D {radius, 0.F, swing.y})}; for (const auto & rcs : railCrossSection) { - const Position3D m {(t * glm::vec4 {rcs.first, 1})}; + const Position3D m {(t * (rcs.first ^ 1))}; vertices.emplace_back(m, Position2D {rcs.second, swing.z}, up); } } -- cgit v1.2.3 From 685b33980cc7a346574b24732464f0cbe3115a1f Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Wed, 15 Nov 2023 01:29:24 +0000 Subject: Switch to millimeters for spatial units Mostly a case of changing far too many magic numbers, something else to fix I guess. I probably missed something. Also there's some hackery when loading 3D models, which are still assumed to be in metres. --- game/network/rail.cpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'game/network/rail.cpp') diff --git a/game/network/rail.cpp b/game/network/rail.cpp index cc61db9..ff101d4 100644 --- a/game/network/rail.cpp +++ b/game/network/rail.cpp @@ -18,7 +18,7 @@ template class NetworkOf; constexpr auto RAIL_CROSSSECTION_VERTICES {5U}; -constexpr Size3D RAIL_HEIGHT {0, 0, .25F}; +constexpr Size3D RAIL_HEIGHT {0, 0, 250.F}; RailLinks::RailLinks() : NetworkOf {"rails.jpg"} { } @@ -104,11 +104,11 @@ constexpr const std::array, RAIL_CROSSSECTION_VERTI // ___________ // _/ \_ // left to right - {{-1.9F, 0.F, 0.F}, 0.F}, - {{-.608F, 0.F, RAIL_HEIGHT.z}, 0.34F}, - {{0, 0.F, RAIL_HEIGHT.z * .7F}, 0.5F}, - {{.608F, 0.F, RAIL_HEIGHT.z}, 0.66F}, - {{1.9F, 0.F, 0.F}, 1.F}, + {{-1900.F, 0.F, 0.F}, 0.F}, + {{-608.F, 0.F, RAIL_HEIGHT.z}, .34F}, + {{0, 0.F, RAIL_HEIGHT.z * .7F}, .5F}, + {{608.F, 0.F, RAIL_HEIGHT.z}, .66F}, + {{1900.F, 0.F, 0.F}, 1.F}, }}; constexpr auto sleepers {5.F}; // There are 5 repetitions of sleepers in the texture @@ -128,7 +128,7 @@ RailLinkStraight::RailLinkStraight(Node::Ptr a, Node::Ptr b, const Position3D & if (glGenVertexArrays) { std::vector vertices; vertices.reserve(2 * railCrossSection.size()); - const auto len = round_sleepers(length / 2.F); + const auto len = round_sleepers(length / 2000.F); const auto e {flat_orientation(diff)}; for (auto ei : {1U, 0U}) { const auto trans {glm::translate(ends[ei].node->pos) * e}; @@ -155,8 +155,8 @@ RailLinkCurve::RailLinkCurve(const Node::Ptr & a, const Node::Ptr & b, Position3 const auto & e0p {ends[0].node->pos}; const auto & e1p {ends[1].node->pos}; const auto slength = round_sleepers(length / 2.F); - const auto segs = std::round(15.F * slength / std::pow(radius, 0.7F)); - const auto step {Position3D {arc_length(arc), e1p.z - e0p.z, slength} / segs}; + const auto segs = std::round(slength / std::pow(radius, 0.7F)); + const auto step {Position3D {arc_length(arc), e1p.z - e0p.z, slength / 1000.F} / segs}; const auto trans {glm::translate(centreBase)}; auto segCount = static_cast(std::lround(segs)) + 1; -- cgit v1.2.3