[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));
|
---|
[155] | 13 | mTraversalStack = new std::stack<HierarchyNode *>;
|
---|
[59] | 14 | }
|
---|
| 15 | //-----------------------------------------------------------------------
|
---|
| 16 | HierarchyInterface::~HierarchyInterface()
|
---|
| 17 | {
|
---|
| 18 | delete mDistanceQueue;
|
---|
[155] | 19 | delete mTraversalStack;
|
---|
[59] | 20 | }
|
---|
| 21 | //-----------------------------------------------------------------------
|
---|
[155] | 22 | void HierarchyInterface::SetHierarchyRoot(HierarchyNode *root)
|
---|
[59] | 23 | {
|
---|
[155] | 24 | mHierarchyRoot = root;
|
---|
[59] | 25 | }
|
---|
| 26 | //-----------------------------------------------------------------------
|
---|
[155] | 27 | void HierarchyInterface::InitTraversal(bool frontToBack)
|
---|
[59] | 28 | {
|
---|
[155] | 29 | // initialise for front-to-back rendering
|
---|
| 30 | if (frontToBack)
|
---|
| 31 | {
|
---|
| 32 | ++ mFrameId;
|
---|
| 33 | mCurrentTestIdx = 0;
|
---|
| 34 | mNumTraversedNodes = 0;
|
---|
| 35 | mRenderedNodes.clear();
|
---|
[59] | 36 |
|
---|
[155] | 37 | mDistanceQueue->push(mHierarchyRoot);
|
---|
| 38 | }
|
---|
| 39 | else
|
---|
| 40 | { // initialise for simple node traversal
|
---|
| 41 | mTraversalStack->push(mHierarchyRoot);
|
---|
| 42 | }
|
---|
[59] | 43 | }
|
---|
| 44 | //-----------------------------------------------------------------------
|
---|
[74] | 45 | unsigned int HierarchyInterface::GetFrameId() const
|
---|
[59] | 46 | {
|
---|
| 47 | return mFrameId;
|
---|
| 48 | }
|
---|
| 49 | //-----------------------------------------------------------------------
|
---|
| 50 | DistanceQueue *HierarchyInterface::GetQueue()
|
---|
| 51 | {
|
---|
| 52 | return mDistanceQueue;
|
---|
| 53 | }
|
---|
[74] | 54 | //-----------------------------------------------------------------------
|
---|
| 55 | bool HierarchyInterface::CheckFrustumVisible(HierarchyNode *node)
|
---|
| 56 | {
|
---|
| 57 | bool intersects = false;
|
---|
| 58 | return CheckFrustumVisible(node, intersects);
|
---|
| 59 | }
|
---|
| 60 | //-----------------------------------------------------------------------
|
---|
[155] | 61 | HierarchyNode *HierarchyInterface::GetHierarchyRoot() const
|
---|
[74] | 62 | {
|
---|
[155] | 63 | return mHierarchyRoot;
|
---|
[74] | 64 | }
|
---|
| 65 | //-----------------------------------------------------------------------
|
---|
| 66 | unsigned int HierarchyInterface::GetNumTraversedNodes()
|
---|
| 67 | {
|
---|
| 68 | return mNumTraversedNodes;
|
---|
| 69 | }
|
---|
| 70 | //-----------------------------------------------------------------------
|
---|
| 71 | unsigned int HierarchyInterface::GetNumRenderedNodes()
|
---|
| 72 | {
|
---|
[130] | 73 | return (unsigned int)mRenderedNodes.size();
|
---|
[74] | 74 | }
|
---|
[130] | 75 | //-----------------------------------------------------------------------
|
---|
[155] | 76 | void HierarchyInterface::TestGeometryForVisibleLeaves(bool testGeometry)
|
---|
[86] | 77 | {
|
---|
[155] | 78 | mTestGeometryForVisibleLeaves = testGeometry;
|
---|
[86] | 79 | }
|
---|
[130] | 80 | //-----------------------------------------------------------------------
|
---|
| 81 | std::vector<HierarchyNode *> *HierarchyInterface::GetRenderedNodes()
|
---|
| 82 | {
|
---|
| 83 | return &mRenderedNodes;
|
---|
| 84 | }
|
---|
[59] | 85 | } // namespace GtpVisibility
|
---|