Skip to main content

Layer

Struct Layer 

Source
pub struct Layer<Index, ID>
where Index: SpatialIndex, ID: ObjectID, Bounds<Index::Point>: IndexGenerator<Index>,
{ /* private fields */ }
Expand description

A group of collision data

Index must be a type implmenting SpatialIndex, such as Index64_3D

ID is the type representing object IDs

Implementations§

Source§

impl<Index, ID> Layer<Index, ID>
where Index: SpatialIndex, ID: ObjectID, Bounds<Index::Point>: IndexGenerator<Index>,

Source

pub fn iter(&self) -> Iter<'_, (Index, ID)>

Iterate over all indices in the Layer

This is primarily intended for visualization + debugging

Source

pub fn clear(&mut self)

Clear all index-ID pairs

Source

pub fn extend<Iter, Point_>( &mut self, system_bounds: Bounds<Point_>, objects: Iter, )
where Iter: Iterator<Item = (Bounds<Point_>, ID)>, Point_: EuclideanSpace<Scalar = f32>, Point_::Diff: ElementWise, Bounds<Point_>: SystemBounds<Point_, Index::Point>,

Append multiple objects to the Layer

Complex geometry may provide multiple bounds for a single object ID; this usage would be common for static geometry, as it prevents extraneous self-collisions

Source

pub fn merge(&mut self, other: &Layer<Index, ID>)

Merge another Layer into this Layer

This may be used, for example, to merge static scene Layer into the current frames’ dynamic Layer without having to recalculate indices for the static data

Source

pub fn par_sort(&mut self)

Sort indices to ready data for detection (parallel)

This will be called implicitly when necessary (i.e. by par_scan_filtered, par_scan, etc.)

Source

pub fn sort(&mut self)

Sort indices to ready data for detection

This will be called implicitly when necessary (i.e. by scan_filtered, scan, etc.)

Source

pub fn test<'a, TestGeom>( &'a mut self, test_geom: &TestGeom, max_depth: Option<u32>, ) -> &'a Vec<ID>
where TestGeom: TestGeometry,

Run a single test on some geometry

This occurs by repeatedly subdividing both this Layer’s index-ID list and the provided test_geom, returning any items at a given depth where both the resulting index list is non-empty and TestGeometry::subdivide returns a result

note: this method may do an implicit, non-parallel sort; you may call par_sort prior to calling this method to perform a parallel sort instead

Source

pub fn test_box<'a, Point_>( &'a mut self, system_bounds: Bounds<Point_>, test_bounds: Bounds<Point_>, max_depth: Option<u32>, ) -> &'a Vec<ID>
where Point_: EuclideanSpace<Scalar = f32> + Debug, Point_::Diff: ElementWise + Index<usize, Output = f32> + Debug, BoxTestGeometry<Point_>: TestGeometry,

A special case of test for bounding box tests, see BoxTestGeometry

The system_bounds provided to this method should, in most cases, be identical to the system_bounds provided to extend

note: this method may do an implicit, non-parallel sort; you may call par_sort prior to calling this method to perform a parallel sort instead

Source

pub fn test_ray<'a, Point_>( &'a mut self, system_bounds: Bounds<Point_>, origin: Point_, direction: Point_::Diff, range_min: f32, range_max: f32, max_depth: Option<u32>, ) -> &'a Vec<ID>
where Point_: EuclideanSpace<Scalar = f32> + VecDim + Debug, Point_::Diff: ElementWise + Index<usize, Output = f32> + Debug, RayTestGeometry<Point_>: TestGeometry,

A special case of test for ray-testing, see RayTestGeometry

The system_bounds provided to this method should, in most cases, be identical to the system_bounds provided to extend

note: this method may do an implicit, non-parallel sort; you may call par_sort prior to calling this method to perform a parallel sort instead

Source

pub fn pick<TestGeom, GetDist>( &mut self, test_geom: &TestGeom, max_dist: f32, max_depth: Option<u32>, get_dist: GetDist, ) -> Option<(f32, ID)>
where TestGeom: TestGeometry, GetDist: FnMut(&TestGeom, f32, ID) -> f32,

Run a picking or hit-test operation

This is implemented similarly to test, but differs in that it returns only the nearest result and may stop searching as soon as the nearest result is found

note: this method may do an implicit, non-parallel sort; you may call par_sort prior to calling this method to perform a parallel sort instead

Source

pub fn pick_ray<Point_, GetDist>( &mut self, system_bounds: Bounds<Point_>, origin: Point_, direction: Point_::Diff, max_dist: f32, max_depth: Option<u32>, get_dist: GetDist, ) -> Option<(f32, ID, Point_)>
where Point_: EuclideanSpace<Scalar = f32> + VecDim + Debug, Point_::Diff: VectorSpace<Scalar = f32> + ElementWise + Index<usize, Output = f32> + Debug, RayTestGeometry<Point_>: TestGeometry, GetDist: FnMut(&Point_, &Point_::Diff, f32, ID) -> f32,

A special case of pick for ray-testing, see RayTestGeometry

The system_bounds provided to this method should, in most cases, be identical to the system_bounds provided to extend

note: this method may do an implicit, non-parallel sort; you may call par_sort prior to calling this method to perform a parallel sort instead

Source

pub fn scan<'a>(&'a mut self) -> &'a Vec<(ID, ID)>

Detects collisions between all objects in the Layer

Source

pub fn scan_filtered<'a, F>(&'a mut self, filter: F) -> &'a Vec<(ID, ID)>
where F: FnMut(ID, ID) -> bool,

Detects collisions between all objects in the Layer, returning only those which pass a user-specified test

Collisions are filtered prior to duplicate removal. This may be faster or slower than filtering post-duplicate-removal (i.e. by scan().iter().filter()) depending on the complexity of the filter.

Source

pub fn par_scan<'a>(&'a mut self) -> &'a Vec<(ID, ID)>
where Index: Send + Sync,

Parallel version of scan

Source

pub fn par_scan_filtered<'a, F>(&'a mut self, filter: F) -> &'a Vec<(ID, ID)>
where Index: Send + Sync, F: Copy + Send + Sync + FnMut(ID, ID) -> bool,

Parallel version of scan_filtered

Trait Implementations§

Source§

impl<Index, ID> Clone for Layer<Index, ID>
where Index: SpatialIndex, ID: ObjectID, Bounds<Index::Point>: IndexGenerator<Index>,

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<Index, ID> Default for Layer<Index, ID>
where Index: SpatialIndex + Default, ID: ObjectID + Default, Bounds<Index::Point>: IndexGenerator<Index>,

Source§

fn default() -> Layer<Index, ID>

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

impl<Index, ID> Eq for Layer<Index, ID>
where Index: SpatialIndex, ID: ObjectID, Bounds<Index::Point>: IndexGenerator<Index>,

Source§

impl<Index, ID> PartialEq for Layer<Index, ID>
where Index: SpatialIndex, ID: ObjectID, Bounds<Index::Point>: IndexGenerator<Index>,

Source§

fn eq(&self, other: &Self) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.

Auto Trait Implementations§

§

impl<Index, ID> !Freeze for Layer<Index, ID>

§

impl<Index, ID> !RefUnwindSafe for Layer<Index, ID>

§

impl<Index, ID> Send for Layer<Index, ID>

§

impl<Index, ID> Sync for Layer<Index, ID>
where Index: Sync,

§

impl<Index, ID> Unpin for Layer<Index, ID>
where ID: Unpin, Index: Unpin,

§

impl<Index, ID> UnsafeUnpin for Layer<Index, ID>

§

impl<Index, ID> UnwindSafe for Layer<Index, ID>
where ID: UnwindSafe, Index: 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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.