From 85bc81d4fce29bf628d31cb978aa482e564aab90 Mon Sep 17 00:00:00 2001 From: Emil Ernerfeldt Date: Thu, 4 Feb 2021 13:11:04 +0100 Subject: Make clippy a bit happier --- src/geometry/broad_phase_multi_sap.rs | 6 +++--- src/geometry/collider.rs | 12 ++++++------ src/geometry/collider_set.rs | 5 +++++ src/geometry/interaction_graph.rs | 4 ++-- src/geometry/narrow_phase.rs | 18 +++++++++--------- 5 files changed, 25 insertions(+), 20 deletions(-) (limited to 'src/geometry') diff --git a/src/geometry/broad_phase_multi_sap.rs b/src/geometry/broad_phase_multi_sap.rs index b0a274d..1b780c3 100644 --- a/src/geometry/broad_phase_multi_sap.rs +++ b/src/geometry/broad_phase_multi_sap.rs @@ -569,16 +569,16 @@ impl BroadPhase { self.removed_colliders = Some(colliders.removed_colliders.subscribe()); } - let mut cursor = self.removed_colliders.take().unwrap(); + let cursor = self.removed_colliders.take().unwrap(); for collider in colliders.removed_colliders.read(&cursor) { self.remove_collider(collider.proxy_index); } - colliders.removed_colliders.ack(&mut cursor); + colliders.removed_colliders.ack(&cursor); self.removed_colliders = Some(cursor); } - fn remove_collider<'a>(&mut self, proxy_index: usize) { + fn remove_collider(&mut self, proxy_index: usize) { if proxy_index == crate::INVALID_USIZE { // This collider has not been added to the broad-phase yet. return; diff --git a/src/geometry/collider.rs b/src/geometry/collider.rs index fa2da68..ce263f8 100644 --- a/src/geometry/collider.rs +++ b/src/geometry/collider.rs @@ -361,14 +361,14 @@ impl ColliderBuilder { /// Initializes a new collider builder with a 2D convex polygon or 3D convex polyhedron /// obtained after computing the convex-hull of the given points. pub fn convex_hull(points: &[Point]) -> Option { - SharedShape::convex_hull(points).map(|cp| Self::new(cp)) + SharedShape::convex_hull(points).map(Self::new) } /// Initializes a new collider builder with a round 2D convex polygon or 3D convex polyhedron /// obtained after computing the convex-hull of the given points. The shape is dilated /// by a sphere of radius `border_radius`. pub fn round_convex_hull(points: &[Point], border_radius: Real) -> Option { - SharedShape::round_convex_hull(points, border_radius).map(|cp| Self::new(cp)) + SharedShape::round_convex_hull(points, border_radius).map(Self::new) } /// Creates a new collider builder that is a convex polygon formed by the @@ -376,7 +376,7 @@ impl ColliderBuilder { /// computed). #[cfg(feature = "dim2")] pub fn convex_polyline(points: Vec>) -> Option { - SharedShape::convex_polyline(points).map(|cp| Self::new(cp)) + SharedShape::convex_polyline(points).map(Self::new) } /// Creates a new collider builder that is a round convex polygon formed by the @@ -384,7 +384,7 @@ impl ColliderBuilder { /// computed). The polygon shape is dilated by a sphere of radius `border_radius`. #[cfg(feature = "dim2")] pub fn round_convex_polyline(points: Vec>, border_radius: Real) -> Option { - SharedShape::round_convex_polyline(points, border_radius).map(|cp| Self::new(cp)) + SharedShape::round_convex_polyline(points, border_radius).map(Self::new) } /// Creates a new collider builder that is a convex polyhedron formed by the @@ -392,7 +392,7 @@ impl ColliderBuilder { /// computed). #[cfg(feature = "dim3")] pub fn convex_mesh(points: Vec>, indices: &[[u32; 3]]) -> Option { - SharedShape::convex_mesh(points, indices).map(|cp| Self::new(cp)) + SharedShape::convex_mesh(points, indices).map(Self::new) } /// Creates a new collider builder that is a round convex polyhedron formed by the @@ -404,7 +404,7 @@ impl ColliderBuilder { indices: &[[u32; 3]], border_radius: Real, ) -> Option { - SharedShape::round_convex_mesh(points, indices, border_radius).map(|cp| Self::new(cp)) + SharedShape::round_convex_mesh(points, indices, border_radius).map(Self::new) } /// Initializes a collider builder with a heightfield shape defined by its set of height and a scale diff --git a/src/geometry/collider_set.rs b/src/geometry/collider_set.rs index 3ceb297..f087bad 100644 --- a/src/geometry/collider_set.rs +++ b/src/geometry/collider_set.rs @@ -80,6 +80,11 @@ impl ColliderSet { self.colliders.len() } + /// `true` if there are no colliders in this set. + pub fn is_empty(&self) -> bool { + self.colliders.is_empty() + } + /// Is this collider handle valid? pub fn contains(&self, handle: ColliderHandle) -> bool { self.colliders.contains(handle.0) diff --git a/src/geometry/interaction_graph.rs b/src/geometry/interaction_graph.rs index 657050c..e2cc218 100644 --- a/src/geometry/interaction_graph.rs +++ b/src/geometry/interaction_graph.rs @@ -120,9 +120,9 @@ impl InteractionGraph { /// All the interaction involving the collision object with graph index `id`. pub fn interactions_with(&self, id: ColliderGraphIndex) -> impl Iterator { - self.graph.edges(id).filter_map(move |e| { + self.graph.edges(id).map(move |e| { let endpoints = self.graph.edge_endpoints(e.id()).unwrap(); - Some((self.graph[endpoints.0], self.graph[endpoints.1], e.weight())) + (self.graph[endpoints.0], self.graph[endpoints.1], e.weight()) }) } diff --git a/src/geometry/narrow_phase.rs b/src/geometry/narrow_phase.rs index c462689..7525a68 100644 --- a/src/geometry/narrow_phase.rs +++ b/src/geometry/narrow_phase.rs @@ -90,10 +90,10 @@ impl NarrowPhase { } /// All the intersections involving the given collider. - pub fn intersections_with<'a>( - &'a self, + pub fn intersections_with( + &self, collider: ColliderHandle, - ) -> Option + 'a> { + ) -> Option + '_> { let id = self.graph_indices.get(collider.0)?; Some( self.intersection_graph @@ -141,9 +141,9 @@ impl NarrowPhase { } /// All the intersection pairs maintained by this narrow-phase. - pub fn intersection_pairs<'a>( - &'a self, - ) -> impl Iterator + 'a { + pub fn intersection_pairs( + &self, + ) -> impl Iterator + '_ { self.intersection_graph .interactions_with_endpoints() .map(|e| (e.0, e.1, *e.2)) @@ -161,7 +161,7 @@ impl NarrowPhase { self.removed_colliders = Some(colliders.removed_colliders.subscribe()); } - let mut cursor = self.removed_colliders.take().unwrap(); + let cursor = self.removed_colliders.take().unwrap(); // TODO: avoid these hash-maps. // They are necessary to handle the swap-remove done internally @@ -196,11 +196,11 @@ impl NarrowPhase { i += 1; } - colliders.removed_colliders.ack(&mut cursor); + colliders.removed_colliders.ack(&cursor); self.removed_colliders = Some(cursor); } - pub(crate) fn remove_collider<'a>( + pub(crate) fn remove_collider( &mut self, intersection_graph_id: ColliderGraphIndex, contact_graph_id: ColliderGraphIndex, -- cgit