-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathintersection.hpp
34 lines (29 loc) · 1.18 KB
/
intersection.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
#pragma once
#include "vector.hpp"
#include "material.hpp"
#include "object.hpp"
class Object;
class Material;
/*
Intersection implementation
*/
struct Intersection {
bool happened; // only valid under intersection meaning, determine whether intersected
Vector3f coordinate; // the coordinate of that point
Vector3f normal; // the normal of that point at that object
double distance; // only valid under intersection meaning, determine the ray time if intersected
Object *object; // the object the point belonging to
Material *material; // the material of the object the point belonging to
Vector2f uv; // only valid when the object is mesh/triangle, determine the barycentric coordinates
uint32_t index; // only valid when the object is mesh, determine the index of the triangle
Intersection() {
happened = false;
coordinate = Vector3f();
normal = Vector3f();
distance = std::numeric_limits<double>::max();
object = nullptr;
material = nullptr;
uv = Vector2f();
index = 0;
}
};