-
Notifications
You must be signed in to change notification settings - Fork 0
/
geometry.hpp
78 lines (62 loc) · 2.24 KB
/
geometry.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#pragma once
//-----------------------------------------------------------------------------
// Includes
//-----------------------------------------------------------------------------
#pragma region
#include "vector.hpp"
#pragma endregion
//-----------------------------------------------------------------------------
// Declarations and Definitions
//-----------------------------------------------------------------------------
namespace pathtracing
{
//-------------------------------------------------------------------------
// Declarations and Definitions: Reflection_t
//-------------------------------------------------------------------------
enum struct Reflection_t
{
Diffuse,
Specular,
Refractive
};
struct Ray final
{
public:
//---------------------------------------------------------------------
// Constructors and Destructors
//---------------------------------------------------------------------
constexpr explicit Ray(Vector3 o, Vector3 d,
double tmin = 0.0, double tmax = INFINITY,
uint32_t depth = 0) noexcept
: m_o(std::move(o)), m_d(std::move(d)),
m_tmin(tmin), m_tmax(tmax), m_depth(depth){};
constexpr Ray(const Ray &ray) noexcept = default;
constexpr Ray(Ray &&ray) noexcept = default;
~Ray() = default;
//---------------------------------------------------------------------
// Assignment Operators
//---------------------------------------------------------------------
constexpr Ray &operator=(const Ray &ray) = default;
constexpr Ray &operator=(Ray &&ray) = default;
//---------------------------------------------------------------------
// Member Methods
//---------------------------------------------------------------------
constexpr const Vector3 operator()(double t) const
{
// generate vector using direction, position and t
return m_o + m_d * t;
}
friend inline std::ostream &operator<<(std::ostream &os, const Ray &r)
{
os << "o: " << r.m_o << std::endl;
os << "d: " << r.m_d << std::endl;
return os;
}
//---------------------------------------------------------------------
// Member Variables
//---------------------------------------------------------------------
Vector3 m_o, m_d;
mutable double m_tmin, m_tmax;
uint32_t m_depth;
};
} // namespace pathtracing