-
Notifications
You must be signed in to change notification settings - Fork 0
/
Common.hpp
55 lines (39 loc) · 1.04 KB
/
Common.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
#pragma once
#include <iostream>
#include <glm/glm.hpp>
#include <glm/ext.hpp>
#define POINT(...) glm::dvec4(__VA_ARGS__, 1)
#define VEC(...) glm::dvec4(__VA_ARGS__, 0)
typedef unsigned int uint;
const double DEG2RAD = M_PI / 180.0;
const double EPSILON = 1e-6;
const double SURFACE_BIAS = 1e-4;
// forward declaration
class GeometryNode;
struct Ray
{
Ray(const glm::dvec4 &origin, const glm::dvec4 &direction, double time, bool opaqueOnly = false)
: origin(origin)
, direction(direction)
, time(time)
, opaqueOnly(opaqueOnly)
{};
glm::dvec4 origin;
glm::dvec4 direction;
double time;
bool opaqueOnly;
};
struct HitInfo
{
glm::dvec4 pos;
glm::dvec4 normal;
double t;
const GeometryNode *hitObject;
};
template <template <typename, glm::precision> class matType, typename T, glm::precision P>
std::ostream &operator<<(std::ostream &os, const matType<T, P> &v)
{
return os << glm::to_string(v);
}
template<>
std::ostream &operator<<(std::ostream &os, const glm::mat4 &mat);