Skip to content

Commit

Permalink
chore: warning/clippy fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
sebcrozet committed Jun 23, 2024
1 parent e6b12f8 commit da87f60
Show file tree
Hide file tree
Showing 48 changed files with 103 additions and 105 deletions.
4 changes: 1 addition & 3 deletions crates/parry2d/examples/point_in_poly2d.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
use macroquad::prelude::*;
use nalgebra::{Point2, UnitComplex, Vector2};
use parry2d::shape::Ball;
use parry2d::transformation::polygons_intersection_points;
use parry2d::utils::point_in_poly2d;

const RENDER_SCALE: f32 = 30.0;
Expand All @@ -14,7 +12,7 @@ async fn main() {
let animation_rotation = UnitComplex::new(0.02);
let spikes_render_pos = Point2::new(screen_width() / 2.0, screen_height() / 2.0);

for i in 0.. {
loop {
clear_background(BLACK);

/*
Expand Down
14 changes: 8 additions & 6 deletions crates/parry2d/examples/polygons_intersection2d.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ async fn main() {
let mut animated_spikes = spikes.clone();

let star = star_polygon();
let mut animated_star = star.clone();

let animation_scale = 2.0;
let animation_rotation = UnitComplex::new(0.008);
Expand All @@ -23,7 +22,10 @@ async fn main() {
clear_background(BLACK);

/*
* Compute polygon intersections.
*
* Compute the rotated/scaled polygons, and compute their intersection with the original
* polygon.
*
*/
animated_spikes
.iter_mut()
Expand All @@ -38,10 +40,13 @@ async fn main() {
* ((i as f32 / 100.0).sin().abs() * animation_scale)
})
.collect();

let star_intersections = polygons_intersection_points(&star, &animated_star);

/*
*
* Render the polygons and their intersections.
*
*/
draw_polygon(&spikes, RENDER_SCALE, spikes_render_pos, BLUE);
draw_polygon(&animated_spikes, RENDER_SCALE, spikes_render_pos, GREEN);
Expand All @@ -60,9 +65,8 @@ async fn main() {
for intersection in intersections {
draw_polygon(&intersection, RENDER_SCALE, spikes_render_pos, RED);
}
} else {
eprintln!("Entered infinite loop.");
}

if let Ok(intersections) = star_intersections {
draw_text(
&format!("# star intersections: {}", intersections.len()),
Expand All @@ -74,8 +78,6 @@ async fn main() {
for intersection in intersections {
draw_polygon(&intersection, RENDER_SCALE, star_render_pos, RED);
}
} else {
eprintln!("Entered infinite loop.");
}

next_frame().await
Expand Down
2 changes: 1 addition & 1 deletion crates/parry3d/benches/query/ray.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use test::Bencher;
#[macro_use]
mod macros;

// FIXME: will the randomness of `solid` and `max_time_of_impact` affect too much the benchmark?
// TODO: will the randomness of `solid` and `max_time_of_impact` affect too much the benchmark?
bench_method!(
bench_ray_against_ball,
cast_ray,
Expand Down
4 changes: 2 additions & 2 deletions src/bounding_volume/aabb_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ where
let mut basis = na::zero::<Vector<Real>>();

for d in 0..DIM {
// FIXME: this could be further improved iterating on `m`'s columns, and passing
// TODO: this could be further improved iterating on `m`'s columns, and passing
// Id as the transformation matrix.
basis[d] = 1.0;
max[d] = i.support_point(m, &basis)[d];
Expand All @@ -40,7 +40,7 @@ where
let mut basis = na::zero::<Vector<Real>>();

for d in 0..DIM {
// FIXME: this could be further improved iterating on `m`'s columns, and passing
// TODO: this could be further improved iterating on `m`'s columns, and passing
// Id as the transformation matrix.
basis[d] = 1.0;
max[d] = i.local_support_point(&basis)[d];
Expand Down
2 changes: 1 addition & 1 deletion src/bounding_volume/bounding_sphere.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ impl BoundingVolume for BoundingSphere {

#[inline]
fn intersects(&self, other: &BoundingSphere) -> bool {
// FIXME: refactor that with the code from narrow_phase::ball_ball::collide(...) ?
// TODO: refactor that with the code from narrow_phase::ball_ball::collide(...) ?
let delta_pos = other.center - self.center;
let distance_squared = delta_pos.norm_squared();
let sum_radius = self.radius + other.radius;
Expand Down
4 changes: 2 additions & 2 deletions src/bounding_volume/bounding_sphere_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use crate::utils;
use na::{self, ComplexField};

/// Computes the bounding sphere of a set of point, given its center.
// FIXME: return a bounding sphere?
// TODO: return a bounding sphere?
#[inline]
pub fn point_cloud_bounding_sphere_with_center(
pts: &[Point<Real>],
Expand All @@ -23,7 +23,7 @@ pub fn point_cloud_bounding_sphere_with_center(
}

/// Computes a bounding sphere of the specified set of point.
// FIXME: return a bounding sphere?
// TODO: return a bounding sphere?
#[inline]
pub fn point_cloud_bounding_sphere(pts: &[Point<Real>]) -> (Point<Real>, Real) {
point_cloud_bounding_sphere_with_center(pts, utils::center(pts))
Expand Down
2 changes: 1 addition & 1 deletion src/bounding_volume/bounding_volume.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use crate::math::{Point, Real};
/// intersection, inclusion test. Two bounding volume must also be mergeable into a bigger bounding
/// volume.
pub trait BoundingVolume {
// FIXME: keep that ? What about non-spacial bounding volumes (e.g. bounding cones, curvature
// TODO: keep that ? What about non-spacial bounding volumes (e.g. bounding cones, curvature
// bounds, etc.) ?
/// Returns a point inside of this bounding volume. This is ideally its center.
fn center(&self) -> Point<Real>;
Expand Down
2 changes: 1 addition & 1 deletion src/partitioning/qbvh/traversal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ impl<LeafData: IndexedData> Qbvh<LeafData> {

/// Retrieve all the data of the nodes with Aabbs intersecting
/// the given Aabb:
// FIXME: implement a visitor pattern to merge intersect_aabb
// TODO: implement a visitor pattern to merge intersect_aabb
// and intersect_ray into a single method.
pub fn intersect_aabb(&self, aabb: &Aabb, out: &mut Vec<LeafData>) {
if self.nodes.is_empty() {
Expand Down
12 changes: 6 additions & 6 deletions src/query/closest_points/closest_points_composite_shape_shape.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,16 @@ use na;
use simba::simd::{SimdBool as _, SimdPartialOrd, SimdValue};

/// Closest points between a composite shape and any other shape.
pub fn closest_points_composite_shape_shape<D: ?Sized, G1: ?Sized>(
pub fn closest_points_composite_shape_shape<D, G1>(
dispatcher: &D,
pos12: &Isometry<Real>,
g1: &G1,
g2: &dyn Shape,
margin: Real,
) -> ClosestPoints
where
D: QueryDispatcher,
G1: TypedSimdCompositeShape,
D: ?Sized + QueryDispatcher,
G1: ?Sized + TypedSimdCompositeShape,
{
let mut visitor =
CompositeShapeAgainstShapeClosestPointsVisitor::new(dispatcher, pos12, g1, g2, margin);
Expand All @@ -30,16 +30,16 @@ where
}

/// Closest points between a shape and a composite shape.
pub fn closest_points_shape_composite_shape<D: ?Sized, G2: ?Sized>(
pub fn closest_points_shape_composite_shape<D, G2>(
dispatcher: &D,
pos12: &Isometry<Real>,
g1: &dyn Shape,
g2: &G2,
margin: Real,
) -> ClosestPoints
where
D: QueryDispatcher,
G2: TypedSimdCompositeShape,
D: ?Sized + QueryDispatcher,
G2: ?Sized + TypedSimdCompositeShape,
{
closest_points_composite_shape_shape(dispatcher, &pos12.inverse(), g2, g1, margin).flipped()
}
Expand Down
2 changes: 1 addition & 1 deletion src/query/closest_points/closest_points_line_line.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ pub fn closest_points_line_line_parameters_eps<const D: usize>(
}
}

// FIXME: can we re-used this for the segment/segment case?
// TODO: can we re-used this for the segment/segment case?
/// Closest points between two segments.
#[inline]
pub fn closest_points_line_line(
Expand Down
2 changes: 1 addition & 1 deletion src/query/closest_points/closest_points_segment_segment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ pub fn closest_points_segment_segment(
}
}

// FIXME: use this specialized procedure for distance/interference/contact determination as well.
// TODO: use this specialized procedure for distance/interference/contact determination as well.
/// Closest points between two segments.
#[inline]
pub fn closest_points_segment_segment_with_locations(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@ use crate::shape::SupportMap;
use na::Unit;

/// Closest points between support-mapped shapes (`Cuboid`, `ConvexHull`, etc.)
pub fn closest_points_support_map_support_map<G1: ?Sized, G2: ?Sized>(
pub fn closest_points_support_map_support_map<G1, G2>(
pos12: &Isometry<Real>,
g1: &G1,
g2: &G2,
prediction: Real,
) -> ClosestPoints
where
G1: SupportMap,
G2: SupportMap,
G1: ?Sized + SupportMap,
G2: ?Sized + SupportMap,
{
match closest_points_support_map_support_map_with_params(
pos12,
Expand All @@ -36,7 +36,7 @@ where
/// Closest points between support-mapped shapes (`Cuboid`, `ConvexHull`, etc.)
///
/// This allows a more fine grained control other the underlying GJK algorigtm.
pub fn closest_points_support_map_support_map_with_params<G1: ?Sized, G2: ?Sized>(
pub fn closest_points_support_map_support_map_with_params<G1, G2>(
pos12: &Isometry<Real>,
g1: &G1,
g2: &G2,
Expand All @@ -45,11 +45,11 @@ pub fn closest_points_support_map_support_map_with_params<G1: ?Sized, G2: ?Sized
init_dir: Option<Vector<Real>>,
) -> GJKResult
where
G1: SupportMap,
G2: SupportMap,
G1: ?Sized + SupportMap,
G2: ?Sized + SupportMap,
{
let dir = match init_dir {
// FIXME: or pos12.translation.vector (without the minus sign) ?
// TODO: or pos12.translation.vector (without the minus sign) ?
None => -pos12.translation.vector,
Some(dir) => dir,
};
Expand Down
6 changes: 3 additions & 3 deletions src/query/contact/contact_composite_shape_shape.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,16 @@ use crate::shape::{Shape, SimdCompositeShape};
use crate::utils::IsometryOpt;

/// Best contact between a composite shape (`Mesh`, `Compound`) and any other shape.
pub fn contact_composite_shape_shape<D: ?Sized, G1: ?Sized>(
pub fn contact_composite_shape_shape<D, G1>(
dispatcher: &D,
pos12: &Isometry<Real>,
g1: &G1,
g2: &dyn Shape,
prediction: Real,
) -> Option<Contact>
where
D: QueryDispatcher,
G1: SimdCompositeShape,
D: ?Sized + QueryDispatcher,
G1: ?Sized + SimdCompositeShape,
{
// Find new collisions
let ls_aabb2 = g2.compute_aabb(pos12).loosened(prediction);
Expand Down
6 changes: 3 additions & 3 deletions src/query/contact/contact_support_map_support_map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@ use crate::shape::SupportMap;
use na::Unit;

/// Contact between support-mapped shapes (`Cuboid`, `ConvexHull`, etc.)
pub fn contact_support_map_support_map<G1: ?Sized, G2: ?Sized>(
pub fn contact_support_map_support_map<G1, G2>(
pos12: &Isometry<Real>,
g1: &G1,
g2: &G2,
prediction: Real,
) -> Option<Contact>
where
G1: SupportMap,
G2: SupportMap,
G1: ?Sized + SupportMap,
G2: ?Sized + SupportMap,
{
let simplex = &mut VoronoiSimplex::new();
match contact_support_map_support_map_with_params(pos12, g1, g2, prediction, simplex, None) {
Expand Down
2 changes: 1 addition & 1 deletion src/query/contact_manifolds/contact_manifold.rs
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ impl<ManifoldData, ContactData: Default + Copy> ContactManifold<ManifoldData, Co
// const DOT_THRESHOLD: Real = 0.crate::COS_10_DEGREES;
// const DOT_THRESHOLD: Real = crate::utils::COS_5_DEGREES;
const DOT_THRESHOLD: Real = crate::utils::COS_1_DEGREES;
const DIST_SQ_THRESHOLD: Real = 1.0e-6; // FIXME: this should not be hard-coded.
const DIST_SQ_THRESHOLD: Real = 1.0e-6; // TODO: this should not be hard-coded.
self.try_update_contacts_eps(pos12, DOT_THRESHOLD, DIST_SQ_THRESHOLD)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ pub fn contact_manifold_capsule_capsule<'a, ManifoldData, ContactData>(
);

// We do this clone to perform contact tracking and transfer impulses.
// FIXME: find a more efficient way of doing this.
// TODO: find a more efficient way of doing this.
let old_manifold_points = manifold.points.clone();
manifold.clear();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ pub fn contact_manifold_cuboid_capsule<'a, ManifoldData, ContactData>(
}

// We do this clone to perform contact tracking and transfer impulses.
// FIXME: find a more efficient way of doing this.
// TODO: find a more efficient way of doing this.
let old_manifold_points = manifold.points.clone();
manifold.clear();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ pub fn contact_manifold_cuboid_cuboid<'a, ManifoldData, ContactData: Default + C
}

// We do this clone to perform contact tracking and transfer impulses.
// FIXME: find a more efficient way of doing this.
// TODO: find a more efficient way of doing this.
let old_manifold_points = manifold.points.clone();
manifold.clear();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ pub fn contact_manifold_cuboid_triangle<'a, ManifoldData, ContactData>(
}

// We do this clone to perform contact tracking and transfer impulses.
// FIXME: find a more efficient way of doing this.
// TODO: find a more efficient way of doing this.
let old_manifold_points = manifold.points.clone();
manifold.clear();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ pub fn contact_manifold_halfspace_pfm<'a, ManifoldData, ContactData, S2>(
pfm2.local_support_feature(&-normal1_2, &mut feature2);

// We do this clone to perform contact tracking and transfer impulses.
// FIXME: find a more efficient way of doing this.
// TODO: find a more efficient way of doing this.
let old_manifold_points = std::mem::take(&mut manifold.points);

for i in 0..feature2.num_vertices {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ pub fn contact_manifolds_trimesh_shape<ManifoldData, ContactData>(
new_local_aabb2.mins -= extra_margin;
new_local_aabb2.maxs += extra_margin;

let local_aabb2 = new_local_aabb2; // .loosened(prediction * 2.0); // FIXME: what would be the best value?
let local_aabb2 = new_local_aabb2; // .loosened(prediction * 2.0); // TODO: what would be the best value?
std::mem::swap(
&mut workspace.old_interferences,
&mut workspace.interferences,
Expand Down
4 changes: 2 additions & 2 deletions src/query/distance/distance_support_map_support_map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ where
G1: SupportMap,
G2: SupportMap,
{
// FIXME: or m2.translation - m1.translation ?
// TODO: or m2.translation - m1.translation ?
let dir = init_dir.unwrap_or_else(|| -pos12.translation.vector);

if let Some(dir) = Unit::try_new(dir, crate::math::DEFAULT_EPSILON) {
Expand All @@ -50,6 +50,6 @@ where
GJKResult::Intersection => 0.0,
GJKResult::ClosestPoints(p1, p2, _) => na::distance(&p1, &p2),
GJKResult::Proximity(_) => unreachable!(),
GJKResult::NoIntersection(_) => 0.0, // FIXME: GJK did not converge.
GJKResult::NoIntersection(_) => 0.0, // TODO: GJK did not converge.
}
}
2 changes: 1 addition & 1 deletion src/query/epa/epa2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ impl EPA {
if f.1 {
let dist = f.0.normal.dot(&f.0.proj.coords);
if dist < curr_dist {
// FIXME: if we reach this point, there were issues due to
// TODO: if we reach this point, there were issues due to
// numerical errors.
let cpts = f.0.closest_points(&self.vertices);
return Some((cpts.0, cpts.1, f.0.normal));
Expand Down
6 changes: 3 additions & 3 deletions src/query/epa/epa3.rs
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,7 @@ impl EPA {
let first_new_face_id = self.faces.len();

if self.silhouette.is_empty() {
// FIXME: Something went very wrong because we failed to extract a silhouette…
// TODO: Something went very wrong because we failed to extract a silhouette…
return None;
}

Expand All @@ -364,7 +364,7 @@ impl EPA {
let new_face_id = self.faces.len();
let new_face;

// FIXME: NLL
// TODO: NLL
{
let face_adj = &mut self.faces[edge.face_id];
let pt_id1 = face_adj.pts[(edge.opp_pt_id + 2) % 3];
Expand All @@ -383,7 +383,7 @@ impl EPA {
let pt = self.vertices[self.faces[new_face_id].pts[0]].point.coords;
let dist = self.faces[new_face_id].normal.dot(&pt);
if dist < curr_dist {
// FIXME: if we reach this point, there were issues due to
// TODO: if we reach this point, there were issues due to
// numerical errors.
let points = face.closest_points(&self.vertices);
return Some((points.0, points.1, face.normal));
Expand Down
Loading

0 comments on commit da87f60

Please sign in to comment.