1 | #include "HierarchyInterface.h"
|
---|
2 |
|
---|
3 | #include <windows.h>
|
---|
4 |
|
---|
5 | namespace GtpVisibility {
|
---|
6 |
|
---|
7 | //-----------------------------------------------------------------------
|
---|
8 | HierarchyInterface::HierarchyInterface():
|
---|
9 | mFrameId(0),
|
---|
10 | mNumTraversedNodes(0),
|
---|
11 | mHierarchyRoot(NULL),
|
---|
12 | mSavedNode(NULL),
|
---|
13 | mCurrentTestIdx(0),
|
---|
14 | mTestGeometryForVisibleLeaves(false)
|
---|
15 | {
|
---|
16 | mDistanceQueue = new DistanceQueue(GtDistance<HierarchyNode *>(this));
|
---|
17 | }
|
---|
18 | //-----------------------------------------------------------------------
|
---|
19 | HierarchyInterface::~HierarchyInterface()
|
---|
20 | {
|
---|
21 | delete mDistanceQueue;
|
---|
22 | }
|
---|
23 | //-----------------------------------------------------------------------
|
---|
24 | void HierarchyInterface::SetHierarchyRoot(HierarchyNode *root)
|
---|
25 | {
|
---|
26 | mHierarchyRoot = root;
|
---|
27 | }
|
---|
28 | //-----------------------------------------------------------------------
|
---|
29 | void HierarchyInterface::InitTraversal()
|
---|
30 | {
|
---|
31 | //////////////
|
---|
32 | //-- initialise for hierarchical traversal
|
---|
33 |
|
---|
34 | ++ mFrameId;
|
---|
35 |
|
---|
36 | mCurrentTestIdx = 0;
|
---|
37 | mNumTraversedNodes = 0;
|
---|
38 | mVisibleNodes.clear();
|
---|
39 |
|
---|
40 | mDistanceQueue->push(mHierarchyRoot);
|
---|
41 | }
|
---|
42 | //-----------------------------------------------------------------------
|
---|
43 | unsigned int HierarchyInterface::GetFrameId() const
|
---|
44 | {
|
---|
45 | return mFrameId;
|
---|
46 | }
|
---|
47 | //-----------------------------------------------------------------------
|
---|
48 | DistanceQueue *HierarchyInterface::GetQueue()
|
---|
49 | {
|
---|
50 | return mDistanceQueue;
|
---|
51 | }
|
---|
52 | //-----------------------------------------------------------------------
|
---|
53 | bool HierarchyInterface::CheckFrustumVisible(HierarchyNode *node)
|
---|
54 | {
|
---|
55 | bool intersects = false;
|
---|
56 | return CheckFrustumVisible(node, intersects);
|
---|
57 | }
|
---|
58 | //-----------------------------------------------------------------------
|
---|
59 | HierarchyNode *HierarchyInterface::GetHierarchyRoot() const
|
---|
60 | {
|
---|
61 | return mHierarchyRoot;
|
---|
62 | }
|
---|
63 | //-----------------------------------------------------------------------
|
---|
64 | unsigned int HierarchyInterface::GetNumTraversedNodes()
|
---|
65 | {
|
---|
66 | return mNumTraversedNodes;
|
---|
67 | }
|
---|
68 | //-----------------------------------------------------------------------
|
---|
69 | unsigned int HierarchyInterface::GetNumRenderedNodes()
|
---|
70 | {
|
---|
71 | return (unsigned int)mVisibleNodes.size();
|
---|
72 | }
|
---|
73 | //-----------------------------------------------------------------------
|
---|
74 | void HierarchyInterface::TestGeometryForVisibleLeaves(bool testGeometry)
|
---|
75 | {
|
---|
76 | mTestGeometryForVisibleLeaves = testGeometry;
|
---|
77 | }
|
---|
78 | //-----------------------------------------------------------------------
|
---|
79 | std::vector<HierarchyNode *> *HierarchyInterface::GetVisibleNodes()
|
---|
80 | {
|
---|
81 | return &mVisibleNodes;
|
---|
82 | }
|
---|
83 | } // namespace GtpVisibility
|
---|