Files
PhotonMF/plane.cpp

22 lines
367 B
C++
Raw Normal View History

2016-12-26 17:43:57 -04:00
#include "plane.hpp"
#define TOL 1e-6
2017-01-02 00:23:04 -04:00
using glm::abs;
2016-12-26 17:43:57 -04:00
using glm::dot;
2016-12-26 19:14:21 -04:00
bool Plane::intersect(Ray & r, float & t) const {
2016-12-26 17:43:57 -04:00
float d = dot(r.m_direction, m_normal);
2017-01-02 00:23:04 -04:00
if (abs(d) > TOL) {
2016-12-26 17:43:57 -04:00
t = dot(m_normal, (m_point - r.m_origin)) / d;
return t >= 0.0f;
}
return false;
}
2016-12-26 19:14:21 -04:00
vec3 Plane::normal_at_int(Ray & r, float & t) const {
return vec3(m_normal);
}