X-Git-Url: https://git.rohieb.name/MicroTrace.git/blobdiff_plain/9e556ed5343384fcf9258fe0f37af3c1fb9b9b3d..430ddbc0e443b60b6d0c7893a96e045411368dbf:/Ray.cxx?ds=sidebyside diff --git a/Ray.cxx b/Ray.cxx index be4a4f4..e0a1ab5 100644 --- a/Ray.cxx +++ b/Ray.cxx @@ -1,12 +1,26 @@ +#include + #include "Ray.hxx" +#define MAX_RECURSION_DEPTH 10 + Ray::Ray() + : m_org(Vec3f()), + m_dir(Vec3f()), + m_level(MAX_RECURSION_DEPTH), + m_hit(0) { + m_t = std::numeric_limits::max(); } -Ray::Ray(const Vec3f& org, +Ray::Ray(const Vec3f& org, const Vec3f& dir) + : m_org(org), + m_dir(dir), + m_level(MAX_RECURSION_DEPTH), + m_hit(0) { + m_t = std::numeric_limits::max(); } Ray::~Ray() @@ -15,28 +29,82 @@ Ray::~Ray() Ray::Ray(const Ray& r) { + m_org = r.m_org; + m_dir = r.m_dir; + m_t = r.m_t; + m_hit = r.m_hit; + m_level = r.m_level; } Ray& Ray::operator=(const Ray& r) { + if(this != &r) + { + m_org = r.m_org; + m_dir = r.m_dir; + m_t = r.m_t; + m_hit = r.m_hit; + } return *this; } const Vec3f& Ray::origin() const { - return Vec3f(); + return m_org; } const Vec3f& Ray::direction() const { - return Vec3f(); + return m_dir; } float Ray::t() const { - return 0.0f; + return m_t; +} + +void +Ray::setOrigin(const Vec3f& o) +{ + m_org = o; +} + +void +Ray::setDir(const Vec3f& d) +{ + m_dir = d; +} + +void +Ray::setT(float t) +{ + m_t = t; +} + +void +Ray::setHit(Primitive * p) +{ + m_hit = p; +} + +Primitive* +Ray::hit() +{ + return m_hit; +} + +unsigned int +Ray::recursionDepth() const +{ + return m_level; +} + +void +Ray::setRecursionDepth(unsigned int i) +{ + m_level = i; }