-
-
Save lolriven/dabdbb88f009c9e1c8ddd9f55eac0bf1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Vectormath https://github.com/erwincoumans/sce_vectormath | |
class Ray | |
{ | |
public: | |
Ray(); | |
public: | |
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; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment