fn check_tree_collision(
  trees: &mut Vec<Tree>,
  point: Point2,
  size: f32,
  min_dist: f32,
  max_dist: f32,
) -> bool {
  for tree in trees {
    if pt2(tree.x, tree.y).distance(pt2(point.x, point.y)) < size * min_dist {
      return false;
    }
    if pt2(tree.x, tree.y).distance(pt2(point.x, point.y)) < size * max_dist {
      tree.children.push(Tree::new(point.x, point.y));
      return true;
    }
    if check_tree_collision(&mut tree.children, point, size, min_dist, max_dist) {
      return true;
    }
  }
  false
}
/// check collision between a point and the cluster.
/// This becomes VERY inefficient as the tree becomes more deeply nested.
/// Would be prudent to consider a new way of determining "collision",
/// or a new data structure for determining collision.
check collision between a point and the cluster.
This becomes VERY inefficient as the tree becomes more deeply nested.
Would be prudent to consider a new way of determining "collision",
or a new data structure for determining collision.
check collision between a point and the cluster . This becomes VERY inefficient as the tree becomes more deeply nested . Would be prudent to consider a new way of determining " collision " or a new data structure for determining collision .
fn check_tree_collision(
  trees: &mut Vec<Tree>,
  point: Point2,
  size: f32,
  min_dist: f32,
  max_dist: f32,
) -> bool {
  for tree in trees {
    if pt2(tree.x, tree.y).distance(pt2(point.x, point.y)) < size * min_dist {
      return false;
    }
    if pt2(tree.x, tree.y).distance(pt2(point.x, point.y)) < size * max_dist {
      tree.children.push(Tree::new(point.x, point.y));
      return true;
    }
    if check_tree_collision(&mut tree.children, point, size, min_dist, max_dist) {
      return true;
    }
  }
  false
}
fn check_tree_collision ( trees : & mut Vec < Tree > , point : Point2 , size : f32 , min_dist : f32 , max_dist : f32 , ) -> bool { for tree in trees { if pt2 ( tree . x , tree . y ) . distance ( pt2 ( point . x , point . y ) ) < size * min_dist { return false ; } if pt2 ( tree . x , tree . y ) . distance ( pt2 ( point . x , point . y ) ) < size * max_dist { tree . children . push ( Tree :: new ( point . x , point . y ) ) ; return true ; } if check_tree_collision ( & mut tree . children , point , size , min_dist , max_dist ) { return true ; } } false }
check collision between a point and the cluster.
check collision between a point and the cluster .
trees
&mut Vec<Tree>
point
Point2
size
f32
min_dist
f32
max_dist
f32