diff --git a/CHANGELOG.md b/CHANGELOG.md index 7cefcb67..b1d56e7c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,12 +2,16 @@ ## Unreleased +### Added + +- `TriMesh` now implements `Shape::feature_normal_at_point` to retrieve the normal of a face, when passing a `FeatureId::Face`. + ## v0.17.1 ### Modified - Improve convergence of epa algorithm in degenerate configurations. -- Fix bug in the esh/mesh intersection algorithm that didn’t properly take mesh transforms into account. +- Fix bug in the mesh/mesh intersection algorithm that didn’t properly take mesh transforms into account. ## v0.17.0 diff --git a/src/shape/shape.rs b/src/shape/shape.rs index 824a587b..de3d2cbf 100644 --- a/src/shape/shape.rs +++ b/src/shape/shape.rs @@ -1130,6 +1130,18 @@ impl Shape for TriMesh { Real::frac_pi_4() } + /// Gets the normal of the triangle represented by `feature`. + fn feature_normal_at_point( + &self, + _feature: FeatureId, + _point: &Point, + ) -> Option>> { + #[cfg(feature = "dim2")] + return None; + #[cfg(feature = "dim3")] + return self.feature_normal(_feature); + } + #[cfg(feature = "std")] fn as_composite_shape(&self) -> Option<&dyn SimdCompositeShape> { Some(self as &dyn SimdCompositeShape) diff --git a/src/shape/trimesh.rs b/src/shape/trimesh.rs index f263f9fc..140ecf2f 100644 --- a/src/shape/trimesh.rs +++ b/src/shape/trimesh.rs @@ -848,6 +848,17 @@ impl TriMesh { ) }) } + + #[cfg(feature = "dim3")] + /// Gets the normal of the triangle represented by `feature`. + pub fn feature_normal(&self, feature: FeatureId) -> Option>> { + match feature { + FeatureId::Face(i) => self + .triangle(i % self.num_triangles() as u32) + .feature_normal(FeatureId::Face(0)), + _ => None, + } + } } impl TriMesh {