summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2025-05-11 00:12:42 +0100
committerDan Goodliffe <dan@randomdan.homeip.net>2025-05-11 00:12:42 +0100
commit1bcce010b5b11b485ba80df58c984277100dc99e (patch)
tree857b8d3f095e6e32e75656eb4560dd795ac9b2ca
parentSet terrain height and surface when adding link (diff)
downloadilt-1bcce010b5b11b485ba80df58c984277100dc99e.tar.bz2
ilt-1bcce010b5b11b485ba80df58c984277100dc99e.tar.xz
ilt-1bcce010b5b11b485ba80df58c984277100dc99e.zip
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.
-rw-r--r--game/network/network.h1
-rw-r--r--game/network/network.impl.h7
-rw-r--r--game/network/rail.cpp2
-rw-r--r--gfx/gl/instanceVertices.h1
4 files changed, 10 insertions, 1 deletions
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
@@ -161,6 +161,13 @@ NetworkOf<T, Links...>::create(const GenCurveDef & def)
}
template<typename T, typename... Links>
+bool
+NetworkOf<T, Links...>::anyLinks() const
+{
+ return !(static_cast<const NetworkLinkHolder<Links> *>(this)->vertices.empty() && ...);
+}
+
+template<typename T, typename... Links>
void
NetworkOf<T, Links...>::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