From da87f6043543346c0b37b06444ca11c762c8a924 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Crozet?= Date: Sun, 23 Jun 2024 16:38:50 +0200 Subject: [PATCH] chore: warning/clippy fixes --- crates/parry2d/examples/point_in_poly2d.rs | 4 +--- .../examples/polygons_intersection2d.rs | 14 +++++++----- crates/parry3d/benches/query/ray.rs | 2 +- src/bounding_volume/aabb_utils.rs | 4 ++-- src/bounding_volume/bounding_sphere.rs | 2 +- src/bounding_volume/bounding_sphere_utils.rs | 4 ++-- src/bounding_volume/bounding_volume.rs | 2 +- src/partitioning/qbvh/traversal.rs | 2 +- .../closest_points_composite_shape_shape.rs | 12 +++++----- .../closest_points_line_line.rs | 2 +- .../closest_points_segment_segment.rs | 2 +- .../closest_points_support_map_support_map.rs | 14 ++++++------ .../contact/contact_composite_shape_shape.rs | 6 ++--- .../contact_support_map_support_map.rs | 6 ++--- .../contact_manifolds/contact_manifold.rs | 2 +- .../contact_manifolds_capsule_capsule.rs | 2 +- .../contact_manifolds_cuboid_capsule.rs | 2 +- .../contact_manifolds_cuboid_cuboid.rs | 2 +- .../contact_manifolds_cuboid_triangle.rs | 2 +- .../contact_manifolds_halfspace_pfm.rs | 2 +- .../contact_manifolds_trimesh_shape.rs | 2 +- .../distance_support_map_support_map.rs | 4 ++-- src/query/epa/epa2.rs | 2 +- src/query/epa/epa3.rs | 6 ++--- src/query/gjk/gjk.rs | 6 ++--- src/query/gjk/voronoi_simplex2.rs | 4 ++-- src/query/gjk/voronoi_simplex3.rs | 6 ++--- ...near_shape_cast_support_map_support_map.rs | 4 ++-- src/query/point/point_aabb.rs | 2 +- src/query/point/point_composite_shape.rs | 4 ++-- src/query/point/point_heightfield.rs | 4 ++-- src/query/point/point_round_shape.rs | 4 ++-- src/query/point/point_segment.rs | 2 +- src/query/ray/ray_support_map.rs | 2 +- src/query/split/split_trimesh.rs | 4 ++-- .../visitors/point_intersections_visitor.rs | 2 +- src/shape/convex_polygon.rs | 2 +- src/shape/convex_polyhedron.rs | 2 +- src/shape/cuboid.rs | 6 ++--- src/shape/heightfield2.rs | 4 ++-- src/shape/heightfield3.rs | 2 +- .../convex_hull3/convex_hull.rs | 12 +++++----- .../convex_hull3/initial_mesh.rs | 2 +- src/transformation/polygon_intersection.rs | 22 +++++++++---------- src/transformation/utils.rs | 2 +- src/utils/as_bytes.rs | 2 +- src/utils/point_in_poly2d.rs | 4 ++-- src/utils/segments_intersection.rs | 2 +- 48 files changed, 103 insertions(+), 105 deletions(-) diff --git a/crates/parry2d/examples/point_in_poly2d.rs b/crates/parry2d/examples/point_in_poly2d.rs index 8524725d..6933c21e 100644 --- a/crates/parry2d/examples/point_in_poly2d.rs +++ b/crates/parry2d/examples/point_in_poly2d.rs @@ -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; @@ -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); /* diff --git a/crates/parry2d/examples/polygons_intersection2d.rs b/crates/parry2d/examples/polygons_intersection2d.rs index 92ec108e..51d03079 100644 --- a/crates/parry2d/examples/polygons_intersection2d.rs +++ b/crates/parry2d/examples/polygons_intersection2d.rs @@ -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); @@ -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() @@ -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); @@ -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()), @@ -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 diff --git a/crates/parry3d/benches/query/ray.rs b/crates/parry3d/benches/query/ray.rs index c1e9976a..beba03de 100644 --- a/crates/parry3d/benches/query/ray.rs +++ b/crates/parry3d/benches/query/ray.rs @@ -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, diff --git a/src/bounding_volume/aabb_utils.rs b/src/bounding_volume/aabb_utils.rs index c990869e..79ac72d5 100644 --- a/src/bounding_volume/aabb_utils.rs +++ b/src/bounding_volume/aabb_utils.rs @@ -16,7 +16,7 @@ where let mut basis = na::zero::>(); 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]; @@ -40,7 +40,7 @@ where let mut basis = na::zero::>(); 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]; diff --git a/src/bounding_volume/bounding_sphere.rs b/src/bounding_volume/bounding_sphere.rs index 75d707da..fc1e4a44 100644 --- a/src/bounding_volume/bounding_sphere.rs +++ b/src/bounding_volume/bounding_sphere.rs @@ -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; diff --git a/src/bounding_volume/bounding_sphere_utils.rs b/src/bounding_volume/bounding_sphere_utils.rs index bdc8c151..238f15c3 100644 --- a/src/bounding_volume/bounding_sphere_utils.rs +++ b/src/bounding_volume/bounding_sphere_utils.rs @@ -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], @@ -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]) -> (Point, Real) { point_cloud_bounding_sphere_with_center(pts, utils::center(pts)) diff --git a/src/bounding_volume/bounding_volume.rs b/src/bounding_volume/bounding_volume.rs index 09807bba..a9cd8b4b 100644 --- a/src/bounding_volume/bounding_volume.rs +++ b/src/bounding_volume/bounding_volume.rs @@ -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; diff --git a/src/partitioning/qbvh/traversal.rs b/src/partitioning/qbvh/traversal.rs index 8c9e77de..c64f0554 100644 --- a/src/partitioning/qbvh/traversal.rs +++ b/src/partitioning/qbvh/traversal.rs @@ -271,7 +271,7 @@ impl Qbvh { /// 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) { if self.nodes.is_empty() { diff --git a/src/query/closest_points/closest_points_composite_shape_shape.rs b/src/query/closest_points/closest_points_composite_shape_shape.rs index 85220a94..915a9e29 100644 --- a/src/query/closest_points/closest_points_composite_shape_shape.rs +++ b/src/query/closest_points/closest_points_composite_shape_shape.rs @@ -8,7 +8,7 @@ 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( +pub fn closest_points_composite_shape_shape( dispatcher: &D, pos12: &Isometry, g1: &G1, @@ -16,8 +16,8 @@ pub fn closest_points_composite_shape_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); @@ -30,7 +30,7 @@ where } /// Closest points between a shape and a composite shape. -pub fn closest_points_shape_composite_shape( +pub fn closest_points_shape_composite_shape( dispatcher: &D, pos12: &Isometry, g1: &dyn Shape, @@ -38,8 +38,8 @@ pub fn closest_points_shape_composite_shape( 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() } diff --git a/src/query/closest_points/closest_points_line_line.rs b/src/query/closest_points/closest_points_line_line.rs index 67aa4662..6e895752 100644 --- a/src/query/closest_points/closest_points_line_line.rs +++ b/src/query/closest_points/closest_points_line_line.rs @@ -71,7 +71,7 @@ pub fn closest_points_line_line_parameters_eps( } } -// 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( diff --git a/src/query/closest_points/closest_points_segment_segment.rs b/src/query/closest_points/closest_points_segment_segment.rs index 259f8ec0..18168f75 100644 --- a/src/query/closest_points/closest_points_segment_segment.rs +++ b/src/query/closest_points/closest_points_segment_segment.rs @@ -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( diff --git a/src/query/closest_points/closest_points_support_map_support_map.rs b/src/query/closest_points/closest_points_support_map_support_map.rs index 17a5bd92..5930b03a 100644 --- a/src/query/closest_points/closest_points_support_map_support_map.rs +++ b/src/query/closest_points/closest_points_support_map_support_map.rs @@ -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( +pub fn closest_points_support_map_support_map( pos12: &Isometry, 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, @@ -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( +pub fn closest_points_support_map_support_map_with_params( pos12: &Isometry, g1: &G1, g2: &G2, @@ -45,11 +45,11 @@ pub fn closest_points_support_map_support_map_with_params>, ) -> 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, }; diff --git a/src/query/contact/contact_composite_shape_shape.rs b/src/query/contact/contact_composite_shape_shape.rs index 0656361d..ec7fbfee 100644 --- a/src/query/contact/contact_composite_shape_shape.rs +++ b/src/query/contact/contact_composite_shape_shape.rs @@ -6,7 +6,7 @@ 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( +pub fn contact_composite_shape_shape( dispatcher: &D, pos12: &Isometry, g1: &G1, @@ -14,8 +14,8 @@ pub fn contact_composite_shape_shape( prediction: Real, ) -> Option where - D: QueryDispatcher, - G1: SimdCompositeShape, + D: ?Sized + QueryDispatcher, + G1: ?Sized + SimdCompositeShape, { // Find new collisions let ls_aabb2 = g2.compute_aabb(pos12).loosened(prediction); diff --git a/src/query/contact/contact_support_map_support_map.rs b/src/query/contact/contact_support_map_support_map.rs index aa06a138..6107a8e9 100644 --- a/src/query/contact/contact_support_map_support_map.rs +++ b/src/query/contact/contact_support_map_support_map.rs @@ -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( +pub fn contact_support_map_support_map( pos12: &Isometry, g1: &G1, g2: &G2, prediction: Real, ) -> Option 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) { diff --git a/src/query/contact_manifolds/contact_manifold.rs b/src/query/contact_manifolds/contact_manifold.rs index e54f0ef6..ec0392a6 100644 --- a/src/query/contact_manifolds/contact_manifold.rs +++ b/src/query/contact_manifolds/contact_manifold.rs @@ -182,7 +182,7 @@ impl ContactManifold( ); // 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(); diff --git a/src/query/contact_manifolds/contact_manifolds_cuboid_capsule.rs b/src/query/contact_manifolds/contact_manifolds_cuboid_capsule.rs index a07d6a9c..0e814a79 100644 --- a/src/query/contact_manifolds/contact_manifolds_cuboid_capsule.rs +++ b/src/query/contact_manifolds/contact_manifolds_cuboid_capsule.rs @@ -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(); diff --git a/src/query/contact_manifolds/contact_manifolds_cuboid_cuboid.rs b/src/query/contact_manifolds/contact_manifolds_cuboid_cuboid.rs index 16be647d..bd8301ff 100644 --- a/src/query/contact_manifolds/contact_manifolds_cuboid_cuboid.rs +++ b/src/query/contact_manifolds/contact_manifolds_cuboid_cuboid.rs @@ -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(); diff --git a/src/query/contact_manifolds/contact_manifolds_cuboid_triangle.rs b/src/query/contact_manifolds/contact_manifolds_cuboid_triangle.rs index 3954d950..eb2baa30 100644 --- a/src/query/contact_manifolds/contact_manifolds_cuboid_triangle.rs +++ b/src/query/contact_manifolds/contact_manifolds_cuboid_triangle.rs @@ -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(); diff --git a/src/query/contact_manifolds/contact_manifolds_halfspace_pfm.rs b/src/query/contact_manifolds/contact_manifolds_halfspace_pfm.rs index f055e8f3..5d1651a6 100644 --- a/src/query/contact_manifolds/contact_manifolds_halfspace_pfm.rs +++ b/src/query/contact_manifolds/contact_manifolds_halfspace_pfm.rs @@ -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 { diff --git a/src/query/contact_manifolds/contact_manifolds_trimesh_shape.rs b/src/query/contact_manifolds/contact_manifolds_trimesh_shape.rs index 763eb61b..4531bf56 100644 --- a/src/query/contact_manifolds/contact_manifolds_trimesh_shape.rs +++ b/src/query/contact_manifolds/contact_manifolds_trimesh_shape.rs @@ -115,7 +115,7 @@ pub fn contact_manifolds_trimesh_shape( 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, diff --git a/src/query/distance/distance_support_map_support_map.rs b/src/query/distance/distance_support_map_support_map.rs index 8c35aa13..5292d465 100644 --- a/src/query/distance/distance_support_map_support_map.rs +++ b/src/query/distance/distance_support_map_support_map.rs @@ -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) { @@ -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. } } diff --git a/src/query/epa/epa2.rs b/src/query/epa/epa2.rs index eb79d3a4..2905f858 100644 --- a/src/query/epa/epa2.rs +++ b/src/query/epa/epa2.rs @@ -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)); diff --git a/src/query/epa/epa3.rs b/src/query/epa/epa3.rs index ac6d3718..e92c390f 100644 --- a/src/query/epa/epa3.rs +++ b/src/query/epa/epa3.rs @@ -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; } @@ -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]; @@ -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)); diff --git a/src/query/gjk/gjk.rs b/src/query/gjk/gjk.rs index 7bbc0573..2b0dde6c 100644 --- a/src/query/gjk/gjk.rs +++ b/src/query/gjk/gjk.rs @@ -99,7 +99,7 @@ where let _eps_tol: Real = eps_tol(); let _eps_rel: Real = ComplexField::sqrt(_eps_tol); - // FIXME: reset the simplex if it is empty? + // TODO: reset the simplex if it is empty? let mut proj = simplex.project_origin_and_reduce(); let mut old_dir; @@ -268,7 +268,7 @@ where let support_point = CSOPoint::from_shapes(pos12, g1, g2, &dir); simplex.reset(support_point.translate(&-curr_ray.origin.coords)); - // FIXME: reset the simplex if it is empty? + // TODO: reset the simplex if it is empty? let mut proj = simplex.project_origin_and_reduce(); let mut max_bound = Real::max_value(); let mut dir; @@ -346,7 +346,7 @@ where if max_bound - min_bound <= _eps_rel * max_bound { // This is needed when using fixed-points to avoid missing // some castes. - // FIXME: I feel like we should always return `Some` in + // TODO: I feel like we should always return `Some` in // this case, even with floating-point numbers. Though it // has not been sufficinetly tested with floats yet to be sure. if cfg!(feature = "improved_fixed_point_support") { diff --git a/src/query/gjk/voronoi_simplex2.rs b/src/query/gjk/voronoi_simplex2.rs index a7c59115..7853d4f7 100644 --- a/src/query/gjk/voronoi_simplex2.rs +++ b/src/query/gjk/voronoi_simplex2.rs @@ -98,7 +98,7 @@ impl VoronoiSimplex { self.proj[0] = 1.0; self.vertices[0].point } else if self.dim == 1 { - // FIXME: NLL + // TODO: NLL let (proj, location) = { let seg = Segment::new(self.vertices[0].point, self.vertices[1].point); seg.project_local_point_and_get_location(&Point::::origin(), true) @@ -123,7 +123,7 @@ impl VoronoiSimplex { proj.point } else { assert!(self.dim == 2); - // FIXME: NLL + // TODO: NLL let (proj, location) = { let tri = Triangle::new( self.vertices[0].point, diff --git a/src/query/gjk/voronoi_simplex3.rs b/src/query/gjk/voronoi_simplex3.rs index f510f021..4ee02329 100644 --- a/src/query/gjk/voronoi_simplex3.rs +++ b/src/query/gjk/voronoi_simplex3.rs @@ -125,7 +125,7 @@ impl VoronoiSimplex { self.proj[0] = 1.0; self.vertices[0].point } else if self.dim == 1 { - // FIXME: NLL + // TODO: NLL let (proj, location) = { let seg = Segment::new(self.vertices[0].point, self.vertices[1].point); seg.project_local_point_and_get_location(&Point::::origin(), true) @@ -150,7 +150,7 @@ impl VoronoiSimplex { proj.point } else if self.dim == 2 { - // FIXME: NLL + // TODO: NLL let (proj, location) = { let tri = Triangle::new( self.vertices[0].point, @@ -192,7 +192,7 @@ impl VoronoiSimplex { proj.point } else { assert!(self.dim == 3); - // FIXME: NLL + // TODO: NLL let (proj, location) = { let tetr = Tetrahedron::new( self.vertices[0].point, diff --git a/src/query/nonlinear_shape_cast/nonlinear_shape_cast_support_map_support_map.rs b/src/query/nonlinear_shape_cast/nonlinear_shape_cast_support_map_support_map.rs index bb04772f..3b4870a9 100644 --- a/src/query/nonlinear_shape_cast/nonlinear_shape_cast_support_map_support_map.rs +++ b/src/query/nonlinear_shape_cast/nonlinear_shape_cast_support_map_support_map.rs @@ -148,7 +148,7 @@ where if let Some((normal1, dist)) = Unit::try_new_and_get(pos12 * p2 - p1, crate::math::DEFAULT_EPSILON) { - // FIXME: do the "inverse transform unit vector" only when we are about to return. + // TODO: do the "inverse transform unit vector" only when we are about to return. result.normal1 = normal1; result.normal2 = pos12.inverse_transform_unit_vector(&-normal1); @@ -203,7 +203,7 @@ where ClosestPoints::Disjoint => { // TODO: this case should be unreachable and needs some debugging // see: https://github.com/dimforge/parry/issues/176 - log::error!( + log::debug!( "Closest points not found despite setting the max distance to infinity." ); result.status = ShapeCastStatus::Failed; diff --git a/src/query/point/point_aabb.rs b/src/query/point/point_aabb.rs index 03c6926e..52a3ede3 100644 --- a/src/query/point/point_aabb.rs +++ b/src/query/point/point_aabb.rs @@ -140,7 +140,7 @@ impl PointQuery for Aabb { if solid || !shift.is_zero() { shift.norm() } else { - // FIXME: optimize that. + // TODO: optimize that. -na::distance(pt, &self.project_local_point(pt, solid).point) } } diff --git a/src/query/point/point_composite_shape.rs b/src/query/point/point_composite_shape.rs index 8ddcf5b2..979f942c 100644 --- a/src/query/point/point_composite_shape.rs +++ b/src/query/point/point_composite_shape.rs @@ -32,7 +32,7 @@ impl PointQuery for Polyline { (proj, polyline_feature) } - // FIXME: implement distance_to_point too? + // TODO: implement distance_to_point too? #[inline] fn contains_local_point(&self, point: &Point) -> bool { @@ -70,7 +70,7 @@ impl PointQuery for TriMesh { (proj, feature_id) } - // FIXME: implement distance_to_point too? + // TODO: implement distance_to_point too? #[inline] fn contains_local_point(&self, point: &Point) -> bool { diff --git a/src/query/point/point_heightfield.rs b/src/query/point/point_heightfield.rs index 25507d24..ec0abccd 100644 --- a/src/query/point/point_heightfield.rs +++ b/src/query/point/point_heightfield.rs @@ -59,11 +59,11 @@ impl PointQuery for HeightField { &self, point: &Point, ) -> (PointProjection, FeatureId) { - // FIXME: compute the feature properly. + // TODO: compute the feature properly. (self.project_local_point(point, false), FeatureId::Unknown) } - // FIXME: implement distance_to_point too? + // TODO: implement distance_to_point too? #[inline] fn contains_local_point(&self, _point: &Point) -> bool { diff --git a/src/query/point/point_round_shape.rs b/src/query/point/point_round_shape.rs index 3d0be151..64eabfce 100644 --- a/src/query/point/point_round_shape.rs +++ b/src/query/point/point_round_shape.rs @@ -8,12 +8,12 @@ use crate::shape::{FeatureId, RoundShape, SupportMap}; impl PointQuery for RoundShape { #[inline] fn project_local_point(&self, point: &Point, solid: bool) -> PointProjection { - #[cfg(not(feature = "std"))] // FIXME: can’t be used without std because of EPA + #[cfg(not(feature = "std"))] // TODO: can’t be used without std because of EPA return unimplemented!( "The projection of points on a round shapes isn’t supported on no-std platforms yet." ); - #[cfg(feature = "std")] // FIXME: can’t be used without std because of EPA + #[cfg(feature = "std")] // TODO: can’t be used without std because of EPA return crate::query::details::local_point_projection_on_support_map( self, &mut VoronoiSimplex::new(), diff --git a/src/query/point/point_segment.rs b/src/query/point/point_segment.rs index 3968548f..03e00052 100644 --- a/src/query/point/point_segment.rs +++ b/src/query/point/point_segment.rs @@ -77,7 +77,7 @@ impl PointQueryWithLocation for Segment { proj = self.a + ab * u; } - // FIXME: is this acceptable? + // TODO: is this acceptable? let inside = relative_eq!(proj, *pt); (PointProjection::new(inside, proj), location) diff --git a/src/query/ray/ray_support_map.rs b/src/query/ray/ray_support_map.rs index 944ea4ff..8ee65fe8 100644 --- a/src/query/ray/ray_support_map.rs +++ b/src/query/ray/ray_support_map.rs @@ -43,7 +43,7 @@ where let shift = (supp - ray.origin).dot(&ndir) + eps; let new_ray = Ray::new(ray.origin + ndir * shift, -ray.dir); - // FIXME: replace by? : simplex.translate_by(&(ray.origin - new_ray.origin)); + // TODO: replace by? : simplex.translate_by(&(ray.origin - new_ray.origin)); simplex.reset(CSOPoint::single_point(supp - new_ray.origin.coords)); gjk::cast_local_ray(shape, simplex, &new_ray, shift + eps).and_then( diff --git a/src/query/split/split_trimesh.rs b/src/query/split/split_trimesh.rs index b2e88b5d..b4c3b166 100644 --- a/src/query/split/split_trimesh.rs +++ b/src/query/split/split_trimesh.rs @@ -153,7 +153,7 @@ impl TriMesh { if intersection_features.0 == FeatureId::Unknown { intersection_features.0 = fid; } else { - // FIXME: this assertion may fire if the triangle is coplanar with the edge? + // TODO: this assertion may fire if the triangle is coplanar with the edge? // assert_eq!(intersection_features.1, FeatureId::Unknown); intersection_features.1 = fid; } @@ -462,7 +462,7 @@ impl TriMesh { if intersection_features.0 == FeatureId::Unknown { intersection_features.0 = fid; } else { - // FIXME: this assertion may fire if the triangle is coplanar with the edge? + // TODO: this assertion may fire if the triangle is coplanar with the edge? // assert_eq!(intersection_features.1, FeatureId::Unknown); intersection_features.1 = fid; } diff --git a/src/query/visitors/point_intersections_visitor.rs b/src/query/visitors/point_intersections_visitor.rs index 12eb3fde..e502d22f 100644 --- a/src/query/visitors/point_intersections_visitor.rs +++ b/src/query/visitors/point_intersections_visitor.rs @@ -4,7 +4,7 @@ use crate::partitioning::{SimdVisitStatus, SimdVisitor}; use simba::simd::{SimdBool as _, SimdValue}; use std::marker::PhantomData; -// FIXME: add a point cost fn. +// TODO: add a point cost fn. /// Spatial partitioning structure visitor collecting nodes that may contain a given point. pub struct PointIntersectionsVisitor<'a, T, F> { diff --git a/src/shape/convex_polygon.rs b/src/shape/convex_polygon.rs index 8a812053..09114fdd 100644 --- a/src/shape/convex_polygon.rs +++ b/src/shape/convex_polygon.rs @@ -260,7 +260,7 @@ impl ConvexPolyhedron for ConvexPolygon { out: &mut ConvexPolygonalFeature, ) { out.clear(); - // FIXME: actualy find the support feature. + // TODO: actualy find the support feature. self.support_face_toward(transform, dir, out) } diff --git a/src/shape/convex_polyhedron.rs b/src/shape/convex_polyhedron.rs index bd30da7f..fc4fec90 100644 --- a/src/shape/convex_polyhedron.rs +++ b/src/shape/convex_polyhedron.rs @@ -374,7 +374,7 @@ impl ConvexPolyhedron { vertices_adj_to_face, }; - // FIXME: for debug. + // TODO: for debug. // res.check_geometry(); Some(res) diff --git a/src/shape/cuboid.rs b/src/shape/cuboid.rs index ef922e3a..2a187989 100644 --- a/src/shape/cuboid.rs +++ b/src/shape/cuboid.rs @@ -48,7 +48,7 @@ impl Cuboid { /// the dot product with `dir`. #[cfg(feature = "dim2")] pub fn vertex_feature_id(vertex: Point) -> u32 { - // FIXME: is this still correct with the f64 version? + // TODO: is this still correct with the f64 version? #[allow(clippy::unnecessary_cast)] // Unnecessary for f32 but necessary for f64. { ((vertex.x.to_bits() >> 31) & 0b001 | (vertex.y.to_bits() >> 30) & 0b010) as u32 @@ -94,7 +94,7 @@ impl Cuboid { /// the dot product with `local_dir`. #[cfg(feature = "dim3")] pub fn support_feature(&self, local_dir: Vector) -> PolygonalFeature { - // FIXME: this should actually return the feature. + // TODO: this should actually return the feature. // And we should change all the callers of this method to use // `.support_face` instead of this method to preserve their old behavior. self.support_face(local_dir) @@ -498,7 +498,7 @@ impl ConvexPolyhedron for Cuboid { let mut iamax = 0; let mut amax = local_dir[0].abs(); - // FIXME: we should use nalgebra's iamax method. + // TODO: we should use nalgebra's iamax method. for i in 1..DIM { let candidate = local_dir[i].abs(); if candidate > amax { diff --git a/src/shape/heightfield2.rs b/src/shape/heightfield2.rs index aa860ea7..0d1352e9 100644 --- a/src/shape/heightfield2.rs +++ b/src/shape/heightfield2.rs @@ -162,7 +162,7 @@ impl HeightField { /// Iterator through all the segments of this heightfield. pub fn segments(&self) -> impl Iterator + '_ { - // FIXME: this is not very efficient since this wil + // TODO: this is not very efficient since this wil // recompute shared points twice. (0..self.num_cells()).filter_map(move |i| self.segment_at(i)) } @@ -226,7 +226,7 @@ impl HeightField { let min_x = self.quantize_floor(ref_mins.x, seg_length); let max_x = self.quantize_ceil(ref_maxs.x, seg_length); - // FIXME: find a way to avoid recomputing the same vertices + // TODO: find a way to avoid recomputing the same vertices // multiple times. for i in min_x..max_x { if self.is_segment_removed(i) { diff --git a/src/shape/heightfield3.rs b/src/shape/heightfield3.rs index f65e1fbb..f5fe6760 100644 --- a/src/shape/heightfield3.rs +++ b/src/shape/heightfield3.rs @@ -709,7 +709,7 @@ impl HeightField { let max_x = self.quantize_ceil(ref_maxs.x, cell_width, ncells_x); let max_z = self.quantize_ceil(ref_maxs.z, cell_height, ncells_z); - // FIXME: find a way to avoid recomputing the same vertices + // TODO: find a way to avoid recomputing the same vertices // multiple times. for j in min_x..max_x { for i in min_z..max_z { diff --git a/src/transformation/convex_hull3/convex_hull.rs b/src/transformation/convex_hull3/convex_hull.rs index 8fe2f0ad..a28fa20e 100644 --- a/src/transformation/convex_hull3/convex_hull.rs +++ b/src/transformation/convex_hull3/convex_hull.rs @@ -49,7 +49,7 @@ pub fn try_convex_hull( continue; } - // FIXME: use triangles[i].furthest_point instead. + // TODO: use triangles[i].furthest_point instead. let pt_id = indexed_support_point_id( &triangles[i].normal, &normalized_points[..], @@ -86,7 +86,7 @@ pub fn try_convex_hull( )?; // Check that the silhouette is valid. - // FIXME: remove this debug code. + // TODO: remove this debug code. // { // for (facet, id) in &silhouette_loop_facets_and_idx { // assert!(triangles[*facet].valid); @@ -110,7 +110,7 @@ pub fn try_convex_hull( )); } - // FIXME: this is very harsh. + // TODO: this is very harsh. triangles[i].valid = true; break; } @@ -208,7 +208,7 @@ fn fix_silhouette_topology( removed_facets: &mut Vec, triangles: &mut [TriangleFacet], ) -> Result<(), ConvexHullError> { - // FIXME: don't allocate this everytime. + // TODO: don't allocate this everytime. let mut workspace = vec![0; points.len()]; let mut needs_fixing = false; @@ -351,7 +351,7 @@ fn attach_and_push_facets( } // Assign to each facets some of the points which can see it. - // FIXME: refactor this with the others. + // TODO: refactor this with the others. for curr_facet in removed_facets.iter() { for visible_point in triangles[*curr_facet].visible_points.iter() { if points[*visible_point] == points[point] { @@ -410,7 +410,7 @@ fn attach_and_push_facets( } // Push facets. - // FIXME: can we avoid the tmp vector `new_facets` ? + // TODO: can we avoid the tmp vector `new_facets` ? triangles.append(&mut new_facets); } diff --git a/src/transformation/convex_hull3/initial_mesh.rs b/src/transformation/convex_hull3/initial_mesh.rs index 32a6b454..9f4ca40c 100644 --- a/src/transformation/convex_hull3/initial_mesh.rs +++ b/src/transformation/convex_hull3/initial_mesh.rs @@ -178,7 +178,7 @@ pub fn try_get_initial_mesh( let mut facets = vec![f1, f2]; // … and attribute visible points to each one of them. - // FIXME: refactor this with the two others. + // TODO: refactor this with the two others. for point in 0..normalized_points.len() { if normalized_points[point] == normalized_points[p1] || normalized_points[point] == normalized_points[p2] diff --git a/src/transformation/polygon_intersection.rs b/src/transformation/polygon_intersection.rs index b672b981..9f4f30e4 100644 --- a/src/transformation/polygon_intersection.rs +++ b/src/transformation/polygon_intersection.rs @@ -1,10 +1,9 @@ use log::error; use na::Point2; use ordered_float::OrderedFloat; -use std::cmp::Ordering; use crate::math::Real; -use crate::shape::{Segment, SegmentPointLocation, Triangle, TriangleOrientation}; +use crate::shape::{SegmentPointLocation, Triangle, TriangleOrientation}; use crate::utils::hashmap::HashMap; use crate::utils::{self, SegmentsIntersection}; @@ -293,6 +292,8 @@ pub enum PolygonsIntersectionError { /// Compute intersections between two polygons that may be non-convex but that must not self-intersect. /// +/// The input polygons are assumed to not self-intersect, and to be oriented counter-clockwise. +/// /// The resulting polygon is output vertex-by-vertex to the `out` closure. /// If two `None` are given to the `out` closure, then one connected component of the intersection /// polygon is complete. @@ -320,6 +321,8 @@ pub fn polygons_intersection_points( /// Compute intersections between two polygons that may be non-convex but that must not self-intersect. /// +/// The input polygons are assumed to not self-intersect, and to be oriented counter-clockwise. +/// /// The resulting polygon is output vertex-by-vertex to the `out` closure. /// If two `None` are given to the `out` closure, then one connected component of the intersection /// polygon is complete. @@ -350,8 +353,6 @@ pub fn polygons_intersection( // We found an intersection we haven’t visited yet, traverse the loop, alternating // between poly1 and poly2 when reaching an intersection. - let mut num_points_emitted = 0; // Guard against infinite loops if the polygon isn’t well-formed. - let [a1, b1] = segment(inter.edges[0], poly1); let [a2, b2] = segment(inter.edges[1], poly2); let poly_to_traverse = match Triangle::orientation2d(&a1, &b1, &a2, EPS) { @@ -362,7 +363,7 @@ pub fn polygons_intersection( TriangleOrientation::Clockwise => 0, TriangleOrientation::CounterClockwise => 1, TriangleOrientation::Degenerate => { - error!("Unhandled edge-edge overlap case."); + log::debug!("Unhandled edge-edge overlap case."); 0 } } @@ -515,14 +516,11 @@ fn compute_sorted_edge_intersections( inter2.entry(i2).or_default().push(intersection); id += 1; } - SegmentsIntersection::Segment { - first_loc1, - first_loc2, - second_loc1, - second_loc2, - } => { + SegmentsIntersection::Segment { .. } => { // TODO - error!("Collinear segment-segment intersections not properly handled yet."); + log::debug!( + "Collinear segment-segment intersections not properly handled yet." + ); } } } diff --git a/src/transformation/utils.rs b/src/transformation/utils.rs index 403f2701..33928001 100644 --- a/src/transformation/utils.rs +++ b/src/transformation/utils.rs @@ -24,7 +24,7 @@ pub fn scaled(mut points: Vec>, scale: Vector) -> Vec, poly: &[Point2]) -> bool { #[cfg(test)] mod tests { use super::*; - use crate::shape::Ball; #[test] fn point_in_poly2d_concave() { @@ -135,8 +134,9 @@ mod tests { } #[test] + #[cfg(feature = "dim2")] fn point_in_poly2d_concave_exact_vertex_bug() { - let poly = Ball::new(1.0).to_polyline(10); + let poly = crate::shape::Ball::new(1.0).to_polyline(10); assert!(point_in_poly2d(&Point2::origin(), &poly)); assert!(point_in_poly2d(&Point2::new(-0.25, 0.0), &poly)); assert!(point_in_poly2d(&Point2::new(0.25, 0.0), &poly)); diff --git a/src/utils/segments_intersection.rs b/src/utils/segments_intersection.rs index 09aab083..700f7fc5 100644 --- a/src/utils/segments_intersection.rs +++ b/src/utils/segments_intersection.rs @@ -148,7 +148,7 @@ fn parallel_intersection( // Assumes the three points are collinear. fn between(a: &Point2, b: &Point2, c: &Point2) -> Option { // If ab not vertical, check betweenness on x; else on y. - // FIXME: handle cases wher we actually are on a vertex (to return OnEdge instead of OnVertex)? + // TODO: handle cases wher we actually are on a vertex (to return OnEdge instead of OnVertex)? if a.x != b.x { if a.x <= c.x && c.x <= b.x { let bcoord = (c.x - a.x) / (b.x - a.x);