Triangle::Triangle(const Vec3f& a,
const Vec3f& b,
- const Vec3f& c)
- : m_a(a),
+ const Vec3f& c,
+ Shader* shader)
+ : Primitive(shader),
+ m_a(a),
m_b(b),
- m_c(c)
+ m_c(c),
+ m_n( (b-a).cross(c-a) )
{
+ m_n.normalize();
}
Triangle::~Triangle()
float f = edge2.dot(qvec);
f *= inv_det;
- if (ray.t() <= f || f < 1e-4 )
+ if (ray.t() <= f || f < Epsilon )
return false;
ray.setT(f);
-
+ ray.setHit(this);
+
return true;
}
+
+Vec3f
+Triangle::GetNormal(Ray& ray)
+{
+ return m_n;
+}