From 27f3dc5b510d77951c7f6d8b7c75cbf1e7a19a0f Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Thu, 3 Apr 2025 12:52:36 +0200 Subject: [PATCH] Prepare for follow-on change --- .../2025-03-18/src/extra/triangulate.rs | 55 +++++++++---------- 1 file changed, 27 insertions(+), 28 deletions(-) diff --git a/experiments/2025-03-18/src/extra/triangulate.rs b/experiments/2025-03-18/src/extra/triangulate.rs index 347d8b10c..87ec891f6 100644 --- a/experiments/2025-03-18/src/extra/triangulate.rs +++ b/experiments/2025-03-18/src/extra/triangulate.rs @@ -41,35 +41,34 @@ pub fn triangulate(face: &Face) -> TriMesh { } fn points(face: &Face) -> Vec { - face.half_edges - .iter() - .map(|half_edge| { - // Here, we project a 3D point (from the vertex) into the face's - // surface, creating a 2D point. Through the surface, this 2D - // point has a position in 3D space. - // - // But this position isn't necessarily going to be the same as - // the position of the original 3D point, due to numerical - // inaccuracy. - // - // This doesn't matter. Neither does the fact, that other faces - // might share the same vertices and project them into their own - // surfaces, creating more redundancy. - // - // The reason that it doesn't, is that we're using the projected - // 2D points _only_ for this local triangulation. Once that - // tells us how the different 3D points must connect, we use the - // original 3D points to build those triangles. We never convert - // the 2D points back into 3D. - let point_surface = - face.surface.geometry.project_point(half_edge.start.point); + let points_from_half_edges = face.half_edges.iter().map(|half_edge| { + // Here, we project a 3D point (from the vertex) into the face's + // surface, creating a 2D point. Through the surface, this 2D + // point has a position in 3D space. + // + // But this position isn't necessarily going to be the same as + // the position of the original 3D point, due to numerical + // inaccuracy. + // + // This doesn't matter. Neither does the fact, that other faces + // might share the same vertices and project them into their own + // surfaces, creating more redundancy. + // + // The reason that it doesn't, is that we're using the projected + // 2D points _only_ for this local triangulation. Once that + // tells us how the different 3D points must connect, we use the + // original 3D points to build those triangles. We never convert + // the 2D points back into 3D. + let point_surface = + face.surface.geometry.project_point(half_edge.start.point); - TriangulationPoint { - point_surface, - point_vertex: half_edge.start.point, - } - }) - .collect() + TriangulationPoint { + point_surface, + point_vertex: half_edge.start.point, + } + }); + + points_from_half_edges.collect() } fn triangles(points: &[TriangulationPoint]) -> Vec<[TriangulationPoint; 3]> {