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