From 27dba8a90d52ec734ad2a496dda4197a8c5094f6 Mon Sep 17 00:00:00 2001 From: Quaternions Date: Mon, 19 Aug 2024 13:33:18 -0700 Subject: [PATCH] bvh: handling for median clumps --- src/bvh.rs | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/src/bvh.rs b/src/bvh.rs index b76c239..c95e2e4 100644 --- a/src/bvh.rs +++ b/src/bvh.rs @@ -137,19 +137,27 @@ 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; + //locate a run of values equal to the median //partition point gives the first index for which the predicate evaluates to false - let first_index_gt_median_x=sort_x.partition_point(|tup|!(median_x