From 8646f32b25d5ae22b5483854059ee584dfc4a2c7 Mon Sep 17 00:00:00 2001 From: Tavian Barnes Date: Tue, 13 Oct 2009 03:39:04 +0000 Subject: Fix ray-box intersection test. --- libdimension/kD_splay_tree.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'libdimension') diff --git a/libdimension/kD_splay_tree.c b/libdimension/kD_splay_tree.c index 758e68c..de70edf 100644 --- a/libdimension/kD_splay_tree.c +++ b/libdimension/kD_splay_tree.c @@ -388,14 +388,14 @@ dmnsn_ray_box_intersection(dmnsn_line line, dmnsn_vector min, dmnsn_vector max, if (line.n.y != 0.0) { /* y == -1.0 */ - t_temp = (-1.0 - line.x0.y)/line.n.y; + t_temp = (min.y - line.x0.y)/line.n.y; p = dmnsn_line_point(line, t_temp); if (p.x >= min.x && p.x <= max.x && p.z >= min.z && p.z <= max.z && t_temp >= 0.0 && (t < 0.0 || t_temp < t)) return 1; /* y == 1.0 */ - t_temp = (1.0 - line.x0.y)/line.n.y; + t_temp = (max.y - line.x0.y)/line.n.y; p = dmnsn_line_point(line, t_temp); if (p.x >= min.x && p.x <= max.x && p.z >= min.z && p.z <= max.z && t_temp >= 0.0 && (t < 0.0 || t_temp < t)) @@ -404,14 +404,14 @@ dmnsn_ray_box_intersection(dmnsn_line line, dmnsn_vector min, dmnsn_vector max, if (line.n.z != 0.0) { /* z == -1.0 */ - t_temp = (-1.0 - line.x0.z)/line.n.z; + t_temp = (min.z - line.x0.z)/line.n.z; p = dmnsn_line_point(line, t_temp); if (p.x >= min.x && p.x <= max.x && p.y >= min.y && p.y <= max.y && t_temp >= 0.0 && (t < 0.0 || t_temp < t)) return 1; /* z == 1.0 */ - t_temp = (1.0 - line.x0.z)/line.n.z; + t_temp = (max.z - line.x0.z)/line.n.z; p = dmnsn_line_point(line, t_temp); if (p.x >= min.x && p.x <= max.x && p.y >= min.y && p.y <= max.y && t_temp >= 0.0 && (t < 0.0 || t_temp < t)) -- cgit v1.2.3