Struct SweepAndPrune

Source
pub struct SweepAndPrune<V> { /* private fields */ }
Expand description

Sweep and prune broad phase collision detection algorithm.

Will sort the bounding boxes of the collision world along some axis, and will then sweep the sorted list, and compare the bounds along the sweep axis, adding them to an active list when they are encountered, and removing them from the active list when the end extent is passed.

Any shape pairs found by the base algorithm, will then do a bounding box intersection test, before adding to the resulting pairs list.

§Type parameters:

  • V: Variance type used for computing what axis to use on the next iteration. SweepAndPrune2 and SweepAndPrune3 provide a variance type for you, so they should be used if you do not have a custom type implementing Variance.

Implementations§

Source§

impl<V> SweepAndPrune<V>
where V: Variance,

Source

pub fn new() -> Self

Create a new sweep and prune algorithm, will use the X axis as the first sweep axis

Source

pub fn with_sweep_axis(sweep_axis: usize) -> Self

Create a new sweep and prune algorithm, starting with the given axis as the first sweep axis

Source

pub fn get_sweep_axis(&self) -> usize

Get sweep axis

Source

pub fn find_collider_pairs<A>( &mut self, shapes: &mut [A], ) -> Vec<(usize, usize)>
where A: HasBound, A::Bound: Bound + Discrete<A::Bound>, V: Variance<Bound = A::Bound>,

Find all potentially colliding pairs of shapes

§Parameters
  • shapes: Shapes to do find potential collisions for
§Returns

Returns tuples with indices into the shapes list, of all potentially colliding pairs. The first value in the tuple will always be first in the list.

§Side effects:

The shapes list might have been resorted. The indices in the return values will be for the sorted list.

Auto Trait Implementations§

§

impl<V> Freeze for SweepAndPrune<V>
where V: Freeze,

§

impl<V> RefUnwindSafe for SweepAndPrune<V>
where V: RefUnwindSafe,

§

impl<V> Send for SweepAndPrune<V>
where V: Send,

§

impl<V> Sync for SweepAndPrune<V>
where V: Sync,

§

impl<V> Unpin for SweepAndPrune<V>
where V: Unpin,

§

impl<V> UnwindSafe for SweepAndPrune<V>
where V: UnwindSafe,

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, U> TryFrom<U> for T
where U: Into<T>,

Source§

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