Skip to main content

DynamicAabbTree

Struct DynamicAabbTree 

Source
pub struct DynamicAabbTree {
    pub margin: Fix128,
    pub metric: MetricWeights,
    /* private fields */
}
Expand description

Dynamic AABB Tree for incremental broadphase

Fields§

§margin: Fix128

AABB fattening margin

§metric: MetricWeights

The metric margin is measured in.

A margin is a clearance, so under a non-Euclidean metric it has to be converted before it can pad a Euclidean box: a clearance of m in the cube metric reaches √3·m in Euclidean space, and padding by the plain m lets pairs through the broadphase. Euclidean by default, and that path is bit-identical to having no metric at all.

Implementations§

Source§

impl DynamicAabbTree

Source

pub const fn new() -> Self

Create a new empty tree

Source

pub fn insert(&mut self, aabb: AABB, user_data: u32) -> u32

Insert a new AABB, returns the proxy (node) ID

Source

pub fn remove(&mut self, proxy_id: u32)

Remove a proxy by its ID

Source

pub fn update(&mut self, proxy_id: u32, new_aabb: AABB) -> bool

Update a proxy’s AABB. Returns true if the tree was modified.

Only re-inserts if the tight AABB has left the fat AABB.

Source

pub fn user_data(&self, proxy_id: u32) -> u32

Get user data for a proxy

Source

pub fn get_aabb(&self, proxy_id: u32) -> AABB

Get the AABB for a proxy

Source

pub fn query(&self, aabb: &AABB) -> Vec<u32>

Query all proxies overlapping the given AABB

Source

pub fn query_callback<F: FnMut(u32)>(&self, aabb: &AABB, callback: F)

Query with callback (avoids allocation)

Source

pub fn find_pairs(&self) -> Vec<(u32, u32)>

Find all potentially overlapping pairs

Source

pub fn proxy_count(&self) -> usize

Number of active proxies (leaf nodes)

Source

pub fn node_count(&self) -> usize

Total node count (including internal)

Source

pub fn height(&self) -> i32

Tree height

Trait Implementations§

Source§

impl Default for DynamicAabbTree

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where 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 T
where 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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

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

Source§

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.