From c1fefc78d46764845c406b60015188cc8f5207a9 Mon Sep 17 00:00:00 2001 From: Tavian Barnes Date: Thu, 15 Jul 2010 20:25:43 -0600 Subject: Add descriptive comment to new branchless ray-AABB intersection tests. --- libdimension/prtree.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/libdimension/prtree.c b/libdimension/prtree.c index 43400a3..6ca6058 100644 --- a/libdimension/prtree.c +++ b/libdimension/prtree.c @@ -544,6 +544,15 @@ static inline bool dmnsn_ray_box_intersection(dmnsn_optimized_line optline, dmnsn_bounding_box box, double t) { + /* + * This is actually correct, even though it appears not to handle edge cases + * (line.n.{x,y,z} == 0). It works because the infinities that result from + * dividing by zero will still behave correctly in the comparisons. Lines + * which are parallel to an axis and outside the box will have tmin == inf + * or tmax == -inf, while lines inside the box will have tmin and tmax + * unchanged. + */ + /* Degenerate box test */ if (box.min.x >= box.max.x) return false; -- cgit v1.2.3