Skip to content

Commit

Permalink
clippy ci (#267)
Browse files Browse the repository at this point in the history
  • Loading branch information
Vrixyz authored Sep 16, 2024
1 parent 81229a5 commit 1cdd453
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 12 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/parry-ci-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ jobs:
run: cargo fmt -- --check
clippy:
runs-on: ubuntu-latest
env:
RUSTFLAGS: -D warnings
steps:
- uses: actions/checkout@v4
- name: Clippy
Expand Down
1 change: 1 addition & 0 deletions src/mass_properties/mass_properties.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ use {na::Matrix3, std::ops::MulAssign};
#[cfg(feature = "rkyv")]
use rkyv::{bytecheck, CheckBytes};

#[cfg_attr(feature = "f32", expect(clippy::unnecessary_cast))]
const EPSILON: Real = f32::EPSILON as Real;

#[derive(Copy, Clone, Debug, Default, PartialEq)]
Expand Down
2 changes: 2 additions & 0 deletions src/query/sat/sat_cuboid_cuboid.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ pub fn cuboid_cuboid_compute_separation_wrt_local_line(
pos12: &Isometry<Real>,
axis1: &Vector<Real>,
) -> (Real, Vector<Real>) {
#[expect(clippy::unnecessary_cast)]
let signum = (1.0 as Real).copysign(pos12.translation.vector.dot(axis1));
let axis1 = axis1 * signum;
let axis2 = pos12.inverse_transform_vector(&-axis1);
Expand Down Expand Up @@ -87,6 +88,7 @@ pub fn cuboid_cuboid_find_local_separating_normal_oneway(
let mut best_dir = Vector::zeros();

for i in 0..DIM {
#[expect(clippy::unnecessary_cast)]
let sign = (1.0 as Real).copysign(pos12.translation.vector[i]);
let axis1 = Vector::ith(i, sign);
let axis2 = pos12.inverse_transform_vector(&-axis1);
Expand Down
1 change: 1 addition & 0 deletions src/shape/cuboid.rs
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ impl Cuboid {
// to make this AoSoA friendly?
let he = self.half_extents;
let iamax = local_dir.iamax();
#[expect(clippy::unnecessary_cast)]
let sign = (1.0 as Real).copysign(local_dir[iamax]);

let vertices = match iamax {
Expand Down
7 changes: 5 additions & 2 deletions src/shape/shape.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1455,7 +1455,7 @@ impl Shape for HalfSpace {

#[cfg(feature = "std")]
fn scale_dyn(&self, scale: &Vector<Real>, _num_subdivisions: u32) -> Option<Box<dyn Shape>> {
Some(Box::new(self.clone().scaled(scale)?))
Some(Box::new(self.scaled(scale)?))
}

fn compute_local_aabb(&self) -> Aabb {
Expand All @@ -1475,7 +1475,10 @@ impl Shape for HalfSpace {
}

fn ccd_thickness(&self) -> Real {
f32::MAX as Real
#[cfg_attr(feature = "f32", expect(clippy::unnecessary_cast))]
let result = f32::MAX as Real;
#[cfg_attr(feature = "f64", expect(clippy::let_and_return))]
result
}

fn ccd_angular_thickness(&self) -> Real {
Expand Down
15 changes: 8 additions & 7 deletions src/transformation/mesh_intersection/mesh_intersection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ pub struct MeshIntersectionTolerances {
impl Default for MeshIntersectionTolerances {
fn default() -> Self {
Self {
#[expect(clippy::unnecessary_cast)]
angle_epsilon: (0.005 as Real).to_radians(), // 0.005 degrees
global_insertion_epsilon: Real::EPSILON * 100.0,
local_insertion_epsilon_scale: 10.,
Expand Down Expand Up @@ -179,8 +180,8 @@ pub fn intersect_meshes_with_tolerances(
let mut constraints1 = BTreeMap::<_, Vec<_>>::new();
let mut constraints2 = BTreeMap::<_, Vec<_>>::new();
for (fid1, fid2) in &intersections {
let tri1 = mesh1.triangle(*fid1).transformed(&pos1);
let tri2 = mesh2.triangle(*fid2).transformed(&pos2);
let tri1 = mesh1.triangle(*fid1).transformed(pos1);
let tri2 = mesh2.triangle(*fid2).transformed(pos2);

let list1 = constraints1.entry(fid1).or_default();
let list2 = constraints2.entry(fid2).or_default();
Expand Down Expand Up @@ -216,8 +217,8 @@ pub fn intersect_meshes_with_tolerances(
mesh1,
mesh2,
&constraints1,
&pos1,
&pos2,
pos1,
pos2,
flip1,
flip2,
&meta_data,
Expand All @@ -229,8 +230,8 @@ pub fn intersect_meshes_with_tolerances(
mesh2,
mesh1,
&constraints2,
&pos2,
&pos1,
pos2,
pos1,
flip2,
flip1,
&meta_data,
Expand Down Expand Up @@ -601,7 +602,7 @@ fn merge_triangle_sets(
// For each sub-triangle that is part of the intersection, add them to the
// output mesh.
for (triangle_id, constraints) in triangle_constraints.iter() {
let tri = mesh1.triangle(**triangle_id).transformed(&pos1);
let tri = mesh1.triangle(**triangle_id).transformed(pos1);

let (delaunay, points) = triangulate_constraints_and_merge_duplicates(
&tri,
Expand Down
6 changes: 3 additions & 3 deletions src/transformation/polygon_intersection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,11 @@ impl PolylinePointLocation {
}

/// Computes the point corresponding to this location.
pub fn to_point(&self, pts: &[Point2<Real>]) -> Point2<Real> {
pub fn to_point(self, pts: &[Point2<Real>]) -> Point2<Real> {
match self {
PolylinePointLocation::OnVertex(i) => pts[*i],
PolylinePointLocation::OnVertex(i) => pts[i],
PolylinePointLocation::OnEdge(i1, i2, bcoords) => {
pts[*i1] * bcoords[0] + pts[*i2].coords * bcoords[1]
pts[i1] * bcoords[0] + pts[i2].coords * bcoords[1]
}
}
}
Expand Down

0 comments on commit 1cdd453

Please sign in to comment.