-
Notifications
You must be signed in to change notification settings - Fork 0
/
ray.cpp
63 lines (50 loc) · 993 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
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
#include "ray.h"
#include <assert.h>
#include <algorithm>
///
/// WARNING: Parallelism...
///
static IdType nRayId = 0;
Ray::Ray()
: fDeltaX(0), fDeltaY(0)
{
id = -1; // for GPU to recognize empty node in the tree
}
void Ray::reset()
{
id = -1;
fDeltaX = 0;
fDeltaY = 0;
vect3d null;
vecCopy(start_point, null);
vecCopy(direction_vec, null);
vecCopy(color, null);
vecCopy(_hitPoint, null);
vecCopy(_hitNorm, null);
}
///
void Ray::copy(Ray &ray)
{
id = ray.id;
vecCopy(start_point, ray.start_point);
vecCopy(direction_vec, ray.direction_vec);
vecCopy(color, ray.color);
fDeltaX = ray.fDeltaX;
fDeltaY = ray.fDeltaY;
vecCopy(_hitPoint, ray._hitPoint);
vecCopy(_hitNorm, ray._hitNorm);
}
Ray::Ray(vect3d &pStart, vect3d &pDir, bool pbIsInObj)
: fDeltaX(0), fDeltaY(0)
{
vecCopy(start_point, pStart);
vecCopy(direction_vec, pDir);
id = nRayId ++;
}
void clampColor(vect3d &pColor)
{
for(int i = 0; i < 3; i ++)
{
if(pColor[i] > 1.f) pColor[i] = 1.f;
}
}