From 1b899a76cc13a3756bd554d5802c57e9a0f4a34a Mon Sep 17 00:00:00 2001 From: jeangab Date: Sat, 22 Jul 2023 10:48:31 -0400 Subject: [PATCH] wip space colonization growing algorithm --- src/space_colonization/mod.rs | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/space_colonization/mod.rs b/src/space_colonization/mod.rs index bec3aa6..211e138 100644 --- a/src/space_colonization/mod.rs +++ b/src/space_colonization/mod.rs @@ -24,6 +24,7 @@ pub struct Attractor { pub struct Node { pub position: Point, pub children: Vec, + pub connected: bool, } impl Node { @@ -41,7 +42,8 @@ impl Node { pub struct SpaceColonization { max_point: Point, kill_distance: u16, - attraction_force: u16, + attraction_distance: u16, + segment_length: u16, density: u16, pub nodes: Vec, pub attractors: Vec, @@ -53,6 +55,7 @@ impl SpaceColonization { nodes.push(Node { position: Point { x: 100, y: 100 }, children: Vec::new(), + connected: false, }); let attractors = Vec::new(); @@ -62,7 +65,8 @@ impl SpaceColonization { y: height, }, kill_distance: 10, - attraction_force: 15, + attraction_distance: 15, + segment_length: 5, density: 30, nodes, attractors, @@ -119,5 +123,13 @@ impl SpaceColonization { pub fn grow(&self) { todo!(); + // iterate through the list of nodes that are not dead yet (still had an active attractor + // previous iteration) + // For each node : + // find attractors within attraction distance of node + // calculate distance to affecting attractors + // determine how many new nodes grow from here + // determine position of new nodes + // remove current node from leaves list } }