Fix clippy and enable clippy on CI

This commit is contained in:
Sébastien Crozet
2024-01-27 16:49:53 +01:00
committed by Sébastien Crozet
parent aef873f20e
commit da92e5c283
81 changed files with 420 additions and 468 deletions

View File

@@ -149,7 +149,7 @@ impl CollisionPipeline {
bodies,
colliders,
&modified_colliders[..],
&mut removed_colliders,
&removed_colliders,
hooks,
events,
true,

View File

@@ -79,12 +79,10 @@ pub trait DebugRenderBackend {
self.draw_line(object, a, b, color);
}
if closed {
if vertices.len() > 2 {
let a = transform * (Scale::from(*scale) * vertices[0]);
let b = transform * (Scale::from(*scale) * vertices.last().unwrap());
self.draw_line(object, a, b, color);
}
if closed && vertices.len() > 2 {
let a = transform * (Scale::from(*scale) * vertices[0]);
let b = transform * (Scale::from(*scale) * vertices.last().unwrap());
self.draw_line(object, a, b, color);
}
}
}

View File

@@ -41,12 +41,17 @@ impl Default for DebugRenderMode {
}
}
#[cfg(feature = "dim2")]
type InstancesMap = HashMap<TypeId, Vec<Point<Real>>>;
#[cfg(feature = "dim3")]
type InstancesMap = HashMap<TypeId, (Vec<Point<Real>>, Vec<[u32; 2]>)>;
/// Pipeline responsible for rendering the state of the physics engine for debugging purpose.
pub struct DebugRenderPipeline {
#[cfg(feature = "dim2")]
instances: HashMap<TypeId, Vec<Point<Real>>>,
instances: InstancesMap,
#[cfg(feature = "dim3")]
instances: HashMap<TypeId, (Vec<Point<Real>>, Vec<[u32; 2]>)>,
instances: InstancesMap,
/// The style used to compute the line colors for each element
/// to render.
pub style: DebugRenderStyle,

View File

@@ -5,4 +5,4 @@ pub use self::debug_render_style::{DebugColor, DebugRenderStyle};
mod debug_render_backend;
mod debug_render_pipeline;
mod debug_render_style;
pub(self) mod outlines;
mod outlines;

View File

@@ -17,6 +17,7 @@ pub fn instances(nsubdivs: u32) -> HashMap<TypeId, Vec<Point<Real>>> {
}
#[cfg(feature = "dim3")]
#[allow(clippy::type_complexity)]
pub fn instances(nsubdivs: u32) -> HashMap<TypeId, (Vec<Point<Real>>, Vec<[u32; 2]>)> {
let mut result = HashMap::new();
result.insert(

View File

@@ -69,7 +69,7 @@ impl<'a> ContactModificationContext<'a> {
// Test the allowed normal with the local-space contact normal that
// points towards the exterior of context.collider1.
let contact_is_ok = self.manifold.local_n1.dot(&allowed_local_n1) >= cang;
let contact_is_ok = self.manifold.local_n1.dot(allowed_local_n1) >= cang;
match *self.user_data {
CONTACT_CONFIGURATION_UNKNOWN => {

View File

@@ -212,7 +212,7 @@ impl PhysicsPipeline {
rb.mprops.update_world_mass_properties(&rb.pos.position);
let effective_mass = rb.mprops.effective_mass();
rb.forces
.compute_effective_force_and_torque(&gravity, &effective_mass);
.compute_effective_force_and_torque(gravity, &effective_mass);
}
self.counters.stages.update_time.pause();
@@ -270,14 +270,13 @@ impl PhysicsPipeline {
.enumerate()
.for_each(|(island_id, solver)| {
let bodies: &mut RigidBodySet =
unsafe { std::mem::transmute(bodies.load(Ordering::Relaxed)) };
unsafe { &mut *bodies.load(Ordering::Relaxed) };
let manifolds: &mut Vec<&mut ContactManifold> =
unsafe { std::mem::transmute(manifolds.load(Ordering::Relaxed)) };
unsafe { &mut *manifolds.load(Ordering::Relaxed) };
let impulse_joints: &mut Vec<JointGraphEdge> =
unsafe { std::mem::transmute(impulse_joints.load(Ordering::Relaxed)) };
let multibody_joints: &mut MultibodyJointSet = unsafe {
std::mem::transmute(multibody_joints.load(Ordering::Relaxed))
};
unsafe { &mut *impulse_joints.load(Ordering::Relaxed) };
let multibody_joints: &mut MultibodyJointSet =
unsafe { &mut *multibody_joints.load(Ordering::Relaxed) };
let mut counters = Counters::new(false);
solver.init_and_solve(

View File

@@ -114,6 +114,7 @@ pub struct QueryFilter<'a> {
/// If set, any collider attached to this rigid-body will be excluded from the scene query.
pub exclude_rigid_body: Option<RigidBodyHandle>,
/// If set, any collider for which this closure returns false will be excluded from the scene query.
#[allow(clippy::type_complexity)] // Type doesnt look really complex?
pub predicate: Option<&'a dyn Fn(ColliderHandle, &Collider) -> bool>,
}
@@ -668,10 +669,10 @@ impl QueryPipeline {
/// the shape is penetrating another shape at its starting point **and** its trajectory is such
/// that its on a path to exist that penetration state.
/// * `filter`: set of rules used to determine which collider is taken into account by this scene query.
pub fn cast_shape<'a>(
pub fn cast_shape(
&self,
bodies: &RigidBodySet,
colliders: &'a ColliderSet,
colliders: &ColliderSet,
shape_pos: &Isometry<Real>,
shape_vel: &Vector<Real>,
shape: &dyn Shape,
@@ -746,10 +747,10 @@ impl QueryPipeline {
/// * `shape` - The shape to test.
/// * `filter`: set of rules used to determine which collider is taken into account by this scene query.
/// * `callback` - A function called with the handles of each collider intersecting the `shape`.
pub fn intersections_with_shape<'a>(
pub fn intersections_with_shape(
&self,
bodies: &RigidBodySet,
colliders: &'a ColliderSet,
colliders: &ColliderSet,
shape_pos: &Isometry<Real>,
shape: &dyn Shape,
filter: QueryFilter,

View File

@@ -111,15 +111,13 @@ pub(crate) fn handle_user_changes_to_rigid_bodies(
}
// Update the active kinematic set.
if changes.contains(RigidBodyChanges::POSITION)
|| changes.contains(RigidBodyChanges::COLLIDERS)
if (changes.contains(RigidBodyChanges::POSITION)
|| changes.contains(RigidBodyChanges::COLLIDERS))
&& rb.is_kinematic()
&& islands.active_kinematic_set.get(ids.active_set_id) != Some(handle)
{
if rb.is_kinematic()
&& islands.active_kinematic_set.get(ids.active_set_id) != Some(handle)
{
ids.active_set_id = islands.active_kinematic_set.len();
islands.active_kinematic_set.push(*handle);
}
ids.active_set_id = islands.active_kinematic_set.len();
islands.active_kinematic_set.push(*handle);
}
// Push the body to the active set if it is not