wip space colonization growing algorithm

This commit is contained in:
jeangab 2023-07-22 10:48:31 -04:00
parent 20c3ae970f
commit 1b899a76cc

View File

@ -24,6 +24,7 @@ pub struct Attractor {
pub struct Node {
pub position: Point,
pub children: Vec<Node>,
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<Node>,
pub attractors: Vec<Attractor>,
@ -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
}
}