- replaced default values by float ones
authorAkiko <akiko@linux-addicted.net>
Fri, 25 Oct 2013 11:14:20 +0000 (13:14 +0200)
committerAkiko <akiko@linux-addicted.net>
Fri, 25 Oct 2013 11:14:20 +0000 (13:14 +0200)
- just a clean up
- updated string() method to print all data

engine/Ray.hxx

index dd30bad..fc39d6c 100644 (file)
@@ -1,6 +1,5 @@
 #pragma once
 
-#include <sstream>
 #include "Vector.hxx"
 
 template <typename MT>
@@ -11,25 +10,23 @@ public:
     // --- constructors and deconstructors ---
 
     Ray()
-    : _origin(0, 0, 0), _direction(0, 0, 0), _rgb(0, 0, 0), _min(5), _max(1000), _depth(10), _valid(false)
+    : _origin(0.0, 0.0, 0.0), _direction(0.0, 0.0, 0.0), _min(1.0), _max(1000.0), _depth(10)
     {
     }
 
-    Ray(const Vector3<MT>& org, const Vector3<MT>& dir, const Vector3<MT>& rgb, const MT& min, const MT& max,
-        const size_t& depth, const bool valid)
-    : _origin(org), _direction(dir), _rgb(rgb), _min(min), _max(max), _depth(depth), _valid(valid)
+    Ray(const Vector3<MT>& org, const Vector3<MT>& dir, const MT& min, const MT& max, const size_t& depth)
+    : _origin(org), _direction(dir), _min(min), _max(max), _depth(depth)
     {
     }
 
     Ray(const Ray& rhs)
-    : _origin(rhs._origin), _direction(rhs._direction), _rgb(rhs._rgb), _min(rhs._min), _max(rhs._max),
-      _depth(rhs._depth), _valid(rhs._valid)
+    : _origin(rhs._origin), _direction(rhs._direction), _min(rhs._min), _max(rhs._max), _depth(rhs._depth)
     {
     }
 
     Ray(Ray&& rhs)
-    : _origin(std::move(rhs._origin)), _direction(std::move(rhs._direction)), _rgb(std::move(rhs._rgb)),
-      _min(std::move(rhs._min)), _max(std::move(rhs._max)), _depth(std::move(rhs._depth)), _valid(std::move(rhs._valid))
+    : _origin(std::move(rhs._origin)), _direction(std::move(rhs._direction)), _min(std::move(rhs._min)),
+      _max(std::move(rhs._max)), _depth(std::move(rhs._depth))
     {
     }
 
@@ -45,11 +42,9 @@ public:
         {
             _origin = rhs._origin;
             _direction = rhs._direction;
-            _rgb = rhs._rgb;
             _min = rhs._min;
             _max = rhs._max;
             _depth = rhs._depth;
-            _valid = rhs._valid;
         }
 
         return *this;
@@ -61,11 +56,9 @@ public:
         {
             _origin = std::move(rhs._origin);
             _direction = std::move(rhs._direction);
-            _rgb = std::move(rhs._rgb);
             _min = std::move(rhs._min);
             _max = std::move(rhs._max);
             _depth = std::move(rhs._depth);
-            _valid = std::move(rhs._valid);
         }
 
         return *this;
@@ -73,8 +66,11 @@ public:
 
     bool operator==(const Ray& rhs) const
     {
-        return _origin == rhs._origin && _direction == rhs._direction && _rgb == rhs._rgb && _min == rhs._min &&
-               _max == rhs._max && _depth == rhs._depth && _valid == rhs._valid;
+        return _origin == rhs._origin &&
+               _direction == rhs._direction &&
+               _min == rhs._min &&
+               _max == rhs._max &&
+               _depth == rhs._depth;
     }
 
     bool operator!=(const Ray& rhs) const
@@ -84,19 +80,9 @@ public:
 
     // --- public methods ---
 
-    void setOrigin(const Vector3<MT>& org)
-    {
-        _origin = org;
-    }
-
-    Vector3<MT> origin() const
-    {
-        return _origin;
-    }
-
-    void setDirection(const Vector3<MT>& dir)
+    size_t depth() const
     {
-        _direction = dir.normalized();
+        return _depth;
     }
 
     Vector3<MT> direction() const
@@ -104,19 +90,9 @@ public:
         return _direction;
     }
 
-    void setRgb(const Vector3<MT>& rgb)
-    {
-        _rgb = rgb;
-    }
-
-    Vector3<MT> rgb() const
-    {
-        return _rgb;
-    }
-
-    void setMin(const MT& min)
+    MT max() const
     {
-        _min = min;
+        return _max;
     }
 
     MT min() const
@@ -124,41 +100,46 @@ public:
         return _min;
     }
 
-    void setMax(const MT& max)
+    Vector3<MT> origin() const
     {
-        _max = max;
+        return _origin;
     }
 
-    MT max() const
+    void setDepth(const size_t& depth)
     {
-        return _max;
+        _depth = depth;
     }
 
-    void setDepth(const size_t& depth)
+    void setDirection(const Vector3<MT>& dir)
     {
-        _depth = depth;
+        _direction = dir.normalized();
     }
 
-    size_t depth() const
+    void setMax(const MT& max)
     {
-        return _depth;
+        _max = max;
     }
 
-    void setValid(const bool valid)
+    void setMin(const MT& min)
     {
-        _valid = valid;
+        _min = min;
     }
 
-    bool valid() const
+    void setOrigin(const Vector3<MT>& org)
     {
-        return _valid;
+        _origin = org;
     }
 
     std::string string() const
     {
         std::stringstream result;
 
-        result << "(" << _origin.string() << "), (" << _direction.string() << ")";
+        result << "org(" << _origin.string()
+               << "), dir(" << _direction.string()
+               << "), min(" << _min
+               << "), max(" << _max
+               << "), dep(" << _depth
+               << ")";
 
         return result.str();
     }
@@ -168,9 +149,7 @@ protected:
 
     Vector3<MT> _origin;
     Vector3<MT> _direction;
-    Vector4<uint8_t> _rgb;  // color ARGB (0, 255 for now)
     MT _min;                // near plane value
     MT _max;                // far plane value
     size_t _depth;          // recursion depth
-    bool _valid;
 };