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 | //-- initialise for front-to-back rendering
|
---|
32 |
|
---|
33 | ++ mFrameId;
|
---|
34 |
|
---|
35 | mCurrentTestIdx = 0;
|
---|
36 | mNumTraversedNodes = 0;
|
---|
37 | mVisibleNodes.clear();
|
---|
38 |
|
---|
39 | mDistanceQueue->push(mHierarchyRoot);
|
---|
40 | }
|
---|
41 | //-----------------------------------------------------------------------
|
---|
42 | unsigned int HierarchyInterface::GetFrameId() const
|
---|
43 | {
|
---|
44 | return mFrameId;
|
---|
45 | }
|
---|
46 | //-----------------------------------------------------------------------
|
---|
47 | DistanceQueue *HierarchyInterface::GetQueue()
|
---|
48 | {
|
---|
49 | return mDistanceQueue;
|
---|
50 | }
|
---|
51 | //-----------------------------------------------------------------------
|
---|
52 | bool HierarchyInterface::CheckFrustumVisible(HierarchyNode *node)
|
---|
53 | {
|
---|
54 | bool intersects = false;
|
---|
55 | return CheckFrustumVisible(node, intersects);
|
---|
56 | }
|
---|
57 | //-----------------------------------------------------------------------
|
---|
58 | HierarchyNode *HierarchyInterface::GetHierarchyRoot() const
|
---|
59 | {
|
---|
60 | return mHierarchyRoot;
|
---|
61 | }
|
---|
62 | //-----------------------------------------------------------------------
|
---|
63 | unsigned int HierarchyInterface::GetNumTraversedNodes()
|
---|
64 | {
|
---|
65 | return mNumTraversedNodes;
|
---|
66 | }
|
---|
67 | //-----------------------------------------------------------------------
|
---|
68 | unsigned int HierarchyInterface::GetNumRenderedNodes()
|
---|
69 | {
|
---|
70 | return (unsigned int)mVisibleNodes.size();
|
---|
71 | }
|
---|
72 | //-----------------------------------------------------------------------
|
---|
73 | void HierarchyInterface::TestGeometryForVisibleLeaves(bool testGeometry)
|
---|
74 | {
|
---|
75 | mTestGeometryForVisibleLeaves = testGeometry;
|
---|
76 | }
|
---|
77 | //-----------------------------------------------------------------------
|
---|
78 | std::vector<HierarchyNode *> *HierarchyInterface::GetVisibleNodes()
|
---|
79 | {
|
---|
80 | return &mVisibleNodes;
|
---|
81 | }
|
---|
82 | } // namespace GtpVisibility
|
---|