From 3bb238d41ca4f3e4a40f4ee3700b27ca7bf03b56 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Fri, 28 Oct 2022 01:08:28 +0100 Subject: Implement extending a network to join link ends --- game/network/network.impl.h | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) (limited to 'game/network/network.impl.h') diff --git a/game/network/network.impl.h b/game/network/network.impl.h index 859d1ac..5b1649d 100644 --- a/game/network/network.impl.h +++ b/game/network/network.impl.h @@ -61,9 +61,16 @@ NetworkOf::candidateStraight(glm::vec3 n1, glm::vec3 n2) template Link::CCollection -NetworkOf::candidateJoins(glm::vec3 n1, glm::vec3 n2) +NetworkOf::candidateJoins(glm::vec3 start, glm::vec3 end) { - return {candidateLink(n1, n2)}; + if (glm::distance(start, end) < 2.F) { + return {}; + } + const auto defs = genCurveDef( + start, end, findNodeDirection(candidateNodeAt(start).first), findNodeDirection(candidateNodeAt(end).first)); + const auto & [c1s, c1e, c1c] = defs.first; + const auto & [c2s, c2e, c2c] = defs.second; + return {candidateLink(c1s, c1e, c1c), candidateLink(c2s, c2e, c2c)}; } template @@ -83,9 +90,15 @@ NetworkOf::addStraight(glm::vec3 n1, glm::vec3 n2) template Link::CCollection -NetworkOf::addJoins(glm::vec3 n1, glm::vec3 n2) +NetworkOf::addJoins(glm::vec3 start, glm::vec3 end) { - return {addLink(n1, n2)}; + if (glm::distance(start, end) < 2.F) { + return {}; + } + const auto defs = genCurveDef(start, end, findNodeDirection(nodeAt(start)), findNodeDirection(nodeAt(end))); + const auto & [c1s, c1e, c1c] = defs.first; + const auto & [c2s, c2e, c2c] = defs.second; + return {addLink(c1s, c1e, c1c), addLink(c2s, c2e, c2c)}; } template -- cgit v1.2.3