drand() needs <cstdlib>
[MicroTrace.git] / kDTree.cxx
1 #include "kDTree.hxx"
2
3 /*************** kDTreeInnerNode ******************/
4
5 kDTreeInnerNode::kDTreeInnerNode(float split,
6 int axis)
7 : m_split(split),
8 m_axis(axis)
9 {
10 }
11
12 kDTreeInnerNode::~kDTreeInnerNode()
13 {
14 // think about correct memory management!
15 }
16
17 kDTreeInnerNode::kDTreeInnerNode()
18 {
19 }
20
21 kDTreeInnerNode::kDTreeInnerNode(const kDTreeInnerNode& node)
22 {
23 operator=(node);
24 }
25
26 kDTreeInnerNode&
27 kDTreeInnerNode::operator=(const kDTreeInnerNode& )
28 {
29 return *this;
30 }
31
32 bool
33 kDTreeInnerNode::Traverse(Ray& ray, float& t0, float& t1)
34 {
35 // implement the traversal of an inner node
36 // think about the correct order
37
38 return false;
39 }
40
41 void
42 kDTreeInnerNode::setChildren(kDTreeNode* left,
43 kDTreeNode* right)
44 {
45 m_children[0] = left;
46 m_children[1] = right;
47 }
48
49
50 /******************** kDTreeLeafNode *******************/
51
52 kDTreeLeafNode::kDTreeLeafNode(const std::vector<Primitive*>& prim)
53 : m_primitives(prim)
54 {
55
56 }
57
58 kDTreeLeafNode::~kDTreeLeafNode()
59 {
60 }
61
62 kDTreeLeafNode::kDTreeLeafNode()
63 {
64 }
65
66 kDTreeLeafNode::kDTreeLeafNode(const kDTreeLeafNode& node)
67 {
68 operator=(node);
69 }
70
71 kDTreeLeafNode&
72 kDTreeLeafNode::operator=(const kDTreeLeafNode& )
73 {
74 return *this;
75 }
76
77 bool
78 kDTreeLeafNode::Traverse(Ray& ray, float& t0, float& t1)
79 {
80 // implement the leaf node traversal here
81 return false;
82 }
83
84
85 /******************** kDTree ***********************/
86
87 kDTree::kDTree(const Box& bounds,
88 const std::vector<Primitive*>& prim)
89 : m_root(0),
90 m_bounds(bounds),
91 m_maxDepth(20),
92 m_minTri(3)
93 {
94 m_root = BuildTree(m_bounds, prim, 0);
95 }
96
97 kDTree::~kDTree()
98 {
99 // think about correct memory management
100 delete m_root;
101 }
102
103 kDTree::kDTree()
104 : m_root(0),
105 m_bounds(Box())
106 {
107 }
108
109 kDTree::kDTree(const kDTree& tree)
110 {
111 operator=(tree);
112 }
113
114 kDTree&
115 kDTree::operator=(const kDTree& )
116 {
117 return *this;
118 }
119
120 kDTreeNode*
121 kDTree::BuildTree(const Box& bounds,
122 const std::vector<Primitive*>& prim,
123 int depth)
124 {
125 // setup tree structure here
126 // these two variables are only here to solve compilation issues!
127 float dummy_split = 0.0f;
128 int dummy_axis = 0;
129 kDTreeInnerNode* node = new kDTreeInnerNode(dummy_split, dummy_axis);
130
131 return node;
132 }
133
134 bool
135 kDTree::Intersect(Ray& ray)
136 {
137 // implement the tree traversal
138 return false;
139 }
This page took 0.05348 seconds and 5 git commands to generate.