Trait bvh::bounding_hierarchy::BoundingHierarchy [−][src]
pub trait BoundingHierarchy { fn build<Shape: BHShape>(shapes: &mut [Shape]) -> Self; fn traverse<'a, Shape: BHShape>(
&'a self,
ray: &Ray,
shapes: &'a [Shape]
) -> Vec<&Shape>; fn pretty_print(&self) { ... } }
This trait defines an acceleration structure with space partitioning. This structure is used to efficiently compute ray-scene intersections.
Required Methods
fn build<Shape: BHShape>(shapes: &mut [Shape]) -> Self
Creates a new BoundingHierarchy
from the shapes
slice.
Examples
use bvh::aabb::{AABB, Bounded}; use bvh::bounding_hierarchy::BoundingHierarchy; use bvh::nalgebra::{Point3, Vector3}; let mut shapes = create_bhshapes(); // Construct a normal `BVH`. { use bvh::bvh::BVH; let bvh = BVH::build(&mut shapes); } // Or construct a `FlatBVH`. { use bvh::flat_bvh::FlatBVH; let bvh = FlatBVH::build(&mut shapes); }
fn traverse<'a, Shape: BHShape>(
&'a self,
ray: &Ray,
shapes: &'a [Shape]
) -> Vec<&Shape>
&'a self,
ray: &Ray,
shapes: &'a [Shape]
) -> Vec<&Shape>
Traverses the BoundingHierarchy
.
Returns a subset of shapes
, in which the AABB
s of the elements were hit by ray
.
Examples
use bvh::aabb::{AABB, Bounded}; use bvh::bounding_hierarchy::BoundingHierarchy; use bvh::bvh::BVH; use bvh::nalgebra::{Point3, Vector3}; use bvh::ray::Ray; let (bvh, shapes) = create_bvh(); 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 hit_shapes = bvh.traverse(&ray, &shapes);
Provided Methods
fn pretty_print(&self)
Prints the BoundingHierarchy
in a tree-like visualization.