From adb5c8f0c363a34a31c7ff8c2c7945d9c0a07c89 Mon Sep 17 00:00:00 2001 From: Mark Nefedov Date: Fri, 14 Aug 2026 23:42:57 +0300 Subject: [PATCH] Pass the best-so-far distance to project_point's primitive_check Bvh::project_point and project_point_and_get_feature document that the Real argument given to primitive_check is the distance to the closest point found so far, but both passed the original max_distance instead. This matches the code to the documented contract, which also lets expensive primitive checks prune against the current best. Conforming callbacks return the same winner; cast_ray in the same module already follows this pattern. --- src/partitioning/bvh/bvh_queries.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/partitioning/bvh/bvh_queries.rs b/src/partitioning/bvh/bvh_queries.rs index d1123771..bcaf922b 100644 --- a/src/partitioning/bvh/bvh_queries.rs +++ b/src/partitioning/bvh/bvh_queries.rs @@ -219,8 +219,8 @@ impl Bvh { self.find_best( max_distance, |node: &BvhNode, _| node.aabb().distance_to_local_point(point, true), - |primitive, _| { - let proj = primitive_check(primitive, max_distance)?; + |primitive, best_so_far| { + let proj = primitive_check(primitive, best_so_far)?; Some((proj.point.distance(point), proj)) }, ) @@ -243,8 +243,8 @@ impl Bvh { self.find_best( max_distance, |node: &BvhNode, _| node.aabb().distance_to_local_point(point, true), - |primitive, _| { - let proj = primitive_check(primitive, max_distance)?; + |primitive, best_so_far| { + let proj = primitive_check(primitive, best_so_far)?; Some((proj.0.point.distance(point), proj)) }, )