-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathray.h
More file actions
50 lines (36 loc) · 801 Bytes
/
Copy pathray.h
File metadata and controls
50 lines (36 loc) · 801 Bytes
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
#pragma once
#include "vectormath.h"
#include "color.h"
// In order to prevent bouncing rays self-intersecting
#define RAY_T_MIN 0.0001f
// 'Infinite' distance, used as a default value
#define RAY_T_MAX 1.0e30f
struct Ray
{
Point origin; // start
Vector direction;
float tMax;
bool invalid;
Ray();
Ray(const Ray& r);
Ray(const Point& origin, const Vector& direction,
float tMax = RAY_T_MAX);
virtual ~Ray();
Ray& operator =(const Ray& r);
Point calculate(float t) const;
};
class Shape;
struct Intersection
{
Ray ray;
float t;
Shape *pShape;
Color color;
Intersection();
Intersection(const Intersection& i);
Intersection(const Ray& ray);
virtual ~Intersection();
Intersection& operator =(const Intersection& i);
bool intersected() const;
Point position() const;
};