source: GTP/trunk/App/Demos/Vis/FriendlyCulling/src/StopAndWaitTraverser.cpp @ 2800

Revision 2800, 1.0 KB checked in by mattausch, 16 years ago (diff)

friendly culling debug version with timers, no materials

Line 
1#include "StopAndWaitTraverser.h"
2#include "SceneEntity.h"
3
4
5namespace CHCDemoEngine
6{
7
8using namespace std;
9
10
11
12StopAndWaitTraverser::StopAndWaitTraverser()
13{
14}
15
16
17void StopAndWaitTraverser::Traverse()
18{
19        while (!mDistanceQueue.empty())
20        {
21                BvhNode *node = mDistanceQueue.top();
22                mDistanceQueue.pop();
23       
24                if (mBvh->IsWithinViewFrustum(node))
25                {
26                        // if intersects near plane assume visible and don't issue test
27                        if (IntersectsNearPlane(node))
28                        {
29                                TraverseNode(node);
30                        }
31                        else
32                        {
33                                OcclusionQuery *query = IssueOcclusionQuery(node);
34
35                                waitTimer.Entry();
36                                bool visible = query->GetQueryResult() > mVisibilityThreshold;
37                                waitTimer.Exit();
38
39                                if (visible)
40                                {
41                                        TraverseNode(node);
42                                }
43                                else
44                                {
45                                        node->SetVisible(false);
46                                        ++ mStats.mNumQueryCulledNodes;
47                                }
48                               
49                                // update node's visited flag (could be interesting for the visualization)
50                                node->SetVisible(visible);             
51                        }
52                }
53                else
54                {
55                        ++ mStats.mNumFrustumCulledNodes;
56                }       
57        }
58}
59
60}
Note: See TracBrowser for help on using the repository browser.