diff options
author | Tavian Barnes <tavianator@gmail.com> | 2010-05-08 13:04:42 -0600 |
---|---|---|
committer | Tavian Barnes <tavianator@gmail.com> | 2010-05-08 13:04:42 -0600 |
commit | 152362a57dc7fe9dce830ef69118984f854d6375 (patch) | |
tree | 43599d21a04e698a3874e5af1dd70566e472ca66 /libdimension/prtree.c | |
parent | 0335b8141b4ab35a94a8f1653a86defcd6768012 (diff) | |
download | dimension-152362a57dc7fe9dce830ef69118984f854d6375.tar.xz |
Handle degenerate cases in ray/box intersections.
Diffstat (limited to 'libdimension/prtree.c')
-rw-r--r-- | libdimension/prtree.c | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/libdimension/prtree.c b/libdimension/prtree.c index cb09b84..04d8cc4 100644 --- a/libdimension/prtree.c +++ b/libdimension/prtree.c @@ -552,7 +552,7 @@ bool dmnsn_prtree_search(const dmnsn_prtree *tree, dmnsn_line ray, dmnsn_intersection *intersection) { - double t = -1; + double t = -1.0; /* Search the unbounded objects */ for (size_t i = 0; i < dmnsn_array_size(tree->unbounded); ++i) { @@ -588,6 +588,9 @@ dmnsn_ray_box_intersection(dmnsn_line line, dmnsn_bounding_box box, double t) if (tmin > tmax) return false; + } else { + if (line.x0.x < box.min.x || line.x0.x > box.max.x) + return false; } if (line.n.y != 0.0) { @@ -599,6 +602,9 @@ dmnsn_ray_box_intersection(dmnsn_line line, dmnsn_bounding_box box, double t) if (tmin > tmax) return false; + } else { + if (line.x0.y < box.min.y || line.x0.y > box.max.y) + return false; } if (line.n.z != 0.0) { @@ -610,6 +616,9 @@ dmnsn_ray_box_intersection(dmnsn_line line, dmnsn_bounding_box box, double t) if (tmin > tmax) return false; + } else { + if (line.x0.z < box.min.z || line.x0.z > box.max.z) + return false; } if (tmax < 0.0) |