Skip to content

Commit

Permalink
feat!: rename narrow-phase methods for more clarity.
Browse files Browse the repository at this point in the history
Renames `contacts_with` to`contact_pairs_with`; and `intersections_with` to `intersection_pairs_with`.
  • Loading branch information
sebcrozet committed Jan 24, 2024
1 parent 5bf3983 commit 46b2441
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/dynamics/island_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ impl IslandManager {
stack: &mut Vec<RigidBodyHandle>,
) {
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 {
if !manifold.data.solver_contacts.is_empty() {
let other = crate::utils::select_other(
Expand Down
26 changes: 19 additions & 7 deletions src/geometry/narrow_phase.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,10 @@ impl NarrowPhase {
///
/// 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.
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
.get_unknown_gen(collider)
.map(|id| id.contact_graph_index)
Expand All @@ -118,8 +121,12 @@ impl NarrowPhase {
.map(|pair| pair.2)
}

/// All the contacts involving the given collider.
pub fn contacts_with<'a>(
/// All the contact pairs involving the given collider.
///
/// 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,
collider: ColliderHandle,
) -> impl Iterator<Item = &ContactPair> {
Expand All @@ -131,11 +138,11 @@ impl NarrowPhase {
.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.
/// 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,
collider: u32,
) -> impl Iterator<Item = (ColliderHandle, ColliderHandle, bool)> + '_ {
Expand All @@ -150,8 +157,13 @@ impl NarrowPhase {
})
}

/// All the intersections involving the given collider.
pub fn intersections_with(
/// All the intersection pairs involving the given collider, where at least one collider
/// 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,
collider: ColliderHandle,
) -> impl Iterator<Item = (ColliderHandle, ColliderHandle, bool)> + '_ {
Expand Down

0 comments on commit 46b2441

Please sign in to comment.