Skip to content

Instantly share code, notes, and snippets.

@dubik dubik/BBox.cpp
Last active Dec 5, 2018

What would you like to do?
// Vectormath
class Ray
Vectormath::Aos::Vector3 m_pos;
Vectormath::Aos::Vector3 m_dir;
Vectormath::Aos::Vector3 m_invDir; // 1.0f / m_dir per elem
float m_min;
float m_max;
bool BBox::Intersect(const Ray &ray) const
using namespace Vectormath;
Aos::Vector3 t1(Aos::mulPerElem(m_min - ray.m_pos, ray.m_invDir));
Aos::Vector3 t2(Aos::mulPerElem(m_max - ray.m_pos, ray.m_invDir));
Aos::Vector3 tmin1(Aos::minPerElem(t1, t2));
Aos::Vector3 tmax1(Aos::maxPerElem(t1, t2));
float tmin = Aos::maxElem(tmin1);
float tmax = Aos::minElem(tmax1);
return tmax >= std::max(ray.m_min, tmin) && tmin < ray.m_max;

This comment has been minimized.

Copy link

commented Nov 16, 2016

Great code. However, what are ray.m_min and ray.m_max?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.