[−][src]Trait bvh::bounding_hierarchy::BoundingHierarchy
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.
Implementors
impl BoundingHierarchy for BVH
[src]
impl BoundingHierarchy for BVH
fn build<Shape: BHShape>(shapes: &mut [Shape]) -> BVH | [src] |
fn traverse<'a, Shape: Bounded>( | [src] |
fn pretty_print(&self) | [src] |
impl BoundingHierarchy for FlatBVH
[src]
impl BoundingHierarchy for FlatBVH
fn build<T: BHShape>(shapes: &mut [T]) -> FlatBVH | [src] |
fn traverse<'a, T: Bounded>(&'a self, ray: &Ray, shapes: &'a [T]) -> Vec<&T> | [src] |
Traverses a FlatBVH
structure iteratively.
Examples
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);
fn pretty_print(&self) | [src] |
Prints a textual representation of a FlatBVH
.