-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathQuadTreeClass.hpp
101 lines (69 loc) · 2.27 KB
/
QuadTreeClass.hpp
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
#ifndef QUADTREECLASS_HPP
#define QUADTREECLASS_HPP
#include "QuadNodeClass.hpp"
#include "ObjectHandlerClass.hpp" // Brings ObjectClass & OBJ_COUNT
#define LAYERS 4
struct HoverCamStruct { //-+-+-+-+-+-+-+-+-+-+
DirectX::XMVECTOR CameraPosition; //
DirectX::XMVECTOR CameraDirection; //
DirectX::XMVECTOR CameraUpDirection; //
DirectX::XMMATRIX View; //
DirectX::XMMATRIX Projection; //
}; //-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
class QuadTreeClass {
private:
QuadNodeClass *RootNode;
float GridMaxX, GridMinX;
float GridMaxY, GridMinY;
float GridMaxZ, GridMinZ;
int PassedCloneCounts[OBJ_COUNT];
int* PassedCloneIDs[OBJ_COUNT]; // Grid; Gets initialized in AssignObjectsToGrid
HoverCamStruct HoverCam;
public:
QuadTreeClass();
~QuadTreeClass();
void ReleaseQuadTree();
/* ------------- COMMENTS -------------
Needs to be called BEFORE SetPassedCloneCount
*/
void SetPassedCloneCount(int ObjectIndex, int Count);
/* ------------- COMMENTS -------------
Needs to be called AFTER SetPassedCloneCount
*/
void SetPassedCloneIDs(int ObjectIndex, int* ArrayWithPassedCloneIDs);
int* GetPassedCloneCounts();
int**GetPassedCloneIDs();
float GetWest();
float GetEast();
float GetNorth();
float GetSouth();
float GetTop();
float GetBot();
QuadNodeClass *GetRootNode();
QuadNodeClass *FindGridSlot(int GridID);
/* ------------- COMMENTS -------------
Builds the tree-node-structure based on the nr_of_layers parameter.
Defines the size of each node (Except the RootNode) in the tree-node-structure,
based on North,South,East,West.
*/
void InitializeNodes();
/* ------------- COMMENTS -------------
Defines the Grid size of the RootNode based on North,South,East,West.
*/
void InitializeGrid(ObjectClass *AllObjects);
/* ------------- COMMENTS -------------
Intializes the NodeObjects in the RootNode based on the AllObjects array.
The cache is this functions slave :)
*/
void AssignObjectsToNodes(ObjectClass *AllObjects);
/* ------------- COMMENTS -------------
*/
void TestFrustumIntersection(Plane* AllFrustumPlanes);
/* ------------- COMMENTS -------------
*/
int CornerDive(DirectX::XMVECTOR FrustumCorner);
void InitializeHoverCam();
DirectX::XMMATRIX GetHoverCamView();
DirectX::XMMATRIX GetHoverCamProjection();
};
#endif