X-Git-Url: https://git.rohieb.name/MicroTrace.git/blobdiff_plain/430ddbc0e443b60b6d0c7893a96e045411368dbf..fd7caf7240f13d618697dbbc403142c1dd6057a6:/Ray.cxx diff --git a/Ray.cxx b/Ray.cxx index e0a1ab5..84617d1 100644 --- a/Ray.cxx +++ b/Ray.cxx @@ -2,22 +2,23 @@ #include "Ray.hxx" -#define MAX_RECURSION_DEPTH 10 - Ray::Ray() : m_org(Vec3f()), m_dir(Vec3f()), - m_level(MAX_RECURSION_DEPTH), + m_level(0), + m_density(1.0), m_hit(0) { m_t = std::numeric_limits::max(); } -Ray::Ray(const Vec3f& org, - const Vec3f& dir) +Ray::Ray(const Vec3f& org, + const Vec3f& dir, + unsigned int recursion_level) : m_org(org), m_dir(dir), - m_level(MAX_RECURSION_DEPTH), + m_level(recursion_level), + m_density(1.0), m_hit(0) { m_t = std::numeric_limits::max(); @@ -34,6 +35,7 @@ Ray::Ray(const Ray& r) m_t = r.m_t; m_hit = r.m_hit; m_level = r.m_level; + m_density = r.m_density; } Ray& @@ -45,6 +47,8 @@ Ray::operator=(const Ray& r) m_dir = r.m_dir; m_t = r.m_t; m_hit = r.m_hit; + m_level = r.m_level; + m_density = r.m_density; } return *this; } @@ -85,19 +89,19 @@ Ray::setT(float t) m_t = t; } -void -Ray::setHit(Primitive * p) -{ - m_hit = p; -} - Primitive* Ray::hit() { return m_hit; } -unsigned int +void +Ray::setHit(Primitive* p) +{ + m_hit = p; +} + +unsigned int Ray::recursionDepth() const { return m_level; @@ -108,3 +112,15 @@ Ray::setRecursionDepth(unsigned int i) { m_level = i; } + +float +Ray::indexOfRefraction() const +{ + return m_density; +} + +void +Ray::setIndexOfRefraction(float d) +{ + m_density = d; +}