// Add intersections to queue void AddIsects( const Ray3D &ray, const Box3D &box, PointQueue &isects ) { const unsigned nPairs = 3; Point3D rayEnd( ray.origin + ray.direction ); for ( unsigned i = 0; i < nPairs; ++i ) { unsigned j = ( i + 1 ) % nPairs, k = ( i + 2 ) % nPairs; if ( rayEnd[i] != ray.origin[i] ) { for ( unsigned m = 0; m < 2; ++m) { float t = (!m) ? ( box.origin[i] - ray.origin[i] ) / ( ray.direction[i] ) : ( box.extent[i] - ray.origin[i] ) / ( ray.direction[i] ); if ( t >= -epsilon && t <= 1.f + epsilon ) { Point3D isect = ray.origin + t * ray.direction; if ( ( isect[j] >= box.origin[j] && isect[j] <= box.extent[j] ) && ( isect[k] >= box.origin[k] && isect[k] <= box.extent[k] ) ) { TimedPoint point = { t, isect }; if ( isects.c.end() == std::find( isects.c.begin(), isects.c.end(), point ) ) isects.push( point ); } } } } } }