Merge pull request #582 from dimforge/misc

Narrow-phase methods renames + some re-exports
This commit is contained in:
Sébastien Crozet
2024-01-24 23:26:35 +01:00
committed by GitHub
4 changed files with 25 additions and 12 deletions

View File

@@ -203,7 +203,7 @@ impl IslandManager {
stack: &mut Vec<RigidBodyHandle>, stack: &mut Vec<RigidBodyHandle>,
) { ) {
for collider_handle in &rb_colliders.0 { for collider_handle in &rb_colliders.0 {
for inter in narrow_phase.contacts_with(*collider_handle) { for inter in narrow_phase.contact_pairs_with(*collider_handle) {
for manifold in &inter.manifolds { for manifold in &inter.manifolds {
if !manifold.data.solver_contacts.is_empty() { if !manifold.data.solver_contacts.is_empty() {
let other = crate::utils::select_other( let other = crate::utils::select_other(

View File

@@ -17,7 +17,9 @@ pub use self::narrow_phase::NarrowPhase;
pub use self::collider::{Collider, ColliderBuilder}; pub use self::collider::{Collider, ColliderBuilder};
pub use self::collider_set::ColliderSet; pub use self::collider_set::ColliderSet;
pub use parry::query::TrackedContact; pub use parry::bounding_volume::BoundingVolume;
pub use parry::query::{PointQuery, PointQueryWithLocation, RayCast, TrackedContact};
pub use parry::shape::SharedShape;
use crate::math::{Real, Vector}; use crate::math::{Real, Vector};
@@ -53,7 +55,6 @@ pub type RayIntersection = parry::query::RayIntersection;
pub type PointProjection = parry::query::PointProjection; pub type PointProjection = parry::query::PointProjection;
/// The the time of impact between two shapes. /// The the time of impact between two shapes.
pub type TOI = parry::query::TOI; pub type TOI = parry::query::TOI;
pub use parry::shape::SharedShape;
bitflags::bitflags! { bitflags::bitflags! {
/// Flags providing more information regarding a collision event. /// Flags providing more information regarding a collision event.

View File

@@ -109,7 +109,10 @@ impl NarrowPhase {
/// ///
/// It is strongly recommended to use the [`NarrowPhase::contacts_with`] method instead. This /// It is strongly recommended to use the [`NarrowPhase::contacts_with`] method instead. This
/// method can be used if the generation number of the collider handle isn't known. /// method can be used if the generation number of the collider handle isn't known.
pub fn contacts_with_unknown_gen(&self, collider: u32) -> impl Iterator<Item = &ContactPair> { pub fn contact_pairs_with_unknown_gen(
&self,
collider: u32,
) -> impl Iterator<Item = &ContactPair> {
self.graph_indices self.graph_indices
.get_unknown_gen(collider) .get_unknown_gen(collider)
.map(|id| id.contact_graph_index) .map(|id| id.contact_graph_index)
@@ -118,8 +121,12 @@ impl NarrowPhase {
.map(|pair| pair.2) .map(|pair| pair.2)
} }
/// All the contacts involving the given collider. /// All the contact pairs involving the given collider.
pub fn contacts_with<'a>( ///
/// The returned contact pairs identify pairs of colliders with intersecting bounding-volumes.
/// To check if any geometric contact happened between the collider shapes, check
/// [`ContactPair::has_any_active_contact`].
pub fn contact_pairs_with<'a>(
&self, &self,
collider: ColliderHandle, collider: ColliderHandle,
) -> impl Iterator<Item = &ContactPair> { ) -> impl Iterator<Item = &ContactPair> {
@@ -131,11 +138,11 @@ impl NarrowPhase {
.map(|pair| pair.2) .map(|pair| pair.2)
} }
/// All the intersections involving the given collider. /// All the intersection pairs involving the given collider.
/// ///
/// It is strongly recommended to use the [`NarrowPhase::intersections_with`] method instead. /// It is strongly recommended to use the [`NarrowPhase::intersections_with`] method instead.
/// This method can be used if the generation number of the collider handle isn't known. /// This method can be used if the generation number of the collider handle isn't known.
pub fn intersections_with_unknown_gen( pub fn intersection_pairs_with_unknown_gen(
&self, &self,
collider: u32, collider: u32,
) -> impl Iterator<Item = (ColliderHandle, ColliderHandle, bool)> + '_ { ) -> impl Iterator<Item = (ColliderHandle, ColliderHandle, bool)> + '_ {
@@ -150,8 +157,13 @@ impl NarrowPhase {
}) })
} }
/// All the intersections involving the given collider. /// All the intersection pairs involving the given collider, where at least one collider
pub fn intersections_with( /// involved in the intersection is a sensor.
///
/// The returned contact pairs identify pairs of colliders (where at least one is a sensor) with
/// intersecting bounding-volumes. To check if any geometric overlap happened between the collider shapes, check
/// the returned boolean.
pub fn intersection_pairs_with(
&self, &self,
collider: ColliderHandle, collider: ColliderHandle,
) -> impl Iterator<Item = (ColliderHandle, ColliderHandle, bool)> + '_ { ) -> impl Iterator<Item = (ColliderHandle, ColliderHandle, bool)> + '_ {

View File

@@ -210,7 +210,7 @@ mod tests {
let mut hit = false; let mut hit = false;
for (_, _, intersecting) in narrow_phase.intersections_with(a_handle) { for (_, _, intersecting) in narrow_phase.intersection_pairs_with(a_handle) {
if intersecting { if intersecting {
hit = true; hit = true;
} }
@@ -262,7 +262,7 @@ mod tests {
let mut hit = false; let mut hit = false;
for (_, _, intersecting) in narrow_phase.intersections_with(a_handle) { for (_, _, intersecting) in narrow_phase.intersection_pairs_with(a_handle) {
if intersecting { if intersecting {
hit = true; hit = true;
} }