-
Notifications
You must be signed in to change notification settings - Fork 1
/
scatteroctree.h
63 lines (52 loc) · 1.32 KB
/
scatteroctree.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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#pragma once
#include <d3dx9.h>
#include <vector>
#include "boundbox.h"
#include "point3.h"
#include "color.h"
#include "bssrdf.h"
struct ScatterSample
{
Point3 position;
Color irradiance;
float area;
};
typedef ScatterSample NodeData;
class ScatterOctree
{
public:
// Max number of data stored in the leaf node.
static const size_t MAX_LEAF = 8;
struct Node
{
Node();
~Node();
Node* children[8];
ScatterSample* data[MAX_LEAF];
ScatterSample value;
size_t count;
bool isLeaf(void) const;
};
public:
ScatterOctree(const BoundBox& box);
~ScatterOctree(void);
void insert(const NodeData& data);
void config(void);
Color lookup(const Point3& p, float maxErr, Bssrdf* bssrdf);
// private member functions
private:
size_t withinChild(const Point3& mid, const Point3& p) const;
void insertPrivate(Node* node, const BoundBox& nodeBound,
const NodeData& data, size_t depth);
void lookupPrivate(Node* node, const BoundBox& nodeBound,
const Point3& p);
void processData(const NodeData& data, const Point3& p);
void configPrivate(Node* node);
// private data members
private:
BoundBox m_bound;
Node m_root;
float m_maxErr;
Color m_resultE;
Bssrdf* m_bssrdf;
};