[][src]Trait broccoli::query::QueriesInner

pub trait QueriesInner<'a>: Queries<'a> where
    Self::T: HasInner<Inner = Self::Inner>, 
{ type Inner; pub fn find_colliding_pairs_mut(
        &mut self,
        func: impl FnMut(&mut Self::Inner, &mut Self::Inner)
    ) { ... }
pub fn find_colliding_pairs_mut_par(
        &mut self,
        func: impl Fn(&mut Self::Inner, &mut Self::Inner) + Clone + Send + Sync
    )
    where
        Self::T: Send + Sync
, { ... }
pub fn find_colliding_pairs_par_ext<B: Send + Sync>(
        &mut self,
        split: impl Fn(&mut B) -> B + Send + Sync + Copy,
        fold: impl Fn(&mut B, B) + Send + Sync + Copy,
        collision: impl Fn(&mut B, &mut Self::Inner, &mut Self::Inner) + Send + Sync + Copy,
        acc: B
    ) -> B
    where
        Self::T: Send + Sync
, { ... }
pub fn for_all_not_in_rect_mut<'b>(
        &'b mut self,
        rect: &Rect<Self::Num>,
        func: impl FnMut(&'b mut Self::Inner)
    )
    where
        'a: 'b
, { ... }
pub fn for_all_intersect_rect_mut<'b>(
        &'b mut self,
        rect: &Rect<Self::Num>,
        func: impl FnMut(&'b mut Self::Inner)
    )
    where
        'a: 'b
, { ... }
pub fn for_all_in_rect_mut<'b>(
        &'b mut self,
        rect: &Rect<Self::Num>,
        func: impl FnMut(&'b mut Self::Inner)
    )
    where
        'a: 'b
, { ... }
#[must_use] pub fn raycast_mut<'b, Acc>(
        &'b mut self,
        ray: Ray<Self::Num>,
        start: &mut Acc,
        broad: impl FnMut(&mut Acc, &Ray<Self::Num>, &Rect<Self::Num>) -> CastResult<Self::Num>,
        fine: impl FnMut(&mut Acc, &Ray<Self::Num>, &Self::T) -> CastResult<Self::Num>,
        border: Rect<Self::Num>
    ) -> CastResult<(Vec<&'b mut Self::Inner>, Self::Num)>
    where
        'a: 'b
, { ... }
#[must_use] pub fn k_nearest_mut<'b, Acc>(
        &'b mut self,
        point: Vec2<Self::Num>,
        num: usize,
        start: &mut Acc,
        broad: impl FnMut(&mut Acc, Vec2<Self::Num>, &Rect<Self::Num>) -> Self::Num,
        fine: impl FnMut(&mut Acc, Vec2<Self::Num>, &Self::T) -> Self::Num,
        border: Rect<Self::Num>
    ) -> Vec<Option<(&'b mut Self::Inner, Self::Num)>>

Notable traits for Vec<u8>

impl Write for Vec<u8>

    where
        'a: 'b
, { ... }
pub fn intersect_with_mut<X: Aabb<Num = Self::Num> + HasInner>(
        &mut self,
        other: &mut [X],
        func: impl Fn(&mut Self::Inner, &mut X::Inner)
    ) { ... } }

Query functions that instead of returning PMut, return T::Inner for convinience. Requires that T implement HasInner.

Associated Types

Loading content...

Provided methods

pub fn find_colliding_pairs_mut(
    &mut self,
    func: impl FnMut(&mut Self::Inner, &mut Self::Inner)
)
[src]

Find all aabb intersections

Examples

 use broccoli::{prelude::*,bbox,rect};
 let mut bots = [bbox(rect(0,10,0,10),0u8),bbox(rect(5,15,5,15),0u8)];
 let mut tree = broccoli::new(&mut bots);
 tree.find_colliding_pairs_mut(|a,b|{
    *a+=1;
    *b+=1;
 });

 assert_eq!(bots[0].inner,1);
 assert_eq!(bots[1].inner,1);

pub fn find_colliding_pairs_mut_par(
    &mut self,
    func: impl Fn(&mut Self::Inner, &mut Self::Inner) + Clone + Send + Sync
) where
    Self::T: Send + Sync
[src]

Find all intersections in parallel

Examples

 use broccoli::{prelude::*,bbox,rect};
 let mut bots = [bbox(rect(0,10,0,10),0u8),bbox(rect(5,15,5,15),0u8)];
 let mut tree = broccoli::new(&mut bots);
 tree.find_colliding_pairs_mut_par(|a,b|{
    *a+=1;
    *b+=1;
 });

 assert_eq!(bots[0].inner,1);
 assert_eq!(bots[1].inner,1);

pub fn find_colliding_pairs_par_ext<B: Send + Sync>(
    &mut self,
    split: impl Fn(&mut B) -> B + Send + Sync + Copy,
    fold: impl Fn(&mut B, B) + Send + Sync + Copy,
    collision: impl Fn(&mut B, &mut Self::Inner, &mut Self::Inner) + Send + Sync + Copy,
    acc: B
) -> B where
    Self::T: Send + Sync
[src]

Allows the user to potentially collect some aspect of every intersection in parallel.

Examples

 use broccoli::{prelude::*,bbox,rect};
 let mut bots = [bbox(rect(0,10,0,10),0u8),bbox(rect(5,15,5,15),1u8)];
 let mut tree = broccoli::new(&mut bots);
 let intersections=tree.find_colliding_pairs_par_ext(
     |_|Vec::new(),              //Start a new thread
     |a,mut b|a.append(&mut b),  //Combine two threads
     |v,a,b|v.push((*a,*b)),     //What to do for each intersection for a thread.
     Vec::new()                  //Starting thread
 );

 assert_eq!(intersections.len(),1);

pub fn for_all_not_in_rect_mut<'b>(
    &'b mut self,
    rect: &Rect<Self::Num>,
    func: impl FnMut(&'b mut Self::Inner)
) where
    'a: 'b, 
[src]

Examples

 use broccoli::{prelude::*,bbox,rect};
 let mut bots = [bbox(rect(0,10,0,10),0u8)];
 let mut tree = broccoli::new(&mut bots);
 tree.for_all_not_in_rect_mut(&rect(10,20,10,20),|a|{
    *a+=1;    
 });

 assert_eq!(bots[0].inner,1);

pub fn for_all_intersect_rect_mut<'b>(
    &'b mut self,
    rect: &Rect<Self::Num>,
    func: impl FnMut(&'b mut Self::Inner)
) where
    'a: 'b, 
[src]

Examples

 use broccoli::{prelude::*,bbox,rect};
 let mut bots = [bbox(rect(0,10,0,10),0u8)];
 let mut tree = broccoli::new(&mut bots);
 tree.for_all_intersect_rect_mut(&rect(9,20,9,20),|a|{
    *a+=1;    
 });

 assert_eq!(bots[0].inner,1);

pub fn for_all_in_rect_mut<'b>(
    &'b mut self,
    rect: &Rect<Self::Num>,
    func: impl FnMut(&'b mut Self::Inner)
) where
    'a: 'b, 
[src]

Examples

 use broccoli::{prelude::*,bbox,rect};
 let mut bots = [bbox(rect(0,10,0,10),0u8)];
 let mut tree = broccoli::new(&mut bots);
 tree.for_all_in_rect_mut(&rect(0,10,0,10),|a|{
    *a+=1;    
 });

 assert_eq!(bots[0].inner,1);

#[must_use]pub fn raycast_mut<'b, Acc>(
    &'b mut self,
    ray: Ray<Self::Num>,
    start: &mut Acc,
    broad: impl FnMut(&mut Acc, &Ray<Self::Num>, &Rect<Self::Num>) -> CastResult<Self::Num>,
    fine: impl FnMut(&mut Acc, &Ray<Self::Num>, &Self::T) -> CastResult<Self::Num>,
    border: Rect<Self::Num>
) -> CastResult<(Vec<&'b mut Self::Inner>, Self::Num)> where
    'a: 'b, 
[src]

Examples

 use broccoli::{prelude::*,bbox,rect};
 use axgeom::{vec2,ray};

 let border = rect(0,100,0,100);

 let mut bots = [bbox(rect(0,10,0,10),vec2(5,5)),
                bbox(rect(2,5,2,5),vec2(4,4)),
                bbox(rect(4,10,4,10),vec2(5,5))];

 let mut bots_copy=bots.clone();
 let mut tree = broccoli::new(&mut bots);
 let ray=ray(vec2(5,-5),vec2(1,2));
 let mut counter =0;
 let res = tree.raycast_mut(
     ray,&mut counter,
     |c,ray,r|{*c+=1;ray.cast_to_rect(r)},
     |c,ray,t|{*c+=1;ray.cast_to_rect(t.get())},   //Do more fine-grained checking here.
     border);

 let (bots,dis)=res.unwrap();
 assert_eq!(dis,2);
 assert_eq!(bots.len(),1);
 assert_eq!(bots[0],&vec2(5,5));

#[must_use]pub fn k_nearest_mut<'b, Acc>(
    &'b mut self,
    point: Vec2<Self::Num>,
    num: usize,
    start: &mut Acc,
    broad: impl FnMut(&mut Acc, Vec2<Self::Num>, &Rect<Self::Num>) -> Self::Num,
    fine: impl FnMut(&mut Acc, Vec2<Self::Num>, &Self::T) -> Self::Num,
    border: Rect<Self::Num>
) -> Vec<Option<(&'b mut Self::Inner, Self::Num)>>

Notable traits for Vec<u8>

impl Write for Vec<u8>
where
    'a: 'b, 
[src]

Examples

 use broccoli::{prelude::*,bbox,rect};
 use axgeom::vec2;

 let border = rect(0,100,0,100);

 let mut bots = [bbox(rect(0,10,0,10),vec2(5,5)),
                bbox(rect(2,4,2,4),vec2(3,3)),
                bbox(rect(6,8,6,8),vec2(7,7))];

 let mut bots_copy=bots.clone();
 let mut tree = broccoli::new(&mut bots);

 let mut counter = 0;
 let res = tree.k_nearest_mut(
     vec2(0,0),
     2,
     &mut counter,
     |c,p,r|{*c+=1;r.distance_squared_to_point(p).unwrap_or(0)},
     |c,p,t|{*c+=1;t.inner.distance_squared_to_point(p)},    //Do more fine-grained checking here.
     border);

 assert_eq!(res.len(),3);
 assert_eq!(*res[0].as_ref().unwrap().0,vec2(3,3));
 assert_eq!(*res[2].as_ref().unwrap().0,vec2(5,5));

pub fn intersect_with_mut<X: Aabb<Num = Self::Num> + HasInner>(
    &mut self,
    other: &mut [X],
    func: impl Fn(&mut Self::Inner, &mut X::Inner)
)
[src]

Examples

 use broccoli::{prelude::*,bbox,rect};
 let mut bots1 = [bbox(rect(0,10,0,10),0u8)];
 let mut bots2 = [bbox(rect(5,15,5,15),0u8)];
 let mut tree = broccoli::new(&mut bots1);

 tree.intersect_with_mut(&mut bots2,|a,b|{
    *a+=1;
    *b+=2;    
 });

 assert_eq!(bots1[0].inner,1);
 assert_eq!(bots2[0].inner,2);
Loading content...

Implementors

impl<'a, A: Axis, T: Aabb + HasInner> QueriesInner<'a> for Tree<'a, A, T>[src]

type Inner = T::Inner

Loading content...