Struct broccoli::Tree

source ·
pub struct Tree<'a, T: Aabb> { /* private fields */ }
Expand description

A broccoli Tree.

Implementations§

source§

impl<'a, T: Aabb> Tree<'a, T>

source

pub fn find_colliding_pairs( &mut self, func: impl FnMut(AabbPin<&mut T>, AabbPin<&mut T>) )

source§

impl<'a, T: Aabb> Tree<'a, T>

source

pub fn draw_divider( &self, line: impl FnMut(AxisDyn, &Node<'_, T, T::Num>, &Rect<T::Num>, usize), rect: Rect<T::Num> )

source§

impl<'a, T: Aabb> Tree<'a, T>

source

pub fn find_knearest( &mut self, point: Vec2<T::Num>, num: usize, ktrait: impl Knearest<T> ) -> KResult<'_, T>

source

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>

source

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>>

source

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>

source

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>) )

source

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>) )

source

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>

source

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>) )

source

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>

source

pub fn handle_nbody<N: Nbody<T = T>>(&mut self, no: &mut N)

source§

impl<'a, T: Aabb> Tree<'a, T>

source

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>

source

pub fn from_nodes(nodes: Vec<Node<'a, T, T::Num>>) -> Self

User responsibility to provide a distribution that is a valid broccoli tree.

source

pub fn into_nodes(self) -> Vec<Node<'a, T, T::Num>>

Return the underlying data.

source

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.

source

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.

source

pub fn new(bots: &'a mut [T]) -> Selfwhere T: ManySwap,

Create a new tree with the default tree height heuristic

source

pub fn vistr_mut(&mut self) -> VistrMutPin<'_, Node<'a, T, T::Num>>

source

pub fn vistr(&self) -> Vistr<'_, Node<'a, T, T::Num>>

source

pub fn num_levels(&self) -> usize

source

pub fn num_nodes(&self) -> usize

source

pub fn get_nodes(&self) -> &[Node<'a, T, T::Num>]

source

pub fn get_nodes_mut(&mut self) -> AabbPin<&mut [Node<'a, T, T::Num>]>

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>

§

impl<'a, T> !UnwindSafe for Tree<'a, T>

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.