pub struct B2broadPhase<UserDataType> { /* private fields */ }
Expand description

The broad-phase is used for computing pairs and performing volume queries and ray casts. This broad-phase does not persist pairs. Instead, this reports potentially new pairs. It is up to the client to consume the new pairs and to track subsequent overlap.

Implementations§

source§

impl<UserDataType: Default + Clone> B2broadPhase<UserDataType>

source

pub fn new() -> Self

source

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

create a proxy with an initial AABB. Pairs are not reported until UpdatePairs is called.

source

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

destroy a proxy. It is up to the client to remove any pairs.

source

pub fn move_proxy(&mut self, proxy_id: i32, aabb: B2AABB, displacement: B2vec2)

Call move_proxy as many times as you like, then when you are done call UpdatePairs to finalized the proxy pairs (for your time step).

source

pub fn touch_proxy(&mut self, proxy_id: i32)

Call to trigger a re-processing of it’s pairs on the next call to UpdatePairs.

source

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

Get the fat AABB for a proxy.

source

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

Get user data from a proxy. Returns None if the id is invalid.

source

pub fn test_overlap(&self, proxy_id_a: i32, proxy_id_b: i32) -> bool

Test overlap of fat AABBs.

source

pub fn get_proxy_count(&self) -> i32

Get the number of proxies.

source

pub fn update_pairs<CallbackType: AddPairTrait<UserDataType>>( &mut self, callback: &mut CallbackType )

update the pairs. This results in pair callbacks. This can only add pairs.

source

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

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

source

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

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

pub fn get_tree_height(&self) -> i32

Get the height of the embedded tree.

source

pub fn get_tree_balance(&self) -> i32

Get the balance of the embedded tree.

source

pub fn get_tree_quality(&self) -> f32

Get the quality metric of the embedded tree.

source

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

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
source

pub fn get_tree_mut(&mut self) -> &mut B2dynamicTree<UserDataType>

Trait Implementations§

source§

impl<UserDataType: Debug> Debug for B2broadPhase<UserDataType>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<UserDataType> RefUnwindSafe for B2broadPhase<UserDataType>where UserDataType: RefUnwindSafe,

§

impl<UserDataType> Send for B2broadPhase<UserDataType>where UserDataType: Send,

§

impl<UserDataType> Sync for B2broadPhase<UserDataType>where UserDataType: Sync,

§

impl<UserDataType> Unpin for B2broadPhase<UserDataType>where UserDataType: Unpin,

§

impl<UserDataType> UnwindSafe for B2broadPhase<UserDataType>where UserDataType: UnwindSafe,

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.