summaryrefslogtreecommitdiff
path: root/game/network/rail.cpp
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2021-03-10 00:53:08 +0000
committerDan Goodliffe <dan@randomdan.homeip.net>2021-03-10 00:53:08 +0000
commitc274ac05690b34ba05b41d6e7864e6a663c73c1a (patch)
treeb73b3654ae8cd99deba893b278378a4831e5c70c /game/network/rail.cpp
parentAdd findNodeAt to locate a node instance by position (diff)
downloadilt-c274ac05690b34ba05b41d6e7864e6a663c73c1a.tar.bz2
ilt-c274ac05690b34ba05b41d6e7864e6a663c73c1a.tar.xz
ilt-c274ac05690b34ba05b41d6e7864e6a663c73c1a.zip
Push RailLinks functionality into new base classes Network and NetworkOf<>
Diffstat (limited to 'game/network/rail.cpp')
-rw-r--r--game/network/rail.cpp28
1 files changed, 6 insertions, 22 deletions
diff --git a/game/network/rail.cpp b/game/network/rail.cpp
index 8ec6893..133b80c 100644
--- a/game/network/rail.cpp
+++ b/game/network/rail.cpp
@@ -1,11 +1,10 @@
#include "rail.h"
-#include "game/network/link.h"
+#include "network.h"
#include <GL/glew.h>
#include <array>
-#include <cache.h>
#include <cassert>
-#include <gfx/gl/shader.h>
-#include <gfx/models/texture.h>
+#include <game/network/link.h>
+#include <game/network/network.impl.h> // IWYU pragma: keep
#include <gfx/models/vertex.hpp>
#include <glm/gtx/transform.hpp>
#include <initializer_list>
@@ -14,10 +13,12 @@
#include <stdexcept>
#include <utility>
+template class NetworkOf<RailLink>;
+
constexpr auto RAIL_CROSSSECTION_VERTICES {5U};
constexpr glm::vec3 RAIL_HEIGHT {0, .25F, 0};
-RailLinks::RailLinks() : texture {Texture::cachedTexture.get("rails.jpg")} { }
+RailLinks::RailLinks() : NetworkOf<RailLink> {"rails.jpg"} { }
void RailLinks::tick(TickDuration) { }
void
@@ -37,15 +38,6 @@ RailLinks::joinLinks(const LinkPtr & l) const
}
}
-NodePtr
-RailLinks::findNodeAt(glm::vec3 pos) const
-{
- if (const auto n = nodes.find(std::make_shared<Node>(pos)); n != nodes.end()) {
- return *n;
- }
- return {};
-}
-
std::shared_ptr<RailLink>
RailLinks::addLinksBetween(glm::vec3 start, glm::vec3 end)
{
@@ -111,14 +103,6 @@ RailLinks::addLinksBetween(glm::vec3 start, glm::vec3 end)
}
void
-RailLinks::render(const Shader & shader) const
-{
- shader.setModel(Location {}, Shader::Program::StaticPos);
- texture->Bind();
- links.apply(&RailLink::render, shader);
-}
-
-void
RailLink::defaultMesh()
{
for (auto n = RAIL_CROSSSECTION_VERTICES; n < vertices.size(); n += 1) {