summaryrefslogtreecommitdiff
path: root/game/network/network.h
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2025-05-10 13:50:08 +0100
committerDan Goodliffe <dan@randomdan.homeip.net>2025-05-10 13:50:08 +0100
commitdf9b9bc264e0bf12e99b447be7903050c822692d (patch)
treee92ddbfb0c61cc94131512ed2d757df798157f72 /game/network/network.h
parentNew genCurveDef for 2 directions (diff)
downloadilt-df9b9bc264e0bf12e99b447be7903050c822692d.tar.bz2
ilt-df9b9bc264e0bf12e99b447be7903050c822692d.tar.xz
ilt-df9b9bc264e0bf12e99b447be7903050c822692d.zip
Add new network building interface
Imperfect, matches some legacy interface in places, has some TODO notes.
Diffstat (limited to 'game/network/network.h')
-rw-r--r--game/network/network.h21
1 files changed, 21 insertions, 0 deletions
diff --git a/game/network/network.h b/game/network/network.h
index 4f5d2b0..114f42b 100644
--- a/game/network/network.h
+++ b/game/network/network.h
@@ -19,8 +19,19 @@ class GeoData;
template<typename> class Ray;
template<size_t... N> using GenDef = std::tuple<glm::vec<N, GlobalDistance>...>;
+using GenStraightDef = GenDef<3, 3>;
using GenCurveDef = GenDef<3, 3, 2>;
+struct CreationDefinitionEnd {
+ GlobalPosition3D position;
+ std::optional<Angle> direction;
+};
+
+struct CreationDefinition {
+ CreationDefinitionEnd fromEnd;
+ CreationDefinitionEnd toEnd;
+};
+
class Network {
public:
using LinkEnd = std::pair<Link::Ptr, unsigned char>;
@@ -49,6 +60,9 @@ public:
[[nodiscard]] virtual float findNodeDirection(Node::AnyCPtr) const = 0;
+ [[nodiscard]] Link::Collection create(const CreationDefinition &);
+ virtual void add(const GeoData *, const Link::Ptr &) = 0;
+
[[nodiscard]] virtual const Surface * getBaseSurface() const = 0;
[[nodiscard]] virtual RelativeDistance getBaseWidth() const = 0;
@@ -58,6 +72,9 @@ protected:
static std::pair<GenCurveDef, GenCurveDef> genCurveDef(
const GlobalPosition3D & start, const GlobalPosition3D & end, float startDir, float endDir);
+ [[nodiscard]] virtual Link::Ptr create(const GenStraightDef &) = 0;
+ [[nodiscard]] virtual Link::Ptr create(const GenCurveDef &) = 0;
+
using Nodes = std::set<Node::Ptr, PtrMemberSorter<Node::Ptr, &Node::pos>>;
Nodes nodes;
Texture::Ptr texture;
@@ -111,6 +128,10 @@ public:
Link::CCollection addExtend(const GeoData *, GlobalPosition3D, GlobalPosition3D) override;
[[nodiscard]] float findNodeDirection(Node::AnyCPtr) const override;
+ using Network::create;
+ [[nodiscard]] Link::Ptr create(const GenStraightDef &) override;
+ [[nodiscard]] Link::Ptr create(const GenCurveDef &) override;
+ void add(const GeoData *, const Link::Ptr &) override;
protected:
Link::CCollection addCurve(const GeoData *, const GenCurveDef &);