diff options
author | Dan Goodliffe <dan@randomdan.homeip.net> | 2021-02-21 13:05:01 +0000 |
---|---|---|
committer | Dan Goodliffe <dan@randomdan.homeip.net> | 2021-02-21 13:05:01 +0000 |
commit | 3a87671757ef081d059187e380274a8a9ba0b24c (patch) | |
tree | 80b4f4a1aa25c240eab867a8823092e1ea7ab40b | |
parent | Add more test rails (diff) | |
download | ilt-3a87671757ef081d059187e380274a8a9ba0b24c.tar.bz2 ilt-3a87671757ef081d059187e380274a8a9ba0b24c.tar.xz ilt-3a87671757ef081d059187e380274a8a9ba0b24c.zip |
Tweak rail mesh to work in junctions better
-rw-r--r-- | game/network/rail.cpp | 13 |
1 files 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 <type_traits> #include <utility> +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<std::pair<glm::vec3, float>, 4> railCrossSection {{ +constexpr const std::array<std::pair<glm::vec3, float>, 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 |