54c9570800ddb9b5f67b6ddd0f421b0356760b04
[MicroTrace.git] / InfinitePlane.cxx
1 #include "InfinitePlane.hxx"
2
3 InfinitePlane::InfinitePlane(const Vec3f& a, const Vec3f& n, Shader* shader)
4 : Primitive(shader),
5 m_a(a),
6 m_n(n)
7 {
8
9 }
10
11 InfinitePlane::~InfinitePlane()
12 {
13 }
14
15 bool
16 InfinitePlane::Intersect(Ray& ray)
17 {
18 Vec3f diff = m_a - ray.origin();
19 float t = diff.dot(m_n) / ray.direction().dot(m_n);
20 if (t < 1e-5 || t > ray.t())
21 return false;
22 ray.setT(t);
23 return true;
24 }
25
26 Vec3f
27 InfinitePlane::GetNormal(Ray& ray)
28 {
29 // We already have the surface normal
30 return m_n;
31 }
This page took 0.061048 seconds and 3 git commands to generate.