conspire/geometry/bvh/from/
mod.rs1#[cfg(test)]
2mod test;
3
4use crate::geometry::{
5 bvh::{BoundingVolumeHierarchy, primitive::Primitives},
6 mesh::{Mesh, Tessellation},
7};
8
9const LEAF_SIZE: usize = 4;
10
11impl<const D: usize> From<Primitives<D>> for BoundingVolumeHierarchy<D> {
12 fn from(mut primitives: Primitives<D>) -> Self {
13 let mut bvh = Self {
14 items: Vec::new(),
15 nodes: Vec::new(),
16 };
17 bvh.build_node(&mut primitives, LEAF_SIZE);
18 bvh
19 }
20}
21
22impl<const D: usize> From<&Mesh<D>> for BoundingVolumeHierarchy<D> {
23 fn from(mesh: &Mesh<D>) -> Self {
24 Primitives::from(mesh).into()
25 }
26}
27
28impl From<&Tessellation> for BoundingVolumeHierarchy<3> {
29 fn from(tessellation: &Tessellation) -> Self {
30 tessellation.mesh().into()
31 }
32}