From 1bcce010b5b11b485ba80df58c984277100dc99e Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Sun, 11 May 2025 00:12:42 +0100 Subject: Fix conditional render of rail links Tests for vertices, not links in network. Fixes case where links are present but not in network, e.g. currently being built. --- game/network/network.h | 1 + game/network/network.impl.h | 7 +++++++ game/network/rail.cpp | 2 +- gfx/gl/instanceVertices.h | 1 + 4 files changed, 10 insertions(+), 1 deletion(-) diff --git a/game/network/network.h b/game/network/network.h index 0c499c6..c1d3265 100644 --- a/game/network/network.h +++ b/game/network/network.h @@ -135,4 +135,5 @@ public: protected: Link::CCollection addCurve(const GeoData *, const GenCurveDef &); + [[nodiscard]] bool anyLinks() const; }; diff --git a/game/network/network.impl.h b/game/network/network.impl.h index 7f7dfb3..04c5d7c 100644 --- a/game/network/network.impl.h +++ b/game/network/network.impl.h @@ -160,6 +160,13 @@ NetworkOf::create(const GenCurveDef & def) *this, candidateNodeAt(std::get<0>(def)).first, candidateNodeAt(std::get<1>(def)).first, std::get<2>(def)); } +template +bool +NetworkOf::anyLinks() const +{ + return !(static_cast *>(this)->vertices.empty() && ...); +} + template void NetworkOf::add(GeoData * geoData, const Link::Ptr & link) diff --git a/game/network/rail.cpp b/game/network/rail.cpp index c0e597d..37eb7df 100644 --- a/game/network/rail.cpp +++ b/game/network/rail.cpp @@ -169,7 +169,7 @@ namespace { void RailLinks::render(const SceneShader & shader, const Frustum &) const { - if (!links.empty()) { + if (anyLinks()) { texture->bind(); glEnable(GL_POLYGON_OFFSET_FILL); glPolygonOffset(-1, 0); diff --git a/gfx/gl/instanceVertices.h b/gfx/gl/instanceVertices.h index 28e11ee..c290afe 100644 --- a/gfx/gl/instanceVertices.h +++ b/gfx/gl/instanceVertices.h @@ -118,6 +118,7 @@ public: } using base::bufferName; + using base::empty; [[nodiscard]] auto size() const -- cgit v1.2.3