From 2b8bb0b705055bd6da8b09de1855254520c1a306 Mon Sep 17 00:00:00 2001 From: Quaternions Date: Sun, 18 Aug 2024 14:42:02 -0700 Subject: [PATCH] bvh: remove unnecessary work --- src/bvh.rs | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/src/bvh.rs b/src/bvh.rs index ee73355..b76c239 100644 --- a/src/bvh.rs +++ b/src/bvh.rs @@ -121,13 +121,11 @@ fn generate_bvh_node(boxen:Vec<(T,Aabb)>,force:bool)->BvhNode{ aabb, } }else{ - let mut octant=std::collections::HashMap::with_capacity(n);//this ids which octant the boxen is put in let mut sort_x=Vec::with_capacity(n); let mut sort_y=Vec::with_capacity(n); let mut sort_z=Vec::with_capacity(n); for (i,(_,aabb)) in boxen.iter().enumerate(){ let center=aabb.center(); - octant.insert(i,0); sort_x.push((i,center.x())); sort_y.push((i,center.y())); sort_z.push((i,center.z())); @@ -139,26 +137,26 @@ fn generate_bvh_node(boxen:Vec<(T,Aabb)>,force:bool)->BvhNode{ let median_x=sort_x[h].1; let median_y=sort_y[h].1; let median_z=sort_z[h].1; - for (i,c) in sort_x{ - if median_x