diff --git a/crates/fj-math/src/triangle.rs b/crates/fj-math/src/triangle.rs index cbafd436e..2c3cffb32 100644 --- a/crates/fj-math/src/triangle.rs +++ b/crates/fj-math/src/triangle.rs @@ -1,4 +1,4 @@ -use parry2d_f64::utils::point_in_triangle::{corner_direction, Orientation}; +use parry2d_f64::utils::point_in_triangle::Orientation; use parry3d_f64::query::{Ray, RayCast as _}; use crate::Vector; @@ -59,8 +59,17 @@ impl Triangle { impl Triangle<2> { /// Returns the direction of the line through the points of the triangle. pub fn winding_direction(&self) -> Winding { - let [v0, v1, v2] = self.points.map(|point| point.to_na()); - corner_direction(&v0, &v1, &v2).into() + let [pa, pb, pc] = self.points.map(|point| point.into()); + let orient2d = robust_predicates::orient2d(&pa, &pb, &pc); + + if orient2d < 0. { + return Winding::Cw; + } + if orient2d > 0. { + return Winding::Ccw; + } + + unreachable!("not a triangle") } }