-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathScene.cpp
More file actions
54 lines (43 loc) · 1.18 KB
/
Scene.cpp
File metadata and controls
54 lines (43 loc) · 1.18 KB
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
#include "Scene.hpp"
using namespace std;
Scene::Scene(std::string name) {
this->name = name;
}
void Scene::addShape(Shape* s) {
shapes.push_back(s);
}
void Scene::addLight(Light* l) {
lights.push_back(l);
}
Hit Scene::generateSceneHit(Ray r, Shape* exclude, fixed32 tLimit) {
Hit minHit = Hit();
for (Shape* shape : shapes) {
if (shape == exclude) continue;
Hit h = shape->intersectRay(r);
if (h && h.t <= tLimit && h.t > 0 && (!minHit || h.t < minHit.t)) {
minHit = h;
}
}
return minHit;
}
Hit Scene::generateSceneHit(Ray r, Shape* exclude) {
return generateSceneHit(r, exclude, fixed32(0x7fff));
}
Hit Scene::generateSceneHit(Ray r) {
return generateSceneHit(r, nullptr);
}
std::list<LightContribution>* Scene::generateLightContributions(Hit h) {
std::list<LightContribution>* contributions = new std::list<LightContribution>();
for (Light* l : lights) {
contributions->push_back(l->contributeLight(h, this));
}
return contributions;
}
string Scene::getName() {
return this->name;
}
void Scene::generateAllSubshapes() {
for (Shape* s : shapes) {
s->generateSubshapes();
}
}