pub struct Tree<'a, T: Aabb> { /* private fields */ }
Expand description
A broccoli Tree.
Implementations§
source§impl<'a, T: Aabb> Tree<'a, T>
impl<'a, T: Aabb> Tree<'a, T>
pub fn find_knearest( &mut self, point: Vec2<T::Num>, num: usize, ktrait: impl Knearest<T> ) -> KResult<'_, T>
pub fn find_knearest_closure( &mut self, point: Vec2<T::Num>, num: usize, broad: impl FnMut(Vec2<T::Num>, AabbPin<&mut T>) -> Option<T::Num>, fine: impl FnMut(Vec2<T::Num>, AabbPin<&mut T>) -> T::Num, xline: impl FnMut(Vec2<T::Num>, T::Num) -> T::Num, yline: impl FnMut(Vec2<T::Num>, T::Num) -> T::Num ) -> KResult<'_, T>
source§impl<'a, T: Aabb> Tree<'a, T>
impl<'a, T: Aabb> Tree<'a, T>
pub fn cast_ray_closure( &mut self, ray: Ray<T::Num>, broad: impl FnMut(&Ray<T::Num>, AabbPin<&mut T>) -> Option<CastResult<T::Num>>, fine: impl FnMut(&Ray<T::Num>, AabbPin<&mut T>) -> CastResult<T::Num>, xline: impl FnMut(&Ray<T::Num>, T::Num) -> CastResult<T::Num>, yline: impl FnMut(&Ray<T::Num>, T::Num) -> CastResult<T::Num> ) -> CastResult<CastAnswer<'_, T>>
pub fn cast_ray<R: RayCast<T>>( &mut self, ray: Ray<T::Num>, rtrait: R ) -> CastResult<CastAnswer<'_, T>>
source§impl<'a, T: Aabb> Tree<'a, T>
impl<'a, T: Aabb> Tree<'a, T>
pub fn find_all_not_in_rect<'b, K: Aabb<Num = T::Num>>( &'b mut self, rect: AabbPin<&mut K>, closure: impl FnMut(AabbPin<&mut K>, AabbPin<&'b mut T>) )
pub fn find_all_in_rect<'b, K: Aabb<Num = T::Num>>( &'b mut self, rect: AabbPin<&mut K>, closure: impl FnMut(AabbPin<&mut K>, AabbPin<&'b mut T>) )
pub fn find_all_intersect_rect<'b, K: Aabb<Num = T::Num>>( &'b mut self, rect: AabbPin<&mut K>, closure: impl FnMut(AabbPin<&mut K>, AabbPin<&'b mut T>) )
source§impl<'a, T: Aabb> Tree<'a, T>
impl<'a, T: Aabb> Tree<'a, T>
pub fn find_colliding_pairs_with<X: Aabb<Num = T::Num>>( &mut self, other: &mut Tree<'_, X>, func: impl FnMut(AabbPin<&mut T>, AabbPin<&mut X>) )
pub fn find_colliding_pairs_with_iter<'x, X: Aabb<Num = T::Num> + 'x>( &mut self, other: impl Iterator<Item = AabbPin<&'x mut X>>, func: impl FnMut(AabbPin<&mut T>, AabbPin<&mut X>) )
source§impl<'a, T: Aabb> Tree<'a, T>
impl<'a, T: Aabb> Tree<'a, T>
pub fn handle_nbody<N: Nbody<T = T>>(&mut self, no: &mut N)
source§impl<'a, T: Aabb> Tree<'a, T>
impl<'a, T: Aabb> Tree<'a, T>
sourcepub fn is_degenerate(&self) -> bool
pub fn is_degenerate(&self) -> bool
If the top 25% of tree levels has more elements than the bottom 75%, consider the tree not good for querying without a considerable jump in computation cost.
If worst case n*n time is unacceptable for your usecase, consider calling this
after tree construction. If the tree is degenerate, consider just handling
a subset of all colliding pairs by using the colliding pair building blocks
in queries::colfind::build
source§impl<'a, T: Aabb + 'a> Tree<'a, T>
impl<'a, T: Aabb + 'a> Tree<'a, T>
sourcepub fn from_nodes(nodes: Vec<Node<'a, T, T::Num>>) -> Self
pub fn from_nodes(nodes: Vec<Node<'a, T, T::Num>>) -> Self
User responsibility to provide a distribution that is a valid broccoli tree.
sourcepub fn into_nodes(self) -> Vec<Node<'a, T, T::Num>>
pub fn into_nodes(self) -> Vec<Node<'a, T, T::Num>>
Return the underlying data.
sourcepub fn get_tree_data(&self) -> TreeData<T::Num>
pub fn get_tree_data(&self) -> TreeData<T::Num>
Store tree data such as the number of elements per node, as well as the bounding range for each node.
sourcepub fn from_tree_data(bots: &'a mut [T], data: &TreeData<T::Num>) -> Self
pub fn from_tree_data(bots: &'a mut [T], data: &TreeData<T::Num>) -> Self
Create a Tree using stored treedata and the original list of elements in the same order.
Use this function if you want to store a constructed tree outside of lifetimes.
It is the user responsibility to feed this function the same
distribution of aabbs in the same order as the distribution that
was used in the original tree from which Tree::get_tree_data()
was called.
Not doing so will make an invalid tree with no error notification.
Consider calling assert::assert_tree_invariants()
after tree construction
if you don’t know if it was the same distribution which will atleast tell
you if the distribution makes a valid tree.
sourcepub fn new(bots: &'a mut [T]) -> Selfwhere
T: ManySwap,
pub fn new(bots: &'a mut [T]) -> Selfwhere T: ManySwap,
Create a new tree with the default tree height heuristic