[][src]Struct box2d_rs::b2_dynamic_tree::B2dynamicTree

pub struct B2dynamicTree<UserDataType> { /* fields omitted */ }

A dynamic AABB tree broad-phase, inspired by Nathanael Presson's btDbvt. A dynamic tree arranges data in a binary tree to accelerate queries such as volume queries and ray casts. Leafs are proxies with an AABB. In the tree we expand the proxy AABB by b2_fatAABBFactor so that the proxy AABB is bigger than the client object. This allows the client object to move by small amounts without triggering a tree update.

Nodes are pooled and relocatable, so we use node indices rather than pointers.

Implementations

impl<UserDataType: Clone + Default> B2dynamicTree<UserDataType>[src]

pub fn new() -> Self[src]

Constructing the tree initializes the node pool.

pub fn create_proxy(&mut self, aabb: B2AABB, user_data: &UserDataType) -> i32[src]

destroy the tree, freeing the node pool. create a proxy. Provide a tight fitting AABB and a user_data pointer.

pub fn destroy_proxy(&mut self, proxy_id: i32)[src]

destroy a proxy. This asserts if the id is invalid.

pub fn move_proxy(
    &mut self,
    proxy_id: i32,
    aabb1: B2AABB,
    displacement: B2vec2
) -> bool
[src]

Move a proxy with a swepted AABB. If the proxy has moved outside of its fattened AABB, then the proxy is removed from the tree and re-inserted. Otherwise the function returns immediately. @return true if the proxy was re-inserted.

pub fn get_user_data(&self, proxy_id: i32) -> Option<UserDataType>[src]

Get proxy user data. @return the proxy user data or 0 if the id is invalid.

pub fn was_moved(&self, proxy_id: i32) -> bool[src]

pub fn clear_moved(&mut self, proxy_id: i32)[src]

pub fn get_fat_aabb(&self, proxy_id: i32) -> B2AABB[src]

Get the fat AABB for a proxy.

pub fn query<F: QueryCallback>(&self, callback: F, aabb: B2AABB)[src]

query an AABB for overlapping proxies. The callback class is called for each proxy that overlaps the supplied AABB.

pub fn ray_cast<T: RayCastCallback>(&self, callback: T, input: &B2rayCastInput)[src]

Ray-cast against the proxies in the tree. This relies on the callback to perform a exact ray-cast in the case were the proxy contains a shape. The callback also performs the any collision filtering. This has performance roughly equal to k * log(n), where k is the number of collisions and n is the number of proxies in the tree.

  • input - the ray-cast input data. The ray extends from p1 to p1 + max_fraction * (p2 - p1).
  • callback - a callback class that is called for each proxy that is hit by the ray.

pub fn validate(&self)[src]

Validate this tree. For testing.

pub fn get_height(&self) -> i32[src]

Compute the height of the binary tree in O(n) time. Should not be called often.

pub fn get_max_balance(&self) -> i32[src]

Get the maximum balance of an node in the tree. The balance is the difference in height of the two children of a node.

pub fn get_area_ration(&self) -> f32[src]

Get the ratio of the sum of the node areas to the root area.

pub fn rebuild_bottom_up(&mut self)[src]

Build an optimal tree. Very expensive. For testing.

pub fn shift_origin(&mut self, new_origin: B2vec2)[src]

Shift the world origin. Useful for large worlds. The shift formula is: position -= new_origin

  • new_origin - the new origin with respect to the old origin

Trait Implementations

impl<UserDataType: Clone> Clone for B2dynamicTree<UserDataType>[src]

impl<UserDataType: Debug> Debug for B2dynamicTree<UserDataType>[src]

impl<UserDataType: Default> Default for B2dynamicTree<UserDataType>[src]

Auto Trait Implementations

impl<UserDataType> RefUnwindSafe for B2dynamicTree<UserDataType> where
    UserDataType: RefUnwindSafe

impl<UserDataType> Send for B2dynamicTree<UserDataType> where
    UserDataType: Send

impl<UserDataType> Sync for B2dynamicTree<UserDataType> where
    UserDataType: Sync

impl<UserDataType> Unpin for B2dynamicTree<UserDataType> where
    UserDataType: Unpin

impl<UserDataType> UnwindSafe for B2dynamicTree<UserDataType> where
    UserDataType: UnwindSafe

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.