summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--libdimension/cube.c9
-rw-r--r--libdimension/prtree.c11
2 files changed, 19 insertions, 1 deletions
diff --git a/libdimension/cube.c b/libdimension/cube.c
index 4c09d04..84b1553 100644
--- a/libdimension/cube.c
+++ b/libdimension/cube.c
@@ -82,6 +82,9 @@ dmnsn_cube_intersection_fn(const dmnsn_object *cube, dmnsn_line line,
if (tmin > tmax)
return false;
+ } else {
+ if (line_trans.x0.x < -1.0 || line_trans.x0.x > 1.0)
+ return false;
}
if (line_trans.n.y != 0.0) {
@@ -110,6 +113,9 @@ dmnsn_cube_intersection_fn(const dmnsn_object *cube, dmnsn_line line,
if (tmin > tmax)
return false;
+ } else {
+ if (line_trans.x0.y < -1.0 || line_trans.x0.y > 1.0)
+ return false;
}
if (line_trans.n.z != 0.0) {
@@ -138,6 +144,9 @@ dmnsn_cube_intersection_fn(const dmnsn_object *cube, dmnsn_line line,
if (tmin > tmax)
return false;
+ } else {
+ if (line_trans.x0.z < -1.0 || line_trans.x0.z > 1.0)
+ return false;
}
if (tmin < 0.0) {
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)