+#include <limits>
+
#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<float>::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<float>::max();
}
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;
}