1 | #include "StopAndWaitCullingManager.h" |
---|
2 | #include <OgreLogManager.h> |
---|
3 | |
---|
4 | |
---|
5 | namespace GtpVisibility { |
---|
6 | |
---|
7 | //----------------------------------------------------------------------- |
---|
8 | void StopAndWaitCullingManager::RenderScene() |
---|
9 | { |
---|
10 | InitFrame(); |
---|
11 | Ogre::LogManager::getSingleton().logMessage("*** STOP AND WAIT CULL ****\n"); |
---|
12 | |
---|
13 | while (!mHierarchyInterface->GetQueue()->empty()) |
---|
14 | { |
---|
15 | HierarchyNode *node = mHierarchyInterface->GetQueue()->top(); |
---|
16 | mHierarchyInterface->GetQueue()->pop(); |
---|
17 | |
---|
18 | // interesting for visualization purpose |
---|
19 | mHierarchyInterface->SetNodeVisible(node, false); |
---|
20 | mHierarchyInterface->SetLastVisited(node, mHierarchyInterface->GetFrameId()); |
---|
21 | |
---|
22 | bool intersects = false; |
---|
23 | |
---|
24 | if (!mHierarchyInterface->CheckFrustumVisible(node, intersects)) |
---|
25 | { |
---|
26 | mNumFrustumCulledNodes ++; |
---|
27 | } |
---|
28 | else |
---|
29 | { |
---|
30 | //if intersects near plane => skip occlusion query because wrong results possible |
---|
31 | if (intersects) |
---|
32 | { |
---|
33 | mHierarchyInterface->SetNodeVisible(node, true); |
---|
34 | mHierarchyInterface->TraverseNode(node); |
---|
35 | continue; |
---|
36 | } |
---|
37 | |
---|
38 | mNumQueriesIssued ++; |
---|
39 | |
---|
40 | unsigned int visiblePixels = 0; |
---|
41 | |
---|
42 | mHierarchyInterface->IssueOcclusionQuery(node)->GetQueryResult(visiblePixels, true); |
---|
43 | |
---|
44 | // node visible |
---|
45 | if (visiblePixels > mVisibilityThreshold) |
---|
46 | { |
---|
47 | mHierarchyInterface->TraverseNode(node); |
---|
48 | } |
---|
49 | else |
---|
50 | { |
---|
51 | mNumQueryCulledNodes ++; |
---|
52 | } |
---|
53 | } |
---|
54 | } |
---|
55 | } |
---|
56 | } // namespace GtpVisibility |
---|