pub struct Tree<'a, T: Aabb> { /* private fields */ }
Expand description
A broccoli Tree.
Implementations
sourceimpl<'a, T: Aabb> Tree<'a, T>
impl<'a, T: Aabb> Tree<'a, T>
sourcepub fn assert_tree_invariants(&self) where
T::Num: Debug,
pub fn assert_tree_invariants(&self) where
T::Num: Debug,
panics if a broken broccoli tree invariant is detected. For debugging purposes only.
sourceimpl<T: Aabb> Tree<'_, T>
impl<T: Aabb> Tree<'_, T>
pub fn find_colliding_pairs_from_args<S: Splitter>(
&mut self,
args: QueryArgs<S>,
func: impl FnMut(AabbPin<&mut T>, AabbPin<&mut T>)
) -> S
pub fn par_find_colliding_pairs_from_args<S: Splitter, F>(
&mut self,
args: QueryArgs<S>,
func: F
) -> S where
F: FnMut(AabbPin<&mut T>, AabbPin<&mut T>),
F: Send + Clone,
S: Send,
T: Send,
T::Num: Send,
pub fn par_find_colliding_pairs_acc<Acc: Splitter, F>(
&mut self,
acc: Acc,
func: F
) -> Acc where
F: FnMut(&mut Acc, AabbPin<&mut T>, AabbPin<&mut T>) + Clone + Send,
Acc: Splitter + Send,
T: Send,
T::Num: Send,
pub fn par_find_colliding_pairs_acc_closure<Acc, A, B, F>(
&mut self,
acc: Acc,
div: A,
add: B,
func: F
) -> Acc where
A: FnMut(&mut Acc) -> Acc + Clone + Send,
B: FnMut(&mut Acc, Acc) + Clone + Send,
F: FnMut(&mut Acc, AabbPin<&mut T>, AabbPin<&mut T>) + Clone + Send,
Acc: Send,
T: Send,
T::Num: Send,
sourceimpl<'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>
sourceimpl<'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>>
sourceimpl<'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>)
)
sourceimpl<'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>)
)
sourceimpl<'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)
sourceimpl<'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
sourceimpl<'a, T: Aabb + 'a> Tree<'a, T>
impl<'a, T: Aabb + 'a> Tree<'a, T>
pub fn into_nodes(self) -> Vec<Node<'a, T>>
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 Tree::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.
pub fn new(bots: &'a mut [T]) -> Self where
T: ManySwap,
pub fn par_new(bots: &'a mut [T]) -> Self where
T: ManySwap,
T: Send,
T::Num: Send,
pub fn from_build_args<P: Splitter>(
bots: &'a mut [T],
args: BuildArgs<P>
) -> (Self, P) where
T: ManySwap,
pub fn par_from_build_args<P: Splitter>(
bots: &'a mut [T],
args: BuildArgs<P>
) -> (Self, P) where
T: ManySwap,
T: Send,
T::Num: Send,
P: Send,
pub fn vistr_mut(&mut self) -> VistrMutPin<'_, Node<'a, T>>
pub fn vistr(&self) -> Vistr<'_, Node<'a, T>>
pub fn num_levels(&self) -> usize
pub fn num_nodes(&self) -> usize
pub fn get_nodes(&self) -> &[Node<'a, T>]
pub fn get_nodes_mut(&mut self) -> AabbPin<&mut [Node<'a, T>]>
Auto Trait Implementations
impl<'a, T> RefUnwindSafe for Tree<'a, T> where
T: RefUnwindSafe,
<T as Aabb>::Num: RefUnwindSafe,
impl<'a, T> Send for Tree<'a, T> where
T: Send,
<T as Aabb>::Num: Send,
impl<'a, T> Sync for Tree<'a, T> where
T: Sync,
<T as Aabb>::Num: Sync,
impl<'a, T> Unpin for Tree<'a, T> where
<T as Aabb>::Num: Unpin,
impl<'a, T> !UnwindSafe for Tree<'a, T>
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more