type FlatBVH = Vec<FlatNode>;
A flat BVH
. Represented by a vector of FlatNode
s. The FlatBVH
is designed for use
where a recursive traversal of a data structure is not possible, for example shader programs.
A FlatBVH
is built from a regular BVH
using the [flatten
] method.
Traverses a FlatBVH
structure iteratively.
use bvh::aabb::{AABB, Bounded};
use bvh::bounding_hierarchy::BoundingHierarchy;
use bvh::flat_bvh::FlatBVH;
use bvh::nalgebra::{Point3, Vector3};
use bvh::ray::Ray;
let origin = Point3::new(0.0,0.0,0.0);
let direction = Vector3::new(1.0,0.0,0.0);
let ray = Ray::new(origin, direction);
let mut shapes = create_bhshapes();
let flat_bvh = FlatBVH::build(&mut shapes);
let hit_shapes = flat_bvh.traverse(&ray, &shapes);
Prints a textual representation of a FlatBVH
.