Files
PhotonMF/plane.cpp

24 lines
387 B
C++

#include <cmath>
#include "plane.hpp"
#define TOL 1e-6
using std::fabs;
using glm::dot;
bool Plane::intersect(Ray & r, float & t) const {
float d = dot(r.m_direction, m_normal);
if (fabs(d) > TOL) {
t = dot(m_normal, (m_point - r.m_origin)) / d;
return t >= 0.0f;
}
return false;
}
vec3 Plane::normal_at_int(Ray & r, float & t) const {
return vec3(m_normal);
}