Struct rhusics_ecs::SpatialCollisionSystem
source · pub struct SpatialCollisionSystem<P, T, D, B, Y = ()>where
P: Primitive,
B: Bound,{ /* private fields */ }
Expand description
Collision detection system for use with
specs
.
Will perform spatial sorting of the collision world.
Has support for both broad phase and narrow phase collision detection. Will only do narrow phase if both broad and narrow phase is activated. If no broad phase is set, it will use a DBVT based broad phase that has complexity O(m log^2 n), where m is the number of shapes that have a dirty pose.
Can handle any transform component type, as long as the type implements
Transform
, and as long as the
storage is wrapped in
FlaggedStorage
.
Type parameters:
P
: Shape primitiveT
: TransformD
: Data accepted by broad phaseY
: Shape type, seeCollider
System Function:
fn(Entities, T, NextFrame<T>, CollisionShape, DynamicBoundingVolumeTree<D>) -> (DynamicBoundingVolumeTree<D>, EventChannel<ContactEvent>)
Implementations
sourceimpl<P, T, D, B, Y> SpatialCollisionSystem<P, T, D, B, Y>where
P: Primitive + Send + Sync + 'static,
<P::Point as EuclideanSpace>::Diff: Debug,
<P::Point as EuclideanSpace>::Scalar: BaseFloat,
B: Clone + Debug + Send + Sync + 'static + Bound<Point = P::Point> + Union<B, Output = B> + Contains<B> + SurfaceArea<Scalar = <P::Point as EuclideanSpace>::Scalar>,
T: Transform<P::Point> + Component,
D: HasBound<Bound = B>,
impl<P, T, D, B, Y> SpatialCollisionSystem<P, T, D, B, Y>where
P: Primitive + Send + Sync + 'static,
<P::Point as EuclideanSpace>::Diff: Debug,
<P::Point as EuclideanSpace>::Scalar: BaseFloat,
B: Clone + Debug + Send + Sync + 'static + Bound<Point = P::Point> + Union<B, Output = B> + Contains<B> + SurfaceArea<Scalar = <P::Point as EuclideanSpace>::Scalar>,
T: Transform<P::Point> + Component,
D: HasBound<Bound = B>,
sourcepub fn new() -> Self
pub fn new() -> Self
Create a new collision detection system, with no broad or narrow phase activated.
sourcepub fn with_narrow_phase<N: NarrowPhase<P, T, B, Y> + 'static>(
self,
narrow: N
) -> Self
pub fn with_narrow_phase<N: NarrowPhase<P, T, B, Y> + 'static>(
self,
narrow: N
) -> Self
Specify what narrow phase algorithm to use
sourcepub fn with_broad_phase<V: BroadPhase<D> + 'static>(self, broad: V) -> Self
pub fn with_broad_phase<V: BroadPhase<D> + 'static>(self, broad: V) -> Self
Specify what broad phase algorithm to use
Trait Implementations
sourceimpl<'a, P, T, Y, B, D> System<'a> for SpatialCollisionSystem<P, T, (usize, D), B, Y>where
P: Primitive + ComputeBound<B> + Send + Sync + 'static,
P::Point: EuclideanSpace,
<P::Point as EuclideanSpace>::Scalar: BaseFloat + Send + Sync + 'static,
B: Clone + Debug + Send + Sync + 'static + Bound<Point = P::Point> + Union<B, Output = B> + Discrete<B> + Contains<B> + SurfaceArea<Scalar = <P::Point as EuclideanSpace>::Scalar>,
<P::Point as EuclideanSpace>::Diff: Debug + Send + Sync + 'static,
P::Point: Debug + Send + Sync + 'static,
T: Component + Clone + Debug + Transform<P::Point> + Send + Sync + 'static,
T::Storage: Tracked,
Y: Default + Send + Sync + 'static,
D: Send + Sync + 'static + TreeValue<Bound = B> + HasBound<Bound = B> + GetId<Entity>,
impl<'a, P, T, Y, B, D> System<'a> for SpatialCollisionSystem<P, T, (usize, D), B, Y>where
P: Primitive + ComputeBound<B> + Send + Sync + 'static,
P::Point: EuclideanSpace,
<P::Point as EuclideanSpace>::Scalar: BaseFloat + Send + Sync + 'static,
B: Clone + Debug + Send + Sync + 'static + Bound<Point = P::Point> + Union<B, Output = B> + Discrete<B> + Contains<B> + SurfaceArea<Scalar = <P::Point as EuclideanSpace>::Scalar>,
<P::Point as EuclideanSpace>::Diff: Debug + Send + Sync + 'static,
P::Point: Debug + Send + Sync + 'static,
T: Component + Clone + Debug + Transform<P::Point> + Send + Sync + 'static,
T::Storage: Tracked,
Y: Default + Send + Sync + 'static,
D: Send + Sync + 'static + TreeValue<Bound = B> + HasBound<Bound = B> + GetId<Entity>,
type SystemData = (Read<'a, EntitiesRes, DefaultProvider>, Storage<'a, T, Fetch<'a, MaskedStorage<T>>>, Storage<'a, NextFrame<T>, Fetch<'a, MaskedStorage<NextFrame<T>>>>, Storage<'a, CollisionShape<P, T, B, Y>, Fetch<'a, MaskedStorage<CollisionShape<P, T, B, Y>>>>, Write<'a, EventChannel<ContactEvent<Entity, <P as Primitive>::Point>>, DefaultProvider>, Write<'a, DynamicBoundingVolumeTree<D>, DefaultProvider>)
type SystemData = (Read<'a, EntitiesRes, DefaultProvider>, Storage<'a, T, Fetch<'a, MaskedStorage<T>>>, Storage<'a, NextFrame<T>, Fetch<'a, MaskedStorage<NextFrame<T>>>>, Storage<'a, CollisionShape<P, T, B, Y>, Fetch<'a, MaskedStorage<CollisionShape<P, T, B, Y>>>>, Write<'a, EventChannel<ContactEvent<Entity, <P as Primitive>::Point>>, DefaultProvider>, Write<'a, DynamicBoundingVolumeTree<D>, DefaultProvider>)
sourcefn run(&mut self, system_data: Self::SystemData)
fn run(&mut self, system_data: Self::SystemData)
sourcefn running_time(&self) -> RunningTime
fn running_time(&self) -> RunningTime
sourcefn accessor<'b>(&'b self) -> AccessorCow<'a, 'b, Self>
fn accessor<'b>(&'b self) -> AccessorCow<'a, 'b, Self>
SystemData
.