Struct ncollide2d::world::CollisionWorld
source · pub struct CollisionWorld<N: Real, T> { /* private fields */ }
Expand description
A world that handles collision objects.
Implementations§
source§impl<N: Real, T> CollisionWorld<N, T>
impl<N: Real, T> CollisionWorld<N, T>
sourcepub fn new(margin: N) -> CollisionWorld<N, T>
pub fn new(margin: N) -> CollisionWorld<N, T>
Creates a new collision world.
sourcepub fn add(
&mut self,
position: Isometry<N>,
shape: ShapeHandle<N>,
collision_groups: CollisionGroups,
query_type: GeometricQueryType<N>,
data: T
) -> CollisionObjectHandle
pub fn add(
&mut self,
position: Isometry<N>,
shape: ShapeHandle<N>,
collision_groups: CollisionGroups,
query_type: GeometricQueryType<N>,
data: T
) -> CollisionObjectHandle
Adds a collision object to the world.
sourcepub fn update(&mut self)
pub fn update(&mut self)
Updates the collision world.
This executes the whole collision detection pipeline:
- Clears the event pools.
- Executes the broad phase first.
- Executes the narrow phase.
sourcepub fn clear_events(&mut self)
pub fn clear_events(&mut self)
Empty the contact and proximity event pools.
sourcepub fn remove(&mut self, handles: &[CollisionObjectHandle])
pub fn remove(&mut self, handles: &[CollisionObjectHandle])
Removed the specified set of collision objects from the world.
Panics of any handle is invalid, or if the list contains duplicates.
sourcepub fn set_position(&mut self, handle: CollisionObjectHandle, pos: Isometry<N>)
pub fn set_position(&mut self, handle: CollisionObjectHandle, pos: Isometry<N>)
Sets the position the collision object attached to the specified object.
sourcepub fn register_broad_phase_pair_filter<F>(&mut self, name: &str, filter: F)where
F: BroadPhasePairFilter<N, T>,
pub fn register_broad_phase_pair_filter<F>(&mut self, name: &str, filter: F)where
F: BroadPhasePairFilter<N, T>,
Adds a filter that tells if a potential collision pair should be ignored or not.
The proximity filter returns false
for a given pair of collision objects if they should
be ignored by the narrow phase. Keep in mind that modifying the proximity filter will have
a non-trivial overhead during the next update as it will force re-detection of all
collision pairs.
sourcepub fn unregister_broad_phase_pair_filter(&mut self, name: &str)
pub fn unregister_broad_phase_pair_filter(&mut self, name: &str)
Removes the pair filter named name
.
sourcepub fn perform_broad_phase(&mut self)
pub fn perform_broad_phase(&mut self)
Executes the broad phase of the collision detection pipeline.
sourcepub fn perform_narrow_phase(&mut self)
pub fn perform_narrow_phase(&mut self)
Executes the narrow phase of the collision detection pipeline.
sourcepub fn set_narrow_phase(
&mut self,
narrow_phase: Box<dyn NarrowPhase<N, T>>
) -> Box<dyn NarrowPhase<N, T>>
pub fn set_narrow_phase(
&mut self,
narrow_phase: Box<dyn NarrowPhase<N, T>>
) -> Box<dyn NarrowPhase<N, T>>
Sets a new narrow phase and returns the previous one.
Keep in mind that modifying the narrow-pase will have a non-trivial overhead during the next update as it will force re-detection of all collision pairs and their associated contacts.
sourcepub fn contact_pair(
&self,
handle1: CollisionObjectHandle,
handle2: CollisionObjectHandle
) -> Option<&ContactAlgorithm<N>>
pub fn contact_pair(
&self,
handle1: CollisionObjectHandle,
handle2: CollisionObjectHandle
) -> Option<&ContactAlgorithm<N>>
The contact pair, if any, between the given collision objects.
sourcepub fn contact_pairs(&self) -> ContactPairs<'_, N, T> ⓘ
pub fn contact_pairs(&self) -> ContactPairs<'_, N, T> ⓘ
Iterates through all the contact pairs detected since the last update.
sourcepub fn proximity_pairs(&self) -> ProximityPairs<'_, N, T> ⓘ
pub fn proximity_pairs(&self) -> ProximityPairs<'_, N, T> ⓘ
Iterates through all the proximity pairs detected since the last update.
sourcepub fn contact_manifolds(&self) -> ContactManifolds<'_, N, T> ⓘ
pub fn contact_manifolds(&self) -> ContactManifolds<'_, N, T> ⓘ
Iterates through every contact detected since the last update.
sourcepub fn collision_objects(&self) -> CollisionObjects<'_, N, T> ⓘ
pub fn collision_objects(&self) -> CollisionObjects<'_, N, T> ⓘ
Iterates through all collision objects.
sourcepub fn collision_object(
&self,
handle: CollisionObjectHandle
) -> Option<&CollisionObject<N, T>>
pub fn collision_object(
&self,
handle: CollisionObjectHandle
) -> Option<&CollisionObject<N, T>>
Returns a reference to the collision object identified by its handle.
sourcepub fn collision_object_mut(
&mut self,
handle: CollisionObjectHandle
) -> Option<&mut CollisionObject<N, T>>
pub fn collision_object_mut(
&mut self,
handle: CollisionObjectHandle
) -> Option<&mut CollisionObject<N, T>>
Returns a mutable reference to the collision object identified by its handle.
sourcepub fn set_collision_groups(
&mut self,
handle: CollisionObjectHandle,
groups: CollisionGroups
)
pub fn set_collision_groups(
&mut self,
handle: CollisionObjectHandle,
groups: CollisionGroups
)
Sets the collision groups of the given collision object.
sourcepub fn interferences_with_ray<'a, 'b>(
&'a self,
ray: &'b Ray<N>,
groups: &'b CollisionGroups
) -> InterferencesWithRay<'a, 'b, N, T> ⓘ
pub fn interferences_with_ray<'a, 'b>(
&'a self,
ray: &'b Ray<N>,
groups: &'b CollisionGroups
) -> InterferencesWithRay<'a, 'b, N, T> ⓘ
Computes the interferences between every rigid bodies on this world and a ray.
sourcepub fn interferences_with_point<'a, 'b>(
&'a self,
point: &'b Point<N>,
groups: &'b CollisionGroups
) -> InterferencesWithPoint<'a, 'b, N, T> ⓘ
pub fn interferences_with_point<'a, 'b>(
&'a self,
point: &'b Point<N>,
groups: &'b CollisionGroups
) -> InterferencesWithPoint<'a, 'b, N, T> ⓘ
Computes the interferences between every rigid bodies of a given broad phase, and a point.
sourcepub fn interferences_with_aabb<'a, 'b>(
&'a self,
aabb: &'b AABB<N>,
groups: &'b CollisionGroups
) -> InterferencesWithAABB<'a, 'b, N, T> ⓘ
pub fn interferences_with_aabb<'a, 'b>(
&'a self,
aabb: &'b AABB<N>,
groups: &'b CollisionGroups
) -> InterferencesWithAABB<'a, 'b, N, T> ⓘ
Computes the interferences between every rigid bodies of a given broad phase, and a aabb.
sourcepub fn contact_events(&self) -> &ContactEvents
pub fn contact_events(&self) -> &ContactEvents
The contact events pool.
sourcepub fn proximity_events(&self) -> &ProximityEvents
pub fn proximity_events(&self) -> &ProximityEvents
The proximity events pool.
Auto Trait Implementations§
impl<N, T> !RefUnwindSafe for CollisionWorld<N, T>
impl<N, T> Send for CollisionWorld<N, T>where
T: Send,
impl<N, T> Sync for CollisionWorld<N, T>where
T: Sync,
impl<N, T> Unpin for CollisionWorld<N, T>where
N: Unpin,
T: Unpin,
impl<N, T> !UnwindSafe for CollisionWorld<N, T>
Blanket Implementations§
source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self
from the equivalent element of its
superset. Read moresource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self
is actually part of its subset T
(and can be converted to it).source§unsafe fn to_subset_unchecked(&self) -> SS
unsafe fn to_subset_unchecked(&self) -> SS
self.to_subset
but without any property checks. Always succeeds.source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self
to the equivalent element of its superset.