summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--game/network/network.h4
-rw-r--r--game/network/rail.cpp14
-rw-r--r--game/network/rail.h3
-rw-r--r--test/test-network.cpp12
4 files changed, 33 insertions, 0 deletions
diff --git a/game/network/network.h b/game/network/network.h
index be0900b..f8739b8 100644
--- a/game/network/network.h
+++ b/game/network/network.h
@@ -14,6 +14,7 @@
#include <utility>
class SceneShader;
+class Surface;
template<typename> class Ray;
template<size_t... n> using GenDef = std::tuple<glm::vec<n, GlobalDistance>...>;
@@ -47,6 +48,9 @@ public:
[[nodiscard]] virtual float findNodeDirection(Node::AnyCPtr) const = 0;
+ [[nodiscard]] virtual const Surface * getBaseSurface() const = 0;
+ [[nodiscard]] virtual RelativeDistance getBaseWidth() const = 0;
+
protected:
static void joinLinks(const Link::Ptr & l, const Link::Ptr & ol);
static GenCurveDef genCurveDef(const GlobalPosition3D & start, const GlobalPosition3D & end, float startDir);
diff --git a/game/network/rail.cpp b/game/network/rail.cpp
index f226327..dc62cf3 100644
--- a/game/network/rail.cpp
+++ b/game/network/rail.cpp
@@ -1,4 +1,6 @@
#include "rail.h"
+#include "game/gamestate.h"
+#include "game/geoData.h"
#include "network.h"
#include <game/network/network.impl.h> // IWYU pragma: keep
#include <gfx/gl/sceneShader.h>
@@ -169,3 +171,15 @@ RailLinks::render(const SceneShader & shader) const
glBindVertexArray(0);
}
}
+
+const Surface *
+RailLinks::getBaseSurface() const
+{
+ return std::dynamic_pointer_cast<Surface>(gameState->assets.at("terrain.surface.gravel")).get();
+}
+
+RelativeDistance
+RailLinks::getBaseWidth() const
+{
+ return 5'700;
+}
diff --git a/game/network/rail.h b/game/network/rail.h
index 0aae718..fa64eda 100644
--- a/game/network/rail.h
+++ b/game/network/rail.h
@@ -77,6 +77,9 @@ public:
std::shared_ptr<RailLink> addLinksBetween(GlobalPosition3D start, GlobalPosition3D end);
void render(const SceneShader &) const override;
+ [[nodiscard]] const Surface * getBaseSurface() const override;
+ [[nodiscard]] RelativeDistance getBaseWidth() const override;
+
private:
void tick(TickDuration elapsed) override;
};
diff --git a/test/test-network.cpp b/test/test-network.cpp
index ce25429..5373dd5 100644
--- a/test/test-network.cpp
+++ b/test/test-network.cpp
@@ -73,6 +73,18 @@ struct TestNetwork : public NetworkOf<TestLink, TestLinkS> {
render(const SceneShader &) const override
{
}
+
+ const Surface *
+ getBaseSurface() const override
+ {
+ return nullptr;
+ }
+
+ RelativeDistance
+ getBaseWidth() const override
+ {
+ return 5'700;
+ }
};
const auto VALID_NODES = boost::unit_test::data::make<GlobalPosition3D>({