From: Akiko Date: Fri, 25 Oct 2013 11:14:20 +0000 (+0200) Subject: - replaced default values by float ones X-Git-Url: http://community.linux-addicted.net/gitweb/?a=commitdiff_plain;h=00e33b64f5b557225f58a61d64c227b87e2a0543;p=qtinns.git - replaced default values by float ones - just a clean up - updated string() method to print all data --- diff --git a/engine/Ray.hxx b/engine/Ray.hxx index dd30bad..fc39d6c 100644 --- a/engine/Ray.hxx +++ b/engine/Ray.hxx @@ -1,6 +1,5 @@ #pragma once -#include #include "Vector.hxx" template @@ -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& org, const Vector3& dir, const Vector3& 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& org, const Vector3& 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& org) - { - _origin = org; - } - - Vector3 origin() const - { - return _origin; - } - - void setDirection(const Vector3& dir) + size_t depth() const { - _direction = dir.normalized(); + return _depth; } Vector3 direction() const @@ -104,19 +90,9 @@ public: return _direction; } - void setRgb(const Vector3& rgb) - { - _rgb = rgb; - } - - Vector3 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 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& 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& 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 _origin; Vector3 _direction; - Vector4 _rgb; // color ARGB (0, 255 for now) MT _min; // near plane value MT _max; // far plane value size_t _depth; // recursion depth - bool _valid; };