Skip to content

Instantly share code, notes, and snippets.

@jleedev
Created April 3, 2011 20:11
Show Gist options
  • Select an option

  • Save jleedev/900730 to your computer and use it in GitHub Desktop.

Select an option

Save jleedev/900730 to your computer and use it in GitHub Desktop.
diff --git i/src/scene.cpp w/src/scene.cpp
index 8382ef7..3ef0d1a 100644
--- i/src/scene.cpp
+++ w/src/scene.cpp
@@ -92,6 +92,9 @@ Color Scene::raytrace(const Ray& camera_ray, int level) const {
continue;
float int_distance2 = Ray::makeRay(camera_ray.getOrigin(),
intersection->getOrigin()).getDir().magnitude2();
+ if (int_distance2 < 1e-6)
+ // Too close! We must move forwards a little.
+ continue;
if (int_distance2 < nearest_distance2) {
// Found a closer hit
nearest_shape = shape;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment