-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscene.h
More file actions
58 lines (45 loc) · 798 Bytes
/
scene.h
File metadata and controls
58 lines (45 loc) · 798 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
51
52
53
54
55
56
57
58
//
#ifndef RAYTRACINGWEEKEND_SCENE_H
#define RAYTRACINGWEEKEND_SCENE_H
#include "bvh.h"
#include "camera.h"
#include "hittable_list.h"
#include "texture.h"
class scene
{
public:
camera s_camera;
std::vector<shared_ptr<hittable>> objects;
std::vector<shared_ptr<material>> materials;
std::vector<shared_ptr<texture>> textures;
hittable_list world;
void update()
{
if (dirty)
{
// Regenerate BVH
bvh_cache = bvh_node(world);
dirty = false;
}
}
bool mark_dirty()
{
auto prev_dirty = dirty;
dirty = true;
return prev_dirty;
}
[[nodiscard]] bool is_dirty() const
{
return dirty;
}
hittable& get_render_scene()
{
if (dirty)
update();
return bvh_cache;
}
private:
bool dirty = true;
bvh_node bvh_cache;
};
#endif //RAYTRACINGWEEKEND_SCENE_H