`dmnsn_ray`

) is by the parametric formula `origin + t*direction`

. Commonly we restrict `t >= 0`

to get a half-line starting from the given origin. So generally `t`

specifies a position along a line. In this case, `t`

is the closest object intersection found so far, so if the bounding box is farther away than `t`

, we can ignore it.
I agree that should be better documented! :)

]]>http://blog.johnnovak.net/2016/10/22/the-nim-raytracer-project-part-4-calculating-box-normals/

]]>

static inline bool dmnsn_ray_box_intersection(dmnsn_optimized_ray optray, dmnsn_aabb box, double t)

It hurts me to say this but I believe that some of the functions do require comments about their input parameters. Or more obvious names.

]]>`<=`

/`>=`

with `<`

/`>`

:
```
bool intersection(box b, ray r) {
double tmin = -INFINITY, tmax = INFINITY;
for (int i = 0; i < 3; ++i) {
if (ray.dir[i] != 0.0) {
double t1 = (b.min[i] - r.origin[i])/r.dir[i];
double t2 = (b.max[i] - r.origin[i])/r.dir[i];
tmin = max(tmin, min(t1, t2));
tmax = min(tmax, max(t1, t2));
} else if (ray.origin[i] < b.min[i] || ray.origin[i] > b.max[i]) {
return false;
}
}
return tmax >= tmin && tmax >= 0.0;
}
```

]]>Having read both this and part 2, I'm unable to work out what changes I need to make in order to reliably detect intersections when a ray is exactly on the edge of an AABB. I have your implementation here with a simple failing test case:

https://github.com/io7m/raycast-issue-20170516

I've stepped through the code and tried making the changes you suggested in the other article (exchanging Math.max and Math.min for implementations that have the semantics of maxNumber and minNumber) but I can't seem to get it to work.

Maybe I've misunderstood the intent of the other article: What changes do I need to make to reliably catch ray/edge intersections? I care less about efficiency and more about avoiding false negatives.

]]>