From df9b9bc264e0bf12e99b447be7903050c822692d Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Sat, 10 May 2025 13:50:08 +0100 Subject: Add new network building interface Imperfect, matches some legacy interface in places, has some TODO notes. --- game/network/network.cpp | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'game/network/network.cpp') diff --git a/game/network/network.cpp b/game/network/network.cpp index 403975c..295e6ec 100644 --- a/game/network/network.cpp +++ b/game/network/network.cpp @@ -142,3 +142,28 @@ Network::genCurveDef(const GlobalPosition3D & start, const GlobalPosition3D & en return {genCurveDef(start, joint, startDir), genCurveDef(end, joint, endDir)}; } + +Link::Collection +Network::create(const CreationDefinition & def) +{ + // TODO + // Where to make a straight to join because angles align? + // Where to drop part of S curve pair if a single curve works? + + if (!def.fromEnd.direction && !def.toEnd.direction) { + // No specific directions at either end, straight link + return {create(GenStraightDef {def.fromEnd.position, def.toEnd.position})}; + } + if (def.fromEnd.direction) { + if (def.toEnd.direction) { + // Two specific directions at both ends, S curves + const auto curves = genCurveDef( + def.fromEnd.position, def.toEnd.position, *def.fromEnd.direction, *def.toEnd.direction); + return {create(curves.first), create(curves.second)}; + } + // One specific direction, single curve from there + return {create(genCurveDef(def.fromEnd.position, def.toEnd.position, *def.fromEnd.direction))}; + } + // One specific direction, single curve from the other + return {create(genCurveDef(def.toEnd.position, def.fromEnd.position, *def.toEnd.direction))}; +} -- cgit v1.2.3