Struct aabb_tree::AabbTree
[−]
[src]
pub struct AabbTree<T, P = f32, A = MinMaxTuple<f32>> where P: Float + FromPrimitive,
A: Into<MinMaxTuple<P>> + From<MinMaxTuple<P>> + Clone { /* fields omitted */ }
A dynamic spatial tree. Data is arranged in a binary tree which allows fast positional queries. The proxies returned from the various methods are leaves in the tree.
Panics
AABB operations are checked for validity and will panic in debug mode if aabb.is_valid()
returns false.
Methods
impl<T, P, A> AabbTree<T, P, A> where P: Float + FromPrimitive,
A: Into<MinMaxTuple<P>> + From<MinMaxTuple<P>> + Clone
[src]
A: Into<MinMaxTuple<P>> + From<MinMaxTuple<P>> + Clone
fn new() -> Self
Returns a new AABB
fn create_proxy(&mut self, aabb: A, user_data: T) -> Proxy
Creates a new node in the tree.
fn destroy_proxy(&mut self, proxy: Proxy)
Destroy a node in the tree. Does not deallocate memory, nodes can be reutilized
on later create_proxy
calls.
Panics
Panics if the proxy_id is not valid (either was destroyed already or is not a leaf).
Use proxies returned by create_proxy
to avoid problems.
fn set_aabb(&mut self, proxy: Proxy, new_aabb: &A)
Changes the AABB of a node, might trigger a tree rebalance if the new AABB doesn't fit within the node's parent AABB.
Panics
Panics if the proxy_id is not valid (either was destroyed already or is not a leaf).
Use proxies returned by create_proxy
to avoid problems.
fn user_data(&self, proxy: Proxy) -> Option<&T>
Returns a reference to the user data associated with the proxy_id
. Returns
None
if the proxy_id
is invalid.
fn user_data_mut(&mut self, proxy: Proxy) -> Option<&mut T>
Returns a mutable reference to the user data associated with the proxy_id
. Returns
None
if the proxy_id
is invalid.
fn query_aabb<F: FnMut(Proxy) -> bool>(&self, aabb: &A, callback: F)
Searchs the tree for every node that overlaps with aabb
and calls the callback
with the node's proxy id as a parameter. The callback returns a boolean value
indicating wether the query should continue or not. The method is a specialized version
of AabbTree::query
, where search
is defined as |other_aabb| other_aabb.overlaps(aabb)
fn query<F, S>(&self, search: S, callback: F) where F: FnMut(Proxy) -> bool, S: FnMut(&A) -> bool
Searchs the AABB using a generic search
function. search
receives the current
AABB being analyzed and should return true if that AABB is within your search
constraints. Once a leaf node is found and search
returns true for that node,
callback
will be called with the node's proxy id as a parameter. The callback
returns a boolean value indicating wether the query should continue or not.
Trait Implementations
impl<T: Clone, P: Clone, A: Clone> Clone for AabbTree<T, P, A> where P: Float + FromPrimitive,
A: Into<MinMaxTuple<P>> + From<MinMaxTuple<P>> + Clone
[src]
A: Into<MinMaxTuple<P>> + From<MinMaxTuple<P>> + Clone
fn clone(&self) -> AabbTree<T, P, A>
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0
Performs copy-assignment from source
. Read more
impl<T, P, A> Debug for AabbTree<T, P, A> where T: Debug,
P: Float + FromPrimitive + Debug,
A: Into<MinMaxTuple<P>> + From<MinMaxTuple<P>> + Clone + Debug
[src]
P: Float + FromPrimitive + Debug,
A: Into<MinMaxTuple<P>> + From<MinMaxTuple<P>> + Clone + Debug