Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Address a few TODOs #273

Merged
merged 9 commits into from
Nov 4, 2024
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions src/bounding_volume/bounding_sphere_convex.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ impl ConvexPolyhedron {
/// Computes the local-space bounding sphere of this convex polyhedron.
#[inline]
pub fn local_bounding_sphere(&self) -> BoundingSphere {
let (center, radius) = bounding_volume::details::point_cloud_bounding_sphere(self.points());

BoundingSphere::new(center, radius)
bounding_volume::details::point_cloud_bounding_sphere(self.points())
}
}
4 changes: 1 addition & 3 deletions src/bounding_volume/bounding_sphere_convex_polygon.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ impl ConvexPolygon {
/// Computes the local-space bounding sphere of this convex polygon.
#[inline]
pub fn local_bounding_sphere(&self) -> BoundingSphere {
let (center, radius) = bounding_volume::details::point_cloud_bounding_sphere(self.points());

BoundingSphere::new(center, radius)
bounding_volume::details::point_cloud_bounding_sphere(self.points())
}
}
4 changes: 1 addition & 3 deletions src/bounding_volume/bounding_sphere_segment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ impl Segment {
#[inline]
pub fn local_bounding_sphere(&self) -> BoundingSphere {
let pts = [self.a, self.b];
let (center, radius) = bounding_volume::details::point_cloud_bounding_sphere(&pts[..]);

BoundingSphere::new(center, radius)
bounding_volume::details::point_cloud_bounding_sphere(&pts[..])
}
}
4 changes: 1 addition & 3 deletions src/bounding_volume/bounding_sphere_triangle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ impl Triangle {
#[inline]
pub fn local_bounding_sphere(&self) -> BoundingSphere {
let pts = [self.a, self.b, self.c];
let (center, radius) = bounding_volume::details::point_cloud_bounding_sphere(&pts[..]);

BoundingSphere::new(center, radius)
bounding_volume::details::point_cloud_bounding_sphere(&pts[..])
}
}
11 changes: 5 additions & 6 deletions src/bounding_volume/bounding_sphere_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@ use crate::math::{Point, Real};
use crate::utils;
use na::{self, ComplexField};

use super::BoundingSphere;

/// Computes the bounding sphere of a set of point, given its center.
// TODO: return a bounding sphere?
#[inline]
pub fn point_cloud_bounding_sphere_with_center(
pts: &[Point<Real>],
center: Point<Real>,
) -> (Point<Real>, Real) {
) -> BoundingSphere {
let mut sqradius = 0.0;

for pt in pts.iter() {
Expand All @@ -18,13 +19,11 @@ pub fn point_cloud_bounding_sphere_with_center(
sqradius = distance_squared
}
}

(center, ComplexField::sqrt(sqradius))
BoundingSphere::new(center, ComplexField::sqrt(sqradius))
}

/// Computes a bounding sphere of the specified set of point.
// TODO: return a bounding sphere?
#[inline]
pub fn point_cloud_bounding_sphere(pts: &[Point<Real>]) -> (Point<Real>, Real) {
pub fn point_cloud_bounding_sphere(pts: &[Point<Real>]) -> BoundingSphere {
Vrixyz marked this conversation as resolved.
Show resolved Hide resolved
point_cloud_bounding_sphere_with_center(pts, utils::center(pts))
}
4 changes: 2 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ the rust programming language.
#![deny(unused_parens)]
#![deny(non_upper_case_globals)]
#![deny(unused_results)]
#![warn(missing_docs)] // TODO: deny this
#![deny(missing_docs)]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let’s keep this a warn and remove the TODO. I find it more convenient to just warn locally, and have it fail only on CI by denying warnings.

#![warn(unused_imports)]
#![allow(missing_copy_implementations)]
#![allow(clippy::too_many_arguments)] // Maybe revisit this one later.
Expand All @@ -20,7 +20,7 @@ the rust programming language.
#![allow(clippy::type_complexity)] // Complains about closures that are fairly simple.
#![doc(html_root_url = "http://docs.rs/parry/0.1.1")]
#![cfg_attr(not(feature = "std"), no_std)]
#![cfg_attr(not(feature = "rkyv"), deny(unused_qualifications))] // TODO: deny that everytime
#![deny(unused_qualifications)]

#[cfg(all(
feature = "simd-is-enabled",
Expand Down
2 changes: 0 additions & 2 deletions src/mass_properties/mass_properties_convex_polygon.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#![allow(dead_code)] // TODO: remove this
Vrixyz marked this conversation as resolved.
Show resolved Hide resolved

use crate::mass_properties::MassProperties;
use crate::math::{Point, Real};
use crate::shape::Triangle;
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>(
}
}

// TODO: can we re-used this for the segment/segment case?
// TODO: can we re-use this for the segment/segment case?
/// Closest points between two segments.
#[inline]
pub fn closest_points_line_line(
Expand Down
18 changes: 7 additions & 11 deletions src/query/epa/epa3.rs
Original file line number Diff line number Diff line change
Expand Up @@ -373,20 +373,16 @@ impl EPA {
for edge in &self.silhouette {
if !self.faces[edge.face_id].deleted {
let new_face_id = self.faces.len();
let new_face;

// TODO: NLL
{
let face_adj = &mut self.faces[edge.face_id];
let pt_id1 = face_adj.pts[(edge.opp_pt_id + 2) % 3];
let pt_id2 = face_adj.pts[(edge.opp_pt_id + 1) % 3];
let face_adj = &mut self.faces[edge.face_id];
let pt_id1 = face_adj.pts[(edge.opp_pt_id + 2) % 3];
let pt_id2 = face_adj.pts[(edge.opp_pt_id + 1) % 3];

let pts = [pt_id1, pt_id2, support_point_id];
let adj = [edge.face_id, new_face_id + 1, new_face_id - 1];
new_face = Face::new(&self.vertices, pts, adj);
let pts = [pt_id1, pt_id2, support_point_id];
let adj = [edge.face_id, new_face_id + 1, new_face_id - 1];
let new_face = Face::new(&self.vertices, pts, adj);

face_adj.adj[(edge.opp_pt_id + 1) % 3] = new_face_id;
}
face_adj.adj[(edge.opp_pt_id + 1) % 3] = new_face_id;

self.faces.push(new_face.0);

Expand Down
22 changes: 8 additions & 14 deletions src/query/gjk/voronoi_simplex2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,11 +98,8 @@ impl VoronoiSimplex {
self.proj[0] = 1.0;
self.vertices[0].point
} else if self.dim == 1 {
// 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::<Real>::origin(), true)
};
let (proj, location) = Segment::new(self.vertices[0].point, self.vertices[1].point)
.project_local_point_and_get_location(&Point::<Real>::origin(), true);

match location {
SegmentPointLocation::OnVertex(0) => {
Expand All @@ -123,15 +120,12 @@ impl VoronoiSimplex {
proj.point
} else {
assert!(self.dim == 2);
// TODO: NLL
let (proj, location) = {
let tri = Triangle::new(
self.vertices[0].point,
self.vertices[1].point,
self.vertices[2].point,
);
tri.project_local_point_and_get_location(&Point::<Real>::origin(), true)
};
let (proj, location) = Triangle::new(
self.vertices[0].point,
self.vertices[1].point,
self.vertices[2].point,
)
.project_local_point_and_get_location(&Point::<Real>::origin(), true);

match location {
TrianglePointLocation::OnVertex(i) => {
Expand Down
39 changes: 15 additions & 24 deletions src/query/gjk/voronoi_simplex3.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,11 +125,8 @@ impl VoronoiSimplex {
self.proj[0] = 1.0;
self.vertices[0].point
} else if self.dim == 1 {
// 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::<Real>::origin(), true)
};
let (proj, location) = Segment::new(self.vertices[0].point, self.vertices[1].point)
.project_local_point_and_get_location(&Point::<Real>::origin(), true);

match location {
SegmentPointLocation::OnVertex(0) => {
Expand All @@ -150,15 +147,12 @@ impl VoronoiSimplex {

proj.point
} else if self.dim == 2 {
// TODO: NLL
let (proj, location) = {
let tri = Triangle::new(
self.vertices[0].point,
self.vertices[1].point,
self.vertices[2].point,
);
tri.project_local_point_and_get_location(&Point::<Real>::origin(), true)
};
let (proj, location) = Triangle::new(
self.vertices[0].point,
self.vertices[1].point,
self.vertices[2].point,
)
.project_local_point_and_get_location(&Point::<Real>::origin(), true);

match location {
TrianglePointLocation::OnVertex(i) => {
Expand Down Expand Up @@ -192,16 +186,13 @@ impl VoronoiSimplex {
proj.point
} else {
assert!(self.dim == 3);
// TODO: NLL
let (proj, location) = {
let tetr = Tetrahedron::new(
self.vertices[0].point,
self.vertices[1].point,
self.vertices[2].point,
self.vertices[3].point,
);
tetr.project_local_point_and_get_location(&Point::<Real>::origin(), true)
};
let (proj, location) = Tetrahedron::new(
self.vertices[0].point,
self.vertices[1].point,
self.vertices[2].point,
self.vertices[3].point,
)
.project_local_point_and_get_location(&Point::<Real>::origin(), true);

match location {
TetrahedronPointLocation::OnVertex(i) => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
#![allow(deprecated)] // Silence warning until we actually remove IntersectionCompositeShapeShapeBestFirstVisitor

use crate::bounding_volume::SimdAabb;
use crate::math::{Isometry, Real, SimdReal, Vector, SIMD_WIDTH};
use crate::partitioning::{
SimdBestFirstVisitStatus, SimdBestFirstVisitor, SimdVisitStatus, SimdVisitor,
};
use crate::math::{Isometry, Real, SIMD_WIDTH};
use crate::partitioning::{SimdVisitStatus, SimdVisitor};
use crate::query::QueryDispatcher;
use crate::shape::{Shape, TypedSimdCompositeShape};
use crate::utils::IsometryOpt;
use simba::simd::{SimdBool as _, SimdPartialOrd, SimdValue};
use simba::simd::SimdBool as _;

/// Intersection test between a composite shape (`Mesh`, `Compound`) and any other shape.
pub fn intersection_test_composite_shape_shape<D, G1>(
Expand Down Expand Up @@ -118,92 +114,3 @@ where
SimdVisitStatus::MaybeContinue(mask)
}
}

/// A visitor for checking if a composite-shape and a shape intersect.
#[deprecated(note = "Use IntersectionCompositeShapeShapeVisitor instead.")]
pub struct IntersectionCompositeShapeShapeBestFirstVisitor<'a, D: ?Sized, G1: ?Sized + 'a> {
Vrixyz marked this conversation as resolved.
Show resolved Hide resolved
msum_shift: Vector<SimdReal>,
msum_margin: Vector<SimdReal>,

dispatcher: &'a D,
pos12: &'a Isometry<Real>,
g1: &'a G1,
g2: &'a dyn Shape,
}

impl<'a, D, G1> IntersectionCompositeShapeShapeBestFirstVisitor<'a, D, G1>
where
D: ?Sized + QueryDispatcher,
G1: ?Sized + TypedSimdCompositeShape,
{
/// Initialize a visitor for checking if a composite-shape and a shape intersect.
pub fn new(
dispatcher: &'a D,
pos12: &'a Isometry<Real>,
g1: &'a G1,
g2: &'a dyn Shape,
) -> IntersectionCompositeShapeShapeBestFirstVisitor<'a, D, G1> {
let ls_aabb2 = g2.compute_aabb(pos12);

IntersectionCompositeShapeShapeBestFirstVisitor {
dispatcher,
msum_shift: Vector::splat(-ls_aabb2.center().coords),
msum_margin: Vector::splat(ls_aabb2.half_extents()),
pos12,
g1,
g2,
}
}
}

impl<'a, D, G1> SimdBestFirstVisitor<G1::PartId, SimdAabb>
for IntersectionCompositeShapeShapeBestFirstVisitor<'a, D, G1>
where
D: ?Sized + QueryDispatcher,
G1: ?Sized + TypedSimdCompositeShape,
{
type Result = (G1::PartId, bool);

fn visit(
&mut self,
best: Real,
bv: &SimdAabb,
data: Option<[Option<&G1::PartId>; SIMD_WIDTH]>,
) -> SimdBestFirstVisitStatus<Self::Result> {
// Compute the minkowski sum of the two Aabbs.
let msum = SimdAabb {
mins: bv.mins + self.msum_shift + (-self.msum_margin),
maxs: bv.maxs + self.msum_shift + self.msum_margin,
};
let dist = msum.distance_to_origin();
let mask = dist.simd_lt(SimdReal::splat(best));

if let Some(data) = data {
let bitmask = mask.bitmask();
let mut found_intersection = false;

for (ii, data) in data.into_iter().enumerate() {
if (bitmask & (1 << ii)) != 0 && data.is_some() {
let part_id = *data.unwrap();
self.g1.map_untyped_part_at(part_id, |part_pos1, g1, _| {
found_intersection = self.dispatcher.intersection_test(
&part_pos1.inv_mul(self.pos12),
g1,
self.g2,
) == Ok(true);
});

if found_intersection {
return SimdBestFirstVisitStatus::ExitEarly(Some((part_id, true)));
}
}
}
}

SimdBestFirstVisitStatus::MaybeContinue {
weights: dist,
mask,
results: [None; SIMD_WIDTH],
}
}
}
4 changes: 1 addition & 3 deletions src/query/intersection_test/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,9 @@ pub use self::intersection_test_ball_point_query::{
intersection_test_ball_point_query, intersection_test_point_query_ball,
};
#[cfg(feature = "std")]
// TODO: remove this once we get rid of IntersectionCompositeShapeShapeBestFirstVisitor
#[allow(deprecated)]
pub use self::intersection_test_composite_shape_shape::{
intersection_test_composite_shape_shape, intersection_test_shape_composite_shape,
IntersectionCompositeShapeShapeBestFirstVisitor, IntersectionCompositeShapeShapeVisitor,
IntersectionCompositeShapeShapeVisitor,
};
pub use self::intersection_test_cuboid_cuboid::intersection_test_cuboid_cuboid;
pub use self::intersection_test_cuboid_segment::{
Expand Down
32 changes: 1 addition & 31 deletions src/transformation/vhacd/vhacd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -164,32 +164,6 @@ impl VHACD {
}
}

// TODO: this should be a method of VoxelSet.
fn compute_axes_aligned_clipping_planes(
vset: &VoxelSet,
downsampling: u32,
planes: &mut Vec<CutPlane>,
) {
let min_v = vset.min_bb_voxels();
let max_v = vset.max_bb_voxels();

for dim in 0..DIM {
let i0 = min_v[dim];
let i1 = max_v[dim];

for i in (i0..=i1).step_by(downsampling as usize) {
let plane = CutPlane {
abc: Vector::ith(dim, 1.0),
axis: dim as u8,
d: -(vset.origin[dim] + (i as Real + 0.5) * vset.scale),
index: i,
};

planes.push(plane);
}
}
}

fn refine_axes_aligned_clipping_planes(
vset: &VoxelSet,
best_plane: &CutPlane,
Expand Down Expand Up @@ -328,11 +302,7 @@ impl VHACD {
Self::compute_preferred_cutting_direction(&eigenvalues);

let mut planes = Vec::new();
Self::compute_axes_aligned_clipping_planes(
&voxels,
params.plane_downsampling,
&mut planes,
);
voxels.compute_axes_aligned_clipping_planes(params.plane_downsampling, &mut planes);

let (mut best_plane, mut min_concavity) = self.compute_best_clipping_plane(
&voxels,
Expand Down
Loading