if(t > ray.t())
return false;
- if( t < 1e-6 )
+ if( t < Epsilon )
{
t = (-B+root)/(2.0f*A);
- if( t < 1e-6 || t > ray.t())
+ if( t < Epsilon || t > ray.t())
return false;
}
+
ray.setT(t);
+ ray.setHit(this);
+
return true;
}
Vec3f
Sphere::GetNormal(Ray& ray)
{
- return Vec3f();
+ Vec3f p = ray.origin()+ray.direction()*ray.t();
+ Vec3f N = (p-m_center);
+ N.normalize();
+
+ return N;
}