1
0
Fork 0
mirror of https://codeberg.org/icewind/vbsp.git synced 2026-06-03 10:44:07 +02:00

basic triangulation for faces

This commit is contained in:
Robin Appelman 2022-02-17 23:37:29 +01:00
commit e348934ec5

View file

@ -361,6 +361,22 @@ impl<'a> Handle<'a, Face> {
}) })
.unwrap_or_default() .unwrap_or_default()
} }
/// Triangulate the face
///
/// Triangulation only works for faces that can be turned into a triangle fan trivially
pub fn triangulate(&self) -> impl Iterator<Item = [Vector; 3]> + 'a {
let mut vertices = self.vertices();
let a = vertices.next().expect("face with <3 points");
let mut b = vertices.next().expect("face with <3 points");
vertices.map(move |c| {
let points = [a.position, b.position, c.position];
b = c;
points
})
}
} }
impl Handle<'_, Node> { impl Handle<'_, Node> {