pub struct GpuAabbTree {
pub nodes: Vec<BvhNodeGpu>,
pub root: usize,
pub num_primitives: usize,
pub morton_codes: Vec<u32>,
}Expand description
Flat AABB tree (BVH) built with parallel bottom-up Morton-code construction.
The tree stores nodes in a flat VecBvhNodeGpu` for cache-friendly GPU
traversal. Construction uses a parallel (CPU-mock) bottom-up merge pass
after sorting leaf centres by Morton code.
Fields§
§nodes: Vec<BvhNodeGpu>Flat array of BVH nodes.
root: usizeIndex of the root node.
num_primitives: usizeNumber of leaf primitives.
morton_codes: Vec<u32>Morton codes computed during last build.
Implementations§
Source§impl GpuAabbTree
impl GpuAabbTree
Sourcepub fn build(&mut self, aabbs: &[AabbGpu])
pub fn build(&mut self, aabbs: &[AabbGpu])
Build the tree from a slice of AabbGpu primitives.
Sorts primitives by Morton code, inserts leaf nodes, then performs a CPU-mock parallel bottom-up merge to form internal nodes.
Sourcepub fn query(&self, query: &AabbGpu) -> Vec<u32>
pub fn query(&self, query: &AabbGpu) -> Vec<u32>
Query all leaf primitives whose AABB overlaps query.
Sourcepub fn leaf_count(&self) -> usize
pub fn leaf_count(&self) -> usize
Count the number of leaf nodes.
Trait Implementations§
Source§impl Debug for GpuAabbTree
impl Debug for GpuAabbTree
Source§impl Default for GpuAabbTree
impl Default for GpuAabbTree
Source§fn default() -> GpuAabbTree
fn default() -> GpuAabbTree
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for GpuAabbTree
impl RefUnwindSafe for GpuAabbTree
impl Send for GpuAabbTree
impl Sync for GpuAabbTree
impl Unpin for GpuAabbTree
impl UnsafeUnpin for GpuAabbTree
impl UnwindSafe for GpuAabbTree
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more