pub struct Layer<Index, ID>{ /* 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>
impl<Index, ID> Layer<Index, ID>
Sourcepub fn iter(&self) -> Iter<'_, (Index, ID)>
pub fn iter(&self) -> Iter<'_, (Index, ID)>
Iterate over all indices in the Layer
This is primarily intended for visualization + debugging
Sourcepub 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>,
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
Sourcepub fn merge(&mut self, other: &Layer<Index, ID>)
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
Sourcepub fn par_sort(&mut self)
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.)
Sourcepub fn sort(&mut self)
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.)
Sourcepub fn test<'a, TestGeom>(
&'a mut self,
test_geom: &TestGeom,
max_depth: Option<u32>,
) -> &'a Vec<ID>where
TestGeom: TestGeometry,
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
Sourcepub 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,
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
Sourcepub 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,
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
Sourcepub fn pick<TestGeom, GetDist>(
&mut self,
test_geom: &TestGeom,
max_dist: f32,
max_depth: Option<u32>,
get_dist: GetDist,
) -> Option<(f32, ID)>
pub fn pick<TestGeom, GetDist>( &mut self, test_geom: &TestGeom, max_dist: f32, max_depth: Option<u32>, get_dist: GetDist, ) -> Option<(f32, ID)>
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
Sourcepub 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,
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
Sourcepub fn scan<'a>(&'a mut self) -> &'a Vec<(ID, ID)>
pub fn scan<'a>(&'a mut self) -> &'a Vec<(ID, ID)>
Detects collisions between all objects in the Layer
Sourcepub fn scan_filtered<'a, F>(&'a mut self, filter: F) -> &'a Vec<(ID, ID)>
pub fn scan_filtered<'a, F>(&'a mut self, filter: F) -> &'a Vec<(ID, ID)>
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.