summaryrefslogtreecommitdiff
path: root/game/network/network.impl.h
diff options
context:
space:
mode:
Diffstat (limited to 'game/network/network.impl.h')
-rw-r--r--game/network/network.impl.h47
1 files changed, 18 insertions, 29 deletions
diff --git a/game/network/network.impl.h b/game/network/network.impl.h
index f9595ed..ff29088 100644
--- a/game/network/network.impl.h
+++ b/game/network/network.impl.h
@@ -2,29 +2,18 @@
#include <gfx/gl/sceneShader.h>
#include <gfx/models/texture.h>
-template<typename T>
+template<typename T, typename... Links>
void
-NetworkOf<T>::render(const SceneShader & shader) const
-{
- if constexpr (std::is_base_of_v<Renderable, T>) {
- shader.absolute.use();
- texture->bind();
- links.apply(&Renderable::render, shader);
- }
-}
-
-template<typename T>
-void
-NetworkOf<T>::joinLinks(const Link::Ptr & l) const
+NetworkOf<T, Links...>::joinLinks(const Link::Ptr & l) const
{
for (const auto & ol : links.objects) {
Network::joinLinks(l, ol);
}
}
-template<typename T>
+template<typename T, typename... Links>
Link::Ptr
-NetworkOf<T>::intersectRayLinks(const Ray<GlobalPosition3D> & ray) const
+NetworkOf<T, Links...>::intersectRayLinks(const Ray<GlobalPosition3D> & ray) const
{
// Click link
if (const auto link = std::find_if(links.objects.begin(), links.objects.end(),
@@ -37,9 +26,9 @@ NetworkOf<T>::intersectRayLinks(const Ray<GlobalPosition3D> & ray) const
return {};
}
-template<typename T>
+template<typename T, typename... Links>
float
-NetworkOf<T>::findNodeDirection(Node::AnyCPtr n) const
+NetworkOf<T, Links...>::findNodeDirection(Node::AnyCPtr n) const
{
for (const auto & l : links.objects) {
for (const auto & e : l->ends) {
@@ -52,16 +41,16 @@ NetworkOf<T>::findNodeDirection(Node::AnyCPtr n) const
throw std::runtime_error("Node exists but couldn't find it");
}
-template<typename T>
+template<typename T, typename... Links>
Link::CCollection
-NetworkOf<T>::candidateStraight(GlobalPosition3D n1, GlobalPosition3D n2)
+NetworkOf<T, Links...>::candidateStraight(GlobalPosition3D n1, GlobalPosition3D n2)
{
return {candidateLink<typename T::StraightLink>(n1, n2)};
}
-template<typename T>
+template<typename T, typename... Links>
Link::CCollection
-NetworkOf<T>::candidateJoins(GlobalPosition3D start, GlobalPosition3D end)
+NetworkOf<T, Links...>::candidateJoins(GlobalPosition3D start, GlobalPosition3D end)
{
if (glm::length(RelativePosition3D(start - end)) < 2000.F) {
return {};
@@ -73,24 +62,24 @@ NetworkOf<T>::candidateJoins(GlobalPosition3D start, GlobalPosition3D end)
return {candidateLink<typename T::CurveLink>(c1s, c1e, c1c), candidateLink<typename T::CurveLink>(c2s, c2e, c2c)};
}
-template<typename T>
+template<typename T, typename... Links>
Link::CCollection
-NetworkOf<T>::candidateExtend(GlobalPosition3D start, GlobalPosition3D end)
+NetworkOf<T, Links...>::candidateExtend(GlobalPosition3D start, GlobalPosition3D end)
{
const auto [cstart, cend, centre] = genCurveDef(start, end, findNodeDirection(candidateNodeAt(start).first));
return {candidateLink<typename T::CurveLink>(cstart, cend, centre)};
}
-template<typename T>
+template<typename T, typename... Links>
Link::CCollection
-NetworkOf<T>::addStraight(GlobalPosition3D n1, GlobalPosition3D n2)
+NetworkOf<T, Links...>::addStraight(GlobalPosition3D n1, GlobalPosition3D n2)
{
return {addLink<typename T::StraightLink>(n1, n2)};
}
-template<typename T>
+template<typename T, typename... Links>
Link::CCollection
-NetworkOf<T>::addJoins(GlobalPosition3D start, GlobalPosition3D end)
+NetworkOf<T, Links...>::addJoins(GlobalPosition3D start, GlobalPosition3D end)
{
if (glm::length(RelativePosition3D(start - end)) < 2000.F) {
return {};
@@ -101,9 +90,9 @@ NetworkOf<T>::addJoins(GlobalPosition3D start, GlobalPosition3D end)
return {addLink<typename T::CurveLink>(c1s, c1e, c1c), addLink<typename T::CurveLink>(c2s, c2e, c2c)};
}
-template<typename T>
+template<typename T, typename... Links>
Link::CCollection
-NetworkOf<T>::addExtend(GlobalPosition3D start, GlobalPosition3D end)
+NetworkOf<T, Links...>::addExtend(GlobalPosition3D start, GlobalPosition3D end)
{
const auto [cstart, cend, centre] = genCurveDef(start, end, findNodeDirection(nodeAt(start)));
return {addLink<typename T::CurveLink>(cstart, cend, centre)};