wip space colonization growing algorithm
This commit is contained in:
parent
20c3ae970f
commit
1b899a76cc
@ -24,6 +24,7 @@ pub struct Attractor {
|
|||||||
pub struct Node {
|
pub struct Node {
|
||||||
pub position: Point,
|
pub position: Point,
|
||||||
pub children: Vec<Node>,
|
pub children: Vec<Node>,
|
||||||
|
pub connected: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Node {
|
impl Node {
|
||||||
@ -41,7 +42,8 @@ impl Node {
|
|||||||
pub struct SpaceColonization {
|
pub struct SpaceColonization {
|
||||||
max_point: Point,
|
max_point: Point,
|
||||||
kill_distance: u16,
|
kill_distance: u16,
|
||||||
attraction_force: u16,
|
attraction_distance: u16,
|
||||||
|
segment_length: u16,
|
||||||
density: u16,
|
density: u16,
|
||||||
pub nodes: Vec<Node>,
|
pub nodes: Vec<Node>,
|
||||||
pub attractors: Vec<Attractor>,
|
pub attractors: Vec<Attractor>,
|
||||||
@ -53,6 +55,7 @@ impl SpaceColonization {
|
|||||||
nodes.push(Node {
|
nodes.push(Node {
|
||||||
position: Point { x: 100, y: 100 },
|
position: Point { x: 100, y: 100 },
|
||||||
children: Vec::new(),
|
children: Vec::new(),
|
||||||
|
connected: false,
|
||||||
});
|
});
|
||||||
let attractors = Vec::new();
|
let attractors = Vec::new();
|
||||||
|
|
||||||
@ -62,7 +65,8 @@ impl SpaceColonization {
|
|||||||
y: height,
|
y: height,
|
||||||
},
|
},
|
||||||
kill_distance: 10,
|
kill_distance: 10,
|
||||||
attraction_force: 15,
|
attraction_distance: 15,
|
||||||
|
segment_length: 5,
|
||||||
density: 30,
|
density: 30,
|
||||||
nodes,
|
nodes,
|
||||||
attractors,
|
attractors,
|
||||||
@ -119,5 +123,13 @@ impl SpaceColonization {
|
|||||||
|
|
||||||
pub fn grow(&self) {
|
pub fn grow(&self) {
|
||||||
todo!();
|
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
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user