-
Notifications
You must be signed in to change notification settings - Fork 4
/
OctTree.h
68 lines (56 loc) · 1.25 KB
/
OctTree.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
64
65
66
67
68
// Copyright (c) 2018 Ryan Dougherty. All rights reserved
#pragma once
#include "CoreMinimal.h"
#include "Runtime/Engine/Classes/GameFramework/Actor.h"
/**
* Octant represents an area of space within a 3D X, Y, Z plane
*/
enum Octant
{
TopLeftBack,
TopRightBack,
BottomLeftBack,
BottomRightBack,
TopLeftFront,
TopRightFront,
BottomLeftFront,
BottomRightFront
};
class OctTree
{
public:
/**
* Default constructor for empty OctTree with no defined boundaries
*/
OctTree() : data()
{
this->topLeftFrontBounds = FVector::ZeroVector;
this->bottomRightBackBounds = FVector::ZeroVector;
for (int i = 0; i < 8; i++)
trees[i] = NULL;
}
private:
/** Bucket size for this tree */
static const int bucket_size = 3;
/** Boundary points for the node */
FVector topLeftFrontBounds;
FVector bottomRightBackBounds;
/** Data stored in this QTree */
TArray<class AActor*> data;
/** Child nodes accessible by array indexing or direct access */
union
{
struct
{
OctTree *topLeftBackTree;
OctTree *topRightBackTree;
OctTree *bottomLeftBackTree;
OctTree *bottomRightBackTree;
OctTree *topLeftFrontTree;
OctTree *topRightFrontTree;
OctTree *bottomLeftFrontTree;
OctTree *bottomRightFrontTree;
};
OctTree *trees[8];
};
};