summaryrefslogtreecommitdiffstats
path: root/libdimension/prtree.c
diff options
context:
space:
mode:
authorTavian Barnes <tavianator@gmail.com>2010-07-15 20:25:43 -0600
committerTavian Barnes <tavianator@gmail.com>2010-07-15 20:25:43 -0600
commitc1fefc78d46764845c406b60015188cc8f5207a9 (patch)
tree9825d20d4c49dd2db70a2a3efd70c378e1c25d3b /libdimension/prtree.c
parentd543caf4ad629ec5313463f6e78e5931c406a353 (diff)
downloaddimension-c1fefc78d46764845c406b60015188cc8f5207a9.tar.xz
Add descriptive comment to new branchless ray-AABB intersection tests.
Diffstat (limited to 'libdimension/prtree.c')
-rw-r--r--libdimension/prtree.c9
1 files changed, 9 insertions, 0 deletions
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;