summaryrefslogtreecommitdiff
path: root/game/network/network.h
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2024-01-24 00:46:57 +0000
committerDan Goodliffe <dan@randomdan.homeip.net>2024-01-24 00:46:57 +0000
commit17aa6053e641d006649f94bb60a834ce945f351e (patch)
treeb76f6fc642b749ee69d4be4b2e3f60e80c0ed7bc /game/network/network.h
parentAdd traits wrapper for setting uniforms (diff)
parentFix network population of position in gBuffer (diff)
downloadilt-17aa6053e641d006649f94bb60a834ce945f351e.tar.bz2
ilt-17aa6053e641d006649f94bb60a834ce945f351e.tar.xz
ilt-17aa6053e641d006649f94bb60a834ce945f351e.zip
Merge remote-tracking branch 'origin/instanced-networks'
Diffstat (limited to 'game/network/network.h')
-rw-r--r--game/network/network.h19
1 files changed, 14 insertions, 5 deletions
diff --git a/game/network/network.h b/game/network/network.h
index fa311ac..5725360 100644
--- a/game/network/network.h
+++ b/game/network/network.h
@@ -1,5 +1,6 @@
#pragma once
+#include "gfx/gl/instanceVertices.h"
#include "link.h"
#include <collection.h>
#include <gfx/renderable.h>
@@ -58,7 +59,17 @@ protected:
std::shared_ptr<Texture> texture;
};
-template<typename T> class NetworkOf : public Network, public Renderable {
+template<typename LinkType> class NetworkLinkHolder {
+public:
+ // Implemented per LinkType to configure vao
+ NetworkLinkHolder();
+ friend LinkType;
+ glVertexArray vao;
+ mutable InstanceVertices<typename LinkType::Vertex> vertices;
+};
+
+template<typename T, typename... Links>
+class NetworkOf : public Network, public Renderable, public NetworkLinkHolder<Links>... {
protected:
using Network::Network;
@@ -75,7 +86,7 @@ public:
requires std::is_base_of_v<T, L>
{
const auto node1 = candidateNodeAt(a).first, node2 = candidateNodeAt(b).first;
- return std::make_shared<L>(node1, node2, std::forward<Params>(params)...);
+ return std::make_shared<L>(*this, node1, node2, std::forward<Params>(params)...);
}
template<typename L, typename... Params>
@@ -84,7 +95,7 @@ public:
requires std::is_base_of_v<T, L>
{
const auto node1 = nodeAt(a), node2 = nodeAt(b);
- auto l {links.template create<L>(node1, node2, std::forward<Params>(params)...)};
+ auto l {links.template create<L>(*this, node1, node2, std::forward<Params>(params)...)};
joinLinks(l);
return l;
}
@@ -98,8 +109,6 @@ public:
[[nodiscard]] float findNodeDirection(Node::AnyCPtr) const override;
- void render(const SceneShader &) const override;
-
protected:
Link::CCollection addJoins();
};