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