Skip to main content

conspire/geometry/bvh/primitive/from/
mod.rs

1#[cfg(test)]
2mod test;
3
4use crate::geometry::{
5    bvh::primitive::{Primitive, Primitives},
6    mesh::Mesh,
7};
8
9impl<const D: usize> From<&Mesh<D>> for Primitives<D> {
10    fn from(mesh: &Mesh<D>) -> Self {
11        mesh.bounding_boxes_and_centroids()
12            .enumerate()
13            .map(|(index, (bounding_box, centroid))| Primitive {
14                bounding_box,
15                centroid,
16                index,
17            })
18            .collect()
19    }
20}