-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRay.h
48 lines (35 loc) · 1.1 KB
/
Ray.h
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
//
// Created by Tizian Rettig on 09.12.2020.
//
#ifndef RAYTRACER_RAY_H
#define RAYTRACER_RAY_H
#include <vector>
#include "CLine.hpp"
#include "SceneObjects/Geometry.h"
#include "Vec.hpp"
#define MAX_CASTING_DISTANCE 1000
/**
* Ray class representing one visual ray cast through the scene.
* @note This represents one single segment of the chain of rays that is needed for a single pixel to be evaluated.
*/
class Ray {
public:
Ray();
Ray(const Vec &origin, const Vec &direction);
bool intersectWorld(Geometry** world, const int& size);
[[nodiscard]] bool hasIntersections() const;
[[nodiscard]] const int & getIntersectionIdx() const;
[[nodiscard]] const CLine &getLine() const;
[[nodiscard]] const Vec &getOrigin() const;
[[nodiscard]] const Vec* getEnd() const;
[[nodiscard]] const Vec &getDirection() const;
[[nodiscard]] const float &getLength() const;
[[nodiscard]] std::string toString() const;
private:
bool m_hasIntersected = false;
int m_intersection_idx = -1;
float m_length;
CLine m_line;
Vec m_end;
};
#endif //RAYTRACER_RAY_H