From 7e91c85822a3f3e04517435c8a9d037d389e2217 Mon Sep 17 00:00:00 2001 From: Quaternions Date: Wed, 24 Jul 2024 14:41:35 -0700 Subject: [PATCH] directly visit all bvh nodes --- src/bvh.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/bvh.rs b/src/bvh.rs index 5235790..e4f0bf6 100644 --- a/src/bvh.rs +++ b/src/bvh.rs @@ -40,6 +40,14 @@ impl BvhNode{ }, } } + pub fn into_visitor(self,f:&mut F){ + match self.content{ + BvhNodeContent::Leaf(model)=>f(model), + BvhNodeContent::Branch(children)=>for child in children{ + child.into_visitor(f) + }, + } + } } pub fn generate_bvh(boxen:Vec<(T,Aabb)>)->BvhNode{