-
Notifications
You must be signed in to change notification settings - Fork 0
/
Ray.cpp
executable file
·32 lines (26 loc) · 909 Bytes
/
Ray.cpp
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
#include "Ray.h"
/* Constructors */
Ray::Ray(const vec3& start, const vec3& end, double min, double max, const Sample& samp, Primitive* lastHit) {
origin = start;
direction = end - start;
tMin = min;
tMax = max;
inverseDirection = vec3(1/direction[0], 1/direction[1], 1/direction[2]);
sign[0] = (inverseDirection[0] < 0);
sign[1] = (inverseDirection[1] < 0);
sign[2] = (inverseDirection[2] < 0);
mySample = samp;
this->lastHit = lastHit;
}
Ray::Ray(const vec3& start, double min, double max, const vec3& direction, const Sample& samp, Primitive* lastHit) {
origin = start;
this->direction = direction;
tMin = min;
tMax = max;
inverseDirection = vec3(1/direction[0], 1/direction[1], 1/direction[2]);
sign[0] = (inverseDirection[0] < 0);
sign[1] = (inverseDirection[1] < 0);
sign[2] = (inverseDirection[2] < 0);
mySample = samp;
this->lastHit = lastHit;
}