Struct avian3d::collision::narrow_phase::NarrowPhase
source · pub struct NarrowPhase<'w, 's, C: AnyCollider> {
pub collisions: ResMut<'w, Collisions>,
pub config: Res<'w, NarrowPhaseConfig>,
/* private fields */
}
Expand description
A system parameter for managing the narrow phase.
The narrow phase computes contacts for each intersection pair
in BroadCollisionPairs
, adds them to the Collisions
resource,
and generates ContactConstraints
for the contacts.
Fields§
§collisions: ResMut<'w, Collisions>
Contacts found by the narrow phase.
config: Res<'w, NarrowPhaseConfig>
Configuration options for the narrow phase.
Implementations§
source§impl<'w, 's, C: AnyCollider> NarrowPhase<'w, 's, C>
impl<'w, 's, C: AnyCollider> NarrowPhase<'w, 's, C>
sourcepub fn handle_entity_pair(
&self,
entity1: Entity,
entity2: Entity,
delta_secs: Scalar
) -> Option<Contacts>
pub fn handle_entity_pair( &self, entity1: Entity, entity2: Entity, delta_secs: Scalar ) -> Option<Contacts>
Returns the Contacts
between entity1
and entity2
if they are intersecting
or expected to start intersecting within the next frame. This includes
speculative collision.
sourcepub fn compute_contact_pair(
&self,
collider1: &ColliderQueryItem<'_, C>,
collider2: &ColliderQueryItem<'_, C>,
max_distance: Scalar
) -> Option<Contacts>
pub fn compute_contact_pair( &self, collider1: &ColliderQueryItem<'_, C>, collider2: &ColliderQueryItem<'_, C>, max_distance: Scalar ) -> Option<Contacts>
Computes contacts between collider1
and collider2
.
Returns None
if no contacts are found.
The given max_distance
determines the maximum distance for a contact
to be detected. A value greater than zero means that contacts are generated
based on the closest points even if the shapes are separated.
sourcepub fn generate_constraints(
&self,
contacts: &Contacts,
constraints: &mut Vec<ContactConstraint>,
body1: &RigidBodyQueryReadOnlyItem<'_>,
body2: &RigidBodyQueryReadOnlyItem<'_>,
collider1: &ColliderQueryItem<'_, C>,
collider2: &ColliderQueryItem<'_, C>,
collision_margin: impl Into<CollisionMargin> + Copy,
contact_softness: ContactSoftnessCoefficients,
delta_secs: Scalar
)
pub fn generate_constraints( &self, contacts: &Contacts, constraints: &mut Vec<ContactConstraint>, body1: &RigidBodyQueryReadOnlyItem<'_>, body2: &RigidBodyQueryReadOnlyItem<'_>, collider1: &ColliderQueryItem<'_, C>, collider2: &ColliderQueryItem<'_, C>, collision_margin: impl Into<CollisionMargin> + Copy, contact_softness: ContactSoftnessCoefficients, delta_secs: Scalar )
Generates ContactConstraint
s for the given bodies and their corresponding colliders
based on the given contacts
. The constraints are added to the constraints
vector.
The collision_margin
can be used to add artificial thickness to the colliders,
which can improve performance and stability in some cases. See CollisionMargin
for more details.
The contact_softness
is used to tune the damping and stiffness of the contact constraints.
Trait Implementations§
source§impl<C: AnyCollider> SystemParam for NarrowPhase<'_, '_, C>
impl<C: AnyCollider> SystemParam for NarrowPhase<'_, '_, C>
§type Item<'w, 's> = NarrowPhase<'w, 's, C>
type Item<'w, 's> = NarrowPhase<'w, 's, C>
Self
, instantiated with new lifetimes. Read moresource§fn init_state(world: &mut World, system_meta: &mut SystemMeta) -> Self::State
fn init_state(world: &mut World, system_meta: &mut SystemMeta) -> Self::State
World
access used by this SystemParam
and creates a new instance of this param’s State
.source§unsafe fn new_archetype(
state: &mut Self::State,
archetype: &Archetype,
system_meta: &mut SystemMeta
)
unsafe fn new_archetype( state: &mut Self::State, archetype: &Archetype, system_meta: &mut SystemMeta )
Archetype
, registers the components accessed by this SystemParam
(if applicable).a Read moresource§fn apply(state: &mut Self::State, system_meta: &SystemMeta, world: &mut World)
fn apply(state: &mut Self::State, system_meta: &SystemMeta, world: &mut World)
SystemParam
’s state.
This is used to apply Commands
during apply_deferred
.source§fn queue(
state: &mut Self::State,
system_meta: &SystemMeta,
world: DeferredWorld<'_>
)
fn queue( state: &mut Self::State, system_meta: &SystemMeta, world: DeferredWorld<'_> )
apply_deferred
.source§unsafe fn get_param<'w, 's>(
state: &'s mut Self::State,
system_meta: &SystemMeta,
world: UnsafeWorldCell<'w>,
change_tick: Tick
) -> Self::Item<'w, 's>
unsafe fn get_param<'w, 's>( state: &'s mut Self::State, system_meta: &SystemMeta, world: UnsafeWorldCell<'w>, change_tick: Tick ) -> Self::Item<'w, 's>
SystemParamFunction
. Read moreimpl<'w, 's, C: AnyCollider> ReadOnlySystemParam for NarrowPhase<'w, 's, C>where
ParallelCommands<'w, 's>: ReadOnlySystemParam,
Query<'w, 's, ColliderQuery<C>>: ReadOnlySystemParam,
Query<'w, 's, (RigidBodyQueryReadOnly, Option<&'static CollisionMargin>, Option<&'static SpeculativeMargin>)>: ReadOnlySystemParam,
ResMut<'w, Collisions>: ReadOnlySystemParam,
Res<'w, NarrowPhaseConfig>: ReadOnlySystemParam,
Res<'w, PhysicsLengthUnit>: ReadOnlySystemParam,
Local<'s, Scalar>: ReadOnlySystemParam,
Auto Trait Implementations§
impl<'w, 's, C> Freeze for NarrowPhase<'w, 's, C>
impl<'w, 's, C> !RefUnwindSafe for NarrowPhase<'w, 's, C>
impl<'w, 's, C> Send for NarrowPhase<'w, 's, C>
impl<'w, 's, C> Sync for NarrowPhase<'w, 's, C>
impl<'w, 's, C> Unpin for NarrowPhase<'w, 's, C>
impl<'w, 's, C> !UnwindSafe for NarrowPhase<'w, 's, C>
Blanket Implementations§
source§impl<T, U> AsBindGroupShaderType<U> for T
impl<T, U> AsBindGroupShaderType<U> for T
source§fn as_bind_group_shader_type(&self, _images: &RenderAssets<GpuImage>) -> U
fn as_bind_group_shader_type(&self, _images: &RenderAssets<GpuImage>) -> U
T
ShaderType
for self
. When used in AsBindGroup
derives, it is safe to assume that all images in self
exist.source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
. Box<dyn Any>
can
then be further downcast
into Box<ConcreteType>
where ConcreteType
implements Trait
.source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
.source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s.source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§impl<T> Pointable for T
impl<T> Pointable for T
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§fn to_subset_unchecked(&self) -> SS
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.