Phong does not work yet, but saving here
[MicroTrace.git] / Sphere.cxx
index 3c19afa..6b8d943 100644 (file)
@@ -26,18 +26,25 @@ Sphere::Intersect(Ray& ray)
   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;
 }
This page took 0.018768 seconds and 4 git commands to generate.