From 64924fcab99e3979b117427c6d34b90b15706760 Mon Sep 17 00:00:00 2001 From: Daniel Oom Date: Sat, 16 Mar 2024 11:46:29 +0100 Subject: [PATCH] Fix accidentally remove boundary enlarging --- src/kdtree/build_naive.rs | 4 +++- src/kdtree/build_sah.rs | 4 ++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/kdtree/build_naive.rs b/src/kdtree/build_naive.rs index 295d1762..032db399 100644 --- a/src/kdtree/build_naive.rs +++ b/src/kdtree/build_naive.rs @@ -1,3 +1,5 @@ +use nalgebra::vector; + use crate::{ geometry::{ aap::{Aap, Axis}, @@ -33,7 +35,7 @@ fn median(values: &[f32]) -> f32 { impl KdTreeBuilder for MedianKdTreeBuilder { fn starting_box(&self) -> KdBox { KdBox { - boundary: triangles_bounding_box(&self.triangles), + boundary: triangles_bounding_box(&self.triangles).enlarge(&vector![0.5, 0.5, 0.5]), triangle_indices: (0u32..self.triangles.len() as u32).collect(), } } diff --git a/src/kdtree/build_sah.rs b/src/kdtree/build_sah.rs index fd81e2d4..c4abe0ca 100644 --- a/src/kdtree/build_sah.rs +++ b/src/kdtree/build_sah.rs @@ -1,3 +1,4 @@ +use nalgebra::vector; use rayon::prelude::*; use crate::{ @@ -57,7 +58,7 @@ impl SahKdTreeBuilder { impl KdTreeBuilder for SahKdTreeBuilder { fn starting_box(&self) -> KdBox { KdBox { - boundary: triangles_bounding_box(&self.triangles), + boundary: triangles_bounding_box(&self.triangles).enlarge(&vector![0.5, 0.5, 0.5]), triangle_indices: (0u32..self.triangles.len() as u32).collect(), } } @@ -158,7 +159,6 @@ mod tests { KdNode::new_leaf(vec![]), ), ); - dbg!(&tree.root); assert_eq!(tree.root, expected); } }