Skip to content

Instantly share code, notes, and snippets.

@cjameshuff
Created January 10, 2016 01:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cjameshuff/d708bf6de9bf9a919f5f to your computer and use it in GitHub Desktop.
Save cjameshuff/d708bf6de9bf9a919f5f to your computer and use it in GitHub Desktop.
template<typename T>
auto BBox::SlopeTest(const t_ClassifiedRay<T> & ray) const -> bool
{
auto && tl = (minExt - ray.origin)*ray.rdir;
auto && th = (maxExt - ray.origin)*ray.rdir;
auto && tmin = std::min(tl.x, th.x);
auto && tmax = std::max(tl.x, th.x);
tmin = std::max(tmin, std::min(std::min(tl.y, th.y), tmax));
tmax = std::min(tmax, std::max(std::max(tl.y, th.y), tmin));
tmin = std::max(tmin, std::min(std::min(tl.z, th.z), tmax));
tmax = std::min(tmax, std::max(std::max(tl.z, th.z), tmin));
return tmax > std::max(tmin, T(0));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment