-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathQuadTreeNode.h
61 lines (53 loc) · 1.32 KB
/
QuadTreeNode.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
#ifndef QUADTREENODE_H
#define QUADTREENODE_H
#include <Windows.h>
#include <D3DX11.h>
#include <xnamath.h>
#include <vector>
struct QuadTreeNode
{
QuadTreeNode* *children; // pointer to array of children pointers of this node
int numChildren;// number of children this QT node has
QuadTreeNode* parent; // parent QT node
float error; // deviation of this QTnode from actual mesh
UINT* indices; // indices into some mesh
int numIndices; // number of indices this node has
QuadTreeNode ( QuadTreeNode* _parent = NULL, int _numIndices = 6, float _error = 100.0f, int _numChildren = 0 )
: parent(_parent), numIndices(_numIndices), error(_error) {
if ( _numChildren > 0 )
{
children = new QuadTreeNode*[_numChildren];
numChildren = _numChildren;
for (int i=0; i< numChildren; i++)
children[i] = NULL;
}
else {
children = NULL;
numChildren = 0;
}
if ( _numIndices > 0 ) {
numIndices = _numIndices;
indices = new UINT[numIndices];
for (int i=0; i< numIndices; i++)
indices[i] = 0;
}
else {
numIndices = 0;
indices = NULL;
}
}
~QuadTreeNode() {
if ( children ) {
if ( numChildren > 0 ) {
for (int i=0;i < numChildren; i++) {
delete children[i];
}
}
delete children;
}
if ( indices ) {
delete indices;
}
}
};
#endif // QUADTREENODE_H