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