From 6c1e8c7ffb32f0dfbb2fbe1abbc95b6f6ec6118b Mon Sep 17 00:00:00 2001 From: Eryn Wells Date: Sat, 21 Sep 2013 17:01:11 -0700 Subject: [PATCH] Add min_weight property to Scene --- src/scene.cc | 3 ++- src/scene.h | 6 +++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/scene.cc b/src/scene.cc index bb2484d..d6f471f 100644 --- a/src/scene.cc +++ b/src/scene.cc @@ -19,6 +19,7 @@ Scene::Scene() : width(640), height(480), max_depth(5), + min_weight(1e-4), ambient(new AmbientLight()), shapes(), lights(), @@ -181,7 +182,7 @@ Scene::trace_ray(const Ray &ray, const int depth, const float weight) { - if (depth >= max_depth) { + if (depth >= max_depth || weight <= min_weight) { return Color::Black; } diff --git a/src/scene.h b/src/scene.h index b0eb9c7..3ac4007 100644 --- a/src/scene.h +++ b/src/scene.h @@ -47,8 +47,12 @@ private: // Pixel dimensions of the image. int width, height; - // Ray tracing parameters. + /* + * Ray tracing parameters. max_depth indicates the maximum depth of the ray tree. min_weight indicates the minimum + * specular weight to apply before giving up. + */ int max_depth; + float min_weight; // Scene objects. AmbientLight *ambient;