summaryrefslogtreecommitdiff
path: root/game/network/network.impl.h
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2022-10-28 01:08:28 +0100
committerDan Goodliffe <dan@randomdan.homeip.net>2022-10-28 02:10:47 +0100
commit3bb238d41ca4f3e4a40f4ee3700b27ca7bf03b56 (patch)
tree532083d6076a8b1e72824fc9789769c5f60fc7b0 /game/network/network.impl.h
parentImplement extending a network into open space (diff)
downloadilt-3bb238d41ca4f3e4a40f4ee3700b27ca7bf03b56.tar.bz2
ilt-3bb238d41ca4f3e4a40f4ee3700b27ca7bf03b56.tar.xz
ilt-3bb238d41ca4f3e4a40f4ee3700b27ca7bf03b56.zip
Implement extending a network to join link ends
Diffstat (limited to 'game/network/network.impl.h')
-rw-r--r--game/network/network.impl.h21
1 files changed, 17 insertions, 4 deletions
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<T>::candidateStraight(glm::vec3 n1, glm::vec3 n2)
template<typename T>
Link::CCollection
-NetworkOf<T>::candidateJoins(glm::vec3 n1, glm::vec3 n2)
+NetworkOf<T>::candidateJoins(glm::vec3 start, glm::vec3 end)
{
- return {candidateLink<typename T::StraightLink>(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<typename T::CurveLink>(c1s, c1e, c1c), candidateLink<typename T::CurveLink>(c2s, c2e, c2c)};
}
template<typename T>
@@ -83,9 +90,15 @@ NetworkOf<T>::addStraight(glm::vec3 n1, glm::vec3 n2)
template<typename T>
Link::CCollection
-NetworkOf<T>::addJoins(glm::vec3 n1, glm::vec3 n2)
+NetworkOf<T>::addJoins(glm::vec3 start, glm::vec3 end)
{
- return {addLink<typename T::StraightLink>(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<typename T::CurveLink>(c1s, c1e, c1c), addLink<typename T::CurveLink>(c2s, c2e, c2c)};
}
template<typename T>