From 3a87671757ef081d059187e380274a8a9ba0b24c Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Sun, 21 Feb 2021 13:05:01 +0000 Subject: Tweak rail mesh to work in junctions better --- game/network/rail.cpp | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/game/network/rail.cpp b/game/network/rail.cpp index 10dfb88..b27aba9 100644 --- a/game/network/rail.cpp +++ b/game/network/rail.cpp @@ -13,6 +13,8 @@ #include #include +constexpr std::size_t RAIL_CROSSSECTION_VERTICES {5}; + RailLinks::RailLinks() : texture {Texture::cachedTexture.get("rails.jpg")} { } void RailLinks::tick(TickDuration) { } @@ -44,8 +46,8 @@ RailLinks::render(const Shader & shader) const void RailLink::defaultMesh() { - for (auto n = 4U; n < vertices.size(); n += 1) { - indices.push_back(n - 4); + for (auto n = RAIL_CROSSSECTION_VERTICES; n < vertices.size(); n += 1) { + indices.push_back(n - RAIL_CROSSSECTION_VERTICES); indices.push_back(n); } @@ -60,13 +62,14 @@ RailLink::render(const Shader &) const meshes.apply(&Mesh::Draw); } -constexpr const std::array, 4> railCrossSection {{ +constexpr const std::array, RAIL_CROSSSECTION_VERTICES> railCrossSection {{ // ___________ // _/ \_ // left to right {{-1.9F, 0.F, 0.F}, 0.F}, - {{-1.43F, .25F, 0.F}, 0.125F}, - {{1.43F, .25F, 0.F}, 0.875F}, + {{-.608F, RAIL_HEIGHT, 0.F}, 0.34F}, + {{0, RAIL_HEIGHT * .7F, 0.F}, 0.5F}, + {{.608F, RAIL_HEIGHT, 0.F}, 0.66F}, {{1.9F, 0.F, 0.F}, 1.F}, }}; constexpr auto sleepers {5.F}; // There are 5 repetitions of sleepers in the texture -- cgit v1.2.3