Merge pull request #104 from EmbarkStudios/clippy-fixes
Make clippy a bit happier
This commit is contained in:
@@ -55,6 +55,11 @@ impl JointSet {
|
|||||||
self.joint_graph.graph.edges.len()
|
self.joint_graph.graph.edges.len()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// `true` if there are no joints in this set.
|
||||||
|
pub fn is_empty(&self) -> bool {
|
||||||
|
self.joint_graph.graph.edges.is_empty()
|
||||||
|
}
|
||||||
|
|
||||||
/// Retrieve the joint graph where edges are joints and nodes are rigid body handles.
|
/// Retrieve the joint graph where edges are joints and nodes are rigid body handles.
|
||||||
pub fn joint_graph(&self) -> &InteractionGraph<RigidBodyHandle, Joint> {
|
pub fn joint_graph(&self) -> &InteractionGraph<RigidBodyHandle, Joint> {
|
||||||
&self.joint_graph
|
&self.joint_graph
|
||||||
|
|||||||
@@ -304,7 +304,7 @@ impl RigidBody {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn integrate_velocity(&self, dt: Real) -> Isometry<Real> {
|
fn integrate_velocity(&self, dt: Real) -> Isometry<Real> {
|
||||||
let com = &self.position * self.mass_properties.local_com;
|
let com = self.position * self.mass_properties.local_com;
|
||||||
let shift = Translation::from(com.coords);
|
let shift = Translation::from(com.coords);
|
||||||
shift * Isometry::new(self.linvel * dt, self.angvel * dt) * shift.inverse()
|
shift * Isometry::new(self.linvel * dt, self.angvel * dt) * shift.inverse()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -106,6 +106,11 @@ impl RigidBodySet {
|
|||||||
self.bodies.len()
|
self.bodies.len()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// `true` if there are no rigid bodies in this set.
|
||||||
|
pub fn is_empty(&self) -> bool {
|
||||||
|
self.bodies.is_empty()
|
||||||
|
}
|
||||||
|
|
||||||
/// Is the given body handle valid?
|
/// Is the given body handle valid?
|
||||||
pub fn contains(&self, handle: RigidBodyHandle) -> bool {
|
pub fn contains(&self, handle: RigidBodyHandle) -> bool {
|
||||||
self.bodies.contains(handle.0)
|
self.bodies.contains(handle.0)
|
||||||
|
|||||||
@@ -84,7 +84,7 @@ impl PrismaticVelocityConstraint {
|
|||||||
// .into_inner();
|
// .into_inner();
|
||||||
// #[cfg(feature = "dim3")]
|
// #[cfg(feature = "dim3")]
|
||||||
// let r21 = Rotation::rotation_between_axis(&axis1, &axis2)
|
// let r21 = Rotation::rotation_between_axis(&axis1, &axis2)
|
||||||
// .unwrap_or(Rotation::identity())
|
// .unwrap_or_else(Rotation::identity)
|
||||||
// .to_rotation_matrix()
|
// .to_rotation_matrix()
|
||||||
// .into_inner();
|
// .into_inner();
|
||||||
// let basis2 = r21 * basis1;
|
// let basis2 = r21 * basis1;
|
||||||
@@ -380,7 +380,7 @@ impl PrismaticVelocityGroundConstraint {
|
|||||||
// .into_inner();
|
// .into_inner();
|
||||||
// #[cfg(feature = "dim3")]
|
// #[cfg(feature = "dim3")]
|
||||||
// let r21 = Rotation::rotation_between_axis(&axis1, &axis2)
|
// let r21 = Rotation::rotation_between_axis(&axis1, &axis2)
|
||||||
// .unwrap_or(Rotation::identity())
|
// .unwrap_or_else(Rotation::identity)
|
||||||
// .to_rotation_matrix()
|
// .to_rotation_matrix()
|
||||||
// .into_inner();
|
// .into_inner();
|
||||||
// let basis2 = r21 * basis1;
|
// let basis2 = r21 * basis1;
|
||||||
|
|||||||
@@ -124,7 +124,7 @@ impl WPrismaticVelocityConstraint {
|
|||||||
// .into_inner();
|
// .into_inner();
|
||||||
// #[cfg(feature = "dim3")]
|
// #[cfg(feature = "dim3")]
|
||||||
// let r21 = Rotation::rotation_between_axis(&axis1, &axis2)
|
// let r21 = Rotation::rotation_between_axis(&axis1, &axis2)
|
||||||
// .unwrap_or(Rotation::identity())
|
// .unwrap_or_else(Rotation::identity)
|
||||||
// .to_rotation_matrix()
|
// .to_rotation_matrix()
|
||||||
// .into_inner();
|
// .into_inner();
|
||||||
// let basis2 = r21 * basis1;
|
// let basis2 = r21 * basis1;
|
||||||
@@ -483,7 +483,7 @@ impl WPrismaticVelocityGroundConstraint {
|
|||||||
// .into_inner();
|
// .into_inner();
|
||||||
// #[cfg(feature = "dim3")]
|
// #[cfg(feature = "dim3")]
|
||||||
// let r21 = Rotation::rotation_between_axis(&axis1, &axis2)
|
// let r21 = Rotation::rotation_between_axis(&axis1, &axis2)
|
||||||
// .unwrap_or(Rotation::identity())
|
// .unwrap_or_else(Rotation::identity)
|
||||||
// .to_rotation_matrix()
|
// .to_rotation_matrix()
|
||||||
// .into_inner();
|
// .into_inner();
|
||||||
// let basis2 = r21 * basis1;
|
// let basis2 = r21 * basis1;
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ impl RevolutePositionConstraint {
|
|||||||
let axis1 = position1 * self.local_axis1;
|
let axis1 = position1 * self.local_axis1;
|
||||||
let axis2 = position2 * self.local_axis2;
|
let axis2 = position2 * self.local_axis2;
|
||||||
let delta_rot =
|
let delta_rot =
|
||||||
Rotation::rotation_between_axis(&axis1, &axis2).unwrap_or(Rotation::identity());
|
Rotation::rotation_between_axis(&axis1, &axis2).unwrap_or_else(Rotation::identity);
|
||||||
let ang_error = delta_rot.scaled_axis() * params.joint_erp;
|
let ang_error = delta_rot.scaled_axis() * params.joint_erp;
|
||||||
let ang_impulse = self.ang_inv_lhs.transform_vector(ang_error);
|
let ang_impulse = self.ang_inv_lhs.transform_vector(ang_error);
|
||||||
|
|
||||||
@@ -129,7 +129,7 @@ impl RevolutePositionGroundConstraint {
|
|||||||
|
|
||||||
let delta_rot =
|
let delta_rot =
|
||||||
Rotation::scaled_rotation_between_axis(&axis2, &self.axis1, params.joint_erp)
|
Rotation::scaled_rotation_between_axis(&axis2, &self.axis1, params.joint_erp)
|
||||||
.unwrap_or(Rotation::identity());
|
.unwrap_or_else(Rotation::identity);
|
||||||
position2.rotation = delta_rot * position2.rotation;
|
position2.rotation = delta_rot * position2.rotation;
|
||||||
|
|
||||||
let anchor2 = position2 * self.local_anchor2;
|
let anchor2 = position2 * self.local_anchor2;
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ impl RevoluteVelocityConstraint {
|
|||||||
]);
|
]);
|
||||||
|
|
||||||
// let r21 = Rotation::rotation_between_axis(&axis1, &axis2)
|
// let r21 = Rotation::rotation_between_axis(&axis1, &axis2)
|
||||||
// .unwrap_or(Rotation::identity())
|
// .unwrap_or_else(Rotation::identity)
|
||||||
// .to_rotation_matrix()
|
// .to_rotation_matrix()
|
||||||
// .into_inner();
|
// .into_inner();
|
||||||
// let basis2 = r21 * basis1;
|
// let basis2 = r21 * basis1;
|
||||||
@@ -208,7 +208,7 @@ impl RevoluteVelocityGroundConstraint {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// let r21 = Rotation::rotation_between_axis(&axis1, &axis2)
|
// let r21 = Rotation::rotation_between_axis(&axis1, &axis2)
|
||||||
// .unwrap_or(Rotation::identity())
|
// .unwrap_or_else(Rotation::identity)
|
||||||
// .to_rotation_matrix()
|
// .to_rotation_matrix()
|
||||||
// .into_inner();
|
// .into_inner();
|
||||||
// let basis2 = /*r21 * */ basis1;
|
// let basis2 = /*r21 * */ basis1;
|
||||||
|
|||||||
@@ -73,7 +73,7 @@ impl WRevoluteVelocityConstraint {
|
|||||||
Matrix3x2::from_columns(&[position1 * local_basis1[0], position1 * local_basis1[1]]);
|
Matrix3x2::from_columns(&[position1 * local_basis1[0], position1 * local_basis1[1]]);
|
||||||
|
|
||||||
// let r21 = Rotation::rotation_between_axis(&axis1, &axis2)
|
// let r21 = Rotation::rotation_between_axis(&axis1, &axis2)
|
||||||
// .unwrap_or(Rotation::identity())
|
// .unwrap_or_else(Rotation::identity)
|
||||||
// .to_rotation_matrix()
|
// .to_rotation_matrix()
|
||||||
// .into_inner();
|
// .into_inner();
|
||||||
// let basis2 = r21 * basis1;
|
// let basis2 = r21 * basis1;
|
||||||
@@ -290,7 +290,7 @@ impl WRevoluteVelocityGroundConstraint {
|
|||||||
let anchor2 = position2 * local_anchor2;
|
let anchor2 = position2 * local_anchor2;
|
||||||
|
|
||||||
// let r21 = Rotation::rotation_between_axis(&axis1, &axis2)
|
// let r21 = Rotation::rotation_between_axis(&axis1, &axis2)
|
||||||
// .unwrap_or(Rotation::identity())
|
// .unwrap_or_else(Rotation::identity)
|
||||||
// .to_rotation_matrix()
|
// .to_rotation_matrix()
|
||||||
// .into_inner();
|
// .into_inner();
|
||||||
// let basis2 = /*r21 * */ basis1;
|
// let basis2 = /*r21 * */ basis1;
|
||||||
|
|||||||
@@ -569,16 +569,16 @@ impl BroadPhase {
|
|||||||
self.removed_colliders = Some(colliders.removed_colliders.subscribe());
|
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) {
|
for collider in colliders.removed_colliders.read(&cursor) {
|
||||||
self.remove_collider(collider.proxy_index);
|
self.remove_collider(collider.proxy_index);
|
||||||
}
|
}
|
||||||
|
|
||||||
colliders.removed_colliders.ack(&mut cursor);
|
colliders.removed_colliders.ack(&cursor);
|
||||||
self.removed_colliders = Some(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 {
|
if proxy_index == crate::INVALID_USIZE {
|
||||||
// This collider has not been added to the broad-phase yet.
|
// This collider has not been added to the broad-phase yet.
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -361,14 +361,14 @@ impl ColliderBuilder {
|
|||||||
/// Initializes a new collider builder with a 2D convex polygon or 3D convex polyhedron
|
/// Initializes a new collider builder with a 2D convex polygon or 3D convex polyhedron
|
||||||
/// obtained after computing the convex-hull of the given points.
|
/// obtained after computing the convex-hull of the given points.
|
||||||
pub fn convex_hull(points: &[Point<Real>]) -> Option<Self> {
|
pub fn convex_hull(points: &[Point<Real>]) -> Option<Self> {
|
||||||
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
|
/// 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
|
/// obtained after computing the convex-hull of the given points. The shape is dilated
|
||||||
/// by a sphere of radius `border_radius`.
|
/// by a sphere of radius `border_radius`.
|
||||||
pub fn round_convex_hull(points: &[Point<Real>], border_radius: Real) -> Option<Self> {
|
pub fn round_convex_hull(points: &[Point<Real>], border_radius: Real) -> Option<Self> {
|
||||||
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
|
/// Creates a new collider builder that is a convex polygon formed by the
|
||||||
@@ -376,7 +376,7 @@ impl ColliderBuilder {
|
|||||||
/// computed).
|
/// computed).
|
||||||
#[cfg(feature = "dim2")]
|
#[cfg(feature = "dim2")]
|
||||||
pub fn convex_polyline(points: Vec<Point<Real>>) -> Option<Self> {
|
pub fn convex_polyline(points: Vec<Point<Real>>) -> Option<Self> {
|
||||||
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
|
/// 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`.
|
/// computed). The polygon shape is dilated by a sphere of radius `border_radius`.
|
||||||
#[cfg(feature = "dim2")]
|
#[cfg(feature = "dim2")]
|
||||||
pub fn round_convex_polyline(points: Vec<Point<Real>>, border_radius: Real) -> Option<Self> {
|
pub fn round_convex_polyline(points: Vec<Point<Real>>, border_radius: Real) -> Option<Self> {
|
||||||
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
|
/// Creates a new collider builder that is a convex polyhedron formed by the
|
||||||
@@ -392,7 +392,7 @@ impl ColliderBuilder {
|
|||||||
/// computed).
|
/// computed).
|
||||||
#[cfg(feature = "dim3")]
|
#[cfg(feature = "dim3")]
|
||||||
pub fn convex_mesh(points: Vec<Point<Real>>, indices: &[[u32; 3]]) -> Option<Self> {
|
pub fn convex_mesh(points: Vec<Point<Real>>, indices: &[[u32; 3]]) -> Option<Self> {
|
||||||
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
|
/// Creates a new collider builder that is a round convex polyhedron formed by the
|
||||||
@@ -404,7 +404,7 @@ impl ColliderBuilder {
|
|||||||
indices: &[[u32; 3]],
|
indices: &[[u32; 3]],
|
||||||
border_radius: Real,
|
border_radius: Real,
|
||||||
) -> Option<Self> {
|
) -> Option<Self> {
|
||||||
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
|
/// Initializes a collider builder with a heightfield shape defined by its set of height and a scale
|
||||||
|
|||||||
@@ -80,6 +80,11 @@ impl ColliderSet {
|
|||||||
self.colliders.len()
|
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?
|
/// Is this collider handle valid?
|
||||||
pub fn contains(&self, handle: ColliderHandle) -> bool {
|
pub fn contains(&self, handle: ColliderHandle) -> bool {
|
||||||
self.colliders.contains(handle.0)
|
self.colliders.contains(handle.0)
|
||||||
|
|||||||
@@ -120,9 +120,9 @@ impl<N: Copy, E> InteractionGraph<N, E> {
|
|||||||
|
|
||||||
/// All the interaction involving the collision object with graph index `id`.
|
/// All the interaction involving the collision object with graph index `id`.
|
||||||
pub fn interactions_with(&self, id: ColliderGraphIndex) -> impl Iterator<Item = (N, N, &E)> {
|
pub fn interactions_with(&self, id: ColliderGraphIndex) -> impl Iterator<Item = (N, N, &E)> {
|
||||||
self.graph.edges(id).filter_map(move |e| {
|
self.graph.edges(id).map(move |e| {
|
||||||
let endpoints = self.graph.edge_endpoints(e.id()).unwrap();
|
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())
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -90,10 +90,10 @@ impl NarrowPhase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// All the intersections involving the given collider.
|
/// All the intersections involving the given collider.
|
||||||
pub fn intersections_with<'a>(
|
pub fn intersections_with(
|
||||||
&'a self,
|
&self,
|
||||||
collider: ColliderHandle,
|
collider: ColliderHandle,
|
||||||
) -> Option<impl Iterator<Item = (ColliderHandle, ColliderHandle, bool)> + 'a> {
|
) -> Option<impl Iterator<Item = (ColliderHandle, ColliderHandle, bool)> + '_> {
|
||||||
let id = self.graph_indices.get(collider.0)?;
|
let id = self.graph_indices.get(collider.0)?;
|
||||||
Some(
|
Some(
|
||||||
self.intersection_graph
|
self.intersection_graph
|
||||||
@@ -141,9 +141,9 @@ impl NarrowPhase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// All the intersection pairs maintained by this narrow-phase.
|
/// All the intersection pairs maintained by this narrow-phase.
|
||||||
pub fn intersection_pairs<'a>(
|
pub fn intersection_pairs(
|
||||||
&'a self,
|
&self,
|
||||||
) -> impl Iterator<Item = (ColliderHandle, ColliderHandle, bool)> + 'a {
|
) -> impl Iterator<Item = (ColliderHandle, ColliderHandle, bool)> + '_ {
|
||||||
self.intersection_graph
|
self.intersection_graph
|
||||||
.interactions_with_endpoints()
|
.interactions_with_endpoints()
|
||||||
.map(|e| (e.0, e.1, *e.2))
|
.map(|e| (e.0, e.1, *e.2))
|
||||||
@@ -161,7 +161,7 @@ impl NarrowPhase {
|
|||||||
self.removed_colliders = Some(colliders.removed_colliders.subscribe());
|
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.
|
// TODO: avoid these hash-maps.
|
||||||
// They are necessary to handle the swap-remove done internally
|
// They are necessary to handle the swap-remove done internally
|
||||||
@@ -196,11 +196,11 @@ impl NarrowPhase {
|
|||||||
i += 1;
|
i += 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
colliders.removed_colliders.ack(&mut cursor);
|
colliders.removed_colliders.ack(&cursor);
|
||||||
self.removed_colliders = Some(cursor);
|
self.removed_colliders = Some(cursor);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn remove_collider<'a>(
|
pub(crate) fn remove_collider(
|
||||||
&mut self,
|
&mut self,
|
||||||
intersection_graph_id: ColliderGraphIndex,
|
intersection_graph_id: ColliderGraphIndex,
|
||||||
contact_graph_id: ColliderGraphIndex,
|
contact_graph_id: ColliderGraphIndex,
|
||||||
|
|||||||
@@ -126,7 +126,7 @@ pub(crate) const INVALID_U64: u64 = u64::MAX;
|
|||||||
pub(crate) const INVALID_USIZE: usize = INVALID_U32 as usize;
|
pub(crate) const INVALID_USIZE: usize = INVALID_U32 as usize;
|
||||||
|
|
||||||
/// The string version of Rapier.
|
/// The string version of Rapier.
|
||||||
pub const VERSION: &'static str = env!("CARGO_PKG_VERSION");
|
pub const VERSION: &str = env!("CARGO_PKG_VERSION");
|
||||||
|
|
||||||
pub mod counters;
|
pub mod counters;
|
||||||
pub mod data;
|
pub mod data;
|
||||||
|
|||||||
@@ -162,7 +162,7 @@ impl PhysicsPipeline {
|
|||||||
self.counters.stages.solver_time.start();
|
self.counters.stages.solver_time.start();
|
||||||
if self.solvers.len() < bodies.num_islands() {
|
if self.solvers.len() < bodies.num_islands() {
|
||||||
self.solvers
|
self.solvers
|
||||||
.resize_with(bodies.num_islands(), || IslandSolver::new());
|
.resize_with(bodies.num_islands(), IslandSolver::new);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(not(feature = "parallel"))]
|
#[cfg(not(feature = "parallel"))]
|
||||||
|
|||||||
Reference in New Issue
Block a user