diff --git a/src/shape/shape.rs b/src/shape/shape.rs index 5c9fd6b7..78c3716a 100644 --- a/src/shape/shape.rs +++ b/src/shape/shape.rs @@ -893,10 +893,13 @@ impl Shape for Triangle { fn feature_normal_at_point( &self, - feature: FeatureId, + _feature: FeatureId, _point: &Point, ) -> Option>> { - self.feature_normal(feature) + #[cfg(feature = "dim2")] + return None; + #[cfg(feature = "dim3")] + return self.feature_normal(_feature); } } diff --git a/src/shape/triangle.rs b/src/shape/triangle.rs index 34d4d8f9..4e23530c 100644 --- a/src/shape/triangle.rs +++ b/src/shape/triangle.rs @@ -1,16 +1,17 @@ //! Definition of the triangle shape. use crate::math::{Isometry, Point, Real, Vector}; -use crate::shape::{FeatureId, SupportMap}; +use crate::shape::SupportMap; use crate::shape::{PolygonalFeature, Segment}; use crate::utils; use na::{self, ComplexField, Unit}; use num::Zero; -#[cfg(feature = "dim3")] -use std::f64; use std::mem; +#[cfg(feature = "dim3")] +use {crate::shape::FeatureId, std::f64}; + #[cfg(feature = "dim2")] use crate::shape::PackedFeatureId; @@ -138,6 +139,7 @@ impl Triangle { /// The normal points such that it is collinear to `AB × AC` (where `×` denotes the cross /// product). #[inline] + #[cfg(feature = "dim3")] pub fn normal(&self) -> Option>> { Unit::try_new(self.scaled_normal(), crate::math::DEFAULT_EPSILON) } @@ -230,10 +232,12 @@ impl Triangle { /// /// The vector points such that it is collinear to `AB × AC` (where `×` denotes the cross /// product). + /// /// Note that on thin triangles the calculated normals can suffer from numerical issues. /// For a more robust (but more computationally expensive) normal calculation, see /// [`Triangle::robust_scaled_normal`]. #[inline] + #[cfg(feature = "dim3")] pub fn scaled_normal(&self) -> Vector { let ab = self.b - self.a; let ac = self.c - self.a; @@ -535,6 +539,7 @@ impl Triangle { } /// The normal of the given feature of this shape. + #[cfg(feature = "dim3")] pub fn feature_normal(&self, _: FeatureId) -> Option>> { self.normal() }