still broken ReflectiveEyeLightShader, saving it for later
[MicroTrace.git] / Sphere.cxx
index 5706cc3..77d4320 100644 (file)
@@ -44,11 +44,15 @@ Sphere::GetNormal(Ray& ray)
   Ray tempRay = ray;
 
   // Surface normal is the difference between intersection and center point
-  Intersect(tempRay);
-  // intersection
-  Vec3f i = tempRay.origin() + tempRay.direction() * tempRay.t();
-  // normal
-  Vec3f n = (i - m_center);
-  n.normalize();
-  return n;
+  if(Intersect(tempRay)) {
+    // intersection point
+    Vec3f i = tempRay.origin() + tempRay.direction() * (tempRay.t() - Epsilon);
+    // normal
+    Vec3f n = (i - m_center);
+    n.normalize();
+    return n;
+  } else {
+    // no intersection with ray, so no surface normal
+    return Vec3f(0,0,0);
+  }
 }
This page took 0.026869 seconds and 4 git commands to generate.